Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13370
This diff adds a new net type (simple_refcount) that does one thing: for all
intermediate results produced by a net, it will keep refcount about internal
usage, and when it finishes its consumption, the net will delete the blob
content to mimic the case of dynamic allocation. In fact, this would also be
the behavior when we go functional: anything that is not explicitly marked as
input or output will be up to the executor for lifetime management.
See the comments in net_simple_refcount.cc for details.
Reviewed By: dzhulgakov
Differential Revision: D12855489
fbshipit-source-id: 594a47a786305d595fd505b6700864dd1d9c72aa