torch-mlir/include/npcomp/Dialect
Sean Silva 58c7030104 Support multiple instances of a class in GlobalizeObjectGraph.
This happens in practice with e.g. ResNet from torchvision (multiple
instances of the same BatchNorm class).

The key observation is that for this program, and the expected set of
programs, we can convert the program to the same globalized form with a
bit more static analysis and effort to suitably monomorphize the
program. Though what we are doing here is fairly annoying to implement,
it saves any nontrivial later pass from having to do similar analyses
(or worse). E.g. shape inference would need to be object-graph aware,
mutation/lifetime analyses would have to be aware, etc. Additionally, it
would make us front-load what it means to have a !torch.nn.Module type
on an ABI boundary, which we are just not ready to handle.

I'm really, really hoping that in practice we can get away with
this, otherwise it's going to be really rough designing a representation
(and implementing everything to back it) that is convenient to transform
and gracefully scales from full object graph (in the most dynamic case)
down to a fixed set of global slots like we have here (in the most
static case, which we presume a lot of practical programs fall into).

This also involved introducing a
`torch-prepare-for-globalize-object-graph` pass that does a minimal set of
lowerings to simplify the IR into a more orthogonal and analyzable form,
and a `torch-globalize-pipeline` helper.

Recommended review order:
- updated documentation in Passes.td
- new tests in `globalize-object-graph-multiple-instances*.mlir`
- implementation of GlobalizeObjectGraph.cpp
- PrepareForGlobalizeObjectGraph.cpp + prepare-for-globalize-object-graph.mlir
- misc stuff like torch-globalize-pipeline pipeline definition.

With this, we can import, globalize, and inline resnet18 from
torchvision:
https://gist.github.com/silvasean/821586afc19b67d9fb72030b2e0adeb8
2021-03-11 19:21:07 -08:00
..
ATen Add initial TorchScript module importer 2021-01-28 11:55:17 -08:00
Basicpy Bump llvm-project to e31c77b1827fa4dd3511f21af11cfab18ecf6d38 2021-03-10 11:01:16 -08:00
Numpy Bump llvm-project to bc556e5685c0f97e79fb7b3c6f15cc5062db8e36 2021-01-08 14:18:09 -08:00
Refback Bump llvm-project to 444822d77a7fea28aa49edf24533c987efa1b2ee 2020-12-11 14:43:38 -08:00
Refbackrt Bump llvm-project to 444822d77a7fea28aa49edf24533c987efa1b2ee 2020-12-11 14:43:38 -08:00
TCF Add TCF convolutional op with bias addition (#137) 2020-12-15 12:53:12 -08:00
TCP Reformat code 2021-01-28 12:01:35 -08:00
Torch Support multiple instances of a class in GlobalizeObjectGraph. 2021-03-11 19:21:07 -08:00
CMakeLists.txt [RefBackend] Rename RefBackend dialect to Refback 2020-10-08 09:07:00 -07:00