Skip to content

Commit

Permalink
refator: to fix the failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyakamarapu committed Jan 17, 2024
1 parent 78b73eb commit 0ccab4a
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 73 deletions.
42 changes: 39 additions & 3 deletions mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ template <typename T> static LogicalResult verifyPoolOp(T op) {
return success();
if (inputETy.isInteger(16) && resultETy.isInteger(16))
return success();
if (inputETy.isInteger(32) && resultETy.isInteger(32))
return success();

return op.emitOpError("input/output element types are incompatible.");
}
Expand Down Expand Up @@ -260,7 +262,6 @@ LogicalResult tosa::AvgPool2dOp::verify() {

if (inputETy.isF32() && !accType.isF32())
return emitOpError("accumulator type for f32 tensor is not f32");

}
return result;
}
Expand Down Expand Up @@ -803,6 +804,33 @@ bool tosa::ReshapeOp::isCompatibleReturnTypes(TypeRange l, TypeRange r) {
return getElementTypeOrSelf(l[0]) == getElementTypeOrSelf(r[0]);
}

bool tosa::TransposeOp::isCompatibleReturnTypes(TypeRange l, TypeRange r) {

if (l.size() != r.size() || l.size() != 1)
return false;

auto left = getElementTypeOrSelf(l[0]);
auto right = getElementTypeOrSelf(r[0]);

if (auto quantType = llvm::dyn_cast<mlir::quant::UniformQuantizedType>(left))
left = quantType.getStorageType();

if (auto quantType = llvm::dyn_cast<mlir::quant::UniformQuantizedPerAxisType>(left))
left = quantType.getStorageType();

if (auto quantType = llvm::dyn_cast<mlir::quant::UniformQuantizedType>(right)){
right = quantType.getStorageType();
}

if (auto quantType = llvm::dyn_cast<mlir::quant::UniformQuantizedPerAxisType>(right)){
right = quantType.getStorageType();
}

if (left != right)
return false;
return succeeded(verifyCompatibleShape(l[0], r[0]));
}

