[acc_tracer] Enable check_mutable_operations (#64456)
authorJordan Fix <jfix@fb.com>
Wed, 8 Sep 2021 23:09:53 +0000 (16:09 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 8 Sep 2021 23:11:15 +0000 (16:11 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64456

att

Test Plan: CI

Reviewed By: protonu

Differential Revision: D30679174

fbshipit-source-id: 73f3a07d58380cd44fb3481aa97d463c0a964de8

torch/fx/experimental/fx_acc/acc_tracer.py

index 1f6a365..21fade9 100644 (file)
@@ -204,6 +204,9 @@ class ConditionalExceptionWrapper(nn.Module):
 # Custom tracer that traces to the functional level and rewrites asserts and
 # exceptions.
 class AccRewritingTracer(Tracer):
+    # Add an explicit check for mutable operations, which break symbolic tracing.
+    check_mutable_operations = True
+
     # Note: Treat ConditionalExceptionWrapper as a leaf so that we don't
     # trace into it, because it contains control flow and raises an exception.
     DEFAULT_LEAF_MODULE_LIST = {