From 2fe4d90cac54bf35948bea2ca6d5d8c510f6a1b4 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Tue, 21 Feb 2023 21:04:00 +0000 Subject: [mlir] make structured transform ops use types Types have been introduced a while ago and provide for better readability and transform-time verification. Use them in the ops from the structured transform dialect extension. In most cases, the types are appended as trailing functional types or a derived format of the functional type that allows for an empty right hand size without the annoying `-> ()` syntax (similarly to `func.func` declaration that may omit the arrow). When handles are used inside mixed static/dynamic lists, such as tile sizes, types of those handles follow them immediately as in `sizes [%0 : !transform.any_value, 42]`. This allows for better readability than matching the trailing type. Update code to remove hardcoded PDL dependencies and expunge PDL from structured transform op code. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D144515 --- .../Linalg/TransformOps/LinalgTransformOps.td | 187 +++--- .../mlir/Dialect/Linalg/TransformOps/Syntax.h | 47 ++ mlir/include/mlir/Dialect/Transform/Utils/Utils.h | 18 +- mlir/include/mlir/Interfaces/ViewLikeInterface.h | 40 +- .../lib/Dialect/Linalg/TransformOps/CMakeLists.txt | 2 +- .../Linalg/TransformOps/DialectExtension.cpp | 2 - .../Dialect/Linalg/TransformOps/LinalgMatchOps.cpp | 77 +-- .../Linalg/TransformOps/LinalgTransformOps.cpp | 136 +++-- mlir/lib/Dialect/Linalg/TransformOps/Syntax.cpp | 76 +++ mlir/lib/Dialect/SCF/IR/SCF.cpp | 12 +- mlir/lib/Dialect/Transform/Utils/Utils.cpp | 23 +- mlir/lib/Interfaces/ViewLikeInterface.cpp | 16 +- mlir/test/Dialect/GPU/transform-gpu-failing.mlir | 12 +- mlir/test/Dialect/LLVM/transform-e2e.mlir | 32 +- .../Linalg/generalize-tensor-pack-tile.mlir | 18 +- .../Linalg/generalize-tensor-unpack-tile.mlir | 18 +- mlir/test/Dialect/Linalg/promote.mlir | 34 +- mlir/test/Dialect/Linalg/promotion_options.mlir | 8 +- .../Dialect/Linalg/tile-to-foreach-thread.mlir | 53 +- .../Dialect/Linalg/transform-op-decompose.mlir | 6 +- .../Linalg/transform-op-fuse-into-containing.mlir | 43 +- mlir/test/Dialect/Linalg/transform-op-fuse.mlir | 26 +- .../Dialect/Linalg/transform-op-generalize.mlir | 6 +- ...sform-op-hoist-pad-build-packing-loop-nest.mlir | 68 +-- .../Dialect/Linalg/transform-op-hoist-pad.mlir | 104 ++-- .../Dialect/Linalg/transform-op-interchange.mlir | 12 +- .../transform-op-matmul-to-outerproduct.mlir | 10 +- mlir/test/Dialect/Linalg/transform-op-pack.mlir | 144 ++--- mlir/test/Dialect/Linalg/transform-op-pad.mlir | 40 +- mlir/test/Dialect/Linalg/transform-op-replace.mlir | 18 +- .../Dialect/Linalg/transform-op-scalarize.mlir | 8 +- .../transform-op-split-reduction-by-scaling.mlir | 5 +- .../Linalg/transform-op-split-reduction.mlir | 30 +- mlir/test/Dialect/Linalg/transform-op-tile.mlir | 9 +- .../Dialect/Linalg/transform-op-vectorize.mlir | 30 +- .../test/Dialect/Linalg/transform-ops-invalid.mlir | 54 +- mlir/test/Dialect/Linalg/transform-ops.mlir | 16 +- mlir/test/Dialect/Linalg/transform-patterns.mlir | 46 +- mlir/test/Dialect/Linalg/transform-promotion.mlir | 44 +- .../Dialect/Linalg/transform-tile-and-fuse.mlir | 16 +- .../Dialect/Linalg/transform-tile-reduction.mlir | 62 +- mlir/test/Dialect/Linalg/vectorization.mlir | 644 ++++++++++----------- .../SCF/transform-op-take-assumed-branch.mlir | 9 +- mlir/test/Dialect/Tensor/tiling.mlir | 102 ++-- .../Dialect/Transform/selective-targeting.mlir | 32 +- mlir/test/Dialect/Vector/transform-vector.mlir | 32 +- 46 files changed, 1304 insertions(+), 1123 deletions(-) create mode 100644 mlir/include/mlir/Dialect/Linalg/TransformOps/Syntax.h create mode 100644 mlir/lib/Dialect/Linalg/TransformOps/Syntax.cpp (limited to 'mlir') diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td index c7bc3767b27c..4f78b7d6c80d 100644 --- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td +++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td @@ -14,7 +14,6 @@ include "mlir/Dialect/Transform/IR/TransformAttrs.td" include "mlir/Dialect/Transform/IR/TransformDialect.td" include "mlir/Dialect/Transform/IR/TransformInterfaces.td" include "mlir/Dialect/Transform/IR/TransformTypes.td" -include "mlir/Dialect/PDL/IR/PDLTypes.td" include "mlir/Dialect/SCF/IR/DeviceMappingInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/IR/OpBase.td" @@ -96,15 +95,16 @@ def DecomposeOp : Op:$tile_sizes, DefaultValuedAttr:$tile_interchange); - let results = (outs PDL_Operation:$transformed, - Variadic:$loops); + let results = (outs TransformHandleTypeInterface:$transformed, + Variadic:$loops); let hasCustomAssemblyFormat = 1; let hasVerifier = 1; @@ -181,10 +181,11 @@ def FuseIntoContainingOp : This operation only reads the containing op handle. }]; - let arguments = (ins PDL_Operation:$producer_op, - PDL_Operation:$containing_op); - let results = (outs PDL_Operation:$fused_op); - let assemblyFormat = "$producer_op `into` $containing_op attr-dict"; + let arguments = (ins TransformHandleTypeInterface:$producer_op, + TransformHandleTypeInterface:$containing_op); + let results = (outs TransformHandleTypeInterface:$fused_op); + let assemblyFormat = "$producer_op `into` $containing_op attr-dict " + " `:` functional-type(operands, results)"; let builders = [ OpBuilder<(ins "Value":$producerOp, "Value":$containingOp)> @@ -205,16 +206,18 @@ def GeneralizeOp : Op(type($target), type($transformed))"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( @@ -239,7 +242,7 @@ def InterchangeOp : Op, [DenseArrayNonNegative]>:$iterator_interchange); - let results = (outs PDL_Operation:$transformed); + let results = (outs TransformHandleTypeInterface:$transformed); let assemblyFormat = [{ $target (`iterator_interchange` `=` $iterator_interchange^)? attr-dict + `:` custom(type($target), type($transformed)) }]; let hasVerifier = 1; @@ -552,13 +556,14 @@ def PackOp : Op:$packed_sizes, + Variadic:$packed_sizes, DefaultValuedAttr:$static_packed_sizes); let results = (outs TransformHandleTypeInterface:$packed_op); let assemblyFormat = [{ $target `packed_sizes` `=` custom($packed_sizes, - $static_packed_sizes) + $static_packed_sizes, + type($packed_sizes)) attr-dict `:` functional-type($target, results) }]; @@ -637,7 +642,7 @@ def PackGreedilyOp : Op needs interface. let arguments = (ins TransformHandleTypeInterface:$target, - Variadic:$matmul_packed_sizes, + Variadic:$matmul_packed_sizes, ConfinedAttr, [DenseArrayCount<3>]>:$static_matmul_packed_sizes, ConfinedAttr, @@ -662,7 +667,8 @@ def PackGreedilyOp : Op($matmul_packed_sizes, - $static_matmul_packed_sizes) + $static_matmul_packed_sizes, + type($matmul_packed_sizes)) (`matmul_padded_sizes_next_multiple_of` `=` $matmul_padded_sizes_next_multiple_of^)? `matmul_inner_dims_order` `=` $matmul_inner_dims_order @@ -758,23 +764,25 @@ def PadOp : Op:$padding_values, DefaultValuedAttr:$padding_dimensions, DefaultValuedAttr:$pack_paddings, DefaultValuedAttr< TypedArrayAttrBase, "{}">:$transpose_paddings); - let results = (outs PDL_Operation:$transformed); + let results = (outs TransformHandleTypeInterface:$transformed); - let assemblyFormat = "$target attr-dict"; + let assemblyFormat = + "$target attr-dict `:` " + "custom(type($target), type($transformed))"; let hasVerifier = 1; let extraClassDeclaration = [{ @@ -898,23 +906,25 @@ def PromoteOp : Op:$operands_to_promote, DefaultValuedAttr:$use_full_tile_buffers, UnitAttr:$use_full_tiles_by_default, UnitAttr:$use_alloca, OptionalAttr:$mapping, OptionalAttr:$alignment); - let results = (outs PDL_Operation:$transformed); + let results = (outs TransformHandleTypeInterface:$transformed); - let assemblyFormat = "$target attr-dict"; + let assemblyFormat = + "$target attr-dict `:`" + "custom(type($target), type($transformed))"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( @@ -943,10 +953,12 @@ def ReplaceOp : Op:$bodyRegion); - let assemblyFormat = "$target attr-dict-with-keyword regions"; + let assemblyFormat = + "$target attr-dict-with-keyword regions `:` " + "custom(type($target), type($replacement))"; let hasVerifier = 1; } @@ -966,7 +978,7 @@ def ScalarizeOp : Op(type($target), type($result))"; let extraClassDeclaration = [{ ::mlir::DiagnosedSilenceableFailure applyToOne( @@ -1016,13 +1030,13 @@ def RewriteInDestinationPassingStyleOp : Op< #### Return modes This operation ignores non-unsupported ops and drops them from the return. - If all the operations referred to by the `target` PDLOperation generalize + If all the operations referred to by the `target` handle generalize properly, the transform succeeds. Otherwise the transform silently fails. The return handle points to a subset of successfully produced operations: - - tensor.pad case, the returned handle points to the tensor.insert_slice. - - tensor.generate case, the returned handle points to the linalg.generic. - - tensor.from_elements case, the returned handle points to the last - tensor.insert. + - `tensor.pad` case, the returned handle points to the tensor.insert_slice. + - `tensor.generate` case, the returned handle points to the linalg.generic. + - `tensor.from_elements` case, the returned handle points to the last + `tensor.insert`. }]; let arguments = (ins TransformHandleTypeInterface:$target); @@ -1110,7 +1124,7 @@ def SplitReductionOp : Op:$split_factor, DefaultValuedAttr:$insert_split_dimension, UnitAttr:$inner_parallel, UnitAttr:$use_scaling_algorithm, UnitAttr:$use_alloc); - let results = (outs PDL_Operation:$init_or_alloc_op, - PDL_Operation:$fill_op, - PDL_Operation:$split_linalg_op, - PDL_Operation:$combining_linalg_op); + let results = (outs TransformHandleTypeInterface:$init_or_alloc_op, + TransformHandleTypeInterface:$fill_op, + TransformHandleTypeInterface:$split_linalg_op, + TransformHandleTypeInterface:$combining_linalg_op); - let assemblyFormat = "$target attr-dict"; + let assemblyFormat = + "$target attr-dict `:`" + "functional-type(operands, results)"; let builders = [ OpBuilder<(ins "Value":$target, @@ -1326,12 +1342,12 @@ def TileReductionUsingScfOp : Op:$tile_sizes); - let results = (outs PDL_Operation:$for_op, - PDL_Operation:$fill_op, - PDL_Operation:$split_linalg_op, - PDL_Operation:$combining_linalg_op); + let results = (outs TransformHandleTypeInterface:$for_op, + TransformHandleTypeInterface:$fill_op, + TransformHandleTypeInterface:$split_linalg_op, + TransformHandleTypeInterface:$combining_linalg_op); let builders = [ OpBuilder<(ins "Value":$target, @@ -1342,6 +1358,7 @@ def TileReductionUsingScfOp : Op:$num_threads, DefaultValuedAttr:$tile_sizes, OptionalAttr:$mapping); - let results = (outs PDL_Operation:$forall_op, - PDL_Operation:$fill_op, - PDL_Operation:$split_linalg_op, - PDL_Operation:$combining_linalg_op); + let results = (outs TransformHandleTypeInterface:$forall_op, + TransformHandleTypeInterface:$fill_op, + TransformHandleTypeInterface:$split_linalg_op, + TransformHandleTypeInterface:$combining_linalg_op); let builders = [ OpBuilder<(ins "Value":$target, @@ -1450,6 +1467,7 @@ def TileReductionUsingForallOp : (`,` `tile_sizes` `=` $tile_sizes^)? (`,` `mapping` `=` $mapping^)? attr-dict + `:` functional-type(operands, results) }]; let extraClassDeclaration = [{ @@ -1577,7 +1595,7 @@ def TileToForallOp : This operation ignores ops that do not implement the TilingInterface and drops them in the return. - If all the operations referred to by the `target` PDLOperation tile + If all the operations referred to by the `target` handle tile successfully, the transform succeeds. Otherwise the transform silently fails. @@ -1604,16 +1622,16 @@ def TileToForallOp : ``` }]; - let arguments = (ins PDL_Operation:$target, - Variadic:$num_threads, - Variadic:$tile_sizes, - Optional:$packed_num_threads, - Optional:$packed_tile_sizes, + let arguments = (ins TransformHandleTypeInterface:$target, + Variadic:$num_threads, + Variadic:$tile_sizes, + Optional:$packed_num_threads, + Optional:$packed_tile_sizes, DefaultValuedOptionalAttr:$static_num_threads, DefaultValuedOptionalAttr:$static_tile_sizes, OptionalAttr:$mapping); - let results = (outs PDL_Operation:$forall_op, - PDL_Operation:$tiled_op); + let results = (outs TransformHandleTypeInterface:$forall_op, + TransformHandleTypeInterface:$tiled_op); let builders = [ OpBuilder<(ins "Value":$target, @@ -1641,12 +1659,17 @@ def TileToForallOp : let assemblyFormat = [{ $target oilist( `num_threads` custom($packed_num_threads, + type($packed_num_threads), $num_threads, + type($num_threads), $static_num_threads) | `tile_sizes` custom($packed_tile_sizes, + type($packed_tile_sizes), $tile_sizes, + type($tile_sizes), $static_tile_sizes)) (`(` `mapping` `=` $mapping^ `)`)? attr-dict + `:` functional-type($target, results) }]; let hasVerifier = 1; @@ -1705,12 +1728,12 @@ def TileToScfForOp : Op:$dynamic_sizes, + let arguments = (ins TransformHandleTypeInterface:$target, + Variadic:$dynamic_sizes, DefaultValuedOptionalAttr:$static_sizes, DefaultValuedOptionalAttr:$interchange); - let results = (outs PDL_Operation:$tiled_linalg_op, - Variadic:$loops); + let results = (outs TransformHandleTypeInterface:$tiled_linalg_op, + Variadic:$loops); let builders = [ OpBuilder<(ins "Value":$target, @@ -1760,7 +1783,7 @@ def VectorizeOp : Op:$vector_sizes, + let arguments = (ins TransformHandleTypeInterface:$target, + Variadic:$vector_sizes, UnitAttr:$vectorize_nd_extract, DefaultValuedOptionalAttr: $static_vector_sizes); @@ -1826,8 +1851,10 @@ def MaskedVectorizeOp : Op($vector_sizes, - $static_vector_sizes) + $static_vector_sizes, + type($vector_sizes)) attr-dict + `:` type($target) }]; let extraClassDeclaration = [{ diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/Syntax.h b/mlir/include/mlir/Dialect/Linalg/TransformOps/Syntax.h new file mode 100644 index 000000000000..13b0dc0e0b95 --- /dev/null +++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/Syntax.h @@ -0,0 +1,47 @@ +//===- Syntax.h - Custom syntax for Linalg transform ops --------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H +#define MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H + +#include "mlir/Support/LLVM.h" + +namespace mlir { +class ParseResult; +class OpAsmParser; +class OpAsmPrinter; +class Type; +class TypeRange; +class Operation; + +/// Parses a single non-function type or a function type with at least one +/// argument. This allows for the following syntax: +/// +/// - type: just the argument type; +/// - `(` type `)` `->` type: one argument and one result type; +/// - `(` type `)` `->` `(` comma-separated-type-list `)`: one argument and +/// multiple result types. +/// +/// Unlike FunctionType, this allows and requires one to omit the parens around +/// the argument type in absence of result types, and does not accept the +/// trailing `-> ()` construct, which makes the syntax nicer for operations. +ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType, + Type &resultType); +ParseResult parseSemiFunctionType(OpAsmParser &parser, Type &argumentType, + SmallVectorImpl &resultTypes); + +/// Prints argument and result types in a syntax similar to that of FunctionType +/// but allowing and requiring one to omit the parens around the argument type +/// in absence of result types, and without the trailing `-> ()`. +void printSemiFunctionType(OpAsmPrinter &printer, Operation *op, + Type argumentType, TypeRange resultType); +void printSemiFunctionType(OpAsmPrinter &printer, Operation *op, + Type argumentType, Type resultType); +} // namespace mlir + +#endif // MLIR_DIALECT_LINALG_TRANSFORMOPS_SYNTAX_H diff --git a/mlir/include/mlir/Dialect/Transform/Utils/Utils.h b/mlir/include/mlir/Dialect/Transform/Utils/Utils.h index 04a0b090e6b9..97b193bc723d 100644 --- a/mlir/include/mlir/Dialect/Transform/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Transform/Utils/Utils.h @@ -22,7 +22,8 @@ class TransformState; /// Printer hook for custom directive in assemblyFormat. /// -/// custom($packed, $values, $integers) +/// custom($packed, type($packed), $values, +/// type($values), $integers) /// /// where `values` are variadic Index values, `integers` is an `I64ArrayAttr` /// and `packed` is a single transform dialect handle who's mapped payload ops @@ -30,20 +31,23 @@ class TransformState; /// or the other two parameters may be specified. /// /// This allows idiomatic printing of mixed value and integer attributes in a -/// list or with a single handle. E.g., `[%arg0, 7, 42, %arg42]` or just `%h`. +/// list or with a single handle. E.g., `[%arg0 : !transform.any_op, 7, 42, +/// %arg42 : !transform.param]` or just `%h : !transform.any_op`. void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op, - Value packed, OperandRange values, + Value packed, Type packedType, + OperandRange values, TypeRange valueTypes, ArrayRef integers); -/// Pasrer hook for custom directive in assemblyFormat. +/// Parser hook for custom directive in assemblyFormat. /// -/// custom($packed, $values, $integers) +/// custom($packed, type($packed), $values, +/// type($values), $integers) /// /// See `printPackedOrDynamicIndexList` for details. ParseResult parsePackedOrDynamicIndexList( OpAsmParser &parser, std::optional &packed, - SmallVectorImpl &values, - DenseI64ArrayAttr &integers); + Type &packedType, SmallVectorImpl &values, + SmallVectorImpl &valueTypes, DenseI64ArrayAttr &integers); } // namespace transform } // namespace mlir diff --git a/mlir/include/mlir/Interfaces/ViewLikeInterface.h b/mlir/include/mlir/Interfaces/ViewLikeInterface.h index 5843ecd061df..87113197524f 100644 --- a/mlir/include/mlir/Interfaces/ViewLikeInterface.h +++ b/mlir/include/mlir/Interfaces/ViewLikeInterface.h @@ -42,35 +42,49 @@ namespace mlir { /// Printer hook for custom directive in assemblyFormat. /// /// custom($values, $integers) +/// custom($values, $integers, type($values)) /// -/// where `values` is of ODS type `Variadic` and `integers` is of ODS +/// where `values` is of ODS type `Variadic<*>` and `integers` is of ODS /// type `I64ArrayAttr`. Prints a list with either (1) the static integer value -/// in `integers` is `dynVal` or (2) the next value otherwise. This allows -/// idiomatic printing of mixed value and integer attributes in a list. E.g. -/// `[%arg0, 7, 42, %arg42]`. +/// in `integers` is `kDynamic` or (2) the next value otherwise. If `valueTypes` +/// is non-empty, it is expected to contain as many elements as `values` +/// indicating their types. This allows idiomatic printing of mixed value and +/// integer attributes in a list. E.g. +/// `[%arg0 : index, 7, 42, %arg42 : i32]`. void printDynamicIndexList( OpAsmPrinter &printer, Operation *op, OperandRange values, - ArrayRef integers, + ArrayRef integers, TypeRange valueTypes = TypeRange(), AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square); -/// Pasrer hook for custom directive in assemblyFormat. +/// Parser hook for custom directive in assemblyFormat. /// /// custom($values, $integers) +/// custom($values, $integers, type($values)) /// -/// where `values` is of ODS type `Variadic` and `integers` is of ODS +/// where `values` is of ODS type `Variadic<*>` and `integers` is of ODS /// type `I64ArrayAttr`. Parse a mixed list with either (1) static integer /// values or (2) SSA values. Fill `integers` with the integer ArrayAttr, where -/// `dynVal` encodes the position of SSA values. Add the parsed SSA values -/// to `values` in-order. -// -/// E.g. after parsing "[%arg0, 7, 42, %arg42]": -/// 1. `result` is filled with the i64 ArrayAttr "[`dynVal`, 7, 42, `dynVal`]" +/// `kDynamic` encodes the position of SSA values. Add the parsed SSA values +/// to `values` in-order. If `valueTypes` is non-null, fill it with types +/// corresponding to values; otherwise the caller must handle the types. +/// +/// E.g. after parsing "[%arg0 : index, 7, 42, %arg42 : i32]": +/// 1. `result` is filled with the i64 ArrayAttr "[`kDynamic`, 7, 42, +/// `kDynamic`]" /// 2. `ssa` is filled with "[%arg0, %arg1]". ParseResult parseDynamicIndexList( OpAsmParser &parser, SmallVectorImpl &values, - DenseI64ArrayAttr &integers, + DenseI64ArrayAttr &integers, SmallVectorImpl *valueTypes = nullptr, AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square); +inline ParseResult parseDynamicIndexList( + OpAsmParser &parser, + SmallVectorImpl &values, + DenseI64ArrayAttr &integers, SmallVectorImpl &valueTypes, + AsmParser::Delimiter delimiter = AsmParser::Delimiter::Square) { + return parseDynamicIndexList(parser, values, integers, &valueTypes, + delimiter); +} /// Verify that a the `values` has as many elements as the number of entries in /// `attr` for which `isDynamic` evaluates to true. diff --git a/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt b/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt index 01038ed297f1..ec1631a9efde 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt @@ -2,6 +2,7 @@ add_mlir_dialect_library(MLIRLinalgTransformOps DialectExtension.cpp LinalgMatchOps.cpp LinalgTransformOps.cpp + Syntax.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Linalg/TransformOps @@ -19,7 +20,6 @@ add_mlir_dialect_library(MLIRLinalgTransformOps MLIRLinalgDialect MLIRLinalgTransforms MLIRParser - MLIRPDLDialect MLIRSCFDialect MLIRSideEffectInterfaces MLIRTransformDialect diff --git a/mlir/lib/Dialect/Linalg/TransformOps/DialectExtension.cpp b/mlir/lib/Dialect/Linalg/TransformOps/DialectExtension.cpp index 6cc296105be7..9578648d6363 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/DialectExtension.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/DialectExtension.cpp @@ -13,7 +13,6 @@ #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.h" #include "mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.h" -#include "mlir/Dialect/PDL/IR/PDL.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Transform/IR/TransformDialect.h" @@ -31,7 +30,6 @@ public: using Base::Base; void init() { - declareDependentDialect(); declareDependentDialect(); declareGeneratedDialect(); diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp index 0d9d533da366..d788c2feaac8 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp @@ -9,6 +9,7 @@ #include "mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.h" #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" +#include "mlir/Dialect/Linalg/TransformOps/Syntax.h" #include "mlir/Dialect/Transform/IR/MatchInterfaces.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/FunctionImplementation.h" @@ -745,82 +746,6 @@ static void printStructuredTransformDims(OpAsmPrinter &printer, Operation *op, printer << ")"; } } -/// Parses a single non-function type or a function type with at least one -/// argument. This allows for the following syntax: -/// -/// - type: just the argument type; -/// - `(` type `)` `->` type: one argument and one result type; -/// - `(` type `)` `->` `(` comma-separated-type-list `)`: one argument and -/// multiple result types. -/// -/// Unlike FunctionType, this allows and requires one to omit the parens around -/// the argument type in absence of result types, and does not accept the -/// trailing `-> ()` construct, which makes the syntax nicer for operations. -static ParseResult parseSemiFunctionType(OpAsmParser &parser, - Type &argumentType, Type &resultType) { - argumentType = resultType = nullptr; - bool hasLParen = parser.parseOptionalLParen().succeeded(); - if (parser.parseType(argumentType).failed()) - return failure(); - if (!hasLParen) - return success(); - - return failure(parser.parseRParen().failed() || - parser.parseArrow().failed() || - parser.parseType(resultType).failed()); -} -static ParseResult parseSemiFunctionType(OpAsmParser &parser, - Type &argumentType, - SmallVectorImpl &resultTypes) { - argumentType = nullptr; - bool hasLParen = parser.parseOptionalLParen().succeeded(); - if (parser.parseType(argumentType).failed()) - return failure(); - if (!hasLParen) - return success(); - - if (parser.parseRParen().failed() || parser.parseArrow().failed()) - return failure(); - - if (parser.parseOptionalLParen().failed()) { - Type type; - if (parser.parseType(type).failed()) - return failure(); - resultTypes.push_back(type); - return success(); - } - if (parser.parseTypeList(resultTypes).failed() || - parser.parseRParen().failed()) { - resultTypes.clear(); - return failure(); - } - return success(); -} - -/// Prints argument and result types in a syntax similar to that of FunctionType -/// but allowing and requiring one to omit the parens around the argument type -/// in absence of result types, and without the trailing `-> ()`. -static void printSemiFunctionType(OpAsmPrinter &printer, Operation *op, - Type argumentType, TypeRange resultType) { - if (!resultType.empty()) - printer << "("; - printer << argumentType; - if (resultType.empty()) - return; - printer << ") -> "; - - if (resultType.size() > 1) - printer << "("; - llvm::interleaveComma(resultType, printer.getStream()); - if (resultType.size() > 1) - printer << ")"; -} -static void printSemiFunctionType(OpAsmPrinter &printer, Operation *op, - Type argumentType, Type resultType) { - return printSemiFunctionType(printer, op, argumentType, - resultType ? TypeRange(resultType) - : TypeRange()); -} #define GET_OP_CLASSES #include "mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp.inc" diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp index 0703ca31f402..baabf1ae67fc 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -14,11 +14,10 @@ #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/GPU/IR/GPUDialect.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" +#include "mlir/Dialect/Linalg/TransformOps/Syntax.h" #include "mlir/Dialect/Linalg/Transforms/Hoisting.h" #include "mlir/Dialect/Linalg/Transforms/Transforms.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" -#include "mlir/Dialect/PDL/IR/PDL.h" -#include "mlir/Dialect/PDL/IR/PDLTypes.h" #include "mlir/Dialect/SCF/Transforms/TileUsingInterface.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Tensor/Utils/Utils.h" @@ -82,7 +81,7 @@ static FailureOr tryApply(Operation *operation, Args &&...args) { /// Assuming that `ofr` is an index attr or a transform dialect handle mapped /// to exactly one op with one index result, return that value. -static DiagnosedSilenceableFailure unpackSingleIndexResultPDLOperations( +static DiagnosedSilenceableFailure unpackSingleIndexResultPayloadOperations( transform::TransformState &state, TransformOpInterface transformOp, SmallVector &result, ArrayRef ofrs) { for (OpFoldResult ofr : ofrs) { @@ -122,7 +121,7 @@ static DiagnosedSilenceableFailure unpackSingleIndexResultPDLOperations( // replaced with the first (and only) OpResult of that payload op. (There // must be exactly one mapped payload op and it must have exactly one // index result.) -static DiagnosedSilenceableFailure unpackSingleIndexResultPDLOperations( +static DiagnosedSilenceableFailure unpackSingleIndexResultPayloadOperations( transform::TransformState &state, TransformOpInterface transformOp, SmallVector &result, Value packedHandle) { for (Operation *op : state.getPayloadOps(packedHandle)) { @@ -259,34 +258,6 @@ static LogicalResult applyTilingToAll( return success(); } -/// Parse a tiling-like operation that returns the tiled op as well as the -/// created tile loops. The function counts the non-zero tile sizes to compute -/// the number of results. -static ParseResult parseTileLikeOp(OpAsmParser &parser, OperationState &result, - StringRef sizesAttrName) { - OpAsmParser::UnresolvedOperand targetOperand; - SMLoc opLoc = parser.getCurrentLocation(); - if (parser.parseOperand(targetOperand) || - parser.parseOptionalAttrDict(result.attributes)) - return failure(); - Attribute sizesAttr = result.attributes.get(sizesAttrName); - if (!sizesAttr) - return parser.emitError(opLoc) - << "expected '" << sizesAttrName << "' attribute"; - auto sizesArrayAttr = dyn_cast(sizesAttr); - if (!sizesArrayAttr) - return parser.emitError(opLoc) - << "'" << sizesAttrName << "' attribute must be an array"; - Type pdlOpType = parser.getBuilder().getType(); - size_t numExpectedLoops = - sizesArrayAttr.size() - - llvm::count(extractFromI64ArrayAttr(sizesArrayAttr), 0); - result.addTypes(SmallVector(numExpectedLoops + 1, pdlOpType)); - if (parser.resolveOperand(targetOperand, pdlOpType, result.operands)) - return failure(); - return success(); -} - DiagnosedSilenceableFailure transform::FuseOp::apply(mlir::transform::TransformResults &transformResults, mlir::transform::TransformState &state) { @@ -315,15 +286,34 @@ transform::FuseOp::apply(mlir::transform::TransformResults &transformResults, ParseResult transform::FuseOp::parse(OpAsmParser &parser, OperationState &result) { - return parseTileLikeOp( - parser, result, - transform::FuseOp::getTileSizesAttrName(result.name).getValue()); + OpAsmParser::UnresolvedOperand targetOperand; + if (parser.parseOperand(targetOperand) || + parser.parseOptionalAttrDict(result.attributes)) + return failure(); + + FunctionType trailingType; + SMLoc typeLoc; + if (parser.getCurrentLocation(&typeLoc) || + parser.parseColonType(trailingType)) { + return failure(); + } + if (trailingType.getNumInputs() != 1) + return parser.emitError(typeLoc) << "expected one input type"; + + result.addTypes(trailingType.getResults()); + if (parser.resolveOperand(targetOperand, trailingType.getInput(0), + result.operands)) + return failure(); + return success(); } void transform::FuseOp::print(OpAsmPrinter &p) { p << ' '; p << getTarget(); p.printOptionalAttrDict((*this)->getAttrs()); + p << " : "; + p.printFunctionalType(TypeRange(getOperand().getType()), + getResults().getTypes()); } LogicalResult transform::FuseOp::verify() { @@ -335,6 +325,12 @@ LogicalResult transform::FuseOp::verify() { return emitOpError() << "expects interchange to be a permutation, found " << getTileInterchange(); } + + SmallVector sizes = extractFromI64ArrayAttr(getTileSizes()); + size_t numExpectedLoops = sizes.size() - llvm::count(sizes, 0); + if (numExpectedLoops != getNumResults() - 1) + return emitOpError() << "expects " << numExpectedLoops << " loop results"; + return success(); } @@ -347,7 +343,7 @@ void transform::FuseIntoContainingOp::build(OpBuilder &builder, Value producerOp, Value containingOp) { result.addOperands({producerOp, containingOp}); - result.addTypes(pdl::OperationType::get(builder.getContext())); + result.addTypes(transform::AnyOpType::get(builder.getContext())); } /// Find the first "extract" user of `producerOp` and tile it right before its @@ -792,7 +788,7 @@ void transform::MatchOp::build(OpBuilder &builder, OperationState &result, result.addOperands(target); result.addAttribute(MatchOp::getOpsAttrName(result.name), builder.getStrArrayAttr(opNames)); - result.addTypes(pdl::OperationType::get(builder.getContext())); + result.addTypes(transform::AnyOpType::get(builder.getContext())); } void transform::MatchOp::build(OpBuilder &builder, OperationState &result, @@ -1022,7 +1018,7 @@ transform::PackOp::apply(transform::TransformResults &transformResults, // Unpack handles to constants or actual SSA index values. SmallVector packedSizes; - DiagnosedSilenceableFailure status = unpackSingleIndexResultPDLOperations( + DiagnosedSilenceableFailure status = unpackSingleIndexResultPayloadOperations( state, *this, packedSizes, getMixedPackedSizes()); TrackingListener listener(state, *this); @@ -2011,7 +2007,7 @@ void transform::SplitReductionOp::build( result.addAttribute(SplitReductionOp::getUseAllocAttrName(result.name), builder.getUnitAttr()); } - auto resultType = pdl::OperationType::get(ctx); + auto resultType = transform::AnyOpType::get(ctx); result.addTypes({resultType, resultType, resultType, resultType}); } @@ -2053,7 +2049,7 @@ void transform::TileReductionUsingScfOp::build( // In the absence of this, horrible bugs ensue. // TODO: support mixed static-dynamic (see TileToForallOp). MLIRContext *ctx = builder.getContext(); - auto opTy = pdl::OperationType::get(ctx); + auto opTy = transform::AnyOpType::get(ctx); auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes); build(builder, result, /*resultTypes=*/TypeRange{opTy, opTy, opTy, opTy}, @@ -2094,7 +2090,7 @@ void transform::TileReductionUsingForallOp::build( // In the absence of this, horrible bugs ensue. // TODO: support mixed static-dynamic (see TileToForallOp). MLIRContext *ctx = builder.getContext(); - auto opTy = pdl::OperationType::get(ctx); + auto opTy = transform::AnyOpType::get(ctx); auto staticNumThreadsAttr = builder.getDenseI64ArrayAttr(staticNumThreads); auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes); build(builder, result, @@ -2448,7 +2444,7 @@ void transform::TileToForallOp::build(OpBuilder &builder, // attributes for multiple variadic operands. In the absence of this, // horrible bugs ensue. MLIRContext *ctx = builder.getContext(); - auto operationType = pdl::OperationType::get(ctx); + auto operationType = transform::AnyOpType::get(ctx); auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes); build(builder, result, /*resultTypes=*/TypeRange{operationType, operationType}, @@ -2485,7 +2481,7 @@ void transform::TileToForallOp::build(OpBuilder &builder, // attributes for multiple variadic operands. In the absence of this, // horrible bugs ensue. MLIRContext *ctx = builder.getContext(); - auto operationType = pdl::OperationType::get(ctx); + auto operationType = transform::AnyOpType::get(ctx); auto staticNumThreadsAttr = builder.getDenseI64ArrayAttr(staticNumThreads); build(builder, result, /*resultTypes=*/TypeRange{operationType, operationType}, @@ -2547,17 +2543,17 @@ transform::TileToForallOp::apply(transform::TransformResults &transformResults, SmallVector mixedNumThreads; DiagnosedSilenceableFailure status = getPackedNumThreads() - ? unpackSingleIndexResultPDLOperations( + ? unpackSingleIndexResultPayloadOperations( state, transformOp, mixedNumThreads, getPackedNumThreads()) - : unpackSingleIndexResultPDLOperations( + : unpackSingleIndexResultPayloadOperations( state, transformOp, mixedNumThreads, getMixedNumThreads()); if (!status.succeeded()) return status; SmallVector mixedTileSizes; status = getPackedTileSizes() - ? unpackSingleIndexResultPDLOperations( + ? unpackSingleIndexResultPayloadOperations( state, transformOp, mixedTileSizes, getPackedTileSizes()) - : unpackSingleIndexResultPDLOperations( + : unpackSingleIndexResultPayloadOperations( state, transformOp, mixedTileSizes, getMixedTileSizes()); if (!status.succeeded()) return status; @@ -2634,8 +2630,8 @@ void transform::TileToScfForOp::build(OpBuilder &builder, auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes); int64_t numExpectedLoops = staticTileSizes.size() - llvm::count(staticTileSizes, 0); - SmallVector resultTypes(numExpectedLoops, - pdl::OperationType::get(builder.getContext())); + SmallVector resultTypes( + numExpectedLoops, transform::AnyOpType::get(builder.getContext())); build(builder, result, /*tiled_linalg_op=*/target.getType(), /*loops=*/resultTypes, @@ -2758,20 +2754,43 @@ ParseResult transform::TileToScfForOp::parse(OpAsmParser &parser, OpAsmParser::UnresolvedOperand target; SmallVector dynamicSizes; DenseI64ArrayAttr staticSizes; - auto pdlOperationType = pdl::OperationType::get(parser.getContext()); + FunctionType trailingType; + llvm::SMLoc typeLoc; if (parser.parseOperand(target) || - parser.resolveOperand(target, pdlOperationType, result.operands) || parseDynamicIndexList(parser, dynamicSizes, staticSizes) || - parser.resolveOperands(dynamicSizes, pdlOperationType, result.operands)) + parseOptionalInterchange(parser, result) || + parser.parseOptionalAttrDict(result.attributes) || + parser.getCurrentLocation(&typeLoc) || + parser.parseColonType(trailingType)) { return ParseResult::failure(); + } - // Parse optional interchange. - if (failed(parseOptionalInterchange(parser, result))) - return ParseResult::failure(); result.addAttribute(getStaticSizesAttrName(result.name), staticSizes); size_t numExpectedLoops = staticSizes.size() - llvm::count(staticSizes.asArrayRef(), 0); - result.addTypes(SmallVector(numExpectedLoops + 1, pdlOperationType)); + + unsigned numExpectedInputTypes = 1 + dynamicSizes.size(); + if (trailingType.getNumInputs() != numExpectedInputTypes) { + return parser.emitError(typeLoc) + << "expected " << numExpectedInputTypes << " operand types, got " + << trailingType.getNumInputs(); + } + + unsigned numExpectedOutputTypes = 1 + numExpectedLoops; + if (trailingType.getNumResults() != numExpectedOutputTypes) { + return parser.emitError(typeLoc) + << "expected " << numExpectedOutputTypes << " result types, got " + << trailingType.getNumResults(); + } + + if (parser.resolveOperand(target, trailingType.getInput(0), + result.operands) || + parser.resolveOperands(dynamicSizes, + trailingType.getInputs().drop_front(), typeLoc, + result.operands) || + parser.addTypesToList(trailingType.getResults(), result.types)) { + return failure(); + } return success(); } @@ -2779,6 +2798,9 @@ void TileToScfForOp::print(OpAsmPrinter &p) { p << ' ' << getTarget(); printDynamicIndexList(p, getOperation(), getDynamicSizes(), getStaticSizes()); printOptionalInterchange(p, getInterchange()); + p.printOptionalAttrDict(getOperation()->getAttrs(), getAttributeNames()); + p << " : "; + p.printFunctionalType(getOperation()); } void transform::TileToScfForOp::getEffects( @@ -2806,7 +2828,7 @@ void transform::VectorizeOp::build(OpBuilder &builder, OperationState &result, result.addAttribute(VectorizeOp::getVectorizeNdExtractAttrName(result.name), builder.getUnitAttr()); } - result.addTypes(pdl::OperationType::get(builder.getContext())); + result.addTypes(transform::AnyOpType::get(builder.getContext())); } namespace { diff --git a/mlir/lib/Dialect/Linalg/TransformOps/Syntax.cpp b/mlir/lib/Dialect/Linalg/TransformOps/Syntax.cpp new file mode 100644 index 000000000000..7ba0a6eb68f4 --- /dev/null +++ b/mlir/lib/Dialect/Linalg/TransformOps/Syntax.cpp @@ -0,0 +1,76 @@ +//===- Syntax.cpp - Custom syntax for Linalg transform ops ----------------===// +// +// 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/Linalg/TransformOps/Syntax.h" +#include "mlir/IR/OpImplementation.h" + +using namespace mlir; + +ParseResult mlir::parseSemiFunctionType(OpAsmParser &parser, Type &argumentType, + Type &resultType) { + argumentType = resultType = nullptr; + bool hasLParen = parser.parseOptionalLParen().succeeded(); + if (parser.parseType(argumentType).failed()) + return failure(); + if (!hasLParen) + return success(); + + return failure(parser.parseRParen().failed() || + parser.parseArrow().failed() || + parser.parseType(resultType).failed()); +} + +ParseResult mlir::parseSemiFunctionType(OpAsmParser &parser, Type &argumentType, + SmallVectorImpl &resultTypes) { + argumentType = nullptr; + bool hasLParen = parser.parseOptionalLParen().succeeded(); + if (parser.parseType(argumentType).failed()) + return failure(); + if (!hasLParen) + return success(); + + if (parser.parseRParen().failed() || parser.parseArrow().failed()) + return failure(); + + if (parser.parseOptionalLParen().failed()) { + Type type; + if (parser.parseType(type).failed()) + return failure(); + resultTypes.push_back(type); + return success(); + } + if (parser.parseTypeList(resultTypes).failed() || + parser.parseRParen().failed()) { + resultTypes.clear(); + return failure(); + } + return success(); +} + +void mlir::printSemiFunctionType(OpAsmPrinter &printer, Operation *op, + Type argumentType, TypeRange resultType) { + if (!resultType.empty()) + printer << "("; + printer << argumentType; + if (resultType.empty()) + return; + printer << ") -> "; + + if (resultType.size() > 1) + printer << "("; + llvm::interleaveComma(resultType, printer.getStream()); + if (resultType.size() > 1) + printer << ")"; +} + +void mlir::printSemiFunctionType(OpAsmPrinter &printer, Operation *op, + Type argumentType, Type resultType) { + return printSemiFunctionType(printer, op, argumentType, + resultType ? TypeRange(resultType) + : TypeRange()); +} diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index a88b9136974a..7048d1348ca8 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -1220,17 +1220,17 @@ void ForallOp::print(OpAsmPrinter &p) { if (isNormalized()) { p << ") in "; printDynamicIndexList(p, op, getDynamicUpperBound(), getStaticUpperBound(), - OpAsmParser::Delimiter::Paren); + /*valueTypes=*/{}, OpAsmParser::Delimiter::Paren); } else { p << ") = "; printDynamicIndexList(p, op, getDynamicLowerBound(), getStaticLowerBound(), - OpAsmParser::Delimiter::Paren); + /*valueTypes=*/{}, OpAsmParser::Delimiter::Paren); p << " to "; printDynamicIndexList(p, op, getDynamicUpperBound(), getStaticUpperBound(), - OpAsmParser::Delimiter::Paren); + /*valueTypes=*/{}, OpAsmParser::Delimiter::Paren); p << " step "; printDynamicIndexList(p, op, getDynamicStep(), getStaticStep(), - OpAsmParser::Delimiter::Paren); + /*valueTypes=*/{}, OpAsmParser::Delimiter::Paren); } printInitializationList(p, getRegionOutArgs(), getOutputs(), " shared_outs"); p << " "; @@ -1262,6 +1262,7 @@ ParseResult ForallOp::parse(OpAsmParser &parser, OperationState &result) { if (succeeded(parser.parseOptionalKeyword("in"))) { // Parse upper bounds. if (parseDynamicIndexList(parser, dynamicUbs, staticUbs, + /*valueTypes=*/nullptr, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(dynamicUbs, indexType, result.operands)) return failure(); @@ -1273,6 +1274,7 @@ ParseResult ForallOp::parse(OpAsmParser &parser, OperationState &result) { // Parse lower bounds. if (parser.parseEqual() || parseDynamicIndexList(parser, dynamicLbs, staticLbs, + /*valueTypes=*/nullptr, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(dynamicLbs, indexType, result.operands)) @@ -1281,6 +1283,7 @@ ParseResult ForallOp::parse(OpAsmParser &parser, OperationState &result) { // Parse upper bounds. if (parser.parseKeyword("to") || parseDynamicIndexList(parser, dynamicUbs, staticUbs, + /*valueTypes=*/nullptr, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(dynamicUbs, indexType, result.operands)) return failure(); @@ -1288,6 +1291,7 @@ ParseResult ForallOp::parse(OpAsmParser &parser, OperationState &result) { // Parse step values. if (parser.parseKeyword("step") || parseDynamicIndexList(parser, dynamicSteps, staticSteps, + /*valueTypes=*/nullptr, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(dynamicSteps, indexType, result.operands)) return failure(); diff --git a/mlir/lib/Dialect/Transform/Utils/Utils.cpp b/mlir/lib/Dialect/Transform/Utils/Utils.cpp index 8f67a8886fd3..d516a56feed4 100644 --- a/mlir/lib/Dialect/Transform/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Transform/Utils/Utils.cpp @@ -15,25 +15,32 @@ using namespace mlir; using namespace mlir::transform; void mlir::transform::printPackedOrDynamicIndexList( - OpAsmPrinter &printer, Operation *op, Value packed, OperandRange values, - ArrayRef integers) { + OpAsmPrinter &printer, Operation *op, Value packed, Type packedType, + OperandRange values, TypeRange valueTypes, ArrayRef integers) { if (packed) { assert(values.empty() && integers.empty() && "expected no values/integers"); - printer << packed; + printer << "*(" << packed << " : " << packedType << ")"; return; } - printDynamicIndexList(printer, op, values, integers); + printDynamicIndexList(printer, op, values, integers, valueTypes); } ParseResult mlir::transform::parsePackedOrDynamicIndexList( OpAsmParser &parser, std::optional &packed, - SmallVectorImpl &values, - DenseI64ArrayAttr &integers) { + Type &packedType, SmallVectorImpl &values, + SmallVectorImpl &valueTypes, DenseI64ArrayAttr &integers) { OpAsmParser::UnresolvedOperand packedOperand; - if (parser.parseOptionalOperand(packedOperand).has_value()) { + 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); + + return parseDynamicIndexList(parser, values, integers, &valueTypes); } diff --git a/mlir/lib/Interfaces/ViewLikeInterface.cpp b/mlir/lib/Interfaces/ViewLikeInterface.cpp index 0b1ecc9115fd..4f48f0a57c30 100644 --- a/mlir/lib/Interfaces/ViewLikeInterface.cpp +++ b/mlir/lib/Interfaces/ViewLikeInterface.cpp @@ -102,6 +102,7 @@ static char getRightDelimiter(AsmParser::Delimiter delimiter) { void mlir::printDynamicIndexList(OpAsmPrinter &printer, Operation *op, OperandRange values, ArrayRef integers, + TypeRange valueTypes, AsmParser::Delimiter delimiter) { char leftDelimiter = getLeftDelimiter(delimiter); char rightDelimiter = getRightDelimiter(delimiter); @@ -112,10 +113,14 @@ void mlir::printDynamicIndexList(OpAsmPrinter &printer, Operation *op, } unsigned idx = 0; llvm::interleaveComma(integers, printer, [&](int64_t integer) { - if (ShapedType::isDynamic(integer)) - printer << values[idx++]; - else + if (ShapedType::isDynamic(integer)) { + printer << values[idx]; + if (!valueTypes.empty()) + printer << " : " << valueTypes[idx]; + ++idx; + } else { printer << integer; + } }); printer << rightDelimiter; } @@ -123,7 +128,8 @@ void mlir::printDynamicIndexList(OpAsmPrinter &printer, Operation *op, ParseResult mlir::parseDynamicIndexList( OpAsmParser &parser, SmallVectorImpl &values, - DenseI64ArrayAttr &integers, AsmParser::Delimiter delimiter) { + DenseI64ArrayAttr &integers, SmallVectorImpl *valueTypes, + AsmParser::Delimiter delimiter) { SmallVector integerVals; auto parseIntegerOrValue = [&]() { @@ -132,6 +138,8 @@ ParseResult mlir::parseDynamicIndexList( if (res.has_value() && succeeded(res.value())) { values.push_back(operand); integerVals.push_back(ShapedType::kDynamic); + if (valueTypes && parser.parseColonType(valueTypes->emplace_back())) + return failure(); } else { int64_t integer; if (failed(parser.parseInteger(integer))) diff --git a/mlir/test/Dialect/GPU/transform-gpu-failing.mlir b/mlir/test/Dialect/GPU/transform-gpu-failing.mlir index 459b800f76d3..813b6f3cd17e 100644 --- a/mlir/test/Dialect/GPU/transform-gpu-failing.mlir +++ b/mlir/test/Dialect/GPU/transform-gpu-failing.mlir @@ -133,10 +133,11 @@ func.func @map_nested_forall_to_threads_not_buffer(%x: tensor<32x32xf32>, %y: te } transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg0 : (!pdl.operation) -> !pdl.operation +^bb1(%arg0: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg0 : (!transform.any_op) -> !transform.any_op %forall, %tiled = transform.structured.tile_to_forall_op %matmul num_threads [10, 20, 30] (mapping = [ #gpu.thread, #gpu.thread, #gpu.thread ] ) - %funcop = transform.structured.match ops{["gpu.launch"]} in %arg0 : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) + %funcop = transform.structured.match ops{["gpu.launch"]} in %arg0 : (!transform.any_op) -> !pdl.operation // expected-error @below {{only bufferized scf.forall can be mapped}} transform.gpu.map_nested_forall_to_threads %funcop block_dims = [128, 4, 1] } @@ -298,8 +299,9 @@ func.func @tiling_buffer_semantic_op(%x: memref<32x32xf32>, %y: memref<32x32xf32 } transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.generic"]} in %arg0 : (!pdl.operation) -> !pdl.operation +^bb1(%arg0: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.generic"]} in %arg0 : (!transform.any_op) -> !transform.any_op // expected-error @below {{transform.structured.tile_to_forall_op failed to apply}} %forall, %tiled = transform.structured.tile_to_forall_op %matmul num_threads [10, 20, 30] (mapping = [ #gpu.thread, #gpu.thread, #gpu.thread ] ) + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/LLVM/transform-e2e.mlir b/mlir/test/Dialect/LLVM/transform-e2e.mlir index 0ca820640777..e9025238020b 100644 --- a/mlir/test/Dialect/LLVM/transform-e2e.mlir +++ b/mlir/test/Dialect/LLVM/transform-e2e.mlir @@ -13,47 +13,47 @@ func.func @matmul_tensors( } transform.sequence failures(propagate) { -^bb1(%module_op: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %module_op : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [2, 2, 2] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2 = get_closest_isolated_parent %1 : (!pdl.operation) -> !pdl.operation - transform.structured.vectorize %2 +^bb1(%module_op: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %module_op : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [2, 2, 2] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2 = get_closest_isolated_parent %1 : (!transform.any_op) -> !transform.any_op + transform.structured.vectorize %2 : (!transform.any_op) -> !transform.any_op %b = transform.bufferization.one_shot_bufferize layout{IdentityLayoutMap} %module_op {bufferize_function_boundaries = true} - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %f = transform.structured.match ops{["func.func"]} in %b - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op // TODO: group these lower-level controls into various properly named vector // lowering TD macros. %func = transform.vector.lower_contraction %f - lowering_strategy = "outerproduct" - : (!pdl.operation) -> !pdl.operation + lowering_strategy = "outerproduct" + : (!transform.any_op) -> !transform.any_op %func_2 = transform.vector.apply_transfer_permutation_patterns %func - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_3 = transform.vector.lower_multi_reduction %func_2 lowering_strategy = "innerparallel" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_4 = transform.vector.split_transfer_full_partial %func_3 split_transfer_strategy = "linalg-copy" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_5 = transform.vector.transfer_to_scf %func_4 max_transfer_rank = 1 full_unroll = true - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_6 = transform.vector.lower_transfer %func_5 max_transfer_rank = 1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_7 = transform.vector.lower_shape_cast %func_6 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_8 = transform.vector.lower_transpose %func_7 lowering_strategy = "shuffle_1d" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/generalize-tensor-pack-tile.mlir b/mlir/test/Dialect/Linalg/generalize-tensor-pack-tile.mlir index c22d29027670..ffc0c28ffa8a 100644 --- a/mlir/test/Dialect/Linalg/generalize-tensor-pack-tile.mlir +++ b/mlir/test/Dialect/Linalg/generalize-tensor-pack-tile.mlir @@ -25,9 +25,9 @@ func.func @KCRS_to_KCRSsr(%arg0: tensor<1x1x128x64xf32>, %arg1: tensor<1x1x4x8x8 // CHECK: %{{.+}} = tensor.insert_slice %[[TRANSP]] into %{{.+}} transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 1] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -54,9 +54,9 @@ func.func @pad_and_pack(%arg0: tensor<13x15xf32>, %arg1: tensor<2x8x8x2xf32>, %a // CHECK: %{{.+}} = tensor.insert_slice %[[TRANSP]] into %{{.+}} transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [1, 1] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [1, 1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -87,7 +87,7 @@ func.func @KC_to_CKkc(%arg0: tensor<128x256xf32>, %arg1: tensor<32x4x32x8xf32>) // CHECK: %{{.+}} = tensor.insert_slice %[[SUB_ITER]] into %{{[a-zA-Z0-9]+}} // CHECK-SAME: [%[[C]], %[[K]], 0, 0] [1, 1, 32, 8] [1, 1, 1, 1] : tensor<1x1x32x8xf32> into tensor<32x4x32x8xf32> transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [1, 1] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [1, 1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/generalize-tensor-unpack-tile.mlir b/mlir/test/Dialect/Linalg/generalize-tensor-unpack-tile.mlir index 02b3babc10cc..6e2933daf5e7 100644 --- a/mlir/test/Dialect/Linalg/generalize-tensor-unpack-tile.mlir +++ b/mlir/test/Dialect/Linalg/generalize-tensor-unpack-tile.mlir @@ -6,9 +6,9 @@ func.func @KCRSsr_to_KCRS(%arg0: tensor<1x1x4x8x8x32xf32>, %arg1: tensor<1x1x128 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 32, 8] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 32, 8] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-DAG: #[[MAP0:.+]] = affine_map<(d0) -> (d0 floordiv 32)> // CHECK-DAG: #[[MAP1:.+]] = affine_map<(d0) -> (d0 floordiv 8)> @@ -68,9 +68,9 @@ func.func @unpack_and_extract_slice(%arg0: tensor<2x8x8x2xf32>, %arg1: tensor<13 // CHECK-SAME: [%[[I]], %[[J]]] [%[[OUT_I_SZ]], %[[OUT_J_SZ]]] [1, 1] transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [8, 2] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [8, 2] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -102,7 +102,7 @@ func.func @CKkc_to_KC(%arg0: tensor<32x4x32x8xf32>, %arg1: tensor<128x256xf32>) transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [32, 8] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [32, 8] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/promote.mlir b/mlir/test/Dialect/Linalg/promote.mlir index b34a86ec901e..4b902acd41f9 100644 --- a/mlir/test/Dialect/Linalg/promote.mlir +++ b/mlir/test/Dialect/Linalg/promote.mlir @@ -67,9 +67,9 @@ func.func @matmul_f32(%A: memref, %M: index, %N: index, %K: index) { // CHECK-NOT: memref.dealloc %[[tmpC]] : memref<24xi8> transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 { use_alloca } +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 { use_alloca } : (!transform.any_op) -> !transform.any_op } // ----- @@ -137,9 +137,9 @@ func.func @matmul_f64(%A: memref, %M: index, %N: index, %K: index) { // CHECK: memref.dealloc %[[tmpC_f64]] : memref<48xi8> transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 : (!transform.any_op) -> !transform.any_op } // ----- @@ -181,10 +181,10 @@ func.func @gemm_shared(%a : memref, %b : memref, %c : memref !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2 = transform.structured.promote %1 { operands_to_promote = [0, 1], mapping = [#gpu.memory_space] } +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2 = transform.structured.promote %1 { operands_to_promote = [0, 1], mapping = [#gpu.memory_space] } : (!transform.any_op) -> !transform.any_op } @@ -223,10 +223,10 @@ func.func @gemm_private(%a : memref, %b : memref, %c : memref< transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2 = transform.structured.promote %1 { operands_to_promote = [0, 1], mapping = [#gpu.memory_space] } +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2 = transform.structured.promote %1 { operands_to_promote = [0, 1], mapping = [#gpu.memory_space] } : (!transform.any_op) -> !transform.any_op } @@ -271,7 +271,7 @@ func.func @promote_rank_reducing_subviews(%arg0: memref !pdl.operation - %1 = transform.structured.promote %0 +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/promotion_options.mlir b/mlir/test/Dialect/Linalg/promotion_options.mlir index f18d448ae9c3..894831ac34c3 100644 --- a/mlir/test/Dialect/Linalg/promotion_options.mlir +++ b/mlir/test/Dialect/Linalg/promotion_options.mlir @@ -35,8 +35,8 @@ func.func @gemm(%a : memref, %b : memref, %c : memref // CHECK: memref.dealloc %[[tmpC]] transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2 = transform.structured.promote %1 { operands_to_promote = [0, 2], force_full_tiles = [false, false], use_full_tiles_by_default } +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [16, 16, 16] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2 = transform.structured.promote %1 { operands_to_promote = [0, 2], force_full_tiles = [false, false], use_full_tiles_by_default } : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/tile-to-foreach-thread.mlir b/mlir/test/Dialect/Linalg/tile-to-foreach-thread.mlir index 731e8d0f5388..63065d5196ab 100644 --- a/mlir/test/Dialect/Linalg/tile-to-foreach-thread.mlir +++ b/mlir/test/Dialect/Linalg/tile-to-foreach-thread.mlir @@ -31,9 +31,10 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:2 = transform.structured.tile_to_forall_op %0 num_threads [10, 20] (mapping = [ #gpu.thread, #gpu.thread ] ) + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } } @@ -73,10 +74,11 @@ func.func @matmul_tile_size_dynamic_dynamic(%A: tensor, %B: tensor !pdl.operation - %sz = transform.structured.match ops{["test.dummy"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes %sz +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %sz = transform.structured.match ops{["test.dummy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes *(%sz : !transform.any_op) + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -112,9 +114,10 @@ func.func @matmul_static(%A: tensor<100x200xf32>, %B: tensor<200x300xf32>, %C: t } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:2 = transform.structured.tile_to_forall_op %0 num_threads [10, 21] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } @@ -153,9 +156,10 @@ func.func @matmul_tile_size_dynamic(%A: tensor, %B: tensor, %C } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes [10, 20] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -189,9 +193,10 @@ func.func @matmul_tile_size_static(%A: tensor<100x200xf32>, %B: tensor<200x300xf } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes [10, 21] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -211,9 +216,10 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:2 = transform.structured.tile_to_forall_op %0 num_threads [2] ( mapping = [#gpu.thread]) + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } } // CHECK-DAG: #[[$map0:.+]] = affine_map<(d0) -> (d0 * 2)> @@ -261,10 +267,11 @@ func.func @matmul_tile_size_dynamic_dynamic(%A: tensor, %B: tensor !pdl.operation - %sz = transform.structured.match ops{["test.dummy"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes [%sz, 20] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %sz = transform.structured.match ops{["test.dummy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1:2 = transform.structured.tile_to_forall_op %0 tile_sizes [%sz : !transform.any_op, 20] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -315,9 +322,10 @@ transform.sequence failures(propagate) { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %forall, %tiled_generic = transform.structured.tile_to_forall_op %0 num_threads [7] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -368,8 +376,9 @@ transform.sequence failures(propagate) { } transform.sequence failures(propagate) { - ^bb1(%IN_MAT2: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %IN_MAT2 : (!pdl.operation) -> !pdl.operation + ^bb1(%IN_MAT2: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %IN_MAT2 : (!transform.any_op) -> !transform.any_op %forall, %tiled_generic = transform.structured.tile_to_forall_op %0 num_threads [4] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/transform-op-decompose.mlir b/mlir/test/Dialect/Linalg/transform-op-decompose.mlir index 82795ec9d4bf..052992fa8711 100644 --- a/mlir/test/Dialect/Linalg/transform-op-decompose.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-decompose.mlir @@ -200,7 +200,7 @@ func.func @pooling_nchw_max(%input: tensor, %filter: tensor<1x?xf32 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.decompose %0 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.decompose %0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir b/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir index 537ee8664df4..29cacb474b96 100644 --- a/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir @@ -42,12 +42,13 @@ module { func.func @dummy3() { return } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.op<"linalg.fill"> + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.op<"scf.forall"> // linalg.fill is tileable. The op is tiled and fused. transform.structured.fuse_into_containing_op %0 into %1 + : (!transform.op<"linalg.fill">, !transform.op<"scf.forall">) -> !transform.any_op } } @@ -85,12 +86,13 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.empty"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.empty"]} in %arg1 : (!transform.any_op) -> !transform.op<"tensor.empty"> + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.op<"scf.forall"> // tensor.empty is not tileable. The op is cloned and fused. transform.structured.fuse_into_containing_op %0 into %1 + : (!transform.op<"tensor.empty">, !transform.op<"scf.forall">) -> !transform.any_op } } @@ -131,12 +133,13 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.op<"linalg.fill"> + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.op<"scf.forall"> // linalg.fill is tileable. The op is tiled and fused. transform.structured.fuse_into_containing_op %0 into %1 + : (!transform.op<"linalg.fill">, !transform.op<"scf.forall">) -> !transform.any_op } } @@ -179,12 +182,13 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.any_op // linalg.fill is tileable. The op is tiled and fused. transform.structured.fuse_into_containing_op %0 into %1 + : (!transform.any_op, !transform.any_op) -> !transform.any_op } } @@ -239,12 +243,13 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.op<"linalg.generic"> + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.op<"scf.forall"> // linalg.generic is tileable. The op is tiled and fused. transform.structured.fuse_into_containing_op %0 into %1 + : (!transform.op<"linalg.generic">, !transform.op<"scf.forall">) -> !transform.any_op } } @@ -273,13 +278,13 @@ module { transform.sequence failures(propagate) { ^bb1(%arg1: !transform.any_op): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !pdl.operation - %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !pdl.operation + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["scf.forall"]} in %arg1 : (!transform.any_op) -> !transform.any_op // Create a new handle that points to `linalg.fill` twice. - %2 = transform.merge_handles %0, %0 : !pdl.operation + %2 = transform.merge_handles %0, %0 : !transform.any_op // It shouldn't be a problem to fuse this handle. - transform.structured.fuse_into_containing_op %2 into %1 + transform.structured.fuse_into_containing_op %2 into %1 : (!transform.any_op, !transform.any_op) -> !transform.any_op } } diff --git a/mlir/test/Dialect/Linalg/transform-op-fuse.mlir b/mlir/test/Dialect/Linalg/transform-op-fuse.mlir index 66328a18fa5d..20beefb351f8 100644 --- a/mlir/test/Dialect/Linalg/transform-op-fuse.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-fuse.mlir @@ -16,9 +16,10 @@ func.func @fuse_unary(%arg0: tensor, %arg1: tensor) -> tensor< } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.elemwise_binary"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.elemwise_binary"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1, %loops:2 = transform.structured.fuse %0 {tile_sizes = [32, 32], tile_interchange = [0, 1]} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -43,11 +44,11 @@ func.func @fuse_unary(%arg0: tensor, %arg1: tensor) -> tensor< } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.elemwise_binary"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.elemwise_binary"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1, %loops:2 = transform.structured.fuse %0 {tile_sizes = [32, 32], tile_interchange = [0, 1]} - %loop = transform.cast %loops#0 : !pdl.operation to !transform.op<"scf.for"> - transform.loop.peel %loop : (!transform.op<"scf.for">) -> !pdl.operation + : (!transform.any_op) -> (!transform.any_op, !transform.op<"scf.for">, !transform.any_op) + transform.loop.peel %loops#0 : (!transform.op<"scf.for">) -> !transform.any_op } // ----- @@ -86,10 +87,12 @@ func.func @interchange_reduction(%input: tensor<12x7x25xf32>) -> tensor<12x25xf3 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1, %loops:2 = transform.structured.fuse %0 {tile_sizes = [5, 0, 7], tile_interchange = [0, 2, 1]} - %2, %loops_2 = transform.structured.tile %1 [0, 4] : (!pdl.operation) -> (!pdl.operation, !pdl.operation) + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) + %2, %loops_2 = transform.structured.tile %1 [0, 4] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -110,7 +113,8 @@ func.func @unpack_elemwise(%arg0: tensor<16x48x8x8xf32>, %arg1: tensor<128x384xf } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.elemwise_unary"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.elemwise_unary"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1, %loops:2 = transform.structured.fuse %0 {tile_sizes = [16, 32], tile_interchange = [0, 1]} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/transform-op-generalize.mlir b/mlir/test/Dialect/Linalg/transform-op-generalize.mlir index 17dd3a350893..470f98eb3a94 100644 --- a/mlir/test/Dialect/Linalg/transform-op-generalize.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-generalize.mlir @@ -26,7 +26,7 @@ func.func @map_no_inputs(%input: tensor<16x32x64xf32>, func.return %reduce : tensor<16x64xf32> } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.generalize %0 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.generalize %0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-hoist-pad-build-packing-loop-nest.mlir b/mlir/test/Dialect/Linalg/transform-op-hoist-pad-build-packing-loop-nest.mlir index 99090ac9e157..996686616f85 100644 --- a/mlir/test/Dialect/Linalg/transform-op-hoist-pad-build-packing-loop-nest.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-hoist-pad-build-packing-loop-nest.mlir @@ -11,25 +11,25 @@ func.func @pad_and_hoist_rhs( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op // In this case, the pad op is actually empty: we only tile the first dimension // and it does not have an impact on the RHS operand. %pad = transform.get_producer_of_operand %matmul_padded[1] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires exactly 2 non-null handles}} transform.structured.hoist_pad.build_packing_loop_nest %pad above %loops_l1 - : (!pdl.operation, !pdl.operation) -> !pdl.operation + : (!transform.any_op, !transform.any_op) -> !transform.any_op } // ----- @@ -43,24 +43,24 @@ func.func @pad_and_hoist_init( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[2] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op // We do not know yet how to hoist the init. // expected-error @below {{could not build packing loop nest}} transform.structured.hoist_pad.build_packing_loop_nest %pad above %loops_l1 - : (!pdl.operation, !pdl.operation) -> !pdl.operation + : (!transform.any_op, !transform.any_op) -> !transform.any_op } // ----- @@ -73,7 +73,7 @@ func.func @pad_and_hoist_lhs( // BUILD-PACKING-LOOP-NEST: %[[PACKED:.*]] = scf.for %{{.*}} -> (tensor) { // BUILD-PACKING-LOOP-NEST: tensor.pad %{{.*}} // BUILD-PACKING-LOOP-NEST: : tensor to tensor<5x12xf32> - // BUILD-PACKING-LOOP-NEST: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] + // BUILD-PACKING-LOOP-NEST: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] // BUILD-PACKING-LOOP-NEST-SAME: : tensor<5x12xf32> into tensor // BUILD-PACKING-LOOP-NEST: scf.for %{{.*}} -> (tensor<24x25xf32>) %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -81,22 +81,22 @@ func.func @pad_and_hoist_lhs( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[0] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op transform.structured.hoist_pad.build_packing_loop_nest %pad above %loops_l1 - : (!pdl.operation, !pdl.operation) -> !pdl.operation + : (!transform.any_op, !transform.any_op) -> !transform.any_op } // ----- @@ -107,11 +107,11 @@ func.func @pad_and_hoist_lhs_transpose( -> tensor<24x25xf32> { // BUILD-PACKING-LOOP-NEST: %[[PACKED:.*]] = scf.for %{{.*}} -> (tensor) { - // BUILD-PACKING-LOOP-NEST: tensor.pad %{{.*}} + // BUILD-PACKING-LOOP-NEST: tensor.pad %{{.*}} // BUILD-PACKING-LOOP-NEST: : tensor to tensor<5x12xf32> // BUILD-PACKING-LOOP-NEST: linalg.generic // BUILD-PACKING-LOOP-NEST: -> tensor<12x5xf32> - // BUILD-PACKING-LOOP-NEST: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] + // BUILD-PACKING-LOOP-NEST: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] // BUILD-PACKING-LOOP-NEST-SAME: : tensor<12x5xf32> into tensor // BUILD-PACKING-LOOP-NEST: scf.for %{{.*}} -> (tensor<24x25xf32>) %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -119,22 +119,22 @@ func.func @pad_and_hoist_lhs_transpose( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[0] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op transform.structured.hoist_pad.build_packing_loop_nest %pad above %loops_l1, transpose by [1, 0] - : (!pdl.operation, !pdl.operation) -> !pdl.operation + : (!transform.any_op, !transform.any_op) -> !transform.any_op } // ----- @@ -147,7 +147,7 @@ func.func @pad_and_hoist_init( // BUILD-PACKING-LOOP-NEST: scf.for %{{.*}} -> (tensor<24x25xf32>) { // BUILD-PACKING-LOOP-NEST: %[[EXTRACTED_SLICE:.*]] = tensor.extract_slice - // BUILD-PACKING-LOOP-NEST: %[[PADDED:.*]] = tensor.pad %[[EXTRACTED_SLICE]] + // BUILD-PACKING-LOOP-NEST: %[[PADDED:.*]] = tensor.pad %[[EXTRACTED_SLICE]] // BUILD-PACKING-LOOP-NEST: : tensor to tensor<5x25xf32> // BUILD-PACKING-LOOP-NEST: scf.for %{{.*}} iter_args({{.*}} = %[[EXTRACTED_SLICE]]) -> (tensor<24x25xf32>, tensor) { %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -155,20 +155,20 @@ func.func @pad_and_hoist_init( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op - %matmul_l1, %loops_l1:2 = transform.structured.tile_to_scf_for %matmul [5, 0, 7] + %matmul_l1, %loops_l1:2 = transform.structured.tile_to_scf_for %matmul [5, 0, 7] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[2] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op transform.structured.hoist_pad.build_packing_loop_nest %pad above %loops_l1#1 - : (!pdl.operation, !pdl.operation) -> !pdl.operation + : (!transform.any_op, !transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-hoist-pad.mlir b/mlir/test/Dialect/Linalg/transform-op-hoist-pad.mlir index 871163ab40cf..33801e2a80d9 100644 --- a/mlir/test/Dialect/Linalg/transform-op-hoist-pad.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-hoist-pad.mlir @@ -2,7 +2,7 @@ func.func @pad_and_hoist_rhs( %arg0: tensor<24x12xf32>, %arg1: tensor<12x25xf32>, %arg2: tensor<24x25xf32>) - -> tensor<24x25xf32> + -> tensor<24x25xf32> { // expected-note @below {{payload operation}} %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -10,34 +10,34 @@ func.func @pad_and_hoist_rhs( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 + : (!transform.any_op) -> !transform.any_op - - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op // In this case, the pad op is actually empty: we only tile the first dimension // and it does not have an impact on the RHS operand. // expected-error @below {{incompatible payload operation name}} %pad = transform.get_producer_of_operand %matmul_padded[1] - : (!pdl.operation) -> !transform.op<"tensor.pad"> + : (!transform.any_op) -> !transform.op<"tensor.pad"> // We do not even reach this transform op. transform.structured.hoist_pad %pad by 1 loops - : (!transform.op<"tensor.pad">) -> !pdl.operation + : (!transform.op<"tensor.pad">) -> !transform.any_op } // ----- func.func @pad_and_hoist_init( %arg0: tensor<24x12xf32>, %arg1: tensor<12x25xf32>, %arg2: tensor<24x25xf32>) - -> tensor<24x25xf32> + -> tensor<24x25xf32> { // expected-note @below {{when applied to this op}} %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -45,25 +45,25 @@ func.func @pad_and_hoist_init( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 + : (!transform.any_op) -> !transform.any_op + - - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[2] - : (!pdl.operation) -> !transform.op<"tensor.pad"> + : (!transform.any_op) -> !transform.op<"tensor.pad"> // We do not know yet how to hoist the init. // expected-error @below {{transform.structured.hoist_pad failed to apply}} transform.structured.hoist_pad %pad by 1 loops - : (!transform.op<"tensor.pad">) -> !pdl.operation + : (!transform.op<"tensor.pad">) -> !transform.any_op } // ----- @@ -71,15 +71,15 @@ transform.sequence failures(propagate) { // CHECK-LABEL: pad_and_hoist_lhs( func.func @pad_and_hoist_lhs( %arg0: tensor<24x12xf32>, %arg1: tensor<12x25xf32>, %arg2: tensor<24x25xf32>) - -> tensor<24x25xf32> + -> tensor<24x25xf32> { // CHECK: %[[PACKED:.*]] = scf.for %{{.*}} -> (tensor<5x5x12xf32>) { - // CHECK: tensor.pad %{{.*}} + // CHECK: tensor.pad %{{.*}} // CHECK: : tensor to tensor<5x12xf32> - // CHECK: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] + // CHECK: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] // CHECK-SAME: : tensor<5x12xf32> into tensor<5x5x12xf32> // CHECK: scf.for %{{.*}} -> (tensor<24x25xf32>) { - // CHECK: %[[PADDED:.*]] = tensor.extract_slice %[[PACKED]][%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] + // CHECK: %[[PADDED:.*]] = tensor.extract_slice %[[PACKED]][%{{.*}}, 0, 0] [1, 5, 12] [1, 1, 1] // CHECK-SAME: : tensor<5x5x12xf32> to tensor<5x12xf32> // CHECK: linalg.matmul ins(%[[PADDED]] %0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32> @@ -87,23 +87,23 @@ func.func @pad_and_hoist_lhs( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 + : (!transform.any_op) -> !transform.any_op + - - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[0] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op transform.structured.hoist_pad %pad by 1 loops - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op } // ----- @@ -111,17 +111,17 @@ transform.sequence failures(propagate) { // CHECK-LABEL: pad_and_hoist_lhs_transpose func.func @pad_and_hoist_lhs_transpose( %arg0: tensor<24x12xf32>, %arg1: tensor<12x25xf32>, %arg2: tensor<24x25xf32>) - -> tensor<24x25xf32> + -> tensor<24x25xf32> { // CHECK: %[[PACKED:.*]] = scf.for %{{.*}} -> (tensor<5x12x5xf32>) { - // CHECK: tensor.pad %{{.*}} + // CHECK: tensor.pad %{{.*}} // CHECK: : tensor to tensor<5x12xf32> // CHECK: linalg.generic // CHECK: -> tensor<12x5xf32> - // CHECK: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] + // CHECK: tensor.insert_slice %{{.*}} into %{{.*}}[%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] // CHECK-SAME: : tensor<12x5xf32> into tensor<5x12x5xf32> // CHECK: scf.for %{{.*}} -> (tensor<24x25xf32>) { - // CHECK: %[[PADDED:.*]] = tensor.extract_slice %[[PACKED]][%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] + // CHECK: %[[PADDED:.*]] = tensor.extract_slice %[[PACKED]][%{{.*}}, 0, 0] [1, 12, 5] [1, 1, 1] // CHECK-SAME: : tensor<5x12x5xf32> to tensor<12x5xf32> // CHECK: %[[TRANSPOSED:.*]] = linalg.generic // CHECK: -> tensor<5x12xf32> @@ -131,23 +131,23 @@ func.func @pad_and_hoist_lhs_transpose( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 + : (!transform.any_op) -> !transform.any_op - - %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] + + %matmul_l1, %loops_l1 = transform.structured.tile_to_scf_for %matmul [5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[0] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op transform.structured.hoist_pad %pad by 1 loops, transpose by [1, 0] - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op } // ----- @@ -155,11 +155,11 @@ transform.sequence failures(propagate) { // CHECK-LABEL: pad_and_hoist_init func.func @pad_and_hoist_init( %arg0: tensor<24x12xf32>, %arg1: tensor<12x25xf32>, %arg2: tensor<24x25xf32>) - -> tensor<24x25xf32> + -> tensor<24x25xf32> { // CHECK: scf.for %{{.*}} -> (tensor<24x25xf32>) { - // CHECK: %[[PADDED:.*]] = tensor.pad %{{.*}} + // CHECK: %[[PADDED:.*]] = tensor.pad %{{.*}} // CHECK: : tensor to tensor<5x25xf32> // CHECK: %[[SCF_YIELD:.*]] = scf.for %{{.*}} iter_args(%[[INNER_PADDED:[0-9a-zA-Z]*]] = %[[PADDED]]) -> (tensor<5x25xf32>) // CHECK: %[[RES:.*]] = linalg.matmul {{.*}} outs(%[[INNER_PADDED]] @@ -174,21 +174,21 @@ func.func @pad_and_hoist_init( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 - : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1 + : (!transform.any_op) -> !transform.any_op + - - %matmul_l1, %loops_l1:2 = transform.structured.tile_to_scf_for %matmul [5, 0, 7] + %matmul_l1, %loops_l1:2 = transform.structured.tile_to_scf_for %matmul [5, 0, 7] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) %matmul_padded = transform.structured.pad %matmul_l1 { padding_values=[0.0: f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2] - } + } : (!transform.any_op) -> !transform.any_op %pad = transform.get_producer_of_operand %matmul_padded[2] - : (!pdl.operation) -> !transform.op<"tensor.pad"> + : (!transform.any_op) -> !transform.op<"tensor.pad"> transform.structured.hoist_pad %pad by 1 loops - : (!transform.op<"tensor.pad">) -> !pdl.operation + : (!transform.op<"tensor.pad">) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-interchange.mlir b/mlir/test/Dialect/Linalg/transform-op-interchange.mlir index 52b636c6bd3f..7966b22a257a 100644 --- a/mlir/test/Dialect/Linalg/transform-op-interchange.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-interchange.mlir @@ -19,9 +19,9 @@ func.func @interchange_generic(%arg0: tensor, %arg1: tensor) - } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.interchange %0 iterator_interchange = [1, 0] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.interchange %0 iterator_interchange = [1, 0] : (!transform.any_op) -> !transform.any_op } // ----- @@ -33,8 +33,8 @@ func.func @interchange_matmul(%arg0: tensor, %arg1: tensor, %a } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{transform applied to the wrong op kind}} - transform.structured.interchange %0 iterator_interchange = [1, 0] + transform.structured.interchange %0 iterator_interchange = [1, 0] : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-matmul-to-outerproduct.mlir b/mlir/test/Dialect/Linalg/transform-op-matmul-to-outerproduct.mlir index 910f019f1a58..e60b89a5c406 100644 --- a/mlir/test/Dialect/Linalg/transform-op-matmul-to-outerproduct.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-matmul-to-outerproduct.mlir @@ -28,9 +28,9 @@ func.func @outerproduct_matmul(%A: memref<3x3xf32>, %B: memref<3x3xf32>, %C: mem // CHECK: } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 - transform.vector.lower_contraction %2 lowering_strategy = "outerproduct" : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op + transform.vector.lower_contraction %2 lowering_strategy = "outerproduct" : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-pack.mlir b/mlir/test/Dialect/Linalg/transform-op-pack.mlir index b2796e335432..eaeb258590d7 100644 --- a/mlir/test/Dialect/Linalg/transform-op-pack.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-pack.mlir @@ -34,10 +34,10 @@ func.func @reduction_2d_static(%t0: tensor<3x7xf16>, %t1: tensor<3xf16>) -> tens } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.pack %0 packed_sizes = [0, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -76,17 +76,17 @@ func.func @col_reduction_2d_static(%t0: tensor<7x3xf16>, %t1: tensor<3xf16>) -> } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pack %0 packed_sizes = [4, 0] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) %pack = transform.get_producer_of_operand %1[0] : (!transform.op<"linalg.generic">) -> (!transform.op<"tensor.pack">) %2, %pack_2, %empty_unpack_2 = transform.structured.pack_transpose %pack with_compute_op(%1) outer_perm = [1, 0] : (!transform.op<"tensor.pack">, !transform.op<"linalg.generic">) - -> (!transform.op<"linalg.generic">, !transform.op<"tensor.pack">, !pdl.operation) + -> (!transform.op<"linalg.generic">, !transform.op<"tensor.pack">, !transform.any_op) } // ----- @@ -131,10 +131,10 @@ func.func @reduction_2d_dynamic(%t0: tensor, %t1: tensor) -> ten } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.pack %0 packed_sizes = [0, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } @@ -177,10 +177,10 @@ func.func @reduction_2d_dynamic(%t0: tensor, %t1: tensor) -> ten } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.pack %0 packed_sizes = [3, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -220,11 +220,11 @@ func.func @matmul(%A: tensor, %B: tensor, %C: tensor) } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // M N K %1 = transform.structured.pack %0 packed_sizes = [2, 3, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) %unpack = transform.get_consumers_of_result %1[0] : (!transform.op<"linalg.generic">) -> (!transform.op<"tensor.unpack">) @@ -268,11 +268,11 @@ func.func @conv_2d_nchw_fchw(%i: tensor<14x512x28x28xf32>, %f: tensor<1024x512x1 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op // N F H W C KH KW %1 = transform.structured.pack %0 packed_sizes = [0, 4, 0, 0, 8, 0, 0] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -309,11 +309,11 @@ func.func @conv_2d_nhwc_hwcf(%input: tensor, %filter: tensor<1x?x?x } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op // N H W F KH KW C %1 = transform.structured.pack %0 packed_sizes = [0, 0, 0, 4, 0, 0, 6] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -355,11 +355,11 @@ func.func @matmul_dynamic_pack_size(%A: tensor, %B: tensor, %C } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %sz = transform.structured.match ops{["some_tile_size"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.pack %0 packed_sizes = [0, %sz, %sz] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %sz = transform.structured.match ops{["some_tile_size"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.pack %0 packed_sizes = [0, %sz : !transform.any_op, %sz : !transform.any_op] + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -372,12 +372,12 @@ func.func @conv_cant_pack(%i: tensor<14x512x28x28xf32>, %f: tensor<1024x512x1x1x } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op // N F H W C KH KW // expected-error @below {{data tiling failed}} %1 = transform.structured.pack %0 packed_sizes = [0, 0, 4, 0, 0, 0, 0] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -394,11 +394,11 @@ func.func @matmul(%A: tensor, %B: tensor, %C: tensor) } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires target to map to exactly 1 LinalgOp (got 2)}} %1 = transform.structured.pack %0 packed_sizes = [2, 3, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } @@ -413,11 +413,11 @@ func.func @matmul(%A: tensor, %B: tensor, %C: tensor) } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires number of packed sizes match the number of loops (2 vs 3)}} %1 = transform.structured.pack %0 packed_sizes = [2, 3] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) } // ----- @@ -430,14 +430,14 @@ func.func @no_single_packing_op(%source: tensor<128x256xf32>, %dest: tensor<4x16 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires target to map to exactly 1 packing op and 1 packed op (got 2 and 1)}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -449,14 +449,14 @@ func.func @no_single_pack_unpack(%source: tensor<128x256xf32>, %dest: tensor<4x1 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["tensor.empty"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["tensor.empty"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires target to map to a tensor.pack or tensor.unpack}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -468,14 +468,14 @@ func.func @no_linalg_target(%source: tensor<128x256xf32>, %dest: tensor<4x16x32x } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{requires a LinalgOp target}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -489,14 +489,14 @@ func.func @no_single_use_by_linalg(%source: tensor<128x256xf32>, %dest: tensor<4 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{not a single use by the LinalgOp target}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -511,14 +511,14 @@ func.func @not_produced_by_linalg(%source: tensor<128x256xf32>, %dest: tensor<4x } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{not produced by the LinalgOp target}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -532,14 +532,14 @@ func.func @no_matching_pack(%source: tensor<16xf32>) { } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{could not find matching pack op}} transform.structured.pack_transpose %0 with_compute_op(%1) inner_perm = [0] - : (!pdl.operation, !pdl.operation) - -> (!pdl.operation, !pdl.operation, !pdl.operation) + : (!transform.any_op, !transform.any_op) + -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -553,10 +553,10 @@ func.func @invalid_outer_perm(%A: tensor, %B: tensor, %C: tens } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pack %0 packed_sizes = [2, 3, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) %unpack = transform.get_consumers_of_result %1[0] : (!transform.op<"linalg.generic">) -> (!transform.op<"tensor.unpack">) @@ -579,10 +579,10 @@ func.func @invalid_inner_perm(%A: tensor, %B: tensor, %C: tens } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pack %0 packed_sizes = [2, 3, 4] - : (!pdl.operation) -> (!transform.op<"linalg.generic">) + : (!transform.any_op) -> (!transform.op<"linalg.generic">) %unpack = transform.get_consumers_of_result %1[0] : (!transform.op<"linalg.generic">) -> (!transform.op<"tensor.unpack">) diff --git a/mlir/test/Dialect/Linalg/transform-op-pad.mlir b/mlir/test/Dialect/Linalg/transform-op-pad.mlir index 3677c1afeecb..78197aa7098d 100644 --- a/mlir/test/Dialect/Linalg/transform-op-pad.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-pad.mlir @@ -32,13 +32,13 @@ func.func @static_sizes_output_divisible(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pad %0 { - padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], - padding_dimensions=[0, 1, 2], + padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], + padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0] - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -74,13 +74,13 @@ func.func @static_sizes_output_divisible_on_empty_op(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pad %0 { padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0] - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -94,14 +94,14 @@ func.func @pad(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{op expects a padding value of type 'f32', got 0 : i32}} %1 = transform.structured.pad %0 { padding_values=[0: i32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0] - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -115,14 +115,14 @@ func.func @pad(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{expects a padding that parses to 'f32', got "{foo}"}} %1 = transform.structured.pad %0 { padding_values=["{foo}", 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0] - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -138,15 +138,15 @@ func.func @pad(%arg0: tensor<24x12xf32>, } transform.sequence failures(suppress) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // This error is silenceable and is not reported by this transform // {{transform.structured.pad failed to apply}} %1 = transform.structured.pad %0 { padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0] - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -200,11 +200,11 @@ func.func @outs_not_produced_by_empty_or_extract_slice(%a : tensor<128x2044xf32> } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1 = transform.structured.pad %0 { padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 1] - } + } : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-replace.mlir b/mlir/test/Dialect/Linalg/transform-op-replace.mlir index 3d30a2cfe14f..3c6a4eb60530 100644 --- a/mlir/test/Dialect/Linalg/transform-op-replace.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-replace.mlir @@ -9,13 +9,13 @@ func.func @bar() { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.replace %0 { func.func @foo() { "dummy_op"() : () -> () } - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -25,12 +25,12 @@ func.func @bar(%arg0: i1) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["another_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["another_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @+1 {{expected target without operands}} transform.structured.replace %0 { "dummy_op"() : () -> () - } + } : (!transform.any_op) -> !transform.any_op } // ----- @@ -40,11 +40,11 @@ func.func @bar() { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["another_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["another_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.replace %0 { ^bb0(%a: i1): // expected-error @+1 {{expected replacement without operands}} "dummy_op"(%a) : (i1) -> () - } + } : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-scalarize.mlir b/mlir/test/Dialect/Linalg/transform-op-scalarize.mlir index 272d0b50333a..40a1b149837d 100644 --- a/mlir/test/Dialect/Linalg/transform-op-scalarize.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-scalarize.mlir @@ -19,8 +19,8 @@ func.func @scalarize(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops = transform.structured.tile %0 [10, 0, 0] : (!pdl.operation) -> (!pdl.operation, !pdl.operation) - %2 = transform.structured.scalarize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops = transform.structured.tile %0 [10, 0, 0] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) + %2 = transform.structured.scalarize %1 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-op-split-reduction-by-scaling.mlir b/mlir/test/Dialect/Linalg/transform-op-split-reduction-by-scaling.mlir index 974a2b763b06..719e0daccfbf 100644 --- a/mlir/test/Dialect/Linalg/transform-op-split-reduction-by-scaling.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-split-reduction-by-scaling.mlir @@ -19,8 +19,9 @@ func.func @matmul_split(%A : tensor, %B: tensor<256x32xf32>, %C: tens } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 2, use_scaling_algorithm, use_alloc} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/transform-op-split-reduction.mlir b/mlir/test/Dialect/Linalg/transform-op-split-reduction.mlir index e5615d54ca7d..9d8f2ed5640b 100644 --- a/mlir/test/Dialect/Linalg/transform-op-split-reduction.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-split-reduction.mlir @@ -32,9 +32,10 @@ func.func @matmul_split(%A : tensor<16x256xf32>, %B: tensor<256x32xf32>, %C: ten // CHECK: return %[[R]] : tensor<16x32xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 2} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -80,9 +81,10 @@ func.func @generic_split_1d(%arg0: tensor<32xf32>, %arg1: tensor, %out: ten // CHECK: return %[[R]] : tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 0} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -131,9 +133,10 @@ func.func @generic_split_3d(%input: tensor<32x2xf32>, %input_2: tensor<5x32xf32> // CHECK: return %[[R]] : tensor<5x2xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 2} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -170,9 +173,10 @@ func.func @matmul_split(%A : tensor<16x256xf32>, %B: tensor<256x32xf32>, %C: ten // CHECK: return %[[R]] : tensor<16x32xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 2, inner_parallel} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -218,9 +222,10 @@ func.func @generic_split_1d(%arg0: tensor<32xf32>, %arg1: tensor, %out: ten // CHECK: return %[[R]] : tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 0, inner_parallel} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -269,7 +274,8 @@ func.func @generic_split_3d(%input: tensor<32x2xf32>, %input_2: tensor<5x32xf32> // CHECK: return %[[R]] : tensor<5x2xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %1:4 = transform.structured.split_reduction %0 { split_factor = 4, insert_split_dimension = 2, inner_parallel} + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/transform-op-tile.mlir b/mlir/test/Dialect/Linalg/transform-op-tile.mlir index 15e8f8c41eba..1ad9383069b1 100644 --- a/mlir/test/Dialect/Linalg/transform-op-tile.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-tile.mlir @@ -128,14 +128,14 @@ func.func @tile_linalg_matmul( // CHECK-LABEL: tile_tensor_pad func.func @tile_tensor_pad( - %arg0 : tensor, %cst : f32, %low: index, %high: index) + %arg0 : tensor, %cst : f32, %low: index, %high: index) -> tensor<20x40xf32> { // CHECK: scf.forall // CHECK: scf.if // CHECK: tensor.generate // CHECK: else - // CHECK: tensor.pad {{.*}} nofold + // CHECK: tensor.pad {{.*}} nofold %0 = tensor.pad %arg0 nofold low[%low, %low] high[%high, %high] { ^bb0(%arg9: index, %arg10: index): tensor.yield %cst : f32 @@ -144,7 +144,8 @@ func.func @tile_tensor_pad( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op transform.structured.tile_to_forall_op %0 tile_sizes[1, 1] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Linalg/transform-op-vectorize.mlir b/mlir/test/Dialect/Linalg/transform-op-vectorize.mlir index 155b0785d2ec..ecc077ae5e9f 100644 --- a/mlir/test/Dialect/Linalg/transform-op-vectorize.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-vectorize.mlir @@ -17,10 +17,10 @@ func.func @vectorize_matmul(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -63,10 +63,10 @@ func.func @vectorize_keep_pad( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -111,10 +111,10 @@ func.func @vectorize_pad( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 {vectorize_padding} +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 {vectorize_padding} : (!transform.any_op) -> !transform.any_op } // ----- @@ -128,8 +128,8 @@ func.func @vectorize(%arg0: tensor<24x12xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{op requires isolated-from-above targets}} - %2 = transform.structured.vectorize %0 + %2 = transform.structured.vectorize %0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-ops-invalid.mlir b/mlir/test/Dialect/Linalg/transform-ops-invalid.mlir index 2adfd9ae97aa..b671f20c1047 100644 --- a/mlir/test/Dialect/Linalg/transform-ops-invalid.mlir +++ b/mlir/test/Dialect/Linalg/transform-ops-invalid.mlir @@ -1,73 +1,89 @@ // RUN: mlir-opt %s --split-input-file --verify-diagnostics transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{'transform.structured.interchange' op expects iterator_interchange to be a permutation, found 1, 1}} - transform.structured.interchange %arg0 iterator_interchange = [1, 1] + transform.structured.interchange %arg0 iterator_interchange = [1, 1] : (!transform.any_op) -> !transform.any_op } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{expects padding_dimensions to contain positive integers, found [1, -7]}} - transform.structured.pad %arg0 {padding_dimensions=[1, -7]} + transform.structured.pad %arg0 {padding_dimensions=[1, -7]} : (!transform.any_op) -> !transform.any_op } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{expects pack_paddings to contain booleans (0/1), found [1, 7]}} - transform.structured.pad %arg0 {pack_paddings=[1, 7]} + transform.structured.pad %arg0 {pack_paddings=[1, 7]} : (!transform.any_op) -> !transform.any_op } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{expects transpose_paddings to be a permutation, found [1, 1]}} - transform.structured.pad %arg0 {transpose_paddings=[[1, 1]]} + transform.structured.pad %arg0 {transpose_paddings=[[1, 1]]} : (!transform.any_op) -> !transform.any_op } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{'transform.structured.interchange' op attribute 'iterator_interchange' failed to satisfy constraint: i64 dense array attribute whose value is non-negative}} - transform.structured.interchange %arg0 iterator_interchange = [-3, 1] + transform.structured.interchange %arg0 iterator_interchange = [-3, 1] : (!transform.any_op) -> !transform.any_op } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{expects all results type to be the same}} "transform.structured.multitile_sizes"(%arg0) { target_size = 3, divisor = 2, dimension = 0 } - : (!pdl.operation) -> (!transform.param, !transform.param, !transform.param) + : (!transform.any_op) -> (!transform.param, !transform.param, !transform.param) } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{not a valid permutation}} transform.structured.pack_greedily %arg0 - matmul_packed_sizes = [8, 0, 32] + matmul_packed_sizes = [8, 0, 32] matmul_inner_dims_order = [1, 1, 0] - : (!pdl.operation) -> !transform.op<"linalg.generic"> + : (!transform.any_op) -> !transform.op<"linalg.generic"> } // ----- transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // expected-error@below {{at most one of the packed_size and the padded_sizes_next_multiple_of can be nonzero}} transform.structured.pack_greedily %arg0 - matmul_packed_sizes = [1, 1, 1] - matmul_padded_sizes_next_multiple_of = [1, 1, 1] + matmul_packed_sizes = [1, 1, 1] + matmul_padded_sizes_next_multiple_of = [1, 1, 1] matmul_inner_dims_order = [0, 1, 2] - : (!pdl.operation) -> !transform.op<"linalg.generic"> + : (!transform.any_op) -> !transform.op<"linalg.generic"> } + +// ----- + +transform.sequence failures(propagate) { +^bb0(%arg0: !transform.any_op): + // expected-error @below {{expected 4 result types, got 2}} + transform.structured.tile_to_scf_for %arg0 [1, 2, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) +} + +// ----- + +transform.sequence failures(propagate) { +^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op): + // expected-error @below {{expected 2 operand types, got 1}} + transform.structured.tile_to_scf_for %arg0 [%arg1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) +} diff --git a/mlir/test/Dialect/Linalg/transform-ops.mlir b/mlir/test/Dialect/Linalg/transform-ops.mlir index 4fa426e1394e..dd850087ba7f 100644 --- a/mlir/test/Dialect/Linalg/transform-ops.mlir +++ b/mlir/test/Dialect/Linalg/transform-ops.mlir @@ -1,9 +1,9 @@ // RUN: mlir-opt %s | mlir-opt | FileCheck %s transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): +^bb1(%arg0: !transform.any_op): // CHECK %{{.*}}, %{{.*}}:2 = transform.structured.tile - %0, %1:2 = transform.structured.tile %arg0 [2, 0, 3] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation) + %0, %1:2 = transform.structured.tile %arg0 [2, 0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } transform.sequence failures(propagate) { @@ -19,19 +19,19 @@ transform.sequence failures(propagate) { //===----------------------------------------------------------------------===// transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): +^bb1(%arg0: !transform.any_op): // CHECK: transform.structured.pad - %0 = transform.structured.pad %arg0 + %0 = transform.structured.pad %arg0 : (!transform.any_op) -> !transform.any_op } transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): +^bb1(%arg0: !transform.any_op): // CHECK: transform.structured.interchange - %0 = transform.structured.interchange %arg0 + %0 = transform.structured.interchange %arg0 : (!transform.any_op) -> !transform.any_op } transform.sequence failures(propagate) { -^bb1(%arg0: !pdl.operation): +^bb1(%arg0: !transform.any_op): // CHECK: transform.structured.scalarize - %0 = transform.structured.scalarize %arg0 + %0 = transform.structured.scalarize %arg0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Linalg/transform-patterns.mlir b/mlir/test/Dialect/Linalg/transform-patterns.mlir index 6214e4e527f1..49a20b563aa6 100644 --- a/mlir/test/Dialect/Linalg/transform-patterns.mlir +++ b/mlir/test/Dialect/Linalg/transform-patterns.mlir @@ -10,9 +10,9 @@ func.func @dot(%x: memref>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.dot"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loop = transform.structured.tile %0 [8000] : (!pdl.operation) -> (!pdl.operation, !pdl.operation) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.dot"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loop = transform.structured.tile %0 [8000] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // CHECK-LABEL: func @dot @@ -34,9 +34,9 @@ func.func @matvec(%A: memref>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile %0 [5, 6] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile %0 [5, 6] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-LABEL: func @matvec @@ -61,12 +61,12 @@ func.func @matmul(%A: memref>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [2000, 3000, 4000] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2, %loops_2:3 = transform.structured.tile %1 [200, 300, 400] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %3, %loops_3:3 = transform.structured.tile %2 [20, 30, 40] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %4, %loops_4:3 = transform.structured.tile %3 [2, 3, 4] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [2000, 3000, 4000] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2, %loops_2:3 = transform.structured.tile %1 [200, 300, 400] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %3, %loops_3:3 = transform.structured.tile %2 [20, 30, 40] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %4, %loops_4:3 = transform.structured.tile %3 [2, 3, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-LABEL: func @matmul @@ -134,9 +134,9 @@ func.func @permute_generic(%A: memref>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.interchange %0 iterator_interchange = [1, 2, 0] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.interchange %0 iterator_interchange = [1, 2, 0] : (!transform.any_op) -> !transform.any_op } // CHECK-LABEL: func @permute_generic @@ -160,9 +160,9 @@ func.func @matvec_perm(%A: memref>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile %0 [5, 6] {interchange = [1, 0]} : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile %0 [5, 6] {interchange = [1, 0]} : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-LABEL: func @matvec_perm @@ -187,11 +187,11 @@ func.func @matmul_perm(%A: memref>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [2000, 3000, 4000] {interchange = [1, 2, 0]} : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2, %loops_2:3 = transform.structured.tile %1 [200, 300, 400] {interchange = [1, 0, 2]} : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %3, %loops_3:3 = transform.structured.tile %2 [20, 30, 40] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [2000, 3000, 4000] {interchange = [1, 2, 0]} : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2, %loops_2:3 = transform.structured.tile %1 [200, 300, 400] {interchange = [1, 0, 2]} : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %3, %loops_3:3 = transform.structured.tile %2 [20, 30, 40] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-LABEL: func @matmul_perm diff --git a/mlir/test/Dialect/Linalg/transform-promotion.mlir b/mlir/test/Dialect/Linalg/transform-promotion.mlir index b29a6cbdc28c..2f98e394fe05 100644 --- a/mlir/test/Dialect/Linalg/transform-promotion.mlir +++ b/mlir/test/Dialect/Linalg/transform-promotion.mlir @@ -59,9 +59,9 @@ func.func @promote_subview_matmul(%arg0: memref) transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 { operands_to_promote = [0, 1, 2], use_full_tiles_by_default } +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 { operands_to_promote = [0, 1, 2], use_full_tiles_by_default } : (!transform.any_op) -> !transform.any_op } // ----- @@ -119,11 +119,11 @@ func.func @promote_first_subview_matmul(%arg0: memref>) transform.with_pdl_patterns { -^bb0(%arg0: !pdl.operation): - sequence %arg0 : !pdl.operation failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 { operands_to_promote = [0], use_full_tiles_by_default } +^bb0(%arg0: !transform.any_op): + sequence %arg0 : !transform.any_op failures(propagate) { + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 { operands_to_promote = [0], use_full_tiles_by_default } : (!transform.any_op) -> !transform.any_op } } @@ -136,13 +136,13 @@ func.func @aligned_promote_fill(%arg0: memref> to memref> + memref> to memref> linalg.fill ins(%cf : f32) outs(%3 : memref>) return } // CHECK-LABEL: func @aligned_promote_fill -// CHECK: %[[cf:.*]] = arith.constant 1.{{.*}} : f32 +// CHECK: %[[cf:.*]] = arith.constant 1.{{.*}} : f32 // CHECK: %[[s0:.*]] = memref.subview {{.*}}: memref to memref // CHECK: %[[a0:.*]] = memref.alloc() {alignment = 32 : i64} : memref<32000000xi8> // CHECK: %[[v0:.*]] = memref.view %[[a0]]{{.*}} : memref<32000000xi8> to memref @@ -152,11 +152,11 @@ func.func @aligned_promote_fill(%arg0: memref) transform.with_pdl_patterns { -^bb0(%arg0: !pdl.operation): - sequence %arg0 : !pdl.operation failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 { operands_to_promote = [1], use_full_tile_buffers = [false, true], alignment = 32} +^bb0(%arg0: !transform.any_op): + sequence %arg0 : !transform.any_op failures(propagate) { + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 { operands_to_promote = [1], use_full_tile_buffers = [false, true], alignment = 32} : (!transform.any_op) -> !transform.any_op } } @@ -170,13 +170,13 @@ func.func @aligned_promote_fill_complex(%arg0: memref, strided< %cf = arith.constant 1.0 : f32 %cc = complex.create %cf, %cf : complex %3 = memref.subview %arg0[%c0, %c0][%c2000, %c4000][%c1, %c1] : - memref, strided<[?, 1], offset: ?>> to memref, strided<[?, ?], offset: ?>> + memref, strided<[?, 1], offset: ?>> to memref, strided<[?, ?], offset: ?>> linalg.fill ins(%cc : complex) outs(%3 : memref, strided<[?, ?], offset: ?>>) return } // CHECK-LABEL: func @aligned_promote_fill_complex -// CHECK: %[[cc:.*]] = complex.create {{.*}} : complex +// CHECK: %[[cc:.*]] = complex.create {{.*}} : complex // CHECK: %[[s0:.*]] = memref.subview {{.*}}: memref, strided{{.*}}> to memref, strided{{.*}}> // CHECK: %[[a0:.*]] = memref.alloc() {alignment = 32 : i64} : memref<64000000xi8> // CHECK: %[[v0:.*]] = memref.view %[[a0]]{{.*}} : memref<64000000xi8> to memref> @@ -186,10 +186,10 @@ func.func @aligned_promote_fill_complex(%arg0: memref, strided< // CHECK: linalg.fill ins(%[[cc]] : complex) outs(%[[v0]] : memref>) transform.with_pdl_patterns { -^bb0(%arg0: !pdl.operation): - sequence %arg0 : !pdl.operation failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.promote %0 { operands_to_promote = [1], use_full_tile_buffers = [false, true], alignment = 32} +^bb0(%arg0: !transform.any_op): + sequence %arg0 : !transform.any_op failures(propagate) { + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.promote %0 { operands_to_promote = [1], use_full_tile_buffers = [false, true], alignment = 32} : (!transform.any_op) -> !transform.any_op } } diff --git a/mlir/test/Dialect/Linalg/transform-tile-and-fuse.mlir b/mlir/test/Dialect/Linalg/transform-tile-and-fuse.mlir index 032b480f5041..3ef94a075bef 100644 --- a/mlir/test/Dialect/Linalg/transform-tile-and-fuse.mlir +++ b/mlir/test/Dialect/Linalg/transform-tile-and-fuse.mlir @@ -41,16 +41,18 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): + ^bb1(%arg1: !transform.any_op): // Find the root and all producers. - %root = transform.structured.match attributes{"__root__"} in %arg1 : (!pdl.operation) -> !pdl.operation - %producers = transform.structured.match attributes{"__producer__"} in %arg1 : (!pdl.operation) -> !pdl.operation + %root = transform.structured.match attributes{"__root__"} in %arg1 : (!transform.any_op) -> !transform.any_op + %producers = transform.structured.match attributes{"__producer__"} in %arg1 : (!transform.any_op) -> !transform.any_op // Tile the root. %forall_op, %tiled_op = transform.structured.tile_to_forall_op %root num_threads [10, 20] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) // Fuse all producers. transform.structured.fuse_into_containing_op %producers into %forall_op + : (!transform.any_op, !transform.any_op) -> !transform.any_op } } @@ -98,16 +100,18 @@ module { } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): + ^bb1(%arg1: !transform.any_op): // Find the root and all producers. - %root = transform.structured.match attributes{"__root__"} in %arg1 : (!pdl.operation) -> !pdl.operation - %producers = transform.structured.match attributes{"__producer__"} in %arg1 : (!pdl.operation) -> !pdl.operation + %root = transform.structured.match attributes{"__root__"} in %arg1 : (!transform.any_op) -> !transform.any_op + %producers = transform.structured.match attributes{"__producer__"} in %arg1 : (!transform.any_op) -> !pdl.operation %reversed_producers = transform.test_reverse_payload_ops %producers // Tile the root. %forall_op, %tiled_op = transform.structured.tile_to_forall_op %root num_threads [10, 20] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) // Fuse all producers. transform.structured.fuse_into_containing_op %reversed_producers into %forall_op + : (!pdl.operation, !transform.any_op) -> !transform.any_op } } diff --git a/mlir/test/Dialect/Linalg/transform-tile-reduction.mlir b/mlir/test/Dialect/Linalg/transform-tile-reduction.mlir index 16578bdb305a..f281add1c28a 100644 --- a/mlir/test/Dialect/Linalg/transform-tile-reduction.mlir +++ b/mlir/test/Dialect/Linalg/transform-tile-reduction.mlir @@ -15,10 +15,10 @@ func.func @reduction_tile(%arg0: tensor, %out: tensor) -> tensor } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %loop, %1, %2, %3 = transform.structured.tile_reduction_using_scf %0 - by tile_sizes = [0, 5] + by tile_sizes = [0, 5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-DAG: #[[MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)> @@ -70,10 +70,10 @@ func.func @reduction_tile_transpose(%arg0: tensor, %out: tensor) } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %loop, %1, %2, %3 = transform.structured.tile_reduction_using_scf %0 - by tile_sizes = [5, 0] +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %loop, %1, %2, %3 = transform.structured.tile_reduction_using_scf %0 + by tile_sizes = [5, 0] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK: func @reduction_tile_transpose @@ -107,10 +107,10 @@ func.func @reduction_tile_parallel( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 - by num_threads = [0, 5], tile_sizes = [] + by num_threads = [0, 5], tile_sizes = [] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-DAG: #[[MAP0:.*]] = affine_map<(d0)[s0] -> (-(d0 * (s0 ceildiv 5)) + s0, s0 ceildiv 5)> @@ -159,10 +159,10 @@ func.func @matmul_tile_parallel( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 - by num_threads = [0, 0, 5], tile_sizes = [] + by num_threads = [0, 0, 5], tile_sizes = [] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-DAG: #[[MAP0:.*]] = affine_map<(d0)[s0] -> (-(d0 * (s0 ceildiv 5)) + s0, s0 ceildiv 5)> @@ -218,10 +218,10 @@ func.func @reduction_tile_parallel_cyclic_dist( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 - by num_threads = [0, 5], tile_sizes = [0, 3], mapping = [#gpu.thread] +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 + by num_threads = [0, 5], tile_sizes = [0, 3], mapping = [#gpu.thread] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // CHECK-DAG: #[[MAP0:.*]] = affine_map<()[s0] -> (s0 * 3)> @@ -283,22 +283,22 @@ func.func @reduction_tile_parallel_cyclic_dist( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 - by num_threads = [0, 5], tile_sizes = [0, 3], mapping = [#gpu.thread] - +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 + by num_threads = [0, 5], tile_sizes = [0, 3], mapping = [#gpu.thread] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + // CHECK: expecting fill // CHECK-NEXT: linalg.fill - transform.print %1 {name = "expecting fill"} : !pdl.operation + transform.print %1 {name = "expecting fill"} : !transform.any_op // CHECK: expecting parallel reduction // CHECK-NEXT: linalg.generic // CHECK: iterator_types = ["parallel", "reduction"] - transform.print %2 {name = "expecting parallel reduction"} : !pdl.operation + transform.print %2 {name = "expecting parallel reduction"} : !transform.any_op // CHECK: expecting parallel reduction // CHECK-NEXT: linalg.generic // CHECK: iterator_types = ["parallel", "reduction"] - transform.print %3 {name = "expecting parallel reduction"} : !pdl.operation + transform.print %3 {name = "expecting parallel reduction"} : !transform.any_op } // ----- @@ -320,11 +320,11 @@ func.func @reduction_untiled_forall( } transform.sequence failures(propagate) { -^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation +^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @below {{could not tile reduction}} %loop, %1, %2, %3 = transform.structured.tile_reduction_using_forall %0 - by num_threads = [5], tile_sizes = [3], mapping = [#gpu.thread] + by num_threads = [5], tile_sizes = [3], mapping = [#gpu.thread] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } @@ -346,9 +346,9 @@ module { return %0 : tensor } transform.sequence failures(propagate) { - ^bb0(%arg0: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg0 : (!pdl.operation) -> !pdl.operation + ^bb0(%arg0: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg0 : (!transform.any_op) -> !transform.any_op // expected-error @below {{transform.structured.tile_reduction_using_scf failed to apply}} - %for_op, %fill_op, %split_linalg_op, %combining_linalg_op = transform.structured.tile_reduction_using_scf %0 by tile_sizes = [0, 5] + %for_op, %fill_op, %split_linalg_op, %combining_linalg_op = transform.structured.tile_reduction_using_scf %0 by tile_sizes = [0, 5] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } } diff --git a/mlir/test/Dialect/Linalg/vectorization.mlir b/mlir/test/Dialect/Linalg/vectorization.mlir index 4712093a81e4..489b76b37598 100644 --- a/mlir/test/Dialect/Linalg/vectorization.mlir +++ b/mlir/test/Dialect/Linalg/vectorization.mlir @@ -11,10 +11,10 @@ func.func @contraction_dot(%A: memref<1584xf32>, %B: memref<1584xf32>, %C: memre } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.dot"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.dot"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -30,10 +30,10 @@ func.func @contraction_matvec(%A: memref<1584x1584xf32>, %B: memref<1584xf32>, % } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -48,10 +48,10 @@ func.func @contraction_matmul(%A: memref<1584x1584xf32>, %B: memref<1584x1584xf3 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -67,10 +67,10 @@ func.func @contraction_batch_matmul(%A: memref<1584x1584x1584xf32>, %B: memref<1 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.batch_matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.batch_matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -107,10 +107,10 @@ func.func @vectorization_test(%A: memref<8x16xf32>, %B: memref<16x32xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -147,10 +147,10 @@ func.func @generic_output_transpose(%A: memref<8x16xf32>, %B: memref<16x32xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -174,10 +174,10 @@ func.func @generic_interchanged_transpose(%arg0: tensor<12x128x32xf32>) -> tenso } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -214,10 +214,10 @@ func.func @vectorization_test_integer(%A: memref<8x16xi32>, %B: memref<16x32xi32 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -234,10 +234,10 @@ func.func @vectorization_test_2(%A: memref<8x16xf32>, %B: memref<16x32xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -258,10 +258,10 @@ func.func @test_vectorize_scalar_input(%A : memref<8x16xf32>, %arg0 : f32) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -282,10 +282,10 @@ func.func @test_do_not_vectorize_unsupported_element_types(%A : memref<8x16xcomp } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -327,10 +327,10 @@ func.func @vectorize_affine_apply(%arg0: tensor<5xf32>, %arg3: index) -> tensor< // CHECK: vector.transfer_write %[[CAST]], %[[EMPTY]][%[[C0:.*]]] {in_bounds = [true]} : vector<5xi32>, tensor<5xi32> transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -344,10 +344,10 @@ func.func @test_vectorize_fill(%A : memref<8x16xf32>, %arg0 : f32) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -362,10 +362,10 @@ func.func @test_vectorize_fill_scalar(%A : memref, %arg0 : f32) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -379,10 +379,10 @@ func.func @test_vectorize_copy(%A : memref<8x16xf32>, %B : memref<8x16xf32>) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -399,10 +399,10 @@ func.func @test_vectorize_copy_scalar(%A : memref, %B : memref) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -415,10 +415,10 @@ func.func @test_vectorize_copy_complex(%A : memref<8x16xcomplex>, %B : memr } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["memref.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -443,10 +443,10 @@ func.func @test_vectorize_trailing_index(%arg0: memref<1x2x4x8xindex>) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -472,10 +472,10 @@ func.func @test_vectorize_inner_index(%arg0: memref<1x2x4x8xindex>) { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -557,10 +557,10 @@ func.func @generic_vectorize(%arg0: memref<4x256xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -648,10 +648,10 @@ func.func @generic_vectorize_tensor(%arg0: tensor<4x256xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -692,10 +692,10 @@ func.func @generic_vectorize_broadcast_transpose( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -735,10 +735,10 @@ func.func @vectorization_transpose(%A: memref<14x7xf32>, %B: memref<16x14xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -767,10 +767,10 @@ func.func @matmul_tensors( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -796,10 +796,10 @@ func.func @pad_static(%arg0: tensor<2x?x2xf32>, %pad_value: f32) -> tensor<2x3x4 transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -825,10 +825,10 @@ func.func @pad_static_source(%arg0: tensor<2x5x2xf32>, %pad_value: f32) -> tenso transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } @@ -862,10 +862,10 @@ func.func @pad_static_dynamic(%arg0: tensor<1x2x2x?xf32>, %low: index, %high: in transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -882,10 +882,10 @@ func.func @pad_static_complex(%arg0: tensor<2x5x2xcomplex>, %pad_value: com transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -912,10 +912,10 @@ func.func @pad_and_transfer_read(%arg0: tensor<5x6xf32>) -> vector<7x9xf32> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -945,10 +945,10 @@ func.func @pad_and_transfer_write_static( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } @@ -982,10 +982,10 @@ func.func @pad_and_transfer_write_dynamic_static( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } @@ -1016,10 +1016,10 @@ func.func @pad_and_insert_slice_source( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } @@ -1044,10 +1044,10 @@ func.func @pad_and_insert_slice_dest( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1081,10 +1081,10 @@ func.func @pad_tensor_non_const_pad_value(%arg0: tensor<5x6xf32>) -> tensor<12x1 transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1116,10 +1116,10 @@ func.func @sum_exp(%input: tensor<4x16x8xf32>, %output: tensor<4x16xf32>) transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1161,10 +1161,10 @@ func.func @sum_exp_2(%input: tensor<3x2xf32>, %input_2: tensor<5x4xf32>, %output transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1191,10 +1191,10 @@ func.func @red_max_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1222,10 +1222,10 @@ func.func @red_min_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1252,10 +1252,10 @@ func.func @red_mul_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1282,10 +1282,10 @@ func.func @red_or_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1312,10 +1312,10 @@ func.func @red_and_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1342,10 +1342,10 @@ func.func @red_xor_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> { transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1376,10 +1376,10 @@ func.func @explicit_broadcast(%arg0: tensor<4x4xf32>, %arg1: tensor<4x1xf32>) -> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 +^bb1(%arg1: !transform.any_op): + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1414,14 +1414,14 @@ func.func @fused_broadcast_red_2d(%arg0: tensor<4x4xf32>, %arg1: tensor<4x1xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op - %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %4 = get_closest_isolated_parent %3 : (!pdl.operation) -> !pdl.operation - %5 = transform.structured.vectorize %4 + %3 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %4 = get_closest_isolated_parent %3 : (!transform.any_op) -> !transform.any_op + %5 = transform.structured.vectorize %4 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1461,10 +1461,10 @@ func.func @reduce_1d(%arg0: tensor<32xf32>) -> tensor { } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } @@ -1492,10 +1492,10 @@ func.func @not_projected_permutation(%arg0: tensor<8x8xf32>) -> tensor<6x6x3x3xf } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1531,10 +1531,10 @@ func.func @mixed_parallel_reduced_results(%arg0 : tensor<2x4x8xf32>, // CHECK-DAG: vector.transfer_write %[[ADD]], %[[ARG3]] transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns, disable_transfer_permutation_map_lowering_patterns } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1567,10 +1567,10 @@ func.func @vectorize_1d_tensor_extract(%arg0: tensor<3xf32>, %arg1: tensor<4x3xi // CHECK: vector.transfer_write %[[GATHER]] transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -1603,10 +1603,10 @@ func.func @vectorize_nd_tensor_extract_constant_idx(%arg0: tensor<3x3xf32>, %arg // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1642,10 +1642,10 @@ func.func @vectorize_nd_tensor_extract_transfer_read_basic(%arg0: tensor<3x3x3xf // CHECK: vector.transfer_write %[[READ]], %[[ARG1]][%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<1x1x3xf32>, tensor<1x1x3xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1692,10 +1692,10 @@ func.func @vectorize_nd_tensor_extract_transfer_read_complex(%6: tensor<45x80x16 // CHECK: %[[VAL_22:.*]] = vector.transfer_write %[[VAL_21]], %[[VAL_5]]{{\[}}%[[VAL_9]], %[[VAL_9]]] {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x4xf32> transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1740,10 +1740,10 @@ func.func @vectorize_nd_tensor_extract_index_from_tensor(%arg0: tensor<3x3xf32>, // CHECK: vector.transfer_write %[[GATHER]], %[[ARG4]][%[[C0]], %[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true, true]} : vector<4x7x3x2xf32>, tensor<4x7x3x2xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1784,10 +1784,10 @@ func.func @vectorize_nd_tensor_extract_contiguous_and_gather(%arg0: tensor<6xf32 // CHECK: return %[[VAL_14]] : tensor<5xf32> transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1826,10 +1826,10 @@ func.func @vectorize_nd_tensor_extract_with_affine_apply_contiguous(%6: tensor<8 // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1896,10 +1896,10 @@ func.func @vectorize_nd_tensor_extract_with_tensor_extract(%input_1: tensor<1x20 // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -1930,9 +1930,9 @@ func.func @masked_static_vectorize_nd_tensor_extract_with_affine_apply_contiguou // CHECK: %[[VAL_22:.*]] = vector.mask %[[VAL_8]] { vector.transfer_write {{.*}} {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x3xf32> } : vector<1x4xi1> -> tensor<1x3xf32> transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } : !transform.any_op } // ----- @@ -1985,9 +1985,9 @@ func.func @masked_dynamic_vectorize_nd_tensor_extract_with_affine_apply_contiguo // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } : !transform.any_op } // ----- @@ -2028,10 +2028,10 @@ func.func @vectorize_nd_tensor_extract_with_affine_apply_gather(%6: tensor<80x16 // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -2067,9 +2067,9 @@ func.func @masked_vectorize_nd_tensor_extract_with_affine_apply_gather(%6: tenso // CHECK: %[[VAL_25:.*]] = vector.mask %[[VAL_8]] { vector.transfer_write {{.*}} {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x3xf32> } : vector<1x4xi1> -> tensor<1x3xf32> transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } : !transform.any_op } // ----- @@ -2122,9 +2122,9 @@ func.func @masked_dynamic_vectorize_nd_tensor_extract_with_affine_apply_gather(% // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [1, 4] { vectorize_nd_extract } : !transform.any_op } // ----- @@ -2161,10 +2161,10 @@ func.func @vectorize_nd_tensor_extract_with_maxsi_gather(%arg0: tensor<80x16xf32 // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -2201,10 +2201,10 @@ func.func @vectorize_nd_tensor_extract_with_maxsi_contiguous(%arg0: tensor<80x16 // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } // ----- @@ -2240,10 +2240,10 @@ func.func @vectorize_nd_tensor_extract_block_arg(%arg0: tensor<5x6xf32>, %arg1: // CHECK: } transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_nd_extract } : (!transform.any_op) -> !transform.any_op } @@ -2265,10 +2265,10 @@ func.func @vectorize_map(%arg0: memref<64xf32>, // CHECK-NEXT: arith.addf %[[LHS]], %[[RHS]] : vector<64xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.map"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.map"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -2284,10 +2284,10 @@ func.func @vectorize_transpose(%arg0: memref<16x32x64xf32>, // CHECK-SAME: [1, 2, 0] : vector<16x32x64xf32> to vector<32x64x16xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.transpose"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.transpose"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -2307,10 +2307,10 @@ func.func @vectorize_reduce(%arg0: memref<16x32x64xf32>, // CHECK-SAME: : vector<16x32x64xf32> to vector<16x64xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.reduce"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.reduce"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -2342,9 +2342,9 @@ func.func @vectorize_dynamic_identity(%arg0: tensor, // CHECK: %[[VAL_14:.*]] = vector.mask %[[VAL_7]] { vector.transfer_write %{{.*}} {in_bounds = [true]} : vector<4xf32>, tensor } : vector<4xi1> -> tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4] : !transform.any_op } // ----- @@ -2376,9 +2376,9 @@ func.func @vectorize_dynamic_1d_broadcast(%arg0: tensor, // CHECK: %[[VAL_14:.*]] = vector.mask %{{.*}} { vector.transfer_write %[[VAL_13]], {{.*}} {in_bounds = [true]} : vector<4xf32>, tensor } : vector<4xi1> -> tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4] : !transform.any_op } // ----- @@ -2414,9 +2414,9 @@ func.func @vectorize_dynamic_2d_transpose(%arg0: tensor, // CHECK: %[[VAL_17:.*]] = vector.mask %[[VAL_12]] { vector.transfer_write %[[VAL_16]], %{{.*}} {in_bounds = [true, true]} : vector<4x8xf32>, tensor } : vector<4x8xi1> -> tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4, 8] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4, 8] : !transform.any_op } // ----- @@ -2451,9 +2451,9 @@ func.func @vectorize_dynamic_generic_2d_broadcast(%arg0: tensor, // CHECK: %[[VAL_18:.*]] = vector.mask %[[VAL_12]] { vector.transfer_write %{{.*}} {in_bounds = [true, true]} : vector<4x8xf32>, tensor } : vector<4x8xi1> -> tensor transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4, 8] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4, 8] : !transform.any_op } // ----- @@ -2473,9 +2473,9 @@ func.func @vectorize_dynamic_reduction(%arg0: tensor, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4, 8] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4, 8] : !transform.any_op } // CHECK-LABEL: @vectorize_dynamic_reduction( @@ -2511,9 +2511,9 @@ func.func @vectorize_dynamic_transpose_reduction(%arg0: tensor, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [4, 8, 16] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [4, 8, 16] : !transform.any_op } // CHECK-LABEL: @vectorize_dynamic_transpose_reduction( @@ -2535,7 +2535,7 @@ transform.sequence failures(propagate) { // ----- // This is a regression test. This IR cannot be vectorized, but -// structured.vectorize should nevertheless succeed. +// structured.vectorize should nevertheless succeed. : (!transform.any_op) -> !transform.any_op #map = affine_map<(d0) -> (d0)> // CHECK-LABEL: @not_vectorizable @@ -2559,9 +2559,9 @@ func.func @not_vectorizable(%arg0: tensor<1x?xf32>, %arg1: index, %arg2: index, return %1 : tensor<1x128xf32> } transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): - %0 = transform.structured.match ops{["func.func"]} in %arg0 : (!pdl.operation) -> !pdl.operation - %1 = transform.structured.vectorize %0 +^bb0(%arg0: !transform.any_op): + %0 = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op + %1 = transform.structured.vectorize %0 : (!transform.any_op) -> !transform.any_op } // ----- @@ -2593,10 +2593,10 @@ func.func @wrong_reduction_detection(%input: tensor<120x64xf32>) -> tensor<120x6 } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // CHECK-LABEL: @wrong_reduction_detection @@ -2605,7 +2605,7 @@ transform.sequence failures(propagate) { // ----- -// Don't vectorize tensor<0xf32> +// Don't vectorize tensor<0xf32> : (!transform.any_op) -> !transform.any_op // CHECK-LABEL: @tensor_size0 // CHECK: linalg.generic func.func @tensor_size0(%arg0: tensor<0xf32>, @@ -2622,10 +2622,10 @@ func.func @tensor_size0(%arg0: tensor<0xf32>, } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } // ----- @@ -2665,9 +2665,9 @@ func.func @vectorize_partial_dynamic_identity(%arg0: tensor<8x?xf32>, transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [8, 32] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [8, 32] : !transform.any_op } // ----- @@ -2715,9 +2715,9 @@ func.func @extract_masked_vectorize(%arg0: tensor, %arg1: tensor, tensor } : vector<3x3xi1> -> tensor transform.sequence failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [3, 3] { vectorize_nd_extract } + ^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [3, 3] { vectorize_nd_extract } : !transform.any_op } // ----- @@ -2742,9 +2742,9 @@ func.func @do_not_generate_masks(%arg0: tensor<8x32xf32>, // CHECK-NOT: vector.mask transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [8, 32] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [8, 32] : !transform.any_op } // ----- @@ -2782,9 +2782,9 @@ func.func @vectorize_static_shape_with_mask(%arg0: tensor<8x30xf32>, // CHECK: %[[VAL_15:.*]] = vector.mask %[[VAL_7]] { vector.transfer_write %[[VAL_13]], %[[VAL_2]][%[[VAL_14]], %[[VAL_14]]] {in_bounds = [true, true]} : vector<8x32xf32>, tensor<8x30xf32> } : vector<8x32xi1> -> tensor<8x30xf32> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [8, 32] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [8, 32] : !transform.any_op } // ----- @@ -2802,9 +2802,9 @@ func.func @vectorize_dynamic_fill(%A : tensor, %arg0 : f32) -> tensor, tensor } : vector<8x16xi1> transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [8, 16] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.fill"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [8, 16] : !transform.any_op } // ----- @@ -2823,9 +2823,9 @@ func.func @test_masked_vectorize_linalg_copy(%A : memref, %B : memref !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [2, 4] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [2, 4] : !transform.any_op } // ----- @@ -2858,10 +2858,10 @@ func.func @test_masked_vectorize_pad( } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): +^bb1(%arg1: !transform.any_op): %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 - : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [2, 4] + : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [2, 4] : !transform.any_op } // ----- @@ -2879,10 +2879,10 @@ func.func @test_masked_pad_static_dynamic(%arg0: tensor<1x2x2x?xf32>, %low: inde transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - %2 = transform.structured.vectorize %1 { vectorize_padding } +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + %2 = transform.structured.vectorize %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op } // ----- @@ -2920,7 +2920,7 @@ func.func @vectorize_dynamic_matmul(%A: memref, %B: memref, %C // CHECK: } transform.sequence failures(propagate) { -^bb1(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.masked_vectorize %0 vector_sizes [8, 16, 4] +^bb1(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.masked_vectorize %0 vector_sizes [8, 16, 4] : !transform.any_op } diff --git a/mlir/test/Dialect/SCF/transform-op-take-assumed-branch.mlir b/mlir/test/Dialect/SCF/transform-op-take-assumed-branch.mlir index 68325702ac28..70876b7184bd 100644 --- a/mlir/test/Dialect/SCF/transform-op-take-assumed-branch.mlir +++ b/mlir/test/Dialect/SCF/transform-op-take-assumed-branch.mlir @@ -10,10 +10,10 @@ func.func @if_no_else(%cond: i1, %a: index, %b: memref, %c: i8) { transform.sequence failures(propagate) { ^bb0(%arg1: !transform.any_op): - %if = transform.structured.match ops{["scf.if"]} in %arg1 + %if = transform.structured.match ops{["scf.if"]} in %arg1 : (!transform.any_op) -> !transform.any_op // expected-error @+1 {{requires an scf.if op with a single-block `else` region}} - transform.scf.take_assumed_branch %if take_else_branch + transform.scf.take_assumed_branch %if take_else_branch : (!transform.any_op) -> () } @@ -63,8 +63,9 @@ func.func @tile_tensor_pad( transform.sequence failures(propagate) { ^bb0(%arg1: !transform.any_op): %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 - : (!transform.any_op) -> !pdl.operation - transform.structured.tile_to_forall_op %0 tile_sizes[1, 1] + : (!transform.any_op) -> !transform.any_op + transform.structured.tile_to_forall_op %0 tile_sizes[1, 1] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op) %if = transform.structured.match ops{["scf.if"]} in %arg1 : (!transform.any_op) -> !transform.any_op diff --git a/mlir/test/Dialect/Tensor/tiling.mlir b/mlir/test/Dialect/Tensor/tiling.mlir index 3f07e3ce6712..4286a5464322 100644 --- a/mlir/test/Dialect/Tensor/tiling.mlir +++ b/mlir/test/Dialect/Tensor/tiling.mlir @@ -32,9 +32,9 @@ func.func @dynamic_pad_tensor_3_4(%input_tensor: tensor, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 3] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -69,9 +69,9 @@ func.func @dynamic_pad_tensor_0_3(%input_tensor: tensor, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -103,9 +103,9 @@ func.func @static_pad_tensor_3_4(%input_tensor: tensor<7x9xf32>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 3] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -135,9 +135,9 @@ func.func @static_pad_tensor_0_3(%input_tensor: tensor<7x9xf32>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -173,9 +173,9 @@ func.func @static_pad_tile_evenly_0_3(%input_tensor: tensor<7x9xf32>, } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loop = transform.structured.tile_to_scf_for %0 [0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op) } // ----- @@ -209,9 +209,9 @@ func.func @NC_to_NCnc(%arg0: tensor<128x256xf32>, %arg1: tensor<4x8x32x32xf32>) } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -237,9 +237,9 @@ func.func @KC_to_CKkc(%arg0: tensor<128x256xf32>, %arg1: tensor<32x4x32x8xf32>) } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -272,9 +272,9 @@ func.func @pad_and_pack_static(%input: tensor<13x15xf32>, %output: tensor<2x8x8x } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -321,9 +321,9 @@ func.func @pad_and_pack_partially_dynamic(%input: tensor, %output: tens } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -375,9 +375,9 @@ func.func @pad_and_pack_fully_dynamic(%source: tensor, %dest: tensor !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -422,9 +422,9 @@ func.func @NCnc_to_NC(%source: tensor<8x8x32x16xf32>, %dest: tensor<256x128xf32> } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -468,9 +468,9 @@ func.func @CKkc_to_KC(%source: tensor<32x4x32x8xf32>, %dest: tensor<128x256xf32> } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -504,9 +504,9 @@ func.func @perfect_CKkc_to_KC(%source: tensor<32x4x2x4xf32>, %dest: tensor<8x128 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -546,9 +546,9 @@ func.func @dynamic_perfect_CKkc_to_KC(%source: tensor, %dest: tenso } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -581,9 +581,9 @@ func.func @perfect_NKPQk_to_NPQK(%source: tensor<1x4x6x6x2xf32>, %dest: tensor<1 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 4] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -607,9 +607,9 @@ func.func @fully_dynamic_unpack(%source: tensor, %dest: tensor !pdl.operation - %1, %loops:2 = transform.structured.tile_to_scf_for %0 [4, 8] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.unpack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:2 = transform.structured.tile_to_scf_for %0 [4, 8] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) } // ----- @@ -641,7 +641,7 @@ func.func @perfect_NPQK_to_NKPQk(%source: tensor<1x6x6x8xf32>, %dest: tensor<1x4 } transform.sequence failures(propagate) { - ^bb0(%arg1: !pdl.operation): - %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!pdl.operation) -> !pdl.operation - %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 1] + ^bb0(%arg1: !transform.any_op): + %0 = transform.structured.match ops{["tensor.pack"]} in %arg1 : (!transform.any_op) -> !transform.any_op + %1, %loops:4 = transform.structured.tile_to_scf_for %0 [1, 1, 1, 1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) } diff --git a/mlir/test/Dialect/Transform/selective-targeting.mlir b/mlir/test/Dialect/Transform/selective-targeting.mlir index 231ff3099d17..13b0a1f40428 100644 --- a/mlir/test/Dialect/Transform/selective-targeting.mlir +++ b/mlir/test/Dialect/Transform/selective-targeting.mlir @@ -53,7 +53,7 @@ func.func @matmul_tensors_3( } transform.with_pdl_patterns { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): // Match matmul operations inside @matmul_tensors with test.attrA set. pdl.pattern @pdl_target_attrA : benefit(1) { %args = operands @@ -74,13 +74,13 @@ transform.with_pdl_patterns { rewrite %0 with "transform.dialect" } - transform.sequence %arg0 : !pdl.operation failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = pdl_match @pdl_target_attrA in %arg1 : (!pdl.operation) -> !pdl.operation - transform.structured.tile %0 [4, 4, 4] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %1 = pdl_match @pdl_target_attrC in %arg1 : (!pdl.operation) -> !pdl.operation - %2 = transform.get_closest_isolated_parent %1 : (!pdl.operation) -> !pdl.operation - transform.structured.vectorize %2 + transform.sequence %arg0 : !transform.any_op failures(propagate) { + ^bb1(%arg1: !transform.any_op): + %0 = pdl_match @pdl_target_attrA in %arg1 : (!transform.any_op) -> !transform.any_op + transform.structured.tile %0 [4, 4, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %1 = pdl_match @pdl_target_attrC in %arg1 : (!transform.any_op) -> !transform.any_op + %2 = transform.get_closest_isolated_parent %1 : (!transform.any_op) -> !transform.any_op + transform.structured.vectorize %2 : (!transform.any_op) -> !transform.any_op } } @@ -111,7 +111,7 @@ func.func @vectorize_none( } transform.with_pdl_patterns { -^bb0(%arg0: !pdl.operation): +^bb0(%arg0: !transform.any_op): pdl.pattern @pdl_target : benefit(1) { %args = operands %results = types @@ -121,11 +121,11 @@ transform.with_pdl_patterns { rewrite %0 with "transform.dialect" } - transform.sequence %arg0 : !pdl.operation failures(propagate) { - ^bb1(%arg1: !pdl.operation): - %0 = pdl_match @pdl_target in %arg1 : (!pdl.operation) -> !pdl.operation - %1 = get_closest_isolated_parent %0 : (!pdl.operation) -> !pdl.operation - transform.structured.vectorize %1 + transform.sequence %arg0 : !transform.any_op failures(propagate) { + ^bb1(%arg1: !transform.any_op): + %0 = pdl_match @pdl_target in %arg1 : (!transform.any_op) -> !transform.any_op + %1 = get_closest_isolated_parent %0 : (!transform.any_op) -> !transform.any_op + transform.structured.vectorize %1 : (!transform.any_op) -> !transform.any_op } } @@ -149,6 +149,6 @@ func.func @vectorize_all( } transform.sequence failures(propagate) { -^bb0(%arg0: !pdl.operation): - transform.structured.vectorize %arg0 +^bb0(%arg0: !transform.any_op): + transform.structured.vectorize %arg0 : (!transform.any_op) -> !transform.any_op } diff --git a/mlir/test/Dialect/Vector/transform-vector.mlir b/mlir/test/Dialect/Vector/transform-vector.mlir index 2fbee4210970..beda04294b84 100644 --- a/mlir/test/Dialect/Vector/transform-vector.mlir +++ b/mlir/test/Dialect/Vector/transform-vector.mlir @@ -14,49 +14,49 @@ func.func @matmul_tensors( } transform.sequence failures(propagate) { -^bb1(%module_op: !pdl.operation): - %0 = transform.structured.match ops{["linalg.matmul"]} in %module_op : (!pdl.operation) -> !pdl.operation - %1, %loops:3 = transform.structured.tile %0 [8, 4, 2] - : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation, !pdl.operation) - %2 = get_closest_isolated_parent %1 : (!pdl.operation) -> !pdl.operation - transform.structured.vectorize %2 +^bb1(%module_op: !transform.any_op): + %0 = transform.structured.match ops{["linalg.matmul"]} in %module_op : (!transform.any_op) -> !transform.any_op + %1, %loops:3 = transform.structured.tile %0 [8, 4, 2] + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) + %2 = get_closest_isolated_parent %1 : (!transform.any_op) -> !transform.any_op + transform.structured.vectorize %2 : (!transform.any_op) -> !transform.any_op %b = transform.bufferization.one_shot_bufferize layout{IdentityLayoutMap} %module_op {bufferize_function_boundaries = true, allow_return_allocs = true} - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %f = transform.structured.match ops{["func.func"]} in %b - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op // TODO: group these lower-level controls into various properly named vector // lowering TD macros. %func = transform.vector.lower_contraction %f lowering_strategy = "outerproduct" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_2 = transform.vector.apply_transfer_permutation_patterns %func - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_3 = transform.vector.lower_multi_reduction %func_2 lowering_strategy = "innerparallel" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_4 = transform.vector.split_transfer_full_partial %func_3 split_transfer_strategy = "linalg-copy" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_5 = transform.vector.transfer_to_scf %func_4 max_transfer_rank = 1 full_unroll = true - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_6 = transform.vector.lower_transfer %func_5 max_transfer_rank = 1 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_7 = transform.vector.lower_shape_cast %func_6 - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op %func_8 = transform.vector.lower_transpose %func_7 lowering_strategy = "shuffle_1d" - : (!pdl.operation) -> !pdl.operation + : (!transform.any_op) -> !transform.any_op } -- cgit v1.2.1