onnxruntime: EfficientNMS_TRT missing attribute class_agnostic w/ TensorRT 8.6

Describe the issue

With the latest 1.15 release the support for TensorRT 8.6 was added (thanks btw!), but it seems that the EfficientNMS plugin changes did not come with it.

In TensorRT 8.6 the support for class-agnostic NMS was added via a new attribute (see this commit) but it seems that it is missing from the ONNX Runtime operator definition here.

When trying to run a mode exported with the EfficientNMS_TRT node that contains this attribute, we get the following error: onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. In Node, ("NMS_Op_sg344", EfficientNMS_TRT, "", -1) : ("/_wrapper/postprocess/Slice_19_output_0": tensor(float),"/_wrapper/postprocess/Mul_42_output_0": tensor(float),) -> ("num_boxes": tensor(int32),"/_wrapper/postprocess/CustomNMS_output_1": tensor(float),"/_wrapper/postprocess/CustomNMS_output_2":tensor(float),"/_wrapper/postprocess/CustomNMS_output_3": tensor(int32),) , Error Unrecognized attribute: class_agnostic for operator EfficientNMS_TRT

The same model executes correctly if I use TensorRT 8.6 without ONNX Runtime or if I don’t specify the class_agnostic attribute when creating the node for the exported model.

To reproduce

I can’t distribute the model at this time but if required I could take some time to produce a MWE.

Urgency

Project deadline around mid June which would greatly benefit from this change.

Platform

Linux

OS Version

Ubuntu 20.04.2 LTS

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.15

ONNX Runtime API

Python

Architecture

X64

Execution Provider

TensorRT

Execution Provider Library Version

TensorRT 8.6

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 35 (12 by maintainers)

Most upvoted comments

Sorry for the late reply. (I was OOF las week)

i investigated further and found out that the behavior of TRT built-in parser and TRT oss parser are slightly different when parsing the identity_neural_network.onnx. The built-in parser didn’t return IdentityConv node as TRT eligible even though the libidentity_conv.so was successfully loaded and the IdentityConv was recognized by TRT through TRT plugin, whereas oss parser did return IdentityConv node as TRT eligible

Following two approaches can help unblock you:

  • Build ORT 1.17.0 with TensorRT OSS parser (see doc here) remember to add one more build arg: --use_tensorrt_oss_parser

  • Use ORT 1.18.0 with TRT 10 GA.

I’m reporting this issue to Nvidia and will reply here once i get some updates.

@chilo-ms I confirm, loading a model w/ a supported plugin such as EfficientNMS_TRT from the trt.plugins domain works with the changes on your branch. Haven’t tried with my custom op yet but would assume it would work just as well.

@chilo-ms Absolutely! Kinda busy this week but will get back to you as soon as I test it.

@laggui This issue is in our backlog. I’m taking a closer look now and might need to discuss internally. Will give you update once i have some progress.

Hi @chilo-ms, good catch! The final application will be in C++ anyway, only the current prototype is written w/ the python bindings.

I guess I’ll move along to the C++ interface until this is fixed 😃

Hi laggui,

As George mentioned, please use the new generic way of supporting TRT plugins. All you need to do is change the EfficientNMS_TRT node in the onnx model with the domain trt.plugins (you can use python to easy modify the onnx node) instead of the default onnx domain which is null string. The old way of using TRT plugins is through contrib op and it checks domain kOnnxDomain which is null string and as you already found out it doesn’t add the new attribute that’s why ORT failed to run the model.

Thanks for pointing out this issue and we can think of better ways to let people use the newer way of supporting TRT plugin. Let me know if you encounter any issues.

we have a more generic way of supporting TRT plugins which does not require contrib op schema updates. see https://github.com/microsoft/onnxruntime/pull/13847 +@chilo-ms to provide more details.