[Static Runtime] Fix ReplaceWithMaybeCopy test in OSS (#88099)

Summary: `ReplaceWithMaybeCopy` is guarded by `FBCODE_CAFFE` in `OptimizeGraph`. Run the pass manually to ensure it does the replacement.

Test Plan: Existing tests

Differential Revision: D40858743

Pull Request resolved: https://github.com/pytorch/pytorch/pull/88099
Approved by: https://github.com/huydhn
This commit is contained in:
Mike Iovine 2022-11-01 09:58:26 +00:00 committed by PyTorch MergeBot
parent 7c6fe21a38
commit 23fe6c8ca1

View File

@ -3194,9 +3194,14 @@ TEST(StaticRuntime, ReplaceWithMaybeCopy) {
smodule.runtime().check_for_memory_leak();
EXPECT_TRUE(expected.equal(actual));
EXPECT_FALSE(hasProcessedNodeWithName(smodule, "aten::to"));
// Make a fresh graph to ensure the pass works in isolation
auto new_graph = std::make_shared<torch::jit::Graph>();
torch::jit::parseIR(to, new_graph.get());
ReplaceWithMaybeCopy(new_graph);
EXPECT_FALSE(hasNodeWithKind(new_graph, "aten::to"));
EXPECT_TRUE(
hasProcessedNodeWithName(smodule, "static_runtime::to_maybe_copy_out"));
hasNodeWithKind(new_graph, "static_runtime::to_maybe_copy_out"));
}
TEST(StaticRuntime, Int) {