pytorch/test/cpp
Elias Ellison ae286d81e0 [JIT] improve alias analysis for list constructs (#39111)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39111

In our present alias analysis, we consider any Value that enter another container as entering the heap, and thus aliasing all other heap values of the same type. There are a number of advantages to this approach:
- it is not to hard to maintain the aliasDb implementation
- it is much easier from an op schema perspective - there are many composite list ops registered internally and externally that would be tricky to register and get right if we did something more complicated
- It limits the size of the AliasDb, because a container of size 10 only contains a single memory dag element instead of 10 elements.

The downside is that we have are unable to handle the simple and extremely common case of a list of tensors being used in an ATen op.

In an example like:

```
 def foo(input):
    x = torch.tensor([1, 2, 3, 4])
    y = [x, x]
    input.add_(1)
    return torch.cat(y)
```

we will consider x to be written to. any write to any wildcard element (an element that enters a tuple, an element that is taken from a list) will mark x as written to. This can be limiting for our ability to create a functional subset and fuse graphs - as a result, 4 of TorchVision classification models could not be functionalized.

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D23828003

Pulled By: eellison

fbshipit-source-id: 9109fcb6f2ca20ca897cae71683530285da9d537
2020-09-22 09:38:59 -07:00
..
api Add one dimensional FFTs to torch.fft namespace (#43011) 2020-09-19 23:32:22 -07:00
common Trim libshm deps, move tempfile.h to c10 (#17019) 2019-02-13 19:38:35 -08:00
dist_autograd Release DistAutogradContainer context for each dist_autograd test case (#38711) 2020-06-18 20:58:55 -07:00
jit [JIT] improve alias analysis for list constructs (#39111) 2020-09-22 09:38:59 -07:00
rpc Make Channel API accept buffer structs rather than raw pointers. (#45014) 2020-09-21 10:18:45 -07:00
tensorexpr [NNC] fix SyncThreads insertion and reenable CudaSharedMem test (#44909) 2020-09-21 09:27:22 -07:00
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00