Skip to content

Commit

Permalink
Fix external weights relative path and loop import (#619)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Chen <kevinch@nvidia.com>
  • Loading branch information
kevinch-nv authored Jan 11, 2021
1 parent 47e2b0f commit 21f62e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin_op_importers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@ DEFINE_BUILTIN_OP_IMPORTER(Loop)
const ::ONNX_NAMESPACE::GraphProto& body = attrs.get<const ::ONNX_NAMESPACE::GraphProto&>("body");

auto loop = ctx->network()->addLoop();
loop->setName(getNodeName(node).c_str());
// Trip count and condition are optional inputs.
nvinfer1::ITensor* tripLimit{nullptr};
if (inputs[0])
Expand Down Expand Up @@ -1732,7 +1733,6 @@ DEFINE_BUILTIN_OP_IMPORTER(Loop)
ctx->loopTensors()[body.input(i).name()] = node.input(i);
ctx->registerTensor(TensorOrWeights{stateVars.back()->getOutput(0)}, body.input(i).name());
}
ctx->registerLayer(stateVars.at(0), node.name());

// Loop body
TRT_CHECK(onnx2trt::parseGraph(ctx, body));
Expand Down
4 changes: 4 additions & 0 deletions onnx2trt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,10 @@ bool parseExternalWeights(IImporterContext* ctx, std::string file, std::string p
{
path.replace(slash + 1, path.size() - (slash + 1), file);
}
else
{
path = file;
}
std::ifstream relPathFile(path, std::ios::binary | std::ios::ate);
if (!relPathFile)
{
Expand Down

0 comments on commit 21f62e9

Please sign in to comment.