INNER CODE UNIT · Python
run_node
onnx/onnx-tensorrt · onnx_tensorrt/backend.py:243
def run_node(cls, node, inputs, device='CUDA:0'):
"""Build and run an engine from the given node.
node -- An ONNX node as a deserialized protobuf.
Note: This function is intended for testing purposes only;
use prepare() or run_model() for other purposes.
"""
super(TensorRTBackend, cls).run_node(node, inputs, device)
# HACK TODO: This is somewhat dodgy. We first try with weights for all
# inputs but the first, then we try again with no weights if
# the first try fails.
model = make_node_test_model(node, inputs, use_weights=True)
try: results = TensorRTBackend.prepare(model, device).run(inputs[:1])
except RuntimeError:
model = make_node_test_model(node, inputs, use_weights=False)
results = TensorRTBackend.prepare(model, device).run(inputs)
return results
@classmethod
def supports_device(cls, device_str):