Files
clang-p2996/mlir/test/Dialect/Transform/test-interpreter.mlir
Alex Zinenko cc6c159203 [mlir] add VectorizeOp to structured transform ops
Vectorization is a key transformation to achieve high performance on most
architectures. In the transform dialect, vectorization is implemented as a
parameterizable transform op. It currently applies to a scope of payload IR
delimited by some isolated-from-above op, mainly because several enabling
transformations (such as affine simplification) are needed to perform
vectorization and these transformation would apply to ops other than the "main"
computational payload op. A separate "navigation" transform op that obtains the
isolated-from-above ancestor of an op is introduced in the core transform
dialect. Even though it is currently only useful for vectorization,
isolated-from-above ops are a common anchor for transformations (usually
implemented as passes) that is likely to be reused in the future.

Depends On D126374

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D126542
2022-05-30 17:37:50 +02:00

131 lines
3.4 KiB
MLIR

// RUN: mlir-opt %s --test-transform-dialect-interpreter --split-input-file --verify-diagnostics
// expected-remark @below {{applying transformation}}
transform.test_transform_op
// -----
%0 = transform.test_produce_param_or_forward_operand 42 { foo = "bar" }
// expected-remark @below {{succeeded}}
transform.test_consume_operand_if_matches_param_or_fail %0[42]
// -----
%0 = transform.test_produce_param_or_forward_operand 42 { foo = "bar" }
// expected-error @below {{expected the operand to be associated with 21 got 42}}
transform.test_consume_operand_if_matches_param_or_fail %0[21]
// -----
// expected-error @below {{operation tracked by two handles}}
%0 = transform.test_produce_param_or_forward_operand 42
// expected-note @below {{handle}}
%1 = transform.test_produce_param_or_forward_operand from %0
// expected-note @below {{handle}}
%2 = transform.test_produce_param_or_forward_operand from %0
transform.test_consume_operand_if_matches_param_or_fail %1[42]
transform.test_consume_operand_if_matches_param_or_fail %2[42]
// -----
transform.sequence {
^bb0(%arg0: !pdl.operation):
sequence %arg0 {
^bb0(%arg1: !pdl.operation):
// expected-remark @below {{applying transformation "a"}}
test_transform_op "a"
// expected-remark @below {{applying transformation "b"}}
test_transform_op "b"
// expected-remark @below {{applying transformation "c"}}
test_transform_op "c"
}
// expected-remark @below {{applying transformation "d"}}
test_transform_op "d"
// expected-remark @below {{applying transformation "e"}}
test_transform_op "e"
}
// -----
transform.sequence {
^bb0(%arg0: !pdl.operation):
%0 = test_produce_param_or_forward_operand 42
sequence %0 {
^bb0(%arg1: !pdl.operation):
// expected-remark @below {{succeeded}}
test_consume_operand_if_matches_param_or_fail %arg1[42]
}
}
// -----
transform.sequence {
^bb0(%arg0: !pdl.operation):
%0 = sequence %arg0 {
^bb0(%arg1: !pdl.operation):
%1 = test_produce_param_or_forward_operand 42
yield %1 : !pdl.operation
} : !pdl.operation
// expected-remark @below {{succeeded}}
test_consume_operand_if_matches_param_or_fail %0[42]
}
// -----
transform.with_pdl_patterns {
^bb0(%arg0: !pdl.operation):
sequence %arg0 {
^bb0(%arg1: !pdl.operation):
%0 = pdl_match @some in %arg1
test_print_remark_at_operand %0, "matched"
}
pdl.pattern @some : benefit(1) {
%0 = pdl.operation "test.some_op"
pdl.rewrite %0 with "transform.dialect"
}
pdl.pattern @other : benefit(1) {
%0 = pdl.operation "test.other_op"
pdl.rewrite %0 with "transform.dialect"
}
}
// expected-remark @below {{matched}}
"test.some_op"() : () -> ()
"test.other_op"() : () -> ()
// expected-remark @below {{matched}}
"test.some_op"() : () -> ()
// -----
// expected-remark @below {{parent function}}
func.func @foo() {
%0 = arith.constant 0 : i32
return
}
// expected-remark @below {{parent function}}
func.func @bar() {
%0 = arith.constant 0 : i32
%1 = arith.constant 1 : i32
return
}
transform.with_pdl_patterns {
^bb0(%arg0: !pdl.operation):
pdl.pattern @const : benefit(1) {
%r = pdl.types
%0 = pdl.operation "arith.constant" -> (%r : !pdl.range<type>)
pdl.rewrite %0 with "transform.dialect"
}
transform.sequence %arg0 {
^bb1(%arg1: !pdl.operation):
%f = pdl_match @const in %arg1
// CHECK: %{{.+}} = get_closest_isolated_parent %{{.+}}
%m = get_closest_isolated_parent %f
test_print_remark_at_operand %m, "parent function"
}
}