From d96ef8c1b1860185f0bd91699f71a087cf9e9efe Mon Sep 17 00:00:00 2001 From: Mike Iovine Date: Mon, 23 Aug 2021 18:43:17 -0700 Subject: [PATCH] [Static Runtime] SR clones graph input (#63704) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63704 Previously SR did not clone the graph. This was leading to subtle bugs in `testStaticRuntime`; static runtime would modify its graph, and the graph used by the JIT interpreter would change as well. The JIT interpreter would then crash if SR-only ops were added! Cloning the graph is more consistent with the behavior of the `Module` ctor. Test Plan: `buck test caffe2/benchmarks/static_runtime/...` Reviewed By: hlu1 Differential Revision: D30463294 fbshipit-source-id: b771551a1f55f95fde79373b23babcf3e5ddf726 --- torch/csrc/jit/runtime/static/impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch/csrc/jit/runtime/static/impl.cpp b/torch/csrc/jit/runtime/static/impl.cpp index 4219be5..1b5ee72 100644 --- a/torch/csrc/jit/runtime/static/impl.cpp +++ b/torch/csrc/jit/runtime/static/impl.cpp @@ -548,7 +548,7 @@ PrepareForStaticModule( StaticModule::StaticModule( std::shared_ptr g, const StaticModuleOptions& opts) - : StaticModule(PrepareForStaticModule(g, opts), opts) {} + : StaticModule(PrepareForStaticModule(g->copy(), opts), opts) {} StaticModule::StaticModule( const torch::jit::Module& m, -- 2.7.4