[Mlir-commits] [mlir] mlir::mesh::shardingOp adding shard-size control (PR #98145)

Boian Petkantchin llvmlistbot at llvm.org
Tue Aug 6 21:58:40 PDT 2024


================
@@ -129,15 +328,28 @@ def Mesh_ShardOp : Mesh_Op<"shard", [
     as an operand in subsequent operations. If not, the sharding applies to the
     operation that defines the tensor value.
 
+    4. `force`: A unit attribute requesting an explicit sharding of the data,
+    therefore not allowing to be optimizied away. This is useful in the presence
+    of halos and inplace semantics.
----------------
sogartar wrote:

`tensor.insert_slice` has a result. It is also a `Pure` operation. Not using its result when this is the intention is an error. Dead code elimination would remove it. In your example, if we are using the result of `tensor.insert_slice`, canonicalization or some other simplification pass should drop the chained `mesh.shard` ops as they refer to the same sharding.
```
...
%x = ...
%t = ...
%sharding = mesh.sharding halo_sizes = [2,2] ...
%t1 = mesh.shard %t %sharding
%x1 = mesh.shard %x %sharding
%t2 = insert_slice %t1 %x1
%t3 = mesh.shard %t2 %sharding
<use %t3>
...
```


https://github.com/llvm/llvm-project/pull/98145


More information about the Mlir-commits mailing list