Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,11 @@ LogicalResult tosa::ClampOp::verify() {
return emitOpError("min/max attributes types are incompatible with "
"input/output element types.");

const bool isUnsigned = cast<IntegerType>(inputETy).isUnsigned();
const bool isUnsigned = inputETy.isUnsignedInteger();
const bool isBoolean = inputETy.isInteger(1);
const APInt minVal = intMinValAttr.getValue();
const APInt maxVal = intMaxValAttr.getValue();
if (isUnsigned ? maxVal.ult(minVal) : maxVal.slt(minVal))
if ((isUnsigned || isBoolean) ? maxVal.ult(minVal) : maxVal.slt(minVal))
return emitOpError("expected min_val <= max_val, got min_val=")
<< minValAttr << ", max_val=" << maxValAttr;
} else {
Expand Down
9 changes: 9 additions & 0 deletions mlir/test/Dialect/Tosa/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,15 @@ func.func @test_mismatch_in_out_shape_clamp(%arg0: tensor<13x21x3xf32>) -> tenso

// -----

// CHECK-LABEL: test_unsupported_boolean_type_clamp
func.func @test_unsupported_boolean_type_clamp(%arg0: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> {
// expected-error@+1 {{'tosa.clamp' op illegal: operation operand/result data types did not align with any profile or extension, got (i1,i1), did you mean (i8,i8)?}}
%0 = tosa.clamp %arg0 {min_val = false, max_val = true} : (tensor<13x21x3xi1>) -> tensor<13x21x3xi1>
return %0 : tensor<13x21x3xi1>
}

// -----

// CHECK-LABEL: test_mismatch_in_out_data_type_erf
func.func @test_mismatch_in_out_data_type_erf(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
// expected-error@+1 {{'tosa.erf' op requires the same element type for all operands and results}}
Expand Down
Loading