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

Resolved Issue: Fix Exporting ONNX Model with Fixed Batch Size of 1 Using export_tensorrt_engine #509

Merged
merged 1 commit into from
Jan 2, 2024
Merged
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
4 changes: 3 additions & 1 deletion yolort/relay/trt_graphsurgeon.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def __init__(
logger.info(f"Loaded saved model from {model_path}")

if input_sample is not None:
self.batch_size = input_sample.shape[0]
input_sample = input_sample.to(device=device)
else:
self.batch_size = 1
model_path = model_path.with_suffix(".onnx")
model.to_onnx(model_path, input_sample=input_sample, enable_dynamic=enable_dynamic)
logger.info("PyTorch2ONNX graph created successfully")
Expand All @@ -85,7 +88,6 @@ def __init__(

# Fold constants via ONNX-GS that PyTorch2ONNX may have missed
self.graph.fold_constants()
self.batch_size = 1
self.precision = precision
self.simplify = simplify

Expand Down
Loading