This is useful for dialects that have logical subparts.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I have a dialect in npcomp that would greatly benefit from this. The basic problem is that we are importing a notion of "op" that is present in PyTorch, and has a "namespace" and "unqualified portion" of the op names. The "namespace" isn't really a dialect, but is useful to map to C++ namespaces in the code. We still model all these ops as part of a single dialect of "registered torch ops".
I don't quire get why can't just use the dialect namespace?
Anyway, not really opposed either, but can you add an op in the test dialect that would use this?
What I want is for different ops in the dialect to be in different namespaces. See dialect.td in the patch for an example.
I understand what the patch is doing and what you want, I don't really understand why...
See my above comment:
I have a dialect in npcomp that would greatly benefit from this. The basic problem is that we are importing a notion of "op" that is present in PyTorch, and has a "namespace" and "unqualified portion" of the op names. The "namespace" isn't really a dialect, but is useful to map to C++ namespaces in the code. We still model all these ops as part of a single dialect of "registered torch ops".
The basic problem is that PyTorch has notions of "ops" like prim::ListUnpack, aten::add, etc. The logical thing (because these "namespaces" are not "dialects" in the MLIR sense; they are just random prefixes that don't really have a strong structure to them) is to import them into the same dialect as torch.prim.ListUnpack and torch.aten.add. However, at the C++ level, I still want to retain ...::prim::ListUnpackOp and ...::aten::AddOp. Does that make sense? I could instead do PrimListUnpackOp and AtenAddOp but it just seems ugly.
I'd have thought it most natural to import each into its own dialect (e.g., torch_prim.ListUnpack) or having "subdialect" concept (which has been tossed around but unclear what it means - although with dialect fallbacks these become interesting because a subdialect could fallback to main dialect ...). These seem to be in same dialect just because from same frontend?
One-dialect-per-torch-namespace-prefix is not a good design point for us, because there are many namespaces, and they don't follow the types of structural rationales that characterize MLIR dialects.
I read it, but beyond saying "it is useful", it didn't bring clarity to me.
However, at the C++ level, I still want to retain ...::prim::ListUnpackOp and ...::aten::AddOp. Does that make sense?
Not really: I mean it seems arbitrary and disconnected from the way Ops in dialect usually work. Again I'm not objecting to adding the feature here to MLIR, but I would find it confusing that I can't access all the ops in a dialect from the dialect namespace. As long as it makes sense in the context of your use case that's fine...
It seems there is agreement that this is a useful feature to support. Can someone LGTM?