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
48 lines
1.8 KiB
C++
48 lines
1.8 KiB
C++
//===- Utils.cpp - Transform dialect utilities ----------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/Dialect/Transform/Utils/Utils.h"
|
|
|
|
#include "mlir/IR/OpDefinition.h"
|
|
#include "mlir/Interfaces/ViewLikeInterface.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::transform;
|
|
|
|
void mlir::transform::printPackedOrDynamicIndexList(
|
|
OpAsmPrinter &printer, Operation *op, Value packed, Type packedType,
|
|
OperandRange values, TypeRange valueTypes, DenseI64ArrayAttr integers) {
|
|
if (packed) {
|
|
assert(values.empty() && (!integers || integers.empty()) &&
|
|
"expected no values/integers");
|
|
printer << "*(" << packed << " : " << packedType << ")";
|
|
return;
|
|
}
|
|
printDynamicIndexList(printer, op, values, integers, valueTypes);
|
|
}
|
|
|
|
ParseResult mlir::transform::parsePackedOrDynamicIndexList(
|
|
OpAsmParser &parser, std::optional<OpAsmParser::UnresolvedOperand> &packed,
|
|
Type &packedType, SmallVectorImpl<OpAsmParser::UnresolvedOperand> &values,
|
|
SmallVectorImpl<Type> &valueTypes, DenseI64ArrayAttr &integers) {
|
|
OpAsmParser::UnresolvedOperand packedOperand;
|
|
if (parser.parseOptionalStar().succeeded()) {
|
|
if (parser.parseLParen().failed() ||
|
|
parser.parseOperand(packedOperand).failed() ||
|
|
parser.parseColonType(packedType).failed() ||
|
|
parser.parseRParen().failed()) {
|
|
return failure();
|
|
}
|
|
packed.emplace(packedOperand);
|
|
integers = parser.getBuilder().getDenseI64ArrayAttr({});
|
|
return success();
|
|
}
|
|
|
|
return parseDynamicIndexList(parser, values, integers, &valueTypes);
|
|
}
|