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

None: Replace the Tensor Layer name from "Unnamed Layer #" to its original name #2384

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions py/torch_tensorrt/dynamo/conversion/converter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ def cast_trt_tensor(
identity_layer = ctx.net.add_identity(input_val)
identity_layer.set_output_type(0, trt_dtype)
identity_layer.name = f"Cast ITensor {input_val.name} from {input_val.dtype} to {trt_dtype} - [{target_name}]-[{name}]"
identity_layer.metadata = f"[{identity_layer.type.name}]-[{target_name}]-[{name}]-[#_of_outputs_{identity_layer.num_outputs}]"

for i in range(identity_layer.num_outputs):
output = identity_layer.get_output(i)
output.name = f"[{output.name}]"

Comment on lines +155 to +160
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this code from the cast_trt_tensor function, and make a new function in this file which is an exact copy of set_layer_name from fx/, with your change added?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afterward, could you search the directory dynamo/conversion/ for any uses of set_layer_name and switch the import to use your new implementation, instead of the legacy fx version?

return identity_layer.get_output(0)
else:
return input_val
Expand Down
5 changes: 5 additions & 0 deletions py/torch_tensorrt/fx/converters/converter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def set_layer_name(
else f"{source_ir}_ops.{target.__name__}"
)
layer.name = f"[{layer.type.name}]-[{target_name}]-[{name}]"
layer.metadata = f"[{layer.type.name}]-[{target_name}]-[{name}]-[#_of_outputs_{layer.num_outputs}]"

for i in range(layer.num_outputs):
output = layer.get_output(i)
output.name = f"[{output.name}]"
Comment on lines +126 to +130
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this change from the fx/ directory, since the contribution should be strictly to Dynamo



def extend_attr_to_tuple(
Expand Down
Loading