torch-mlir/lib/Dialect
Sean Silva fef1733e12 Fix issue with unused functions in torch::jit::CompilationUnit
As described in the code comment:

```
When we import TorchScript IR, we import their entire "compilation unit",
which can contain numerous functions unrelated to the current program,
which breaks torch-globalization-pipeline; for example, there can be
random functions referencing types that haven't been imported
as part of the root `torch.nn.Module` we imported. Those will
be unreferenced private functions which symbol-dce will clean up nicely.
```

This situation is really easy to hit in jupyter notebooks, where the
same cell is evaluated multiple times. That results in the same
class name (at the Python level, e.g. class `Foo` in the top-level
main module). Internally to PyTorch, it handles this situation by
mangling in a unique number to the names of ClassType's and such. When
we import the new ClassType's, we see not just the new
torch::jit::Function's in the CompilationUnit, but, also all the old
ones, which reference ClassType's that are not reachable from the
`torch.nn.Module` that we imported.

Note: there is no way to avoid importing the whole CompilationUnit
(including these old remnants) without doing a fairly complicated call
graph reachability analysis of which functions are reachable from the
methods of the ClassType's we imported. It turns out that once we are
inside MLIR, we model visibility correctly so that `symbol-dce`
"Just Works" for this use case. That is to say, this is not a quick
hack, but rather seems like a totally palatable long-term solution.
2021-04-20 12:00:35 -07:00
..
ATen Bump llvm-project to 0524a09cc7e1a0797982feacf505825231efbee7 2021-03-23 14:29:05 -07:00
Basicpy Bump llvm-project to 0524a09cc7e1a0797982feacf505825231efbee7 2021-03-23 14:29:05 -07:00
Numpy Add RefinePublicReturn pass. 2021-04-07 11:06:34 -07:00
Refback [RefBackend] Use std.global_memref instead of homegrown thing 2020-11-13 18:43:50 -08:00
Refbackrt [refbackrt] Scalar arg support 2021-03-23 13:16:44 -07:00
TCF Bump llvm-project to 16c6e9c58e9ae50a775945e6b407f1891f353d2f 2021-01-05 16:12:11 -08:00
TCP Bump llvm-project to 0524a09cc7e1a0797982feacf505825231efbee7 2021-03-23 14:29:05 -07:00
Torch Fix issue with unused functions in torch::jit::CompilationUnit 2021-04-20 12:00:35 -07:00
CMakeLists.txt [RefBackend] Rename RefBackend dialect to Refback 2020-10-08 09:07:00 -07:00