11// RUN: rocmlir-opt %s -split-input-file -verify-diagnostics
22
3+ // ---- migraphx.shaped type ----
4+
5+ // expected-error @+1 {{migraphx.shaped type has 1 elements in its shape but 2 strides defined}}
6+ func.func @invalid_more_strides_than_shapes (%arg: !migraphx.shaped <1 xf32 , 1 x1 >) {
7+ func.return
8+ }
9+
10+ // -----
11+
12+ // expected-error @+1 {{migraphx.shaped type has 2 elements in its shape but 1 strides defined}}
13+ func.func @invalid_more_shapes_than_strides (%arg: !migraphx.shaped <1 x1 xf32 , 1 >) {
14+ func.return
15+ }
16+
17+ // -----
18+
19+ // ---- migraphx.reshape ----
20+
321func.func @mlir_reshape_inconsistent_dims (%arg0: !migraphx.shaped <4096 x4096 xf16 , 0x1 >) {
422 // expected-error@+1 {{'migraphx.reshape' op dimValue: 64 inconsistent with result dimension 4096}}
523 %0 = migraphx.reshape %arg0 {dims = [64 , 128 ]} : <4096 x4096 xf16 , 0x1 > -> <4096 x4096 xf16 , 16536 x2 >
@@ -42,6 +60,10 @@ func.func @mlir_neg_one_with_zero(%arg0: !migraphx.shaped<2x4xf16, 0x1>) {
4260 return
4361}
4462
63+ // -----
64+
65+ // ---- migraphx.equal ----
66+
4567func.func @func_equal (%arg0: !migraphx.shaped <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 >) -> !migraphx.shaped <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 > attributes {rock.kernel , rock.arch = " " } {
4668 %cst = migraphx.literal (dense <1 > : tensor <1 x36 x384 x64 xi32 >) : <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 >
4769 %0 = migraphx.add %arg0 , %cst : <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 >, <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 > -> <1 x36 x384 x64 xi32 , 884736 x24576 x64 x1 >
@@ -50,6 +72,104 @@ func.func @func_equal(%arg0: !migraphx.shaped<1x36x384x64xi32, 884736x24576x64x1
5072 return %1 : !migraphx.shaped <1 x36 x384 x64 xi16 , 884736 x24576 x64 x1 >
5173}
5274
75+ // -----
76+
77+ // ---- migraphx.clip ----
78+
79+ func.func @clip_mismatched_element_types (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >, %arg1: !migraphx.shaped <4 x8 xf16 , 8 x1 >, %arg2: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x8 xf32 , 8 x1 > {
80+ // expected-error @+1 {{op failed to verify that all of {x, minVals, maxVals, output} have same element type}}
81+ %0 = migraphx.clip %arg0 , %arg1 , %arg2 : <4 x8 xf32 , 8 x1 >, <4 x8 xf16 , 8 x1 >, <4 x8 xf32 , 8 x1 > -> <4 x8 xf32 , 8 x1 >
82+ return %0 : !migraphx.shaped <4 x8 xf32 , 8 x1 >
83+ }
84+
85+ // -----
86+
87+ func.func @clip_mismatched_shapes (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >, %arg1: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg2: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x8 xf32 , 8 x1 > {
88+ // expected-error @+1 {{op failed to verify that all of {x, minVals, maxVals, output} have same shape}}
89+ %0 = migraphx.clip %arg0 , %arg1 , %arg2 : <4 x8 xf32 , 8 x1 >, <4 x4 xf32 , 4 x1 >, <4 x8 xf32 , 8 x1 > -> <4 x8 xf32 , 8 x1 >
90+ return %0 : !migraphx.shaped <4 x8 xf32 , 8 x1 >
91+ }
92+
93+ // -----
94+
95+ // ---- migraphx.where ----
96+
97+ func.func @where_cond_not_bool (%arg0: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg1: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg2: !migraphx.shaped <4 x4 xf32 , 4 x1 >) -> !migraphx.shaped <4 x4 xf32 , 4 x1 > {
98+ // expected-error @+1 {{'migraphx.where' op operand #0 must be !migraphx.shaped of 8-bit signless integer or 8-bit signed integer or 8-bit unsigned integer values, but got '!migraphx.shaped<4x4xf32, 4x1>'}}
99+ %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xf32 , 4 x1 >, <4 x4 xf32 , 4 x1 >, <4 x4 xf32 , 4 x1 > -> <4 x4 xf32 , 4 x1 >
100+ return %0 : !migraphx.shaped <4 x4 xf32 , 4 x1 >
101+ }
102+
103+ // -----
104+
105+ func.func @where_mismatched_types (%arg0: !migraphx.shaped <4 x4 xi8 , 4 x1 >, %arg1: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg2: !migraphx.shaped <4 x4 xf16 , 4 x1 >) -> !migraphx.shaped <4 x4 xf32 , 4 x1 > {
106+ // expected-error @+1 {{op failed to verify that all of {inA, inB, output} have same element type}}
107+ %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xi8 , 4 x1 >, <4 x4 xf32 , 4 x1 >, <4 x4 xf16 , 4 x1 > -> <4 x4 xf32 , 4 x1 >
108+ return %0 : !migraphx.shaped <4 x4 xf32 , 4 x1 >
109+ }
110+
111+ // -----
112+
113+ func.func @where_mismatched_shapes (%arg0: !migraphx.shaped <4 x4 xi8 , 4 x1 >, %arg1: !migraphx.shaped <4 x8 xf32 , 8 x1 >, %arg2: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x8 xf32 , 8 x1 > {
114+ // expected-error @+1 {{op failed to verify that all of {inA, inB, output, cond} have same shape}}
115+ %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xi8 , 4 x1 >, <4 x8 xf32 , 8 x1 >, <4 x8 xf32 , 8 x1 > -> <4 x8 xf32 , 8 x1 >
116+ return %0 : !migraphx.shaped <4 x8 xf32 , 8 x1 >
117+ }
118+
119+ // -----
120+
121+ // ---- migraphx.convert ----
122+
123+ func.func @convert_shape_mismatch (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x4 xf16 , 4 x1 > {
124+ // expected-error @+1 {{op failed to verify that all of {inA, output} have same shape}}
125+ %0 = migraphx.convert %arg0 : <4 x8 xf32 , 8 x1 > to <4 x4 xf16 , 4 x1 >
126+ return %0 : !migraphx.shaped <4 x4 xf16 , 4 x1 >
127+ }
128+
129+ // -----
130+
131+ // ---- migraphx.abs ----
132+
133+ func.func @abs_shape_mismatch (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x4 xf32 , 4 x1 > {
134+ // expected-error @+1 {{op failed to verify that all of {inA, output} have same shape}}
135+ %0 = migraphx.abs %arg0 : <4 x8 xf32 , 8 x1 > -> <4 x4 xf32 , 4 x1 >
136+ return %0 : !migraphx.shaped <4 x4 xf32 , 4 x1 >
137+ }
138+
139+ // -----
140+
141+ // ---- migraphx.exp ----
142+
143+ func.func @exp_rank_mismatch (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <32 xf32 , 1 > {
144+ // expected-error @+1 {{op failed to verify that all of {inA, output} have same shape}}
145+ %0 = migraphx.exp %arg0 : <4 x8 xf32 , 8 x1 > -> <32 xf32 , 1 >
146+ return %0 : !migraphx.shaped <32 xf32 , 1 >
147+ }
148+
149+ // -----
150+
151+ // ---- migraphx.relu ----
152+
153+ func.func @relu_shape_mismatch (%arg0: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <2 x8 xf32 , 8 x1 > {
154+ // expected-error @+1 {{op failed to verify that all of {inA, output} have same shape}}
155+ %0 = migraphx.relu %arg0 : <4 x8 xf32 , 8 x1 > -> <2 x8 xf32 , 8 x1 >
156+ return %0 : !migraphx.shaped <2 x8 xf32 , 8 x1 >
157+ }
158+
159+ // -----
160+
161+ // ---- migraphx.sigmoid ----
162+
163+ func.func @func_sigmoid_2d_i32 (%arg0: !migraphx.shaped <4 x8 xi32 , 8 x1 >) -> !migraphx.shaped <4 x8 xi32 , 8 x1 > {
164+ // expected-error @+1 {{only support floating point}}
165+ %0 = migraphx.sigmoid %arg0 : <4 x8 xi32 , 8 x1 > -> <4 x8 xi32 , 8 x1 >
166+ return %0 : !migraphx.shaped <4 x8 xi32 , 8 x1 >
167+ }
168+
169+ // -----
170+
171+ // ---- migraphx.quant_dot ----
172+
53173// Test: Only scaleA provided (should fail - both scales required)
54174func.func @quant_dot_only_scale_a (
55175 %arg0: !migraphx.shaped <1 x16 x512 xf4 E2 M1 FN, 8192 x512 x1 >,
@@ -228,6 +348,8 @@ func.func @migraphx_quant_dot_f4_n_scales(%arg0: !migraphx.shaped<1x16x512xf4E2M
228348
229349// -----
230350
351+ // ---- migraphx.dot ----
352+
231353// CHECK-LABEL: func.func @dot_rank_less_than_2
232354func.func @dot_rank_less_than_2 (%arg0: !migraphx.shaped <320 xf16 , 1 >, %arg1: !migraphx.shaped <320 x64 xf16 , 64 x1 >) -> !migraphx.shaped <64 xf16 , 1 > {
233355 // expected-error @+1 {{expect operand to have rank greater or equal to 2}}
@@ -273,51 +395,7 @@ func.func @dot_result_shape_mismatch(%arg0: !migraphx.shaped<2x3x4xf16, 12x4x1>,
273395
274396// -----
275397
276- // expected-error @+1 {{migraphx.shaped type has 1 elements in its shape but 2 strides defined}}
277- func.func @invalid_more_strides_than_shapes (%arg: !migraphx.shaped <1 xf32 , 1 x1 >) {
278- func.return
279- }
280-
281- // -----
282-
283- // expected-error @+1 {{migraphx.shaped type has 2 elements in its shape but 1 strides defined}}
284- func.func @invalid_more_shapes_than_strides (%arg: !migraphx.shaped <1 x1 xf32 , 1 >) {
285- func.return
286- }
287-
288- // -----
289-
290- func.func @func_sigmoid_2d_i32 (%arg0: !migraphx.shaped <4 x8 xi32 , 8 x1 >) -> !migraphx.shaped <4 x8 xi32 , 8 x1 > {
291- // expected-error @+1 {{only support floating point}}
292- %0 = migraphx.sigmoid %arg0 : <4 x8 xi32 , 8 x1 > -> <4 x8 xi32 , 8 x1 >
293- return %0 : !migraphx.shaped <4 x8 xi32 , 8 x1 >
294- }
295-
296- // -----
297-
298- func.func @where_cond_not_bool (%arg0: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg1: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg2: !migraphx.shaped <4 x4 xf32 , 4 x1 >) -> !migraphx.shaped <4 x4 xf32 , 4 x1 > {
299- // expected-error @+1 {{'migraphx.where' op operand #0 must be !migraphx.shaped of 8-bit signless integer or 8-bit signed integer or 8-bit unsigned integer values, but got '!migraphx.shaped<4x4xf32, 4x1>'}}
300- %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xf32 , 4 x1 >, <4 x4 xf32 , 4 x1 >, <4 x4 xf32 , 4 x1 > -> <4 x4 xf32 , 4 x1 >
301- return %0 : !migraphx.shaped <4 x4 xf32 , 4 x1 >
302- }
303-
304- // -----
305-
306- func.func @where_mismatched_types (%arg0: !migraphx.shaped <4 x4 xi8 , 4 x1 >, %arg1: !migraphx.shaped <4 x4 xf32 , 4 x1 >, %arg2: !migraphx.shaped <4 x4 xf16 , 4 x1 >) -> !migraphx.shaped <4 x4 xf32 , 4 x1 > {
307- // expected-error @+1 {{op failed to verify that all of {inA, inB, output} have same element type}}
308- %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xi8 , 4 x1 >, <4 x4 xf32 , 4 x1 >, <4 x4 xf16 , 4 x1 > -> <4 x4 xf32 , 4 x1 >
309- return %0 : !migraphx.shaped <4 x4 xf32 , 4 x1 >
310- }
311-
312- // -----
313-
314- func.func @where_mismatched_shapes (%arg0: !migraphx.shaped <4 x4 xi8 , 4 x1 >, %arg1: !migraphx.shaped <4 x8 xf32 , 8 x1 >, %arg2: !migraphx.shaped <4 x8 xf32 , 8 x1 >) -> !migraphx.shaped <4 x8 xf32 , 8 x1 > {
315- // expected-error @+1 {{op failed to verify that all of {inA, inB, output, cond} have same shape}}
316- %0 = migraphx.where %arg0 , %arg1 , %arg2 : <4 x4 xi8 , 4 x1 >, <4 x8 xf32 , 8 x1 >, <4 x8 xf32 , 8 x1 > -> <4 x8 xf32 , 8 x1 >
317- return %0 : !migraphx.shaped <4 x8 xf32 , 8 x1 >
318- }
319-
320- // -----
398+ // ---- migraphx.slice ----
321399
322400func.func @invalid_attr_size_mismatch (%input: !migraphx.shaped <10 x10 xf32 , 10 x1 >) {
323401 // expected-error @+1 {{op axes, starts, and ends must have the same size}}
0 commit comments