[Static Runtime] Check if outputs of a node do not overlap with each other (#63013)
authorDon Jang <djang@fb.com>
Wed, 15 Sep 2021 15:35:57 +0000 (08:35 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 15 Sep 2021 15:38:05 +0000 (08:38 -0700)
commit3fb33b38b9edfb294b32b61e6c6133822e48f215
treee35f8fc3e9d9a0bed132310916a6dcc69782a3d0
parent26e43fe9f3e9d5790dead654349842992e4ded8a
[Static Runtime] Check if outputs of a node do not overlap with each other (#63013)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63013

This change enhances the current memory overlapping check to include outputs: the enhancement enforces a constraint that all outputs of a node should NOT overlap with each other since they are supposed to be update by a node at the same time, holding the node's outputs.

This check will detect a problem like T97393697 immediately in debug mode.

Test Plan:
- Added a unittest `ProcessedNode.VerifyMemoryOverlapWithOverlappingOutputs`

- Ran `inline_cvr` on ./buck-out/opt/gen/caffe2/caffe2/fb/predictor/ptvsc2_predictor_bench with this diff and confirmed that the checking condition holds true during the run.

Reviewed By: hlu1

Differential Revision: D30211705

fbshipit-source-id: 994d8dace2422e2498e504eb61452a55739238c0
benchmarks/static_runtime/test_static_runtime.cc
torch/csrc/jit/runtime/static/impl.cpp
torch/csrc/jit/runtime/static/impl.h