invalid-ops.mlir
34.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
func @dim(%arg : tensor<1x?xf32>) {
%c2 = constant 2 : index
dim %arg, %c2 : tensor<1x?xf32> // expected-error {{'std.dim' op index is out of range}}
return
}
// -----
func @rank(f32) {
^bb(%0: f32):
"std.rank"(%0): (f32)->index // expected-error {{'std.rank' op operand #0 must be any tensor or memref type}}
return
}
// -----
func @constant() {
^bb:
%x = "std.constant"(){value = "xyz"} : () -> i32 // expected-error {{unsupported 'value' attribute}}
return
}
// -----
func @constant_out_of_range() {
^bb:
%x = "std.constant"(){value = 100} : () -> i1 // expected-error {{requires attribute's type ('i64') to match op's return type ('i1')}}
return
}
// -----
func @constant_wrong_type() {
^bb:
%x = "std.constant"(){value = 10.} : () -> f32 // expected-error {{requires attribute's type ('f64') to match op's return type ('f32')}}
return
}
// -----
func @affine_apply_no_map() {
^bb0:
%i = constant 0 : index
%x = "affine.apply" (%i) { } : (index) -> (index) // expected-error {{requires attribute 'map'}}
return
}
// -----
func @affine_apply_wrong_operand_count() {
^bb0:
%i = constant 0 : index
%x = "affine.apply" (%i) {map = affine_map<(d0, d1) -> ((d0 + 1), (d1 + 2))>} : (index) -> (index) // expected-error {{'affine.apply' op operand count and affine map dimension and symbol count must match}}
return
}
// -----
func @affine_apply_wrong_result_count() {
^bb0:
%i = constant 0 : index
%j = constant 1 : index
%x = "affine.apply" (%i, %j) {map = affine_map<(d0, d1) -> ((d0 + 1), (d1 + 2))>} : (index,index) -> (index) // expected-error {{'affine.apply' op mapping must produce one value}}
return
}
// -----
func @unknown_custom_op() {
^bb0:
%i = crazyThing() {value = 0} : () -> index // expected-error {{custom op 'crazyThing' is unknown}}
return
}
// -----
func @unknown_std_op() {
// expected-error@+1 {{unregistered operation 'std.foo_bar_op' found in dialect ('std') that does not allow unknown operations}}
%0 = "std.foo_bar_op"() : () -> index
return
}
// -----
func @bad_alloc_wrong_dynamic_dim_count() {
^bb0:
%0 = constant 7 : index
// Test alloc with wrong number of dynamic dimensions.
%1 = alloc(%0)[%1] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> // expected-error {{op 'std.alloc' dimension operand count does not equal memref dynamic dimension count}}
return
}
// -----
func @bad_alloc_wrong_symbol_count() {
^bb0:
%0 = constant 7 : index
// Test alloc with wrong number of symbols
%1 = alloc(%0) : memref<2x?xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> // expected-error {{operand count does not equal dimension plus symbol operand count}}
return
}
// -----
func @test_store_zero_results() {
^bb0:
%0 = alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1>
%1 = constant 0 : index
%2 = constant 1 : index
%3 = load %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1>
// Test that store returns zero results.
%4 = store %3, %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> // expected-error {{cannot name an operation with no results}}
return
}
// -----
func @test_store_zero_results2(%x: i32, %p: memref<i32>) {
"std.store"(%x,%p) : (i32, memref<i32>) -> i32 // expected-error {{'std.store' op requires zero results}}
return
}
// -----
func @test_alloc_memref_map_rank_mismatch() {
^bb0:
%0 = alloc() : memref<1024x64xf32, affine_map<(d0) -> (d0)>, 1> // expected-error {{memref affine map dimension mismatch}}
return
}
// -----
func @intlimit2() {
^bb:
%0 = "std.constant"() {value = 0} : () -> i4096
%1 = "std.constant"() {value = 1} : () -> i4097 // expected-error {{integer bitwidth is limited to 4096 bits}}
return
}
// -----
func @calls(%arg0: i32) {
%x = call @calls() : () -> i32 // expected-error {{incorrect number of operands for callee}}
return
}
// -----
func @func_with_ops(f32) {
^bb0(%a : f32):
%sf = addf %a, %a, %a : f32 // expected-error {{'std.addf' op expected 2 operands}}
}
// -----
func @func_with_ops(f32) {
^bb0(%a : f32):
%sf = addf(%a, %a) : f32 // expected-error {{expected ':'}}
}
// -----
func @func_with_ops(f32) {
^bb0(%a : f32):
%sf = addf{%a, %a} : f32 // expected-error {{expected attribute name}}
}
// -----
func @func_with_ops(f32) {
^bb0(%a : f32):
// expected-error@+1 {{'std.addi' op operand #0 must be signless-integer-like}}
%sf = addi %a, %a : f32
}
// -----
func @func_with_ops(i32) {
^bb0(%a : i32):
%sf = addf %a, %a : i32 // expected-error {{'std.addf' op operand #0 must be floating-point-like}}
}
// -----
func @func_with_ops(i32) {
^bb0(%a : i32):
// expected-error@+1 {{failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}
%r = "std.cmpi"(%a, %a) {predicate = 42} : (i32, i32) -> i1
}
// -----
// Comparison are defined for arguments of the same type.
func @func_with_ops(i32, i64) {
^bb0(%a : i32, %b : i64): // expected-note {{prior use here}}
%r = cmpi "eq", %a, %b : i32 // expected-error {{use of value '%b' expects different type than prior uses}}
}
// -----
// Comparisons must have the "predicate" attribute.
func @func_with_ops(i32, i32) {
^bb0(%a : i32, %b : i32):
%r = cmpi %a, %b : i32 // expected-error {{expected non-function type}}
}
// -----
// Integer comparisons are not recognized for float types.
func @func_with_ops(f32, f32) {
^bb0(%a : f32, %b : f32):
%r = cmpi "eq", %a, %b : f32 // expected-error {{'lhs' must be signless-integer-like, but got 'f32'}}
}
// -----
// Result type must be boolean like.
func @func_with_ops(i32, i32) {
^bb0(%a : i32, %b : i32):
%r = "std.cmpi"(%a, %b) {predicate = 0} : (i32, i32) -> i32 // expected-error {{op result #0 must be bool-like}}
}
// -----
func @func_with_ops(i32, i32) {
^bb0(%a : i32, %b : i32):
// expected-error@+1 {{requires attribute 'predicate'}}
%r = "std.cmpi"(%a, %b) {foo = 1} : (i32, i32) -> i1
}
// -----
func @func_with_ops() {
^bb0:
%c = constant dense<0> : vector<42 x i32>
// expected-error@+1 {{op requires the same shape for all operands and results}}
%r = "std.cmpi"(%c, %c) {predicate = 0} : (vector<42 x i32>, vector<42 x i32>) -> vector<41 x i1>
}
// -----
func @func_with_ops(i32, i32, i32) {
^bb0(%cond : i32, %t : i32, %f : i32):
// expected-error@+2 {{different type than prior uses}}
// expected-note@-2 {{prior use here}}
%r = select %cond, %t, %f : i32
}
// -----
func @func_with_ops(i32, i32, i32) {
^bb0(%cond : i32, %t : i32, %f : i32):
// expected-error@+1 {{op operand #0 must be bool-like}}
%r = "std.select"(%cond, %t, %f) : (i32, i32, i32) -> i32
}
// -----
func @func_with_ops(i1, i32, i64) {
^bb0(%cond : i1, %t : i32, %f : i64):
// expected-error@+1 {{all of {true_value, false_value, result} have same type}}
%r = "std.select"(%cond, %t, %f) : (i1, i32, i64) -> i32
}
// -----
func @func_with_ops(vector<12xi1>, vector<42xi32>, vector<42xi32>) {
^bb0(%cond : vector<12xi1>, %t : vector<42xi32>, %f : vector<42xi32>):
// expected-error@+1 {{expected condition type to have the same shape as the result type, expected 'vector<42xi1>', but got 'vector<12xi1>'}}
%r = "std.select"(%cond, %t, %f) : (vector<12xi1>, vector<42xi32>, vector<42xi32>) -> vector<42xi32>
}
// -----
func @func_with_ops(tensor<12xi1>, tensor<42xi32>, tensor<42xi32>) {
^bb0(%cond : tensor<12xi1>, %t : tensor<42xi32>, %f : tensor<42xi32>):
// expected-error@+1 {{expected condition type to have the same shape as the result type, expected 'tensor<42xi1>', but got 'tensor<12xi1>'}}
%r = "std.select"(%cond, %t, %f) : (tensor<12xi1>, tensor<42xi32>, tensor<42xi32>) -> tensor<42xi32>
}
// -----
func @invalid_cmp_shape(%idx : () -> ()) {
// expected-error@+1 {{'lhs' must be signless-integer-like, but got '() -> ()'}}
%cmp = cmpi "eq", %idx, %idx : () -> ()
// -----
func @dma_start_not_enough_operands() {
// expected-error@+1 {{expected at least 4 operands}}
"std.dma_start"() : () -> ()
}
// -----
func @dma_no_src_memref(%m : f32, %tag : f32, %c0 : index) {
// expected-error@+1 {{expected source to be of memref type}}
dma_start %m[%c0], %m[%c0], %c0, %tag[%c0] : f32, f32, f32
}
// -----
func @dma_start_not_enough_operands_for_src(
%src: memref<2x2x2xf32>, %idx: index) {
// expected-error@+1 {{expected at least 7 operands}}
"std.dma_start"(%src, %idx, %idx, %idx) : (memref<2x2x2xf32>, index, index, index) -> ()
}
// -----
func @dma_start_src_index_wrong_type(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>, %flt: f32) {
// expected-error@+1 {{expected source indices to be of index type}}
"std.dma_start"(%src, %idx, %flt, %dst, %idx, %tag, %idx)
: (memref<2x2xf32>, index, f32, memref<2xf32,1>, index, memref<i32,2>, index) -> ()
}
// -----
func @dma_no_dst_memref(%m : f32, %tag : f32, %c0 : index) {
%mref = alloc() : memref<8 x f32>
// expected-error@+1 {{expected destination to be of memref type}}
dma_start %mref[%c0], %m[%c0], %c0, %tag[%c0] : memref<8 x f32>, f32, f32
}
// -----
func @dma_start_not_enough_operands_for_dst(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>) {
// expected-error@+1 {{expected at least 7 operands}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %idx)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, index) -> ()
}
// -----
func @dma_start_dst_index_wrong_type(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>, %flt: f32) {
// expected-error@+1 {{expected destination indices to be of index type}}
"std.dma_start"(%src, %idx, %idx, %dst, %flt, %tag, %idx)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, f32, memref<i32,2>, index) -> ()
}
// -----
func @dma_start_dst_index_wrong_type(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>, %flt: f32) {
// expected-error@+1 {{expected num elements to be of index type}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %flt, %tag)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, f32, memref<i32,2>) -> ()
}
// -----
func @dma_no_tag_memref(%tag : f32, %c0 : index) {
%mref = alloc() : memref<8 x f32>
// expected-error@+1 {{expected tag to be of memref type}}
dma_start %mref[%c0], %mref[%c0], %c0, %tag[%c0] : memref<8 x f32>, memref<8 x f32>, f32
}
// -----
func @dma_start_not_enough_operands_for_tag(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<2xi32,2>) {
// expected-error@+1 {{expected at least 8 operands}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %idx, %tag)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, index, memref<2xi32,2>) -> ()
}
// -----
func @dma_start_dst_index_wrong_type(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<2xi32,2>, %flt: f32) {
// expected-error@+1 {{expected tag indices to be of index type}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %idx, %tag, %flt)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, index, memref<2xi32,2>, f32) -> ()
}
// -----
func @dma_start_same_space(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32>,
%tag: memref<i32,2>) {
// expected-error@+1 {{DMA should be between different memory spaces}}
dma_start %src[%idx, %idx], %dst[%idx], %idx, %tag[] : memref<2x2xf32>, memref<2xf32>, memref<i32,2>
}
// -----
func @dma_start_too_many_operands(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>) {
// expected-error@+1 {{incorrect number of operands}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %idx, %tag, %idx, %idx, %idx)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, index, memref<i32,2>, index, index, index) -> ()
}
// -----
func @dma_start_wrong_stride_type(
%src: memref<2x2xf32>, %idx: index, %dst: memref<2xf32,1>,
%tag: memref<i32,2>, %flt: f32) {
// expected-error@+1 {{expected stride and num elements per stride to be of type index}}
"std.dma_start"(%src, %idx, %idx, %dst, %idx, %idx, %tag, %idx, %flt)
: (memref<2x2xf32>, index, index, memref<2xf32,1>, index, index, memref<i32,2>, index, f32) -> ()
}
// -----
func @dma_wait_not_enough_operands() {
// expected-error@+1 {{expected at least 2 operands}}
"std.dma_wait"() : () -> ()
}
// -----
func @dma_wait_no_tag_memref(%tag : f32, %c0 : index) {
// expected-error@+1 {{expected tag to be of memref type}}
"std.dma_wait"(%tag, %c0, %c0) : (f32, index, index) -> ()
}
// -----
func @dma_wait_wrong_index_type(%tag : memref<2xi32>, %idx: index, %flt: f32) {
// expected-error@+1 {{expected tag indices to be of index type}}
"std.dma_wait"(%tag, %flt, %idx) : (memref<2xi32>, f32, index) -> ()
}
// -----
func @dma_wait_wrong_num_elements_type(%tag : memref<2xi32>, %idx: index, %flt: f32) {
// expected-error@+1 {{expected the number of elements to be of index type}}
"std.dma_wait"(%tag, %idx, %flt) : (memref<2xi32>, index, f32) -> ()
}
// -----
func @invalid_cmp_attr(%idx : i32) {
// expected-error@+1 {{invalid kind of attribute specified}}
%cmp = cmpi i1, %idx, %idx : i32
// -----
func @cmpf_generic_invalid_predicate_value(%a : f32) {
// expected-error@+1 {{attribute 'predicate' failed to satisfy constraint: allowed 64-bit signless integer cases}}
%r = "std.cmpf"(%a, %a) {predicate = 42} : (f32, f32) -> i1
}
// -----
func @cmpf_canonical_invalid_predicate_value(%a : f32) {
// expected-error@+1 {{invalid predicate attribute specification: "foo"}}
%r = cmpf "foo", %a, %a : f32
}
// -----
func @cmpf_canonical_invalid_predicate_value_signed(%a : f32) {
// expected-error@+1 {{invalid predicate attribute specification: "sge"}}
%r = cmpf "sge", %a, %a : f32
}
// -----
func @cmpf_canonical_invalid_predicate_value_no_order(%a : f32) {
// expected-error@+1 {{invalid predicate attribute specification: "eq"}}
%r = cmpf "eq", %a, %a : f32
}
// -----
func @cmpf_canonical_no_predicate_attr(%a : f32, %b : f32) {
%r = cmpf %a, %b : f32 // expected-error {{}}
}
// -----
func @cmpf_generic_no_predicate_attr(%a : f32, %b : f32) {
// expected-error@+1 {{requires attribute 'predicate'}}
%r = "std.cmpf"(%a, %b) {foo = 1} : (f32, f32) -> i1
}
// -----
func @cmpf_wrong_type(%a : i32, %b : i32) {
%r = cmpf "oeq", %a, %b : i32 // expected-error {{must be floating-point-like}}
}
// -----
func @cmpf_generic_wrong_result_type(%a : f32, %b : f32) {
// expected-error@+1 {{result #0 must be bool-like}}
%r = "std.cmpf"(%a, %b) {predicate = 0} : (f32, f32) -> f32
}
// -----
func @cmpf_canonical_wrong_result_type(%a : f32, %b : f32) -> f32 {
%r = cmpf "oeq", %a, %b : f32 // expected-note {{prior use here}}
// expected-error@+1 {{use of value '%r' expects different type than prior uses}}
return %r : f32
}
// -----
func @cmpf_result_shape_mismatch(%a : vector<42xf32>) {
// expected-error@+1 {{op requires the same shape for all operands and results}}
%r = "std.cmpf"(%a, %a) {predicate = 0} : (vector<42 x f32>, vector<42 x f32>) -> vector<41 x i1>
}
// -----
func @cmpf_operand_shape_mismatch(%a : vector<42xf32>, %b : vector<41xf32>) {
// expected-error@+1 {{op requires all operands to have the same type}}
%r = "std.cmpf"(%a, %b) {predicate = 0} : (vector<42 x f32>, vector<41 x f32>) -> vector<42 x i1>
}
// -----
func @cmpf_generic_operand_type_mismatch(%a : f32, %b : f64) {
// expected-error@+1 {{op requires all operands to have the same type}}
%r = "std.cmpf"(%a, %b) {predicate = 0} : (f32, f64) -> i1
}
// -----
func @cmpf_canonical_type_mismatch(%a : f32, %b : f64) { // expected-note {{prior use here}}
// expected-error@+1 {{use of value '%b' expects different type than prior uses}}
%r = cmpf "oeq", %a, %b : f32
}
// -----
func @extract_element_no_operands() {
// expected-error@+1 {{op expected 1 or more operands}}
%0 = "std.extract_element"() : () -> f32
return
}
// -----
func @extract_element_no_indices(%v : vector<3xf32>) {
// expected-error@+1 {{incorrect number of indices for extract_element}}
%0 = "std.extract_element"(%v) : (vector<3xf32>) -> f32
return
}
// -----
func @extract_element_invalid_index_type(%v : vector<3xf32>, %i : i32) {
// expected-error@+1 {{operand #1 must be index}}
%0 = "std.extract_element"(%v, %i) : (vector<3xf32>, i32) -> f32
return
}
// -----
func @extract_element_element_result_type_mismatch(%v : vector<3xf32>, %i : index) {
// expected-error@+1 {{result type matches element type of aggregate}}
%0 = "std.extract_element"(%v, %i) : (vector<3xf32>, index) -> f64
return
}
// -----
func @extract_element_vector_too_many_indices(%v : vector<3xf32>, %i : index) {
// expected-error@+1 {{incorrect number of indices for extract_element}}
%0 = "std.extract_element"(%v, %i, %i) : (vector<3xf32>, index, index) -> f32
return
}
// -----
func @extract_element_tensor_too_many_indices(%t : tensor<2x3xf32>, %i : index) {
// expected-error@+1 {{incorrect number of indices for extract_element}}
%0 = "std.extract_element"(%t, %i, %i, %i) : (tensor<2x3xf32>, index, index, index) -> f32
return
}
// -----
func @extract_element_tensor_too_few_indices(%t : tensor<2x3xf32>, %i : index) {
// expected-error@+1 {{incorrect number of indices for extract_element}}
%0 = "std.extract_element"(%t, %i) : (tensor<2x3xf32>, index) -> f32 return
}
// -----
func @tensor_from_elements_wrong_result_type() {
// expected-error@+2 {{'result' must be 1D tensor of any type values, but got 'tensor<*xi32>'}}
%c0 = constant 0 : i32
%0 = tensor_from_elements %c0 : tensor<*xi32>
return
}
// -----
func @tensor_from_elements_wrong_elements_count() {
// expected-error@+2 {{1 operands present, but expected 2}}
%c0 = constant 0 : index
%0 = tensor_from_elements %c0 : tensor<2xindex>
return
}
// -----
func @index_cast_index_to_index(%arg0: index) {
// expected-error@+1 {{are cast incompatible}}
%0 = index_cast %arg0: index to index
return
}
// -----
func @index_cast_float(%arg0: index, %arg1: f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = index_cast %arg0 : index to f32
return
}
// -----
func @index_cast_float_to_index(%arg0: f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = index_cast %arg0 : f32 to index
return
}
// -----
func @sitofp_i32_to_i64(%arg0 : i32) {
// expected-error@+1 {{are cast incompatible}}
%0 = sitofp %arg0 : i32 to i64
return
}
// -----
func @sitofp_f32_to_i32(%arg0 : f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = sitofp %arg0 : f32 to i32
return
}
// -----
func @fpext_f32_to_f16(%arg0 : f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : f32 to f16
return
}
// -----
func @fpext_f16_to_f16(%arg0 : f16) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : f16 to f16
return
}
// -----
func @fpext_i32_to_f32(%arg0 : i32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : i32 to f32
return
}
// -----
func @fpext_f32_to_i32(%arg0 : f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : f32 to i32
return
}
// -----
func @fpext_vec(%arg0 : vector<2xf16>) {
// expected-error@+1 {{requires the same shape for all operands and results}}
%0 = fpext %arg0 : vector<2xf16> to vector<3xf32>
return
}
// -----
func @fpext_vec_f32_to_f16(%arg0 : vector<2xf32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : vector<2xf32> to vector<2xf16>
return
}
// -----
func @fpext_vec_f16_to_f16(%arg0 : vector<2xf16>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : vector<2xf16> to vector<2xf16>
return
}
// -----
func @fpext_vec_i32_to_f32(%arg0 : vector<2xi32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : vector<2xi32> to vector<2xf32>
return
}
// -----
func @fpext_vec_f32_to_i32(%arg0 : vector<2xf32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fpext %arg0 : vector<2xf32> to vector<2xi32>
return
}
// -----
func @fptrunc_f16_to_f32(%arg0 : f16) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : f16 to f32
return
}
// -----
func @fptrunc_f32_to_f32(%arg0 : f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : f32 to f32
return
}
// -----
func @fptrunc_i32_to_f32(%arg0 : i32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : i32 to f32
return
}
// -----
func @fptrunc_f32_to_i32(%arg0 : f32) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : f32 to i32
return
}
// -----
func @fptrunc_vec(%arg0 : vector<2xf16>) {
// expected-error@+1 {{requires the same shape for all operands and results}}
%0 = fptrunc %arg0 : vector<2xf16> to vector<3xf32>
return
}
// -----
func @fptrunc_vec_f16_to_f32(%arg0 : vector<2xf16>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : vector<2xf16> to vector<2xf32>
return
}
// -----
func @fptrunc_vec_f32_to_f32(%arg0 : vector<2xf32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : vector<2xf32> to vector<2xf32>
return
}
// -----
func @fptrunc_vec_i32_to_f32(%arg0 : vector<2xi32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : vector<2xi32> to vector<2xf32>
return
}
// -----
func @fptrunc_vec_f32_to_i32(%arg0 : vector<2xf32>) {
// expected-error@+1 {{are cast incompatible}}
%0 = fptrunc %arg0 : vector<2xf32> to vector<2xi32>
return
}
// -----
func @sexti_index_as_operand(%arg0 : index) {
// expected-error@+1 {{'index' is not a valid operand type}}
%0 = sexti %arg0 : index to i128
return
}
// -----
func @zexti_index_as_operand(%arg0 : index) {
// expected-error@+1 {{'index' is not a valid operand type}}
%0 = zexti %arg0 : index to i128
return
}
// -----
func @trunci_index_as_operand(%arg0 : index) {
// expected-error@+1 {{'index' is not a valid operand type}}
%2 = trunci %arg0 : index to i128
return
}
// -----
func @sexti_index_as_result(%arg0 : i1) {
// expected-error@+1 {{'index' is not a valid result type}}
%0 = sexti %arg0 : i1 to index
return
}
// -----
func @zexti_index_as_operand(%arg0 : i1) {
// expected-error@+1 {{'index' is not a valid result type}}
%0 = zexti %arg0 : i1 to index
return
}
// -----
func @trunci_index_as_result(%arg0 : i128) {
// expected-error@+1 {{'index' is not a valid result type}}
%2 = trunci %arg0 : i128 to index
return
}
// -----
func @sexti_cast_to_narrower(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = sexti %arg0 : i16 to i15
return
}
// -----
func @zexti_cast_to_narrower(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = zexti %arg0 : i16 to i15
return
}
// -----
func @trunci_cast_to_wider(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = trunci %arg0 : i16 to i17
return
}
// -----
func @sexti_cast_to_same_width(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = sexti %arg0 : i16 to i16
return
}
// -----
func @zexti_cast_to_same_width(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = zexti %arg0 : i16 to i16
return
}
// -----
func @trunci_cast_to_same_width(%arg0 : i16) {
// expected-error@+1 {{must be wider}}
%0 = trunci %arg0 : i16 to i16
return
}
// -----
func @return_not_in_function() {
"foo.region"() ({
// expected-error@+1 {{'std.return' op expects parent op 'func'}}
return
}): () -> ()
return
}
// -----
func @invalid_splat(%v : f32) {
splat %v : memref<8xf32>
// expected-error@-1 {{must be vector of any type values or statically shaped tensor of any type values}}
return
}
// -----
func @invalid_splat(%v : vector<8xf32>) {
%w = splat %v : tensor<8xvector<8xf32>>
// expected-error@-1 {{must be integer or float type}}
return
}
// -----
func @invalid_splat(%v : f32) { // expected-note {{prior use here}}
splat %v : vector<8xf64>
// expected-error@-1 {{expects different type than prior uses}}
return
}
// -----
func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<2048xi8>
// expected-error@+1 {{expects 1 offset operand}}
%1 = view %0[][%arg0, %arg1]
: memref<2048xi8> to memref<?x?xf32>
return
}
// -----
func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<2048xi8, affine_map<(d0) -> (d0 floordiv 8, d0 mod 8)>>
// expected-error@+1 {{unsupported map for base memref type}}
%1 = view %0[%arg2][%arg0, %arg1]
: memref<2048xi8, affine_map<(d0) -> (d0 floordiv 8, d0 mod 8)>> to
memref<?x?xf32, affine_map<(d0, d1)[s0] -> (d0 * 4 + d1 + s0)>>
return
}
// -----
func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<2048xi8>
// expected-error@+1 {{unsupported map for result memref type}}
%1 = view %0[%arg2][%arg0, %arg1]
: memref<2048xi8> to memref<?x?xf32, affine_map<(d0, d1)[s0] -> (d0, d1, s0)>>
return
}
// -----
func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<2048xi8, 2>
// expected-error@+1 {{different memory spaces}}
%1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8, 2> to memref<?x?xf32, 1>
return
}
// -----
func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<2048xi8>
// expected-error@+1 {{incorrect number of size operands for type}}
%1 = view %0[%arg2][%arg0]
: memref<2048xi8> to memref<?x?xf32>
return
}
// -----
func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<8x16x4xf32, offset: 0, strides: [64, 4, 1], 2>
// expected-error@+1 {{different memory spaces}}
%1 = subview %0[0, 0, 0][%arg2][1, 1, 1]
: memref<8x16x4xf32, offset: 0, strides: [64, 4, 1], 2> to
memref<8x?x4xf32, affine_map<(d0, d1, d2)[s0] -> (d0 * s0 + d1 * 4 + d2)>>
return
}
// -----
func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 + d1, d1 + d2, d2)>>
// expected-error@+1 {{is not strided}}
%1 = subview %0[0, 0, 0][%arg2][1, 1, 1]
: memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 + d1, d1 + d2, d2)>> to
memref<8x?x4xf32, offset: 0, strides: [?, 4, 1]>
return
}
// -----
func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<8x16x4xf32>
// expected-error@+1 {{expected 3 offset values}}
%1 = subview %0[%arg0, %arg1][%arg2][1, 1, 1]
: memref<8x16x4xf32> to
memref<8x?x4xf32, offset: 0, strides:[?, ?, 4]>
return
}
// -----
func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<8x16x4xf32>
// expected-error@+1 {{expected result type to be 'memref<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + s0 + d1 * s2 + d2 * s3)>>'}}
%1 = subview %0[%arg0, %arg1, %arg2][%arg0, %arg1, %arg2][%arg0, %arg1, %arg2]
: memref<8x16x4xf32> to
memref<?x?x?xf32, offset: ?, strides: [64, 4, 1]>
return
}
// -----
func @invalid_rank_reducing_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<8x16x4xf32>
// expected-error@+1 {{expected result type to be 'memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>>'}}
%1 = subview %0[0, 0, 0][8, 16, 4][1, 1, 1]
: memref<8x16x4xf32> to memref<16x4xf32>
return
}
// -----
func @invalid_memref_cast(%arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]>) {
// expected-error@+1{{operand type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2)>>' and result type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 128 + d1 * 32 + d2 * 2)>>' are cast incompatible}}
%0 = memref_cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:0, strides:[128, 32, 2]>
return
}
// -----
func @invalid_memref_cast(%arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]>) {
// expected-error@+1{{operand type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2)>>' and result type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2 + 16)>>' are cast incompatible}}
%0 = memref_cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:16, strides:[64, 16, 1]>
return
}
// -----
// incompatible element types
func @invalid_memref_cast() {
%0 = alloc() : memref<2x5xf32, 0>
// expected-error@+1 {{operand type 'memref<2x5xf32>' and result type 'memref<*xi32>' are cast incompatible}}
%1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xi32>
return
}
// -----
func @invalid_prefetch_rw(%i : index) {
%0 = alloc() : memref<10xf32>
// expected-error@+1 {{rw specifier has to be 'read' or 'write'}}
prefetch %0[%i], rw, locality<0>, data : memref<10xf32>
return
}
// -----
func @invalid_prefetch_cache_type(%i : index) {
%0 = alloc() : memref<10xf32>
// expected-error@+1 {{cache type has to be 'data' or 'instr'}}
prefetch %0[%i], read, locality<0>, false : memref<10xf32>
return
}
// -----
func @invalid_prefetch_locality_hint(%i : index) {
%0 = alloc() : memref<10xf32>
// expected-error@+1 {{32-bit signless integer attribute whose minimum value is 0 whose maximum value is 3}}
prefetch %0[%i], read, locality<5>, data : memref<10xf32>
return
}
// -----
// incompatible memory space
func @invalid_memref_cast() {
%0 = alloc() : memref<2x5xf32, 0>
// expected-error@+1 {{operand type 'memref<2x5xf32>' and result type 'memref<*xf32, 1>' are cast incompatible}}
%1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xf32, 1>
return
}
// -----
// unranked to unranked
func @invalid_memref_cast() {
%0 = alloc() : memref<2x5xf32, 0>
%1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xf32, 0>
// expected-error@+1 {{operand type 'memref<*xf32>' and result type 'memref<*xf32>' are cast incompatible}}
%2 = memref_cast %1 : memref<*xf32, 0> to memref<*xf32, 0>
return
}
// -----
func @atomic_rmw_idxs_rank_mismatch(%I: memref<16x10xf32>, %i : index, %val : f32) {
// expected-error@+1 {{expects the number of subscripts to be equal to memref rank}}
%x = atomic_rmw "addf" %val, %I[%i] : (f32, memref<16x10xf32>) -> f32
return
}
// -----
func @atomic_rmw_expects_float(%I: memref<16x10xi32>, %i : index, %val : i32) {
// expected-error@+1 {{expects a floating-point type}}
%x = atomic_rmw "addf" %val, %I[%i, %i] : (i32, memref<16x10xi32>) -> i32
return
}
// -----
func @atomic_rmw_expects_int(%I: memref<16x10xf32>, %i : index, %val : f32) {
// expected-error@+1 {{expects an integer type}}
%x = atomic_rmw "addi" %val, %I[%i, %i] : (f32, memref<16x10xf32>) -> f32
return
}
// -----
func @generic_atomic_rmw_wrong_arg_num(%I: memref<10xf32>, %i : index) {
// expected-error@+1 {{expected single number of entry block arguments}}
%x = generic_atomic_rmw %I[%i] : memref<10xf32> {
^bb0(%arg0 : f32, %arg1 : f32):
%c1 = constant 1.0 : f32
atomic_yield %c1 : f32
}
return
}
// -----
func @generic_atomic_rmw_wrong_arg_type(%I: memref<10xf32>, %i : index) {
// expected-error@+1 {{expected block argument of the same type result type}}
%x = generic_atomic_rmw %I[%i] : memref<10xf32> {
^bb0(%old_value : i32):
%c1 = constant 1.0 : f32
atomic_yield %c1 : f32
}
return
}
// -----
func @generic_atomic_rmw_result_type_mismatch(%I: memref<10xf32>, %i : index) {
// expected-error@+1 {{failed to verify that result type matches element type of memref}}
%0 = "std.generic_atomic_rmw"(%I, %i) ( {
^bb0(%old_value: f32):
%c1 = constant 1.0 : f32
atomic_yield %c1 : f32
}) : (memref<10xf32>, index) -> i32
return
}
// -----
func @generic_atomic_rmw_has_side_effects(%I: memref<10xf32>, %i : index) {
// expected-error@+4 {{should contain only operations with no side effects}}
%x = generic_atomic_rmw %I[%i] : memref<10xf32> {
^bb0(%old_value : f32):
%c1 = constant 1.0 : f32
%buf = alloc() : memref<2048xf32>
atomic_yield %c1 : f32
}
}
// -----
func @atomic_yield_type_mismatch(%I: memref<10xf32>, %i : index) {
// expected-error@+4 {{op types mismatch between yield op: 'i32' and its parent: 'f32'}}
%x = generic_atomic_rmw %I[%i] : memref<10xf32> {
^bb0(%old_value : f32):
%c1 = constant 1 : i32
atomic_yield %c1 : i32
}
return
}
// -----
// alignment is not power of 2.
func @assume_alignment(%0: memref<4x4xf16>) {
// expected-error@+1 {{alignment must be power of 2}}
std.assume_alignment %0, 12 : memref<4x4xf16>
return
}
// -----
// 0 alignment value.
func @assume_alignment(%0: memref<4x4xf16>) {
// expected-error@+1 {{attribute 'alignment' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive}}
std.assume_alignment %0, 0 : memref<4x4xf16>
return
}
// -----
"alloca_without_scoped_alloc_parent"() ( {
std.alloca() : memref<1xf32>
// expected-error@-1 {{requires an ancestor op with AutomaticAllocationScope trait}}
return
}) : () -> ()
// -----
func @complex_number_from_non_float_operands(%real: i32, %imag: i32) {
// expected-error@+1 {{'complex' must be complex type with floating-point elements, but got 'complex<i32>'}}
std.create_complex %real, %imag : complex<i32>
return
}
// -----
// expected-note@+1 {{prior use here}}
func @complex_number_from_different_float_types(%real: f32, %imag: f64) {
// expected-error@+1 {{expects different type than prior uses: 'f32' vs 'f64'}}
std.create_complex %real, %imag : complex<f32>
return
}
// -----
// expected-note@+1 {{prior use here}}
func @complex_number_from_incompatible_float_type(%real: f32, %imag: f32) {
// expected-error@+1 {{expects different type than prior uses: 'f64' vs 'f32'}}
std.create_complex %real, %imag : complex<f64>
return
}
// -----
// expected-note@+1 {{prior use here}}
func @real_part_from_incompatible_complex_type(%cplx: complex<f32>) {
// expected-error@+1 {{expects different type than prior uses: 'complex<f64>' vs 'complex<f32>'}}
std.re %cplx : complex<f64>
return
}
// -----
// expected-note@+1 {{prior use here}}
func @imaginary_part_from_incompatible_complex_type(%cplx: complex<f64>) {
// expected-error@+1 {{expects different type than prior uses: 'complex<f32>' vs 'complex<f64>'}}
std.re %cplx : complex<f32>
return
}
// -----
func @subtensor_wrong_dynamic_type(%t: tensor<8x16x4xf32>, %idx : index) {
// expected-error @+1 {{expected result type to be 'tensor<4x4x4xf32>'}}
%0 = subtensor %t[0, 2, 0][4, 4, 4][1, 1, 1]
: tensor<8x16x4xf32> to tensor<?x4x4xf32>
return
}
// -----
func @subtensor_wrong_static_type(%t: tensor<8x16x4xf32>, %idx : index) {
// expected-error @+1 {{expected result type to be 'tensor<?x3x?xf32>'}}
%0 = subtensor %t[0, 0, 0][%idx, 3, %idx][1, 1, 1]
: tensor<8x16x4xf32> to tensor<4x4x4xf32>
return
}