@@ -94,6 +94,7 @@ func.func @test_add_0d(%arg0: tensor<f32>, %arg1: tensor<f32>) -> tensor<f32> {
9494 // CHECK: } -> tensor<f32>
9595 %0 = tosa.add %arg0 , %arg1 : (tensor <f32 >, tensor <f32 >) -> tensor <f32 >
9696
97+
9798 // CHECK: return [[RESULT]] : tensor<f32>
9899 return %0 : tensor <f32 >
99100}
@@ -104,20 +105,20 @@ func.func @test_add_0d(%arg0: tensor<f32>, %arg1: tensor<f32>) -> tensor<f32> {
104105// CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1) -> (0, 0)>
105106// CHECK: #[[$MAP2:.+]] = affine_map<(d0, d1) -> (d0, d1)>
106107
107- // CHECK-LABEL: func.func @test_add_0d_broadcast (
108+ // CHECK-LABEL: func.func @test_add_2d_broadcast (
108109// CHECK-SAME: %[[ARG0:.*]]: tensor<2x1xf32>,
109- // CHECK-SAME: %[[ARG1:.*]]: tensor<f32>) -> tensor<2x1xf32> {
110- // CHECK: %[[EXPANDED:.*]] = tensor.expand_shape %[[ARG1]] [] output_shape [1, 1] : tensor<f32> into tensor<1x1xf32>
110+ // CHECK-SAME: %[[ARG1:.*]]: tensor<1x1xf32>) -> tensor<2x1xf32> {
111111// CHECK: %[[EMPTY_TENSOR:.*]] = tensor.empty() : tensor<2x1xf32>
112- // CHECK: %[[RESULT:.*]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]], #[[$MAP2]]], iterator_types = ["parallel", "parallel"]} ins(%[[ARG0]], %[[EXPANDED ]] : tensor<2x1xf32>, tensor<1x1xf32>) outs(%[[EMPTY_TENSOR]] : tensor<2x1xf32>) {
112+ // CHECK: %[[RESULT:.*]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]], #[[$MAP2]]], iterator_types = ["parallel", "parallel"]} ins(%[[ARG0]], %[[ARG1 ]] : tensor<2x1xf32>, tensor<1x1xf32>) outs(%[[EMPTY_TENSOR]] : tensor<2x1xf32>) {
113113// CHECK: ^bb0(%[[IN0:.*]]: f32, %[[IN1:.*]]: f32, %[[OUT:.*]]: f32):
114114// CHECK: %[[ADD:.*]] = arith.addf %[[IN0]], %[[IN1]] : f32
115115// CHECK: linalg.yield %[[ADD]] : f32
116116// CHECK: } -> tensor<2x1xf32>
117117// CHECK: return %[[RESULT]] : tensor<2x1xf32>
118118// CHECK: }
119- func.func @test_add_0d_broadcast (%arg0: tensor <2 x1 xf32 >, %arg1: tensor <f32 >) -> tensor <2 x1 xf32 > {
120- %0 = tosa.add %arg0 , %arg1 : (tensor <2 x1 xf32 >, tensor <f32 >) -> tensor <2 x1 xf32 >
119+ func.func @test_add_2d_broadcast (%arg0: tensor <2 x1 xf32 >, %arg1: tensor <1 x1 xf32 >) -> tensor <2 x1 xf32 > {
120+ // tosa element-wise operators now require operands of equal ranks
121+ %0 = tosa.add %arg0 , %arg1 : (tensor <2 x1 xf32 >, tensor <1 x1 xf32 >) -> tensor <2 x1 xf32 >
121122 return %0 : tensor <2 x1 xf32 >
122123}
123124
@@ -364,23 +365,9 @@ func.func @test_add_2d_all_dynamic(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32
364365
365366// -----
366367
367- // CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1, d2) -> (0, d1, d2)>
368- // CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
369- // CHECK-LABEL: @test_add_2d_different_ranks
370- // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
371- // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
372368func.func @test_add_2d_different_ranks (%arg0: tensor <3 x4 xf32 >, %arg1: tensor <2 x3 x4 xf32 >) -> tensor <2 x3 x4 xf32 > {
373-
374- // CHECK: %[[ARG0_EXPANDED:.*]] = tensor.expand_shape %[[ARG0]] {{\[\[}}0, 1], [2]] output_shape [1, 3, 4] : tensor<3x4xf32> into tensor<1x3x4xf32>
375- // CHECK: %[[VAL_0:.*]] = tensor.empty() : tensor<2x3x4xf32>
376- // CHECK: %[[RESULT:.*]] = linalg.generic {indexing_maps = [#[[$MAP0]], #[[$MAP1]], #[[$MAP1]]], iterator_types = ["parallel", "parallel", "parallel"]} ins(%[[ARG0_EXPANDED]], %[[ARG1]] : tensor<1x3x4xf32>, tensor<2x3x4xf32>) outs(%[[VAL_0]] : tensor<2x3x4xf32>) {
377- // CHECK: ^bb0(%[[VAL_1:.*]]: f32, %[[VAL_2:.*]]: f32, %[[VAL_3:.*]]: f32):
378- // CHECK: %[[VAL_4:.*]] = arith.addf %[[VAL_1]], %[[VAL_2]] : f32
379- // CHECK: linalg.yield %[[VAL_4]] : f32
380- // CHECK: } -> tensor<2x3x4xf32>
381- %0 = tosa.add %arg0 , %arg1 : (tensor <3 x4 xf32 >, tensor <2 x3 x4 xf32 >) -> tensor <2 x3 x4 xf32 >
382-
383- // CHECK: return %[[RESULT]] : tensor<2x3x4xf32>
369+ // expected-error@+1 {{'tosa.add' op operands don't have matching ranks}}
370+ %0 = " tosa.add" (%arg0 , %arg1 ) : (tensor <3 x4 xf32 >, tensor <2 x3 x4 xf32 >) -> tensor <2 x3 x4 xf32 >
384371 return %0 : tensor <2 x3 x4 xf32 >
385372}
386373
0 commit comments