@@ -812,3 +812,64 @@ func.func @test_vectorize_unpack_no_masks(%source: tensor<8x8x32x16xf32>, %dest:
812
812
transform.yield
813
813
}
814
814
}
815
+
816
+ // -----
817
+
818
+ // CHECK-LABEL: test_vectorize_pack_no_vector_sizes
819
+ func.func @test_vectorize_pack_no_vector_sizes (%arg0: tensor <64 x4 xf32 >, %arg1: tensor <2 x4 x16 x2 xf32 >) -> tensor <2 x4 x16 x2 xf32 > {
820
+ %pack = tensor.pack %arg0 outer_dims_perm = [1 , 0 ] inner_dims_pos = [0 , 1 ] inner_tiles = [16 , 2 ] into %arg1 : tensor <64 x4 xf32 > -> tensor <2 x4 x16 x2 xf32 >
821
+ return %pack : tensor <2 x4 x16 x2 xf32 >
822
+ }
823
+ // CHECK-DAG: %[[cst:.*]] = arith.constant 0.000000e+00 : f32
824
+ // CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
825
+ // CHECK: %[[read:.*]] = vector.transfer_read %{{.*}}[%[[c0]], %[[c0]]], %[[cst]]
826
+ // CHECK-SAME: {in_bounds = [true, true]} : tensor<64x4xf32>, vector<64x4xf32>
827
+ // CHECK: %[[shape_cast:.*]] = vector.shape_cast %[[read]] : vector<64x4xf32> to vector<4x16x2x2xf32>
828
+ // CHECK: %[[transpose:.*]] = vector.transpose %[[shape_cast]], [2, 0, 1, 3] : vector<4x16x2x2xf32> to vector<2x4x16x2xf32>
829
+ // CHECK-DAG: %[[c0_1:.*]] = arith.constant 0 : index
830
+ // CHECK-DAG: %[[empty:.*]] = tensor.empty() : tensor<2x4x16x2xf32>
831
+ // CHECK: %[[write:.*]] = vector.transfer_write %[[transpose]], %[[empty]][%[[c0_1]], %[[c0_1]], %[[c0_1]], %[[c0_1]]]
832
+ // CHECK-SAME: {in_bounds = [true, true, true, true]} : vector<2x4x16x2xf32>, tensor<2x4x16x2xf32>
833
+ // CHECK: return %[[write]] : tensor<2x4x16x2xf32>
834
+
835
+ module attributes {transform.with_named_sequence } {
836
+ transform.named_sequence @__transform_main (%arg0: !transform.any_op {transform.readonly }) {
837
+ %0 = transform.structured.match ops {[" tensor.pack" ]} in %arg0 : (!transform.any_op ) -> !transform.any_op
838
+ transform.structured.vectorize %0 : !transform.any_op
839
+ transform.yield
840
+ }
841
+ }
842
+
843
+ // -----
844
+
845
+ // CHECK-LABEL: test_vectorize_padded_pack_no_vector_sizes
846
+ func.func @test_vectorize_padded_pack_no_vector_sizes (%arg0: tensor <32 x7 x15 xf32 >, %arg1: tensor <32 x4 x1 x16 x2 xf32 >) -> tensor <32 x4 x1 x16 x2 xf32 > {
847
+ %pad = arith.constant 0.000000e+00 : f32
848
+ %pack = tensor.pack %arg0 padding_value (%pad : f32 ) inner_dims_pos = [2 , 1 ] inner_tiles = [16 , 2 ] into %arg1 : tensor <32 x7 x15 xf32 > -> tensor <32 x4 x1 x16 x2 xf32 >
849
+ return %pack : tensor <32 x4 x1 x16 x2 xf32 >
850
+ }
851
+ // CHECK-DAG: %[[cst:.*]] = arith.constant 0.000000e+00 : f32
852
+ // CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
853
+ // CHECK-DAG: %[[c32:.*]] = arith.constant 32 : index
854
+ // CHECK-DAG: %[[c7:.*]] = arith.constant 7 : index
855
+ // CHECK-DAG: %[[c15:.*]] = arith.constant 15 : index
856
+ // CHECK: %[[mask:.*]] = vector.create_mask %[[c32]], %[[c7]], %[[c15]] : vector<32x8x16xi1>
857
+ // CHECK: %[[masked_read:.*]] = vector.mask %[[mask]] {
858
+ // CHECK-SAME: vector.transfer_read %{{.*}}[%[[c0]], %[[c0]], %[[c0]]], %[[cst]]
859
+ // CHECK-SAME: {in_bounds = [true, true, true]} : tensor<32x7x15xf32>, vector<32x8x16xf32>
860
+ // CHECK-SAME: } : vector<32x8x16xi1> -> vector<32x8x16xf32>
861
+ // CHECK: %[[shape_cast:.*]] = vector.shape_cast %[[masked_read]] : vector<32x8x16xf32> to vector<32x4x2x1x16xf32>
862
+ // CHECK: %[[transpose:.*]] = vector.transpose %[[shape_cast]], [0, 1, 3, 4, 2] : vector<32x4x2x1x16xf32> to vector<32x4x1x16x2xf32>
863
+ // CHECK-DAG: %[[c0_1:.*]] = arith.constant 0 : index
864
+ // CHECK-DAG: %[[empty:.*]] = tensor.empty() : tensor<32x4x1x16x2xf32>
865
+ // CHECK: %[[write:.*]] = vector.transfer_write %[[transpose]], %[[empty]][%[[c0_1]], %[[c0_1]], %[[c0_1]], %[[c0_1]], %[[c0_1]]]
866
+ // CHECK-SAME: {in_bounds = [true, true, true, true, true]} : vector<32x4x1x16x2xf32>, tensor<32x4x1x16x2xf32>
867
+ // CHECK: return %[[write]] : tensor<32x4x1x16x2xf32>
868
+
869
+ module attributes {transform.with_named_sequence } {
870
+ transform.named_sequence @__transform_main (%arg0: !transform.any_op {transform.readonly }) {
871
+ %0 = transform.structured.match ops {[" tensor.pack" ]} in %arg0 : (!transform.any_op ) -> !transform.any_op
872
+ transform.structured.vectorize %0 : !transform.any_op
873
+ transform.yield
874
+ }
875
+ }
0 commit comments