From 336c8f480bc2a8cf98c8f170b09116c69e58f801 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Tue, 26 Apr 2022 16:32:35 -0700 Subject: [PATCH] Fix issue when onnx outputs are also used by other nodes (#1323) Importing onnx graph fails if an output is also used by another node. This happens because the output ValueInfo will be registered, and then it will throw an error that it already exists when importing internal ValueInfos. Solution is to import the internal ValueInfos before importing the output ValueInfos. Resolves #1376 Signed-off-by: Michael Holman --- src/Builder/FrontendDialectTransformer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Builder/FrontendDialectTransformer.cpp b/src/Builder/FrontendDialectTransformer.cpp index e21996910ae7..1eaef850a76f 100644 --- a/src/Builder/FrontendDialectTransformer.cpp +++ b/src/Builder/FrontendDialectTransformer.cpp @@ -448,16 +448,17 @@ class FrontendGenImpl { ++numInputs; } } + + for (const auto &internal : graph.value_info()) { + AddValueInfo(internal); + } + for (const auto &output : graph.output()) { // Output tensor may be in input list AddValueInfo(output, true); outputNames.push_back(output.name()); } - for (const auto &internal : graph.value_info()) { - AddValueInfo(internal); - } - entryBlock->addArguments(argTypes, llvm::SmallVector(argTypes.size(), UnknownLoc()));