From: Mike Iovine Date: Fri, 20 Aug 2021 13:14:13 +0000 (-0700) Subject: [Static Runtime] Enable RemoveListMutation (#63536) X-Git-Tag: accepted/tizen/8.0/unified/20231005.095509~852 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae901e372e7b05fe1802e44fe2f1f6aa015710af;p=platform%2Fupstream%2Fpytorch.git [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 --- 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); };