Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fp16 support for python backend. #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions onnx_tensorrt/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def count_trailing_ones(vals):


class TensorRTBackendRep(BackendRep):
def __init__(self, model, device, max_batch_size=32,
def __init__(self, model, device, max_batch_size=32, fp16_mode=False,
max_workspace_size=None, serialize_engine=False, **kwargs):
if not isinstance(device, Device):
device = Device(device)
Expand Down Expand Up @@ -89,6 +89,7 @@ def __init__(self, model, device, max_batch_size=32,

self.builder.max_batch_size = max_batch_size
self.builder.max_workspace_size = max_workspace_size
self.builder.fp16_mode = fp16_mode

for layer in self.network:
print(layer.name)
Expand Down Expand Up @@ -231,4 +232,4 @@ def supports_device(cls, device_str):
prepare = TensorRTBackend.prepare
run_node = TensorRTBackend.run_node
run_model = TensorRTBackend.run_model
supports_device = TensorRTBackend.supports_device
supports_device = TensorRTBackend.supports_device