[llvm-branch-commits] [mlir] [mlir][ODS] Add so-called "Natural Sharding" to ops (PR #239254)
Markus Böck via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Nov 6 01:07:54 PST 2026
================
@@ -1370,6 +1370,110 @@ cc_library(
)
```
+#### Natural Sharding with Op Partitions
+
+Sharding by index splits the ops arbitrarily: which shard an op ends up in
+depends on the number of shards and on the names of all other ops. As an
+alternative, a dialect can shard its ops "naturally" by grouping them into
+named *op partitions*, such as arithmetic, memory or control flow ops. Each
+partition is generated into its own declaration and definition files, almost as
+if it were a dialect of its own, but all ops are still registered in one
+dialect.
+
+Partitions are `Partition` records with a name, which must be a C++
+identifier. The dialect lists its partitions, and every op sets its `partition`
+to one of these records (a different record with the same name is rejected),
+typically with a `let` around a group of ops:
+
+```tablegen
+def MyDialect_ArithPartition : Partition<"Arith">;
+def MyDialect_MemoryPartition : Partition<"Memory">;
+
+def MyDialect : Dialect {
+ let name = "my_dialect";
+ let opPartitions = [MyDialect_ArithPartition, MyDialect_MemoryPartition];
+}
+
+let partition = MyDialect_ArithPartition in {
----------------
zero9178 wrote:
Could also do that if we want to enforce that all ops of a partition must be adjacent to each other.
The current design with the let has the advantage that depending on the situation there is a good way to apply it:
* singular let if one-off
* top-level `let` statement that does the same kind of delimiting as the `defset` syntax
* specify in a base-class for good defaults
Not opposed to the `defset` but does make use slightly more inflexible. Note also that I want to have type and attribute partitions in the future too (which might be different partitions than the op partitions), so it'd probably be `OpPartition<MyDialect, SomePartition>` if we were to go with your syntax.
https://github.com/llvm/llvm-project/pull/239254
More information about the llvm-branch-commits
mailing list