Skip to content

Commit c847164

Browse files
Varchocopybara-github
authored andcommitted
[SDY] Add equi-sharding op ShardingGroupOp parsing and printing.
PiperOrigin-RevId: 651172814
1 parent 158707d commit c847164

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

shardy/dialect/sdy/ir/ops.td

+25
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,31 @@ def Sdy_ManualComputationOp : Sdy_Op<"manual_computation",
187187
}];
188188
}
189189

190+
def Sdy_ShardingGroupOp : Sdy_Op<"sharding_group",
191+
// Op is non-pure since it modifies the internal representation of the
192+
// sharding group.
193+
[]>{
194+
let summary = "Sharding group operation";
195+
let description = [{
196+
This op provides an interface to assign tensors to sharding groups (
197+
groups of tensors that will be enforced to have identical shardings).
198+
During propagation, as soon as one group element is sharded, all other
199+
members will be sharded in exactly the same way. This operation takes the
200+
argument group ID and returns no result, but instead modifies the internal
201+
sharding group representation to add the input tensor to the group with the
202+
given ID.
203+
}];
204+
205+
let arguments = (ins
206+
AnyRankedTensor:$input,
207+
I64Attr:$group_id);
208+
209+
// Dangling op has no results.
210+
let results = (outs);
211+
212+
let assemblyFormat = "$input `group_id````=```$group_id attr-dict `:` type($input)";
213+
}
214+
190215
def Sdy_ConstantOp : Sdy_Op<"constant",
191216
[Pure, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
192217
let summary = "Constant operation";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: sdy_opt %s 2>&1 | FileCheck %s
2+
3+
// CHECK-LABEL: func @add_to_default_group_type
4+
func.func @add_to_default_group_type(%arg0: tensor<8xf32>) {
5+
// CHECK sdy.sharding_group %arg0 group_id=21 type=AS : tensor<8xf32>
6+
sdy.sharding_group %arg0 group_id=21 : tensor<8xf32>
7+
func.return
8+
}

0 commit comments

Comments
 (0)