-
Notifications
You must be signed in to change notification settings - Fork 371
fix: prelu perf gap on Unet #3717
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
base: main
Are you sure you want to change the base?
Conversation
95c2633
to
90fcd2b
Compare
9e171ba
to
cf0f12d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If possible consider adding a test, we talked a bit about a new INetwork verification test based on expected numbers of ops. Might be a simple case to build the harness for |
@narendasan I'll merge this PR now and cherrypick to the release 2.8, and then work on the number of ops check in another PR for the next release. sounds like a plan? |
there's an error. will merge after fixing |
this case fails because
self.input_names: ['x'] Since |
2b14b94
to
cf9e7bd
Compare
for i, output in enumerate(outputs): | ||
# In some cases, the same output tensor may be marked multiple times, such as _to_oppy, | ||
# so we skip marking if the output is already marked | ||
if id(output) in marked_outputs_ids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this id function come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id()
is a built-in function that returns the "identity" of an object.
@@ -1094,7 +1094,7 @@ def aten_ops_clone_copy_dtype( | |||
name, | |||
args[0], | |||
kwargs.get("dtype", args[0].dtype), | |||
force_layer=True, | |||
force_layer=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there might be cases where we might need to actually force_layer=True. Do you know when that would be useful?. Also consider adding a comment here conveying that force_layer=False results in better performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know when we need force_layer=True? My understanding is that 1) Since cast_trt_tensor
would be called even if the force_layer=False, it only adds Cast Layer if necessary. 2) If an operator satisfies not is_only_operator_on_placeholder
, that means there's other operator on the placeholder or the lowering pass repair_input_as_output
to promise "input is not output", so we don't have to explicitly add Cast Layer.
Description
In Monai/Unet, I observed that Torch-TRT's prelu is slower than ONNX-TRT, and what is worse is that using prelu converter is even slower than decomposing it.
Update: The perf issue is because
to_copy
forces to insert Cast Layer.Fixes #3715 #3723
Type of change
Checklist: