-// RUN: mlir-opt %s -test-linalg-transform-patterns=test-linalg-to-vector-patterns -split-input-file | FileCheck %s
+// RUN: mlir-opt %s -test-transform-dialect-interpreter -split-input-file | FileCheck %s
// -----
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.dot"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: contraction_matvec
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.matvec"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: contraction_matmul
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: contraction_batch_matmul
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.batch_matmul"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true }
+ }
+}
+
// -----
#matmul_trait = {
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
#matmul_transpose_out_trait = {
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
#map0 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
return %1 : tensor<128x12x32xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
#matmul_trait = {
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @vectorization_test_2
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_scalar_input
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_do_not_vectorize_unsupported_element_types
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_fill
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.fill"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_fill
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.fill"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_copy
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["memref.copy"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_copy_scalar
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["memref.copy"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
// -----
// CHECK-LABEL: func @test_vectorize_trailing_index
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @test_vectorize_inner_index
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// CHECK-LABEL: func @generic_vectorize
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 {disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @generic_vectorize_tensor
tensor<4x256xf32>, tensor<4x256xf32>, tensor<4x256xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-DAG: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, 0, 0, d1)>
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 {disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// Test different input maps.
return
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 {disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @matmul_tensors
return %0 : tensor<8x12xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @pad_static(
return %0 : tensor<2x3x4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { vectorize_padding = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @pad_static_source(
return %0 : tensor<2x6x4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { vectorize_padding = true }
+ }
+}
+
+
// -----
// CHECK-LABEL: func @pad_static_dynamic(
return %0 : tensor<6x?x?x?xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { vectorize_padding = true }
+ }
+}
+
+
// -----
// CHECK-LABEL: func @pad_and_transfer_read
return %1 : vector<7x9xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { vectorize_padding = true }
+ }
+}
+
// -----
func.func private @make_vector() -> vector<7x9xf32>
return %3 : tensor<5x6xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { vectorize_padding = true }
+ }
+}
+
+
// -----
func.func private @make_vector() -> vector<7x9xf32>
return %3 : tensor<?x6xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { vectorize_padding = true }
+ }
+}
+
+
// -----
func.func private @make_vector() -> tensor<12x13xf32>
return %r : tensor<12x13xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { vectorize_padding = true }
+ }
+}
+
+
// -----
func.func private @make_vector() -> tensor<12x13xf32>
return %r : tensor<1x12x13xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @pad_tensor_non_const_pad_value
return %0 : tensor<12x13xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["tensor.pad"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { vectorize_padding = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @sum_exp
return %0 : tensor<4x16xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-DAG: #[[$M1:.*]] = affine_map<(d0, d1) -> (d1, d0, 0, 0)>
return %0 : tensor<5x2xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @red_max_2d(
func.func @red_max_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> {
// CHECK: %[[CMINF:.+]] = arith.constant dense<-3.402820e+38> : vector<4xf32>
// CHECK: linalg.init_tensor [4] : tensor<4xf32>
- // CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
// CHECK: vector.multi_reduction <maxf>, {{.*}}, %[[CMINF]] [1] : vector<4x4xf32> to vector<4xf32>
// CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
%ident = arith.constant -3.40282e+38 : f32
return %red : tensor<4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4 { vectorize_padding = true }
+ }
+}
+
// -----
// CHECK-LABEL: func @red_min_2d(
func.func @red_min_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> {
// CHECK: %[[CMAXF:.+]] = arith.constant dense<3.402820e+38> : vector<4xf32>
// CHECK: linalg.init_tensor [4] : tensor<4xf32>
- // CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
// CHECK: vector.transfer_read {{.*}} : tensor<4x4xf32>, vector<4x4xf32>
// CHECK: vector.multi_reduction <minf>, {{.*}}, %[[CMAXF]] [1] : vector<4x4xf32> to vector<4xf32>
// CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
return %red : tensor<4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @red_mul_2d(
func.func @red_mul_2d(%arg0: tensor<4x4xf32>) -> tensor<4xf32> {
// CHECK: linalg.init_tensor [4] : tensor<4xf32>
- // CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
// CHECK: vector.transfer_read {{.*}} : tensor<4x4xf32>, vector<4x4xf32>
// CHECK: vector.multi_reduction <mul>, {{.*}}, {{.*}} [1] : vector<4x4xf32> to vector<4xf32>
// CHECK: vector.transfer_write {{.*}} : vector<4xf32>, tensor<4xf32>
return %red : tensor<4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @red_or_2d(
func.func @red_or_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> {
// CHECK: linalg.init_tensor [4] : tensor<4xi1>
- // CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
// CHECK: vector.transfer_read {{.*}} : tensor<4x4xi1>, vector<4x4xi1>
// CHECK: vector.multi_reduction <or>, {{.*}}, {{.*}} [1] : vector<4x4xi1> to vector<4xi1>
// CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
return %red : tensor<4xi1>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @red_and_2d(
func.func @red_and_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> {
// CHECK: linalg.init_tensor [4] : tensor<4xi1>
- // CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
// CHECK: vector.transfer_read {{.*}} : tensor<4x4xi1>, vector<4x4xi1>
// CHECK: vector.multi_reduction <and>, {{.*}}, {{.*}} [1] : vector<4x4xi1> to vector<4xi1>
// CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
return %red : tensor<4xi1>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @red_xor_2d(
func.func @red_xor_2d(%arg0: tensor<4x4xi1>) -> tensor<4xi1> {
// CHECK: linalg.init_tensor [4] : tensor<4xi1>
- // CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
// CHECK: vector.transfer_read {{.*}} : tensor<4x4xi1>, vector<4x4xi1>
// CHECK: vector.multi_reduction <xor>, {{.*}}, {{.*}} [1] : vector<4x4xi1> to vector<4xi1>
// CHECK: vector.transfer_write {{.*}} : vector<4xi1>, tensor<4xi1>
return %red : tensor<4xi1>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-DAG: #[[$M5:.*]] = affine_map<(d0, d1) -> (d0, 0)>
return %red : tensor<4x4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-DAG: #[[$M6:.*]] = affine_map<(d0, d1) -> (d0, 0)>
return %red : tensor<4xf32>
}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.fill"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+
+ %3 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %4 = get_closest_isolated_parent %3
+ %5 = transform.structured.vectorize %4
+ }
+}
+
// -----
// CHECK-LABEL: func @reduce_1d(
// CHECK: %[[init:.*]] = linalg.init_tensor [] : tensor<f32>
%0 = linalg.init_tensor [] : tensor<f32>
- // CHECK: %[[f:.*]] = vector.transfer_write %[[vF0]], %[[init]][]
- // CHECK-SAME: : vector<f32>, tensor<f32>
%1 = linalg.fill ins(%f0 : f32) outs(%0 : tensor<f32>) -> tensor<f32>
// CHECK: %[[r:.*]] = vector.transfer_read %[[A]][%[[C0]]]
// CHECK-SAME: : tensor<32xf32>, vector<32xf32>
// CHECK: %[[red:.*]] = vector.multi_reduction <add>, %[[r]], %[[f0]] [0]
// CHECK-SAME: : vector<32xf32> to f32
// CHECK: %[[red_v1:.*]] = vector.broadcast %[[red]] : f32 to vector<f32>
- // CHECK: %[[res:.*]] = vector.transfer_write %[[red_v1]], %[[f]][]
+ // CHECK: %[[res:.*]] = vector.transfer_write %[[red_v1]], %[[init]][]
// CHECK-SAME: : vector<f32>, tensor<f32>
%2 = linalg.generic {
indexing_maps = [affine_map<(d0) -> (d0)>,
return %2 : tensor<f32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
return %result : tensor<6x6x3x3xf32>
}
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1
+ }
+}
+
// -----
// Check vectorization can handle cases where outputs are a mix of reduced and non-reduced values.
// CHECK-DAG: %[[ADD:.+]] = vector.multi_reduction <add>, %[[MUL]], %[[V2]]
// CHECK-DAG: vector.transfer_write %[[MUL]], %[[ARG2]]
// CHECK-DAG: vector.transfer_write %[[ADD]], %[[ARG3]]
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ transform.sequence %arg0 failures(propagate) {
+ ^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
+ %1 = get_closest_isolated_parent %0
+ %2 = transform.structured.vectorize %1 { disable_multi_reduction_to_contract_patterns = true, disable_transfer_permutation_map_lowering_patterns = true }
+ }
+}
\ No newline at end of file