Skip to content

Commit ab86b8c

Browse files
[mlir][linalg][transform] Fix printing of TileToForall in edge case.
The `static_(num_threads|tile_sizes)` attributes of this op are `DefaultValuedOptionalAttr`s, so they can be constructed *without* such an attribute. In other words, the following is a valid op (note the absense of the `static_num_threads` attribute): "builtin.module"() ({ "transform.sequence"() <{failure_propagation_mode = 1 : i32, operand_segment_sizes = array<i32: 0, 0>}> ({ ^bb0(%arg0: !pdl.operation, %arg1: !transform.op<"linalg.matmul">, %arg2: !transform.op<"linalg.elemwise_binary">): %0 = "transform.structured.match"(%arg0) <{ops = ["test.dummy"]}> : (!pdl.operation) -> !pdl.operation %1:2 = "transform.structured.tile_to_forall_op"(%arg1, %0) <{operand_segment_sizes = array<i32: 1, 0, 0, 0, 1>}> : (!transform.op<"linalg.matmul">, !pdl.operation) -> (!transform.op<"scf.forall">, !transform.op<"linalg.matmul">) "transform.yield"() : () -> () }) : () -> () }) : () -> () However, the custom printing directive converted those to an `ArrayRef`, which crashes if done on an empty `ArrayAttr`. This patch changes the signature such that no automatic conversion takes place and extends the test to test for existinnce of the attribute. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D155062
1 parent 58d1eaa commit ab86b8c

File tree

2 files changed

+4
-3
lines changed
  • mlir

2 files changed

+4
-3
lines changed

mlir/include/mlir/Dialect/Transform/Utils/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TransformState;
3636
void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op,
3737
Value packed, Type packedType,
3838
OperandRange values, TypeRange valueTypes,
39-
ArrayRef<int64_t> integers);
39+
DenseI64ArrayAttr integers);
4040

4141
/// Parser hook for custom directive in assemblyFormat.
4242
///

mlir/lib/Dialect/Transform/Utils/Utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ using namespace mlir::transform;
1616

1717
void mlir::transform::printPackedOrDynamicIndexList(
1818
OpAsmPrinter &printer, Operation *op, Value packed, Type packedType,
19-
OperandRange values, TypeRange valueTypes, ArrayRef<int64_t> integers) {
19+
OperandRange values, TypeRange valueTypes, DenseI64ArrayAttr integers) {
2020
if (packed) {
21-
assert(values.empty() && integers.empty() && "expected no values/integers");
21+
assert(values.empty() && (!integers || integers.empty()) &&
22+
"expected no values/integers");
2223
printer << "*(" << packed << " : " << packedType << ")";
2324
return;
2425
}

0 commit comments

Comments
 (0)