Skip to content

Commit

Permalink
Fix issue when onnx outputs are also used by other nodes (llvm#1323)
Browse files Browse the repository at this point in the history
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 llvm#1376

Signed-off-by: Michael Holman <[email protected]>
  • Loading branch information
MikeHolman authored Apr 26, 2022
1 parent 313928c commit 336c8f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Builder/FrontendDialectTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Location, 4>(argTypes.size(), UnknownLoc()));

Expand Down

0 comments on commit 336c8f4

Please sign in to comment.