LogicalResult tosa::ReshapeOp::inferReturnTypeComponents(
MLIRContext *context, ::std::optional<Location> location,
ValueShapeRange operands, DictionaryAttr attributes,
Expand Down Expand Up @@ -953,6 +981,15 @@ LogicalResult tosa::TransposeOp::inferReturnTypeComponents(
ShapeAdaptor permsShape = operands.getShape(1);
auto inputType = getElementTypeOrSelf(operands[0]);

if (auto quantType =
llvm::dyn_cast<mlir::quant::UniformQuantizedType>(inputType))
inputType = quantType.getStorageType();

if (auto quantType =
llvm::dyn_cast<mlir::quant::UniformQuantizedPerAxisType>(inputType))
inputType = quantType.getStorageType();


// If input rank and permutation length is unknown, the output rank is
// unknown.
if (!inputShape.hasRank() || !permsShape.hasRank() ||
Expand Down Expand Up @@ -1161,7 +1198,6 @@ REDUCE_SHAPE_INFER(tosa::ReduceProdOp)
REDUCE_SHAPE_INFER(tosa::ReduceSumOp)
#undef REDUCE_SHAPE_INFER
COMPATIBLE_RETURN_TYPES(tosa::ConcatOp)
COMPATIBLE_RETURN_TYPES(tosa::TransposeOp)
#undef COMPATIBLE_RETURN_TYPES

static LogicalResult NAryInferReturnTypes(
Expand Down Expand Up @@ -1369,7 +1405,7 @@ LogicalResult tosa::SelectOp::verify() {
llvm::cast<ShapedType>(getOperand(1).getType()).getElementType();
auto input3ETy =
llvm::cast<ShapedType>(getOperand(2).getType()).getElementType();
auto resultETy = getElementTypeOrSelf(getResult());
auto resultETy = getElementTypeOrSelf(getResult());

auto result1 = verifyForSameRank(*this, input1ShapeType, input2ShapeType);
if (result1.failed()) {
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ func.func @max_pool_i16(%arg0: tensor<1x6x34x62xi16>) -> () {
return
}

// CHECK-LABEL: @max_pool_i32
func.func @max_pool_i32(%arg0: tensor<1x6x34x62xi32>) -> () {
// CHECK: arith.constant -2147483648
// CHECK: linalg.pooling_nhwc_max
%0 = "tosa.max_pool2d"(%arg0) {pad = array<i64: 0, 0, 0, 0>, kernel = array<i64: 3, 3>, stride = array<i64: 1, 1>} : (tensor<1x6x34x62xi32>) -> (tensor<1x4x32x62xi32>)
return
}

// -----

// CHECK-LABEL: @avg_pool_f32
Expand Down
6 changes: 3 additions & 3 deletions mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1415,11 +1415,11 @@ func.func @table8_dyn_table(%arg0: tensor<6xi8>, %arg1: tensor<?xi8>) -> () {

// CHECK-DAG: affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>
// CHECK-DAG: affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
// CHECK-DAG: affine_map<(d0, d1, d2, d3) -> ()>
// CHECK-DAG: affine_map<(d0, d1, d2, d3) -> (d0)>
// CHECK-LABEL: @select_fp32
func.func @select_fp32(%arg0: tensor<1x1x5x5xi1>, %arg1: tensor<1x12x5x5xf32>, %arg2: tensor<f32>) -> tensor<1x12x5x5xf32> {
func.func @select_fp32(%arg0: tensor<1x1x5x5xi1>, %arg1: tensor<1x12x5x5xf32>, %arg2: tensor<1x1x1x1xf32>) -> tensor<1x12x5x5xf32> {
// CHECK: linalg.generic
%0 = "tosa.select"(%arg0, %arg1, %arg2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>) -> tensor<1x12x5x5xf32>
%0 = "tosa.select"(%arg0, %arg1, %arg2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<1x1x1x1xf32>) -> tensor<1x12x5x5xf32>
return %0 : tensor<1x12x5x5xf32>
}

Expand Down
14 changes: 7 additions & 7 deletions mlir/test/Dialect/Tosa/inlining.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ func.func @inlined_while_fn(%arg0: tensor<i32>, %arg1: tensor<i32>, %arg2: tenso
%2 = call @while_cond_40(%arg4, %arg5, %arg6, %arg7) : (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>) -> tensor<i1>
"tosa.yield"(%2) : (tensor<i1>) -> ()
}, {
^bb0(%arg4: tensor<i32>, %arg5: tensor<i32>, %arg6: tensor<i32>, %arg7: tensor<10xi32>):
%2:4 = call @while_body_50(%arg4, %arg5, %arg6, %arg7) : (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>)
"tosa.yield"(%2#0, %2#1, %2#2, %2#3) : (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>) -> ()
^bb0(%arg4: tensor<1xi32>, %arg5: tensor<1xi32>, %arg6: tensor<1xi32>, %arg7: tensor<10xi32>):
%2:4 = call @while_body_50(%arg4, %arg5, %arg6, %arg7) : (tensor<1xi32>, tensor<1xi32>, tensor<1xi32>, tensor<10xi32>) -> (tensor<1xi32>, tensor<1xi32>, tensor<1xi32>, tensor<10xi32>)
"tosa.yield"(%2#0, %2#1, %2#2, %2#3) : (tensor<1xi32>, tensor<1xi32>, tensor<1xi32>, tensor<10xi32>) -> ()
}) : (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>)
return %1#3 : tensor<10xi32>
}
func.func private @while_body_50(%arg0: tensor<i32>, %arg1: tensor<i32>, %arg2: tensor<i32>, %arg3: tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>) {
%1 = "tosa.add"(%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> tensor<i32>
%2 = "tosa.add"(%arg3, %1) : (tensor<10xi32>, tensor<i32>) -> tensor<10xi32>
return %1, %arg1, %arg2, %2: tensor<i32>, tensor<i32>, tensor<i32>, tensor<10xi32>
func.func private @while_body_50(%arg0: tensor<1xi32>, %arg1: tensor<1xi32>, %arg2: tensor<1xi32>, %arg3: tensor<10xi32>) -> (tensor<1xi32>, tensor<1xi32>, tensor<1xi32>, tensor<10xi32>) {
%1 = "tosa.add"(%arg0, %arg1) : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
%2 = "tosa.add"(%arg3, %1) : (tensor<10xi32>, tensor<1xi32>) -> tensor<10xi32>
return %1, %arg1, %arg2, %2: tensor<1xi32>, tensor<1xi32>, tensor<1xi32>, tensor<10xi32>
}
func.func private @while_cond_40(%arg0: tensor<i32>, %arg1: tensor<i32>, %arg2: tensor<i32>, %arg3: tensor<10xi32>) -> tensor<i1> {
%0 = "tosa.greater_equal"(%arg0, %arg1) : (tensor<i32>, tensor<i32>) -> tensor<i1>
Expand Down
120 changes: 60 additions & 60 deletions mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func.func @test_return(%arg0 : tensor<4xf32>) -> tensor<*xf32> {
return %0 : tensor<*xf32>
}

// -----
// -----

// CHECK-LABEL: @test_multiple
func.func @test_multiple(%arg0 : tensor<4xf32>, %arg1 : tensor<1xf32>, %arg2 : tensor<f32>) -> tensor<*xf32> {
Expand Down Expand Up @@ -104,33 +104,33 @@ func.func @test_unary_i32(%arg0 : tensor<4xi32>) -> () {
// -----

// CHECK-LABEL: @test_binary_scalar_f32
func.func @test_binary_scalar_f32(%arg0 : tensor<4xf32>, %arg1 : tensor<f32>) -> () {
// CHECK: "tosa.add"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%0 = "tosa.add"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
func.func @test_binary_scalar_f32(%arg0 : tensor<4xf32>, %arg1 : tensor<1xf32>) -> () {
// CHECK: "tosa.add"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%0 = "tosa.add"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.maximum"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%1 = "tosa.maximum"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
// CHECK: "tosa.maximum"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%1 = "tosa.maximum"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.minimum"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%2 = "tosa.minimum"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
// CHECK: "tosa.minimum"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%2 = "tosa.minimum"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.mul"(%arg0, %arg1) <{shift = 0 : i32}> : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%3 = "tosa.mul"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
// CHECK: "tosa.mul"(%arg0, %arg1) <{shift = 0 : i32}> : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%3 = "tosa.mul"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.pow"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%4 = "tosa.pow"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
// CHECK: "tosa.pow"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%4 = "tosa.pow"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.sub"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
%5 = "tosa.sub"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
// CHECK: "tosa.sub"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
%5 = "tosa.sub"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>

// CHECK: "tosa.equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xi1>
%6 = "tosa.equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xi1>
// CHECK: "tosa.equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xi1>
%6 = "tosa.equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xi1>

// CHECK: "tosa.greater"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xi1>
%7 = "tosa.greater"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xi1>
// CHECK: "tosa.greater"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xi1>
%7 = "tosa.greater"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xi1>

// CHECK: "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<4xi1>
%8 = "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<f32>) -> tensor<*xi1>
// CHECK: "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xi1>
%8 = "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xi1>

return
}
Expand Down Expand Up @@ -172,48 +172,48 @@ func.func @test_binary_broadcast_f32(%arg0 : tensor<4xf32>, %arg1 : tensor<1xf32
// -----

// CHECK-LABEL: @test_binary_i32
func.func @test_binary_i32(%arg0 : tensor<4xi32>, %arg1 : tensor<i32>) -> () {
// CHECK: "tosa.add"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%0 = "tosa.add"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
func.func @test_binary_i32(%arg0 : tensor<4xi32>, %arg1 : tensor<1xi32>) -> () {
// CHECK: "tosa.add"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%0 = "tosa.add"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.bitwise_and"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%1 = "tosa.bitwise_and"(%arg0, %arg1): (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.bitwise_and"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%1 = "tosa.bitwise_and"(%arg0, %arg1): (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.bitwise_or"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%2 = "tosa.bitwise_or"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.bitwise_or"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%2 = "tosa.bitwise_or"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.bitwise_xor"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%3 = "tosa.bitwise_xor"(%arg0, %arg1): (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.bitwise_xor"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%3 = "tosa.bitwise_xor"(%arg0, %arg1): (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi1>
%4 = "tosa.equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi1>
// CHECK: "tosa.equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi1>
%4 = "tosa.equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi1>

// CHECK: "tosa.greater"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi1>
%5 = "tosa.greater"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi1>
// CHECK: "tosa.greater"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi1>
%5 = "tosa.greater"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi1>

// CHECK: "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi1>
%6 = "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi1>
// CHECK: "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi1>
%6 = "tosa.greater_equal"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi1>

// CHECK: "tosa.logical_left_shift"(%arg0, %arg1) {shift = 0 : i32} : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%7 = "tosa.logical_left_shift"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.logical_left_shift"(%arg0, %arg1) {shift = 0 : i32} : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%7 = "tosa.logical_left_shift"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.logical_right_shift"(%arg0, %arg1) {shift = 0 : i32} : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%8 = "tosa.logical_right_shift"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.logical_right_shift"(%arg0, %arg1) {shift = 0 : i32} : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%8 = "tosa.logical_right_shift"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.maximum"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%9 = "tosa.maximum"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.maximum"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%9 = "tosa.maximum"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.minimum"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%10 = "tosa.minimum"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.minimum"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%10 = "tosa.minimum"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.mul"(%arg0, %arg1) <{shift = 0 : i32}> : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%11 = "tosa.mul"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.mul"(%arg0, %arg1) <{shift = 0 : i32}> : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%11 = "tosa.mul"(%arg0, %arg1) { shift = 0 : i32 }: (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.pow"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%12 = "tosa.pow"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.pow"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%12 = "tosa.pow"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

// CHECK: "tosa.sub"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
%13 = "tosa.sub"(%arg0, %arg1) : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
// CHECK: "tosa.sub"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<4xi32>
%13 = "tosa.sub"(%arg0, %arg1) : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi32>

return
}
Expand All @@ -237,9 +237,9 @@ func.func @test_binary_i1(%arg0 : tensor<4xi1>, %arg1 : tensor<i1>) -> () {
// -----

// CHECK-LABEL: @test_select_i32
func.func @test_select_i32(%arg0 : tensor<4xi1>, %arg1 : tensor<i32>, %arg2 : tensor<4xi32>) -> () {
// CHECK: "tosa.select"(%arg0, %arg1, %arg2) : (tensor<4xi1>, tensor<i32>, tensor<4xi32>) -> tensor<4xi32>
%0 = "tosa.select"(%arg0, %arg1, %arg2): (tensor<4xi1>, tensor<i32>, tensor<4xi32>) -> tensor<*xi32>
func.func @test_select_i32(%arg0 : tensor<4xi1>, %arg1 : tensor<1xi32>, %arg2 : tensor<4xi32>) -> () {
// CHECK: "tosa.select"(%arg0, %arg1, %arg2) : (tensor<4xi1>, tensor<1xi32>, tensor<4xi32>) -> tensor<4xi32>
%0 = "tosa.select"(%arg0, %arg1, %arg2): (tensor<4xi1>, tensor<1xi32>, tensor<4xi32>) -> tensor<*xi32>

return
}
Expand Down Expand Up @@ -703,11 +703,11 @@ func.func @test_pool_dynamic_input(%arg0: tensor<?x?x?x?xf32>) {

// CHECK-LABEL: @test_pool_padded
func.func @test_pool_padded(%arg0: tensor<3x5x6x7xf32>) {
// CHECK: -> tensor<3x5x11x7xf32>
%0 = "tosa.avg_pool2d"(%arg0) {acc_type = f32, kernel = array<i64: 4, 3>, pad = array<i64: 1, 2, 3, 4>, stride = array<i64: 1, 1>} : (tensor<3x5x6x7xf32>) -> tensor<?x?x?x?xf32>
// CHECK: -> tensor<3x5x8x7xf32>
%0 = "tosa.avg_pool2d"(%arg0) {acc_type = f32, kernel = array<i64: 4, 3>, pad = array<i64: 1, 2, 2, 2>, stride = array<i64: 1, 1>} : (tensor<3x5x6x7xf32>) -> tensor<?x?x?x?xf32>

// CHECK: -> tensor<3x5x11x7xf32>
%1 = "tosa.max_pool2d"(%arg0) {kernel = array<i64: 4, 3>, pad = array<i64: 1, 2, 3, 4>, stride = array<i64: 1, 1>} : (tensor<3x5x6x7xf32>) -> tensor<?x?x?x?xf32>
// CHECK: -> tensor<3x5x8x7xf32>
%1 = "tosa.max_pool2d"(%arg0) {kernel = array<i64: 4, 3>, pad = array<i64: 1, 2, 2, 2>, stride = array<i64: 1, 1>} : (tensor<3x5x6x7xf32>) -> tensor<?x?x?x?xf32>
return
}

Expand All @@ -733,11 +733,11 @@ func.func @conv2d_dynamic_bias(%input: tensor<2x8x9x3xf32>, %weights: tensor<5x3

// CHECK-LABEL: @test_pool_stride
func.func @test_pool_stride(%arg0: tensor<3x11x12x7xf32>) {
// CHECK: -> tensor<3x4x4x7xf32>
%0 = "tosa.avg_pool2d"(%arg0) {acc_type = f32, kernel = array<i64: 4, 3>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 2, 3>} : (tensor<3x11x12x7xf32>) -> tensor<?x?x?x?xf32>
// CHECK: -> tensor<3x5x4x7xf32>
%0 = "tosa.avg_pool2d"(%arg0) {acc_type = f32, kernel = array<i64: 4, 3>, pad = array<i64: 1, 0, 0, 0>, stride = array<i64: 2, 3>} : (tensor<3x11x12x7xf32>) -> tensor<?x?x?x?xf32>

// CHECK: -> tensor<3x4x4x7xf32>
%1 = "tosa.max_pool2d"(%arg0) {kernel = array<i64: 4, 3>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 2, 3>} : (tensor<3x11x12x7xf32>) -> tensor<?x?x?x?xf32>
// CHECK: -> tensor<3x5x4x7xf32>
%1 = "tosa.max_pool2d"(%arg0) {kernel = array<i64: 4, 3>, pad = array<i64: 1, 0, 0, 0>, stride = array<i64: 2, 3>} : (tensor<3x11x12x7xf32>) -> tensor<?x?x?x?xf32>
return
}

Expand Down

0 comments on commit 0ccab4a

Please sign in to comment.