@@ -442,98 +442,124 @@ func @test_transpose(%arg0: tensor<1x2x3xi32>) -> () {
442
442
// -----
443
443
444
444
// CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
445
- // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (d1)>
446
- // CHECK: #[[$MAP2:.*]] = affine_map<(d0, d1) -> (d0)>
445
+ // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (0, d1)>
446
+ // CHECK: #[[$MAP2:.*]] = affine_map<(d0, d1) -> (d0, 0 )>
447
447
448
448
// CHECK-LABEL: @reduce_float
449
449
// CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xf32>
450
450
func @reduce_float (%arg0: tensor <5 x4 xf32 >) -> () {
451
- // CHECK: [[INIT:%.+]] = linalg.init_tensor [4]
451
+ // CHECK: [[INIT:%.+]] = linalg.init_tensor [1, 4]
452
452
// CHECK: [[CST0:%.+]] = constant 0.0
453
453
// CHECK: [[FILL:%.+]] = linalg.fill([[INIT]], [[CST0]])
454
- // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["reduction", "parallel"]} ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<4xf32 >)
454
+ // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["reduction", "parallel"]} ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<1x4xf32 >)
455
455
// CHECK: ^bb0(%arg1: f32, %arg2: f32)
456
456
// CHECK: [[RES:%.+]] = addf %arg1, %arg2 : f32
457
457
// CHECK: linalg.yield [[RES]] : f32
458
- %0 = " tosa.reduce_sum" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <4 x f32 >
458
+ %0 = " tosa.reduce_sum" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <1 x 4 x f32 >
459
459
460
- // CHECK: [[INIT:%.+]] = linalg.init_tensor [5]
460
+ // CHECK: [[INIT:%.+]] = linalg.init_tensor [5, 1 ]
461
461
// CHECK: [[CST0:%.+]] = constant 0.0
462
462
// CHECK: [[FILL:%.+]] = linalg.fill([[INIT]], [[CST0]])
463
- // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP2]]], iterator_types = ["parallel", "reduction"]} ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<5xf32 >)
463
+ // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP2]]], iterator_types = ["parallel", "reduction"]} ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<5x1xf32 >)
464
464
// CHECK: ^bb0(%arg1: f32, %arg2: f32)
465
465
// CHECK: [[RES:%.+]] = addf %arg1, %arg2 : f32
466
466
// CHECK: linalg.yield [[RES]] : f32
467
- %1 = " tosa.reduce_sum" (%arg0 ) {axis = 1 : i64 } : (tensor <5 x4 xf32 >) -> tensor <5 x f32 >
467
+ %1 = " tosa.reduce_sum" (%arg0 ) {axis = 1 : i64 } : (tensor <5 x4 xf32 >) -> tensor <5 x 1 x f32 >
468
468
469
469
// CHECK: constant 1.0
470
470
// CHECK: linalg.fill
471
471
// CHECK: linalg.generic
472
472
// CHECK: mulf
473
- %2 = " tosa.reduce_prod" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <4 x f32 >
473
+ %2 = " tosa.reduce_prod" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <1 x 4 x f32 >
474
474
475
475
// CHECK: constant 3.40282347E+38 : f32
476
476
// CHECK: linalg.fill
477
477
// CHECK: linalg.generic
478
478
// CHECK: cmpf olt
479
479
// CHECK: select
480
- %3 = " tosa.reduce_min" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <4 x f32 >
480
+ %3 = " tosa.reduce_min" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <1 x 4 x f32 >
481
481
482
482
// CHECK: constant -3.40282347E+38 : f32
483
483
// CHECK: linalg.fill
484
484
// CHECK: linalg.generic
485
485
// CHECK: cmpf ogt
486
486
// CHECK: select
487
- %4 = " tosa.reduce_max" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <4 x f32 >
487
+ %4 = " tosa.reduce_max" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xf32 >) -> tensor <1 x 4 x f32 >
488
488
return
489
489
}
490
490
491
491
// -----
492
492
493
493
// CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
494
- // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (d1)>
495
- // CHECK: #[[$MAP2:.*]] = affine_map<(d0, d1) -> (d0)>
494
+ // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (0, d1)>
495
+ // CHECK: #[[$MAP2:.*]] = affine_map<(d0, d1) -> (d0, 0 )>
496
496
497
497
// CHECK-LABEL: @reduce_int
498
498
// CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xi32>
499
499
func @reduce_int (%arg0: tensor <5 x4 xi32 >) -> () {
500
- // CHECK: [[INIT:%.+]] = linalg.init_tensor [4]
500
+ // CHECK: [[INIT:%.+]] = linalg.init_tensor [1, 4]
501
501
// CHECK: [[CST0:%.+]] = constant 0
502
502
// CHECK: [[FILL:%.+]] = linalg.fill([[INIT]], [[CST0]])
503
- // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["reduction", "parallel"]} ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<4xi32 >)
503
+ // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["reduction", "parallel"]} ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<1x4xi32 >)
504
504
// CHECK: ^bb0(%arg1: i32, %arg2: i32)
505
505
// CHECK: [[RES:%.+]] = addi %arg1, %arg2 : i32
506
506
// CHECK: linalg.yield [[RES]] : i32
507
- %0 = " tosa.reduce_sum" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <4 x i32 >
507
+ %0 = " tosa.reduce_sum" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <1 x 4 x i32 >
508
508
509
- // CHECK: [[INIT:%.+]] = linalg.init_tensor [5]
509
+ // CHECK: [[INIT:%.+]] = linalg.init_tensor [5, 1 ]
510
510
// CHECK: [[CST0:%.+]] = constant 0
511
511
// CHECK: [[FILL:%.+]] = linalg.fill([[INIT]], [[CST0]])
512
- // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP2]]], iterator_types = ["parallel", "reduction"]} ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<5xi32 >)
512
+ // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP2]]], iterator_types = ["parallel", "reduction"]} ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<5x1xi32 >)
513
513
// CHECK: ^bb0(%arg1: i32, %arg2: i32)
514
514
// CHECK: [[RES:%.+]] = addi %arg1, %arg2 : i32
515
515
// CHECK: linalg.yield [[RES]] : i32
516
- %1 = " tosa.reduce_sum" (%arg0 ) {axis = 1 : i64 } : (tensor <5 x4 xi32 >) -> tensor <5 x i32 >
516
+ %1 = " tosa.reduce_sum" (%arg0 ) {axis = 1 : i64 } : (tensor <5 x4 xi32 >) -> tensor <5 x 1 x i32 >
517
517
518
518
// CHECK: constant 1
519
519
// CHECK: linalg.fill
520
520
// CHECK: linalg.generic
521
521
// CHECK: muli
522
- %2 = " tosa.reduce_prod" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <4 x i32 >
522
+ %2 = " tosa.reduce_prod" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <1 x 4 x i32 >
523
523
524
524
// CHECK: constant 2147483647 : i32
525
525
// CHECK: linalg.fill
526
526
// CHECK: linalg.generic
527
527
// CHECK: cmpi slt
528
528
// CHECK: select
529
- %3 = " tosa.reduce_min" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <4 x i32 >
529
+ %3 = " tosa.reduce_min" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <1 x 4 x i32 >
530
530
531
531
// CHECK: constant -2147483648 : i32
532
532
// CHECK: linalg.fill
533
533
// CHECK: linalg.generic
534
534
// CHECK: cmpi sgt
535
535
// CHECK: select
536
- %4 = " tosa.reduce_max" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <4 xi32 >
536
+ %4 = " tosa.reduce_max" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi32 >) -> tensor <1 x4 xi32 >
537
+ return
538
+ }
539
+
540
+ // -----
541
+
542
+ // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
543
+ // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (0, d1)>
544
+
545
+ // CHECK-LABEL: @reduce_bool
546
+ // CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xi1>
547
+ func @reduce_bool (%arg0: tensor <5 x4 xi1 >) -> () {
548
+ // CHECK: [[INIT:%.+]] = linalg.init_tensor [1, 4]
549
+ // CHECK: [[CST0:%.+]] = constant true
550
+ // CHECK: [[FILL:%.+]] = linalg.fill([[INIT]], [[CST0]])
551
+ // CHECK: [[GENERIC:%.+]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]]], iterator_types = ["reduction", "parallel"]} ins([[ARG0]] : tensor<5x4xi1>) outs([[FILL]] : tensor<1x4xi1>)
552
+ // CHECK: ^bb0(%arg1: i1, %arg2: i1)
553
+ // CHECK: [[RES:%.+]] = and %arg1, %arg2 : i1
554
+ // CHECK: linalg.yield [[RES]] : i1
555
+ %0 = " tosa.reduce_all" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi1 >) -> tensor <1 x4 xi1 >
556
+
557
+ // CHECK: constant false
558
+ // CHECK: linalg.fill
559
+ // CHECK: linalg.generic
560
+ // CHECK: or
561
+ %1 = " tosa.reduce_any" (%arg0 ) {axis = 0 : i64 } : (tensor <5 x4 xi1 >) -> tensor <1 x4 xi1 >
562
+
537
563
return
538
564
}
539
565
0 commit comments