Skip to content

Commit 8071824

Browse files
jdh8ayerofieiev-tt
andauthored
Optimize out aten.detach (#378)
This op is no-op with disabled gradient. Removing its instances should be fine in a valid graph. https://pytorch.org/docs/stable/generated/torch.Tensor.detach.html Co-authored-by: Artem Yerofieiev <[email protected]>
1 parent 29cc28f commit 8071824

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

torch_ttnn/passes/lowering/to_tt_pass.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def __init__(self, target, args, kwargs):
323323
# TODO: no ttnn op can convert _adaptive_avg_pool2d
324324
return self.call_function_prop_meta(target, args, kwargs)
325325

326+
if target == torch.ops.aten.detach.default:
327+
return args[0]
328+
326329
return self.call_function_prop_meta(target, args, kwargs)
327330

328331

0 commit comments

Comments
 (0)