torch-mlir/lib
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
..
Backend Add npcomp-verify-backend-contract pass. 2021-04-20 12:00:35 -07:00
CAPI Add npcomp-verify-backend-contract pass. 2021-04-20 12:00:35 -07:00
Conversion Add `aten.mm` to linalg lowering. 2021-04-16 12:03:31 -07:00
Dialect Fix issue with unused functions in torch::jit::CompilationUnit 2021-04-20 12:00:35 -07:00
RefBackend Bump llvm-project to 223dcdcfbe23affdf17ada7f023ee1872fd76160 2021-04-05 17:56:35 -07:00
Typing Bump llvm-project to c68d2895a1f4019b387c69d1e5eec31b0eb5e7b0 2021-02-22 12:23:24 -08:00
CMakeLists.txt Add npcomp-verify-backend-contract pass. 2021-04-20 12:00:35 -07:00
InitAll.cpp Add npcomp-verify-backend-contract pass. 2021-04-20 12:00:35 -07:00