From ae901e372e7b05fe1802e44fe2f1f6aa015710af Mon Sep 17 00:00:00 2001 From: Mike Iovine Date: Fri, 20 Aug 2021 06:14:13 -0700 Subject: [PATCH] [Static Runtime] Enable RemoveListMutation (#63536) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63536 Enable a pass that transforms sequences like this: ``` li = [] li.append(1) li.append(2) ``` into this: ``` li = [1, 2] ``` Initially I implemented this pass myself (D30387213), but I discovered that there is an existing pass that does the same thing. Reviewed By: hlu1 Differential Revision: D30412970 fbshipit-source-id: 0810ef03480878d5039bd800a40f5fd31c2652ec --- torch/csrc/jit/passes/freeze_module.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torch/csrc/jit/passes/freeze_module.cpp b/torch/csrc/jit/passes/freeze_module.cpp index 063b867..df1c64b 100644 --- a/torch/csrc/jit/passes/freeze_module.cpp +++ b/torch/csrc/jit/passes/freeze_module.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -90,6 +91,7 @@ class AttributePropagator { auto applyOptimizations = [](std::shared_ptr& subgraph) { runOptimization( subgraph, /* unroll? */ false, /* const_prop_user_classes? */ false); + RemoveListMutation(subgraph); LowerSimpleTuples(subgraph); }; -- 2.7.4