INNER CODE UNIT · Python
run_model
onnx/onnx-tensorrt · onnx_tensorrt/backend.py:235
def run_model(cls, model, inputs, device='CUDA:0', **kwargs):
"""Build and run an engine from the given model.
model -- An ONNX model as a deserialized protobuf, or a string or file-
object containing a serialized protobuf.
inputs -- Input tensor(s) as a Numpy array or list of Numpy arrays.
"""
return cls.prepare(model, device, **kwargs).run(inputs)
@classmethod
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.