Skip to content

Loop operator with no initial values for loop-carried dependencies aborts #543

@mneilly

Description

@mneilly

The attached DLRM model uses ONNX loop operators which have only the trip count and condition inputs but no initial values for the loop-carried dependencies. This results in onnx2trt aborting as follows when it hits an empty std::vector:

$ onnx2trt -o dlrm_s_pytorch.trt dlrm_s_pytorch.onnx 
----------------------------------------------------------------
Input filename:   dlrm_s_pytorch.onnx
ONNX IR version:  0.0.6
Opset version:    11
Producer name:    pytorch
Producer version: 1.8
Domain:           
Model version:    0
Doc string:       
----------------------------------------------------------------
Parsing model
[2020-10-15 05:44:40 WARNING] [TRT]/local/tensorRT/onnx-tensorrt/onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[2020-10-15 05:44:40 WARNING] [TRT]/local/tensorRT/onnx-tensorrt/onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Aborted (core dumped)

This occurs when there are no initial values and an empty stateVars vector is accessed at line 1730 below:

// Add initial state inputs using recurrent layers.
std::vector<nvinfer1::IRecurrenceLayer*> stateVars{};
for (size_t i = 2; i < inputs.size(); ++i)
{
stateVars.emplace_back(loop->addRecurrence(convertToTensor(inputs[i], ctx)));
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());

I can't upload the version with embedded tensors since it is too large so I'm attaching the version with external tensors. #542 needs to be resolved or worked around to hit this issue when using external tensors.

dlrm-external-tensors.zip

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriagedIssue has been triaged by maintainers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions