Skip to content

Commit dd5fc1c

Browse files
author
git apple-llvm automerger
committed
Merge commit '5db0d770c7e8' from llvm.org/release/17.x into stable/20230725
2 parents 49d978b + 5db0d77 commit dd5fc1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+233
-226
lines changed

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ static mlir::ParseResult parseAllocatableOp(FN wrapResultType,
128128
parser.emitError(parser.getNameLoc(), "invalid allocate type: ") << intype;
129129
return mlir::failure();
130130
}
131-
result.addAttribute(
132-
"operand_segment_sizes",
133-
builder.getDenseI32ArrayAttr({typeparamsSize, shapeSize}));
131+
result.addAttribute("operandSegmentSizes", builder.getDenseI32ArrayAttr(
132+
{typeparamsSize, shapeSize}));
134133
if (parser.parseOptionalAttrDict(result.attributes) ||
135134
parser.addTypeToList(restype, result.types))
136135
return mlir::failure();
@@ -149,7 +148,7 @@ static void printAllocatableOp(mlir::OpAsmPrinter &p, OP &op) {
149148
p << ", ";
150149
p.printOperand(sh);
151150
}
152-
p.printOptionalAttrDict(op->getAttrs(), {"in_type", "operand_segment_sizes"});
151+
p.printOptionalAttrDict(op->getAttrs(), {"in_type", "operandSegmentSizes"});
153152
}
154153

155154
//===----------------------------------------------------------------------===//

flang/test/Fir/convert-to-llvm-openmp-and-fir.fir

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func.func @_QPsb1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref<!
2828
// CHECK: %[[ONE_2:.*]] = llvm.mlir.constant(1 : i32) : i32
2929
// CHECK: omp.parallel {
3030
// CHECK: %[[ONE_3:.*]] = llvm.mlir.constant(1 : i64) : i64
31-
// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
31+
// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operandSegmentSizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
3232
// CHECK: %[[N:.*]] = llvm.load %[[N_REF]] : !llvm.ptr<i32>
3333
// CHECK: omp.wsloop nowait
3434
// CHECK-SAME: for (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) inclusive step (%[[ONE_2]]) {
@@ -200,7 +200,7 @@ func.func @_QPsimd1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref
200200
// CHECK: %[[ONE_2:.*]] = llvm.mlir.constant(1 : i32) : i32
201201
// CHECK: omp.parallel {
202202
// CHECK: %[[ONE_3:.*]] = llvm.mlir.constant(1 : i64) : i64
203-
// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
203+
// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operandSegmentSizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
204204
// CHECK: %[[N:.*]] = llvm.load %[[N_REF]] : !llvm.ptr<i32>
205205
// CHECK: omp.simdloop
206206
// CHECK-SAME: (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) step (%[[ONE_2]]) {
@@ -231,13 +231,13 @@ func.func @_QPomp_target_data() {
231231

232232
// CHECK-LABEL: llvm.func @_QPomp_target_data() {
233233
// CHECK: %[[VAL_0:.*]] = llvm.mlir.constant(1 : i64) : i64
234-
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<1024 x i32> {bindc_name = "a", in_type = !fir.array<1024xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEa"} : (i64) -> !llvm.ptr<array<1024 x i32>>
234+
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<1024 x i32> {bindc_name = "a", in_type = !fir.array<1024xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEa"} : (i64) -> !llvm.ptr<array<1024 x i32>>
235235
// CHECK: %[[VAL_2:.*]] = llvm.mlir.constant(1 : i64) : i64
236-
// CHECK: %[[VAL_3:.*]] = llvm.alloca %[[VAL_2]] x !llvm.array<1024 x i32> {bindc_name = "b", in_type = !fir.array<1024xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEb"} : (i64) -> !llvm.ptr<array<1024 x i32>>
236+
// CHECK: %[[VAL_3:.*]] = llvm.alloca %[[VAL_2]] x !llvm.array<1024 x i32> {bindc_name = "b", in_type = !fir.array<1024xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEb"} : (i64) -> !llvm.ptr<array<1024 x i32>>
237237
// CHECK: %[[VAL_4:.*]] = llvm.mlir.constant(1 : i64) : i64
238-
// CHECK: %[[VAL_5:.*]] = llvm.alloca %[[VAL_4]] x !llvm.array<1024 x i32> {bindc_name = "c", in_type = !fir.array<1024xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEc"} : (i64) -> !llvm.ptr<array<1024 x i32>>
238+
// CHECK: %[[VAL_5:.*]] = llvm.alloca %[[VAL_4]] x !llvm.array<1024 x i32> {bindc_name = "c", in_type = !fir.array<1024xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEc"} : (i64) -> !llvm.ptr<array<1024 x i32>>
239239
// CHECK: %[[VAL_6:.*]] = llvm.mlir.constant(1 : i64) : i64
240-
// CHECK: %[[VAL_7:.*]] = llvm.alloca %[[VAL_6]] x !llvm.array<1024 x i32> {bindc_name = "d", in_type = !fir.array<1024xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEd"} : (i64) -> !llvm.ptr<array<1024 x i32>>
240+
// CHECK: %[[VAL_7:.*]] = llvm.alloca %[[VAL_6]] x !llvm.array<1024 x i32> {bindc_name = "d", in_type = !fir.array<1024xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_target_dataEd"} : (i64) -> !llvm.ptr<array<1024 x i32>>
241241
// CHECK: omp.target_enter_data map((to -> %[[VAL_1]] : !llvm.ptr<array<1024 x i32>>), (to -> %[[VAL_3]] : !llvm.ptr<array<1024 x i32>>), (always, alloc -> %[[VAL_5]] : !llvm.ptr<array<1024 x i32>>))
242242
// CHECK: omp.target_exit_data map((from -> %[[VAL_1]] : !llvm.ptr<array<1024 x i32>>), (from -> %[[VAL_3]] : !llvm.ptr<array<1024 x i32>>), (release -> %[[VAL_5]] : !llvm.ptr<array<1024 x i32>>), (always, delete -> %[[VAL_7]] : !llvm.ptr<array<1024 x i32>>))
243243
// CHECK: llvm.return
@@ -278,9 +278,9 @@ func.func @_QPopenmp_target_data_region() {
278278

279279
// CHECK-LABEL: llvm.func @_QPopenmp_target_data_region() {
280280
// CHECK: %[[VAL_0:.*]] = llvm.mlir.constant(1 : i64) : i64
281-
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<1024 x i32> {bindc_name = "a", in_type = !fir.array<1024xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_data_regionEa"} : (i64) -> !llvm.ptr<array<1024 x i32>>
281+
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<1024 x i32> {bindc_name = "a", in_type = !fir.array<1024xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_data_regionEa"} : (i64) -> !llvm.ptr<array<1024 x i32>>
282282
// CHECK: %[[VAL_2:.*]] = llvm.mlir.constant(1 : i64) : i64
283-
// CHECK: %[[VAL_3:.*]] = llvm.alloca %[[VAL_2]] x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_data_regionEi"} : (i64) -> !llvm.ptr<i32>
283+
// CHECK: %[[VAL_3:.*]] = llvm.alloca %[[VAL_2]] x i32 {bindc_name = "i", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_data_regionEi"} : (i64) -> !llvm.ptr<i32>
284284
// CHECK: omp.target_data map((tofrom -> %[[VAL_1]] : !llvm.ptr<array<1024 x i32>>)) {
285285
// CHECK: %[[VAL_4:.*]] = llvm.mlir.constant(1 : i32) : i32
286286
// CHECK: %[[VAL_5:.*]] = llvm.sext %[[VAL_4]] : i32 to i64
@@ -338,7 +338,7 @@ func.func @_QPomp_target() {
338338

339339
// CHECK-LABEL: llvm.func @_QPomp_target() {
340340
// CHECK: %[[VAL_0:.*]] = llvm.mlir.constant(1 : i64) : i64
341-
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<512 x i32> {bindc_name = "a", in_type = !fir.array<512xi32>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFomp_targetEa"} : (i64) -> !llvm.ptr<array<512 x i32>>
341+
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.array<512 x i32> {bindc_name = "a", in_type = !fir.array<512xi32>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFomp_targetEa"} : (i64) -> !llvm.ptr<array<512 x i32>>
342342
// CHECK: %[[VAL_2:.*]] = llvm.mlir.constant(64 : i32) : i32
343343
// CHECK: omp.target thread_limit(%[[VAL_2]] : i32) map((tofrom -> %[[VAL_1]] : !llvm.ptr<array<512 x i32>>)) {
344344
// CHECK: %[[VAL_3:.*]] = llvm.mlir.constant(10 : i32) : i32
@@ -544,7 +544,7 @@ func.func @_QPsb() {
544544
// CHECK: llvm.func @_QPsb() {
545545
// CHECK: %[[ONE:.*]] = llvm.mlir.constant(1 : i32) : i32
546546
// CHECK: %[[SIZE:.*]] = llvm.mlir.constant(1 : i64) : i64
547-
// CHECK: %[[LI_REF:.*]] = llvm.alloca %6 x i32 {bindc_name = "li", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFsbEli"} : (i64) -> !llvm.ptr<i32>
547+
// CHECK: %[[LI_REF:.*]] = llvm.alloca %6 x i32 {bindc_name = "li", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFsbEli"} : (i64) -> !llvm.ptr<i32>
548548
// CHECK: omp.sections {
549549
// CHECK: omp.section {
550550
// CHECK: llvm.br ^[[BB_ENTRY:.*]]({{.*}})
@@ -582,7 +582,7 @@ func.func @_QPsb() {
582582
// CHECK: }
583583
// CHECK-LABEL: @_QPsimple_reduction
584584
// CHECK-SAME: %[[ARRAY_REF:.*]]: !llvm.ptr<array<100 x i32>>
585-
// CHECK: %[[RED_ACCUMULATOR:.*]] = llvm.alloca %2 x i32 {bindc_name = "x", in_type = !fir.logical<4>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFsimple_reductionEx"} : (i64) -> !llvm.ptr<i32>
585+
// CHECK: %[[RED_ACCUMULATOR:.*]] = llvm.alloca %2 x i32 {bindc_name = "x", in_type = !fir.logical<4>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFsimple_reductionEx"} : (i64) -> !llvm.ptr<i32>
586586
// CHECK: omp.parallel {
587587
// CHECK: omp.wsloop reduction(@[[EQV_REDUCTION]] -> %[[RED_ACCUMULATOR]] : !llvm.ptr<i32>) for
588588
// CHECK: %[[ARRAY_ELEM_REF:.*]] = llvm.getelementptr %[[ARRAY_REF]][0, %{{.*}}] : (!llvm.ptr<array<100 x i32>>, i64) -> !llvm.ptr<i32>

flang/test/Fir/convert-to-llvm.fir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ func.func @no_reassoc(%arg0: !fir.ref<i32>) {
17481748
// CHECK-LABEL: llvm.func @no_reassoc(
17491749
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<i32>) {
17501750
// CHECK: %[[C1:.*]] = llvm.mlir.constant(1 : i64) : i64
1751-
// CHECK: %[[ALLOC:.*]] = llvm.alloca %[[C1]] x i32 {in_type = i32, operand_segment_sizes = array<i32: 0, 0>} : (i64) -> !llvm.ptr<i32>
1751+
// CHECK: %[[ALLOC:.*]] = llvm.alloca %[[C1]] x i32 {in_type = i32, operandSegmentSizes = array<i32: 0, 0>} : (i64) -> !llvm.ptr<i32>
17521752
// CHECK: %[[LOAD:.*]] = llvm.load %[[ARG0]] : !llvm.ptr<i32>
17531753
// CHECK: llvm.store %[[LOAD]], %[[ALLOC]] : !llvm.ptr<i32>
17541754
// CHECK: llvm.return
@@ -1868,7 +1868,7 @@ func.func private @_QPxb(!fir.box<!fir.array<?x?xf64>>)
18681868
// CHECK: %[[C1_0:.*]] = llvm.mlir.constant(1 : i64) : i64
18691869
// CHECK: %[[ARR_SIZE_TMP1:.*]] = llvm.mul %[[C1_0]], %[[N1]] : i64
18701870
// CHECK: %[[ARR_SIZE:.*]] = llvm.mul %[[ARR_SIZE_TMP1]], %[[N2]] : i64
1871-
// CHECK: %[[ARR:.*]] = llvm.alloca %[[ARR_SIZE]] x f64 {bindc_name = "arr", in_type = !fir.array<?x?xf64>, operand_segment_sizes = array<i32: 0, 2>, uniq_name = "_QFsbEarr"} : (i64) -> !llvm.ptr<f64>
1871+
// CHECK: %[[ARR:.*]] = llvm.alloca %[[ARR_SIZE]] x f64 {bindc_name = "arr", in_type = !fir.array<?x?xf64>, operandSegmentSizes = array<i32: 0, 2>, uniq_name = "_QFsbEarr"} : (i64) -> !llvm.ptr<f64>
18721872
// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(28 : i32) : i32
18731873
// CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr<f64>
18741874
// CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1]
@@ -1945,9 +1945,9 @@ func.func private @_QPtest_dt_callee(%arg0: !fir.box<!fir.array<?xi32>>)
19451945
// CHECK: %[[C10:.*]] = llvm.mlir.constant(10 : i64) : i64
19461946
// CHECK: %[[C2:.*]] = llvm.mlir.constant(2 : i64) : i64
19471947
// CHECK: %[[ALLOCA_SIZE_V:.*]] = llvm.mlir.constant(1 : i64) : i64
1948-
// CHECK: %[[V:.*]] = llvm.alloca %[[ALLOCA_SIZE_V]] x i32 {bindc_name = "v", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEv"} : (i64) -> !llvm.ptr<i32>
1948+
// CHECK: %[[V:.*]] = llvm.alloca %[[ALLOCA_SIZE_V]] x i32 {bindc_name = "v", in_type = i32, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEv"} : (i64) -> !llvm.ptr<i32>
19491949
// CHECK: %[[ALLOCA_SIZE_X:.*]] = llvm.mlir.constant(1 : i64) : i64
1950-
// CHECK: %[[X:.*]] = llvm.alloca %[[ALLOCA_SIZE_X]] x !llvm.array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>> {bindc_name = "x", in_type = !fir.array<20x!fir.type<_QFtest_dt_sliceTt{i:i32,j:i32}>>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEx"} : (i64) -> !llvm.ptr<array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>>>
1950+
// CHECK: %[[X:.*]] = llvm.alloca %[[ALLOCA_SIZE_X]] x !llvm.array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>> {bindc_name = "x", in_type = !fir.array<20x!fir.type<_QFtest_dt_sliceTt{i:i32,j:i32}>>, operandSegmentSizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEx"} : (i64) -> !llvm.ptr<array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>>>
19511951
// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32
19521952
// CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr<i32>
19531953
// CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1]

mlir/docs/PatternRewriter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Example output is shown below:
383383
```
384384
//===-------------------------------------------===//
385385
Processing operation : 'cf.cond_br'(0x60f000001120) {
386-
"cf.cond_br"(%arg0)[^bb2, ^bb2] {operand_segment_sizes = array<i32: 1, 0, 0>} : (i1) -> ()
386+
"cf.cond_br"(%arg0)[^bb2, ^bb2] {operandSegmentSizes = array<i32: 1, 0, 0>} : (i1) -> ()
387387
388388
* Pattern SimplifyConstCondBranchPred : 'cf.cond_br -> ()' {
389389
} -> failure : pattern failed to match

mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ def IRDL_OperandsOp : IRDL_Op<"operands", [HasParent<"OperationOp">]> {
223223

224224
The `mul` operation will expect two operands of type `cmath.complex`, that
225225
have the same type, and return a result of the same type.
226+
227+
The operands can also be marked as variadic or optional:
228+
```mlir
229+
irdl.operands(%0, single %1, optional %2, variadic %3)
230+
```
231+
232+
Here, %0 and %1 are required single operands, %2 is an optional operand,
233+
and %3 is a variadic operand.
234+
235+
When more than one operand is marked as optional or variadic, the operation
236+
will expect a 'operandSegmentSizes' attribute that defines the number of
237+
operands in each segment.
226238
}];
227239

228240
let arguments = (ins Variadic<IRDL_AttributeType>:$args);
@@ -254,6 +266,18 @@ def IRDL_ResultsOp : IRDL_Op<"results", [HasParent<"OperationOp">]> {
254266

255267
The operation will expect one operand of the `cmath.complex` type, and two
256268
results that have the underlying type of the `cmath.complex`.
269+
270+
The results can also be marked as variadic or optional:
271+
```mlir
272+
irdl.results(%0, single %1, optional %2, variadic %3)
273+
```
274+
275+
Here, %0 and %1 are required single results, %2 is an optional result,
276+
and %3 is a variadic result.
277+
278+
When more than one result is marked as optional or variadic, the operation
279+
will expect a 'resultSegmentSizes' attribute that defines the number of
280+
results in each segment.
257281
}];
258282

259283
let arguments = (ins Variadic<IRDL_AttributeType>:$args);

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -874,23 +874,6 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
874874
return cast<DestinationStyleOpInterface>(*this->getOperation())
875875
.hasTensorSemantics();
876876
}
877-
878-
//========================================================================//
879-
// Helper functions to mutate the `operand_segment_sizes` attribute.
880-
// These are useful when cloning and changing operand types.
881-
//========================================================================//
882-
void setNumInputs(unsigned num) { setOperandSegmentAt(0, num); }
883-
void setNumOutputBuffers(unsigned num) { setOperandSegmentAt(1, num); }
884-
885-
private:
886-
void setOperandSegmentAt(unsigned idx, unsigned val) {
887-
auto attr = ::llvm::cast<DenseIntElementsAttr>(
888-
(*this)->getAttr("operand_segment_sizes"));
889-
unsigned i = 0;
890-
auto newAttr = attr.mapValues(IntegerType::get(getContext(), 32),
891-
[&](const APInt &v) { return (i++ == idx) ? APInt(32, val) : v; });
892-
getOperation()->setAttr("operand_segment_sizes", newAttr);
893-
}
894877
}];
895878

896879
let verify = [{ return detail::verifyStructuredOpInterface($_op); }];

mlir/include/mlir/IR/OpBase.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ def SameVariadicOperandSize : GenInternalOpTrait<"SameVariadicOperandSize">;
21782178
// to have the same array size.
21792179
def SameVariadicResultSize : GenInternalOpTrait<"SameVariadicResultSize">;
21802180

2181-
// Uses an attribute named `operand_segment_sizes` to specify how many actual
2181+
// Uses an attribute named `operandSegmentSizes` to specify how many actual
21822182
// operand each ODS-declared operand (variadic or not) corresponds to.
21832183
// This trait is used for ops that have multiple variadic operands but do
21842184
// not know statically their size relationship. The attribute must be a 1D
@@ -2188,7 +2188,7 @@ def SameVariadicResultSize : GenInternalOpTrait<"SameVariadicResultSize">;
21882188
def AttrSizedOperandSegments :
21892189
NativeOpTrait<"AttrSizedOperandSegments">, StructuralOpTrait;
21902190
// Similar to AttrSizedOperandSegments, but used for results. The attribute
2191-
// should be named as `result_segment_sizes`.
2191+
// should be named as `resultSegmentSizes`.
21922192
def AttrSizedResultSegments :
21932193
NativeOpTrait<"AttrSizedResultSegments">, StructuralOpTrait;
21942194

mlir/include/mlir/IR/OpDefinition.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,17 +1331,15 @@ struct HasParent {
13311331
/// relationship is not always known statically. For such cases, we need
13321332
/// a per-op-instance specification to divide the operands into logical groups
13331333
/// or segments. This can be modeled by attributes. The attribute will be named
1334-
/// as `operand_segment_sizes`.
1334+
/// as `operandSegmentSizes`.
13351335
///
13361336
/// This trait verifies the attribute for specifying operand segments has
13371337
/// the correct type (1D vector) and values (non-negative), etc.
13381338
template <typename ConcreteType>
13391339
class AttrSizedOperandSegments
13401340
: public TraitBase<ConcreteType, AttrSizedOperandSegments> {
13411341
public:
1342-
static StringRef getOperandSegmentSizeAttr() {
1343-
return "operand_segment_sizes";
1344-
}
1342+
static StringRef getOperandSegmentSizeAttr() { return "operandSegmentSizes"; }
13451343

13461344
static LogicalResult verifyTrait(Operation *op) {
13471345
return ::mlir::OpTrait::impl::verifyOperandSizeAttr(
@@ -1354,7 +1352,7 @@ template <typename ConcreteType>
13541352
class AttrSizedResultSegments
13551353
: public TraitBase<ConcreteType, AttrSizedResultSegments> {
13561354
public:
1357-
static StringRef getResultSegmentSizeAttr() { return "result_segment_sizes"; }
1355+
static StringRef getResultSegmentSizeAttr() { return "resultSegmentSizes"; }
13581356

13591357
static LogicalResult verifyTrait(Operation *op) {
13601358
return ::mlir::OpTrait::impl::verifyResultSizeAttr(

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,28 +1675,28 @@ py::object PyOpView::buildGeneric(
16751675
} else {
16761676
attributes = py::dict();
16771677
}
1678-
if (attributes->contains("result_segment_sizes") ||
1679-
attributes->contains("operand_segment_sizes")) {
1680-
throw py::value_error("Manually setting a 'result_segment_sizes' or "
1681-
"'operand_segment_sizes' attribute is unsupported. "
1678+
if (attributes->contains("resultSegmentSizes") ||
1679+
attributes->contains("operandSegmentSizes")) {
1680+
throw py::value_error("Manually setting a 'resultSegmentSizes' or "
1681+
"'operandSegmentSizes' attribute is unsupported. "
16821682
"Use Operation.create for such low-level access.");
16831683
}
16841684

1685-
// Add result_segment_sizes attribute.
1685+
// Add resultSegmentSizes attribute.
16861686
if (!resultSegmentLengths.empty()) {
16871687
MlirAttribute segmentLengthAttr =
16881688
mlirDenseI32ArrayGet(context->get(), resultSegmentLengths.size(),
16891689
resultSegmentLengths.data());
1690-
(*attributes)["result_segment_sizes"] =
1690+
(*attributes)["resultSegmentSizes"] =
16911691
PyAttribute(context, segmentLengthAttr);
16921692
}
16931693

1694-
// Add operand_segment_sizes attribute.
1694+
// Add operandSegmentSizes attribute.
16951695
if (!operandSegmentLengths.empty()) {
16961696
MlirAttribute segmentLengthAttr =
16971697
mlirDenseI32ArrayGet(context->get(), operandSegmentLengths.size(),
16981698
operandSegmentLengths.data());
1699-
(*attributes)["operand_segment_sizes"] =
1699+
(*attributes)["operandSegmentSizes"] =
17001700
PyAttribute(context, segmentLengthAttr);
17011701
}
17021702
}

0 commit comments

Comments
 (0)