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
StaticModule::StaticModule(
std::shared_ptr<torch::jit::Graph> g,
const StaticModuleOptions& opts)
- : StaticModule(PrepareForStaticModule(g, opts), opts) {}
+ : StaticModule(PrepareForStaticModule(g->copy(), opts), opts) {}
StaticModule::StaticModule(
const torch::jit::Module& m,