Skip to content

fix: Switch all copies to force cast #2563

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

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
4 changes: 2 additions & 2 deletions py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def aten_ops_clone_copy_dtype(
name,
args[0],
kwargs.get("dtype", args[0].dtype),
force_layer=False,
force_layer=True,
)


Expand Down Expand Up @@ -1043,7 +1043,7 @@ def aten_ops_sum(
name,
sum_,
kwargs["output_dtype"],
force_layer=False,
force_layer=True,
)
else:
return sum_
Expand Down
15 changes: 15 additions & 0 deletions tests/py/dynamo/conversion/test_casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ def forward(self, x):
inputs,
)

def test_to_copy_multiple_returns(self):
class ToCopyReturns(nn.Module):
def forward(self, x):
x_1 = x + 1
y = torch.ops.aten._to_copy.default(x_1, dtype=torch.float)
z = torch.ops.aten._to_copy.default(x_1, dtype=torch.float)
return y, z

inputs = [torch.rand((1, 3, 10))]
self.run_test(
ToCopyReturns(),
inputs,
precision=torch.float,
)


if __name__ == "__main__":
run_tests()