|
1 | 1 | // RUN: imex-opt --split-input-file --convert-ndarray-to-linalg %s -verify-diagnostics -o -| FileCheck %s |
2 | 2 |
|
3 | | -// ----- |
4 | | -func.func @test_subview(%arg0: tensor<?xi64>) -> tensor<?xi64> { |
5 | | - %c0 = arith.constant 0 : index |
6 | | - %c3 = arith.constant 3 : index |
7 | | - %0 = ndarray.subview %arg0[%c0][%c3][%c3] : tensor<?xi64> to tensor<?xi64> |
8 | | - return %0 : tensor<?xi64> |
9 | | -} |
10 | | -// CHECK-LABEL: @test_subview |
11 | | -// CHECK-SAME: ([[V:%.*]]: tensor<?xi64>) -> tensor<?xi64> { |
12 | | -// CHECK-NEXT: [[C0:%.*]] = arith.constant |
13 | | -// CHECK-NEXT: [[C1:%.*]] = arith.constant |
14 | | -// CHECK-NEXT: [[V0:%.*]] = bufferization.to_memref [[V]] : tensor<?xi64> to memref<?xi64, strided<[?], offset: ?>> |
15 | | -// CHECK-NEXT: [[S0:%.*]] = memref.subview [[V0]][[[C0]]] [[[C1]]] [[[C1]]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64, strided<[?], offset: ?>> |
16 | | -// CHECK-NEXT: [[V1:%.*]] = bufferization.to_tensor [[S0]] restrict writable : memref<?xi64, strided<[?], offset: ?>> |
17 | | -// CHECK-NEXT: return [[V1]] : tensor<?xi64> |
18 | | - |
19 | 3 | // ----- |
20 | 4 | func.func @test_linspace(%arg0: i64, %arg1: i64, %arg2: index) -> tensor<?xindex> { |
21 | 5 | %0 = ndarray.linspace %arg0 %arg1 %arg2 false : (i64, i64, index) -> tensor<?xindex> |
@@ -72,42 +56,6 @@ func.func @test_reshape2(%arg0: index) -> tensor<?x?xi64> { |
72 | 56 | // CHECK: tensor.reshape |
73 | 57 | // CHECK-SAME: -> tensor<?x?xi64> |
74 | 58 |
|
75 | | -// ----- |
76 | | -func.func @test_insert_slice(%arg0: tensor<?xi64>, %arg1: tensor<?xi64>) { |
77 | | - %i0 = arith.constant 0 : index |
78 | | - %i1 = arith.constant 1 : index |
79 | | - %i3 = arith.constant 3 : index |
80 | | - ndarray.insert_slice %arg1 into %arg0[%i0] [%i3] [%i1] : tensor<?xi64> into tensor<?xi64> |
81 | | - return |
82 | | -} |
83 | | -// CHECK-LABEL: @test_insert_slice |
84 | | -// CHECK-SAME: ([[V:%.*]]: tensor<?xi64>, [[VV:%.*]]: tensor<?xi64>) { |
85 | | -// CHECK-NEXT: [[C0:%.*]] = arith.constant |
86 | | -// CHECK-NEXT: [[C1:%.*]] = arith.constant |
87 | | -// CHECK-NEXT: [[C3:%.*]] = arith.constant |
88 | | -// CHECK-NEXT: [[V0:%.*]] = bufferization.to_memref [[VV]] |
89 | | -// CHECK-NEXT: [[V1:%.*]] = bufferization.to_memref [[V]] |
90 | | -// CHECK-NEXT: [[SV:%.*]] = memref.subview [[V1]][[[C0]]] [[[C3]]] [[[C1]]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64, strided<[?], offset: ?>> |
91 | | -// CHECK: memref.copy [[V0]], [[SV]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64, strided<[?], offset: ?>> |
92 | | - |
93 | | -// ----- |
94 | | -func.func @test_insert_slice_scalar(%arg0: tensor<?xi64>, %arg1: tensor<i64>) { |
95 | | - %i0 = arith.constant 0 : index |
96 | | - %i1 = arith.constant 1 : index |
97 | | - %i3 = arith.constant 3 : index |
98 | | - ndarray.insert_slice %arg1 into %arg0[%i0] [%i3] [%i1] : tensor<i64> into tensor<?xi64> |
99 | | - return |
100 | | -} |
101 | | -// CHECK-LABEL: @test_insert_slice_scalar |
102 | | -// CHECK-SAME: ([[V:%.*]]: tensor<?xi64>, [[VV:%.*]]: tensor<i64>) { |
103 | | -// CHECK-NEXT: [[C0:%.*]] = arith.constant |
104 | | -// CHECK-NEXT: [[C1:%.*]] = arith.constant |
105 | | -// CHECK-NEXT: [[C3:%.*]] = arith.constant |
106 | | -// CHECK-NEXT: [[V0:%.*]] = bufferization.to_memref [[VV]] |
107 | | -// CHECK-NEXT: [[V1:%.*]] = bufferization.to_memref [[V]] |
108 | | -// CHECK-NEXT: [[SV:%.*]] = memref.subview [[V1]][[[C0]]] [[[C3]]] [[[C1]]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64, strided<[?], offset: ?>> |
109 | | -// CHECK-NEXT: linalg.generic {indexing_maps = [#map, #map1], iterator_types = ["parallel"]} ins([[V0]] : memref<i64, strided<[], offset: ?>>) outs([[SV]] : memref<?xi64, strided<[?], offset: ?>>) |
110 | | - |
111 | 59 | // ----- |
112 | 60 | #GPUENV = #ndarray.envs<#region.gpu_env<device = "g">> |
113 | 61 | func.func @test_env() -> (tensor<16x16xf32, #GPUENV>, tensor<256xf32, #GPUENV>) attributes {llvm.emit_c_interface} { |
@@ -170,41 +118,36 @@ func.func @test_env() -> (tensor<16x16xf32, #GPUENV>, tensor<256xf32, #GPUENV>) |
170 | 118 | // COM: CHECK-SAME: memref<?xi64, strided<[?], offset: ?>> |
171 | 119 |
|
172 | 120 | // ----- |
173 | | -func.func @test_copy(%a: !ndarray.ndarray<?xi64>) -> !ndarray.ndarray<?xi64> { |
174 | | - %0 = ndarray.copy %a: !ndarray.ndarray<?xi64> -> !ndarray.ndarray<?xi64> |
175 | | - %1 = ndarray.copy %0: !ndarray.ndarray<?xi64> -> !ndarray.ndarray<?xi64, #region.gpu_env<device = "XeGPU">> |
176 | | - %2 = ndarray.copy %1: !ndarray.ndarray<?xi64, #region.gpu_env<device = "XeGPU">> -> !ndarray.ndarray<?xi64> |
177 | | - return %0 : !ndarray.ndarray<?xi64> |
| 121 | +func.func @test_copy(%a: tensor<?xi64>) -> tensor<?xi64> { |
| 122 | + %0 = ndarray.copy %a: tensor<?xi64> -> tensor<?xi64> |
| 123 | + %1 = ndarray.copy %0: tensor<?xi64> -> tensor<?xi64, #region.gpu_env<device = "XeGPU">> |
| 124 | + %2 = ndarray.copy %1: tensor<?xi64, #region.gpu_env<device = "XeGPU">> -> tensor<?xi64> |
| 125 | + return %0 : tensor<?xi64> |
178 | 126 | } |
179 | | -// CHECK-LABEL: func.func @test_copy |
180 | | -// CHECK-NEXT: bufferization.to_tensor |
181 | | -// CHECK-NEXT: arith.constant 0 : index |
182 | | -// CHECK-NEXT: tensor.dim |
183 | | -// CHECK-NEXT: memref.alloc |
184 | | -// CHECK-NEXT: bufferization.to_memref |
185 | | -// CHECK-NEXT: region.env_region "protect_copy_op" |
186 | | -// CHECK-NEXT: memref.copy |
187 | | -// CHECK-NEXT: } |
188 | | -// CHECK-NEXT: bufferization.to_tensor |
189 | | -// CHECK-NEXT: bufferization.to_memref |
190 | | -// CHECK-NEXT: arith.constant 0 : index |
191 | | -// CHECK-NEXT: tensor.dim |
192 | | -// CHECK-NEXT: memref.alloc |
193 | | -// CHECK-NEXT: bufferization.to_memref |
194 | | -// CHECK-NEXT: region.env_region "gpu_copy_op" |
195 | | -// CHECK-NEXT: memref.copy |
196 | | -// CHECK-NEXT: } |
197 | | -// CHECK-NEXT: bufferization.to_tensor |
198 | | -// CHECK-NEXT: arith.constant 0 : index |
199 | | -// CHECK-NEXT: tensor.dim |
200 | | -// CHECK-NEXT: memref.alloc |
201 | | -// CHECK-NEXT: bufferization.to_memref |
202 | | -// CHECK-NEXT: region.env_region "gpu_copy_op" |
203 | | -// CHECK-NEXT: memref.copy |
204 | | -// CHECK-NEXT: } |
205 | | -// CHECK-NEXT: bufferization.to_tensor |
206 | | -// CHECK-NEXT: return |
207 | | -// CHECK-SAME: memref<?xi64, strided<[?], offset: ?>> |
| 127 | +// CHECK-LABEL: func.func @test_copy( |
| 128 | +// CHECK-SAME: [[varg0:%.*]]: tensor<?xi64>) -> tensor<?xi64> { |
| 129 | +// CHECK-NEXT: [[vc0:%.*]] = arith.constant 0 : index |
| 130 | +// CHECK-NEXT: [[vdim:%.*]] = tensor.dim [[varg0]], [[vc0]] : tensor<?xi64> |
| 131 | +// CHECK-NEXT: [[valloc:%.*]] = memref.alloc([[vdim]]) {alignment = 8 : i64} : memref<?xi64> |
| 132 | +// CHECK-NEXT: [[v0:%.*]] = bufferization.to_memref [[varg0]] : tensor<?xi64> to memref<?xi64, strided<[?], offset: ?>> |
| 133 | +// CHECK-NEXT: region.env_region "protect_copy_op" { |
| 134 | +// CHECK-NEXT: memref.copy [[v0]], [[valloc]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64> |
| 135 | +// CHECK: [[v1:%.*]] = bufferization.to_tensor [[valloc]] restrict writable : memref<?xi64> to tensor<?xi64> |
| 136 | +// CHECK-NEXT: [[vc0_0:%.*]] = arith.constant 0 : index |
| 137 | +// CHECK-NEXT: [[vdim_1:%.*]] = tensor.dim [[v1]], [[vc0_0]] : tensor<?xi64> |
| 138 | +// CHECK-NEXT: [[valloc_2:%.*]] = memref.alloc([[vdim_1]]) {alignment = 8 : i64} : memref<?xi64> |
| 139 | +// CHECK-NEXT: [[v2:%.*]] = bufferization.to_memref [[v1]] : tensor<?xi64> to memref<?xi64, strided<[?], offset: ?>> |
| 140 | +// CHECK-NEXT: region.env_region "protect_copy_op" { |
| 141 | +// CHECK-NEXT: memref.copy [[v2]], [[valloc_2]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64> |
| 142 | +// CHECK: [[v3:%.*]] = bufferization.to_tensor [[valloc_2]] restrict writable : memref<?xi64> to tensor<?xi64, #region.gpu_env<device = "XeGPU">> |
| 143 | +// CHECK-NEXT: [[vc0_3:%.*]] = arith.constant 0 : index |
| 144 | +// CHECK-NEXT: [[vdim_4:%.*]] = tensor.dim [[v3]], [[vc0_3]] : tensor<?xi64, #region.gpu_env<device = "XeGPU">> |
| 145 | +// CHECK-NEXT: [[valloc_5:%.*]] = memref.alloc([[vdim_4]]) {alignment = 8 : i64} : memref<?xi64> |
| 146 | +// CHECK-NEXT: [[v4:%.*]] = bufferization.to_memref [[v3]] : tensor<?xi64, #region.gpu_env<device = "XeGPU">> to memref<?xi64, strided<[?], offset: ?>> |
| 147 | +// CHECK-NEXT: region.env_region "protect_copy_op" { |
| 148 | +// CHECK-NEXT: memref.copy [[v4]], [[valloc_5]] : memref<?xi64, strided<[?], offset: ?>> to memref<?xi64> |
| 149 | +// CHECK: [[v5:%.*]] = bufferization.to_tensor [[valloc_5]] restrict writable : memref<?xi64> to tensor<?xi64> |
| 150 | +// CHECK-NEXT: return [[v1]] : tensor<?xi64> |
208 | 151 |
|
209 | 152 | // ----- |
210 | 153 | func.func @test_delete(%arg0: tensor<?xi64>) { |
|
0 commit comments