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
19 changes: 10 additions & 9 deletions mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,15 +1018,8 @@ void TosaValidation::runOnOperation() {
if (op->getDialect() != tosaDialect)
return;

// Profile-Extension based validation should be performed at the beginning.
if (strictOpSpecAlignment &&
failed(profileComp.checkProfile(op, targetEnv)))
return signalPassFailure();

if (strictOpSpecAlignment &&
failed(profileComp.checkExtension(op, targetEnv)))
return signalPassFailure();

// perform valid element type check at the beginning to
// protect rest of code against quantized element types
for (Value operand : op->getOperands()) {
auto elementTy = getElementTypeOrSelf(operand);
if (!isValidElementType(elementTy)) {
Expand All @@ -1044,6 +1037,14 @@ void TosaValidation::runOnOperation() {
}
}

if (strictOpSpecAlignment &&
failed(profileComp.checkProfile(op, targetEnv)))
return signalPassFailure();

if (strictOpSpecAlignment &&
failed(profileComp.checkExtension(op, targetEnv)))
return signalPassFailure();

if (!allowInvalidOpDatatypeCombinations &&
failed(profileComp.checkInvalid(op))) {
op->emitOpError("illegal: operand/result data types not supported");
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 @@ -253,6 +253,15 @@ func.func @test_conv2d_quant_any_acc(%arg0: tensor<1x4x4x4x!quant.any<i8<-8:7>>>
return %0 : tensor<1x4x4x8x!quant.any<i8<-8:7>>>
}

// -----
// CHECK-LABEL: conv2d_quant_any
func.func @test_conv2d_quant_any(%arg0: tensor<1x4x4x4x!quant.any<i8<-8:7>>>, %arg1: tensor<8x1x1x4x!quant.any<i8<-8:7>>>, %arg2: tensor<8x!quant.any<i32<-8:7>>>) -> tensor<1x4x4x8x!quant.any<i32<-8:7>>> {
%zp = "tosa.const" () { values = dense<0> : tensor<1xi8> } : () -> tensor<1xi8>
// expected-error@+1 {{'tosa.conv2d' op is not profile-aligned: element type '!quant.any<i8<-8:7>>'}}
%0 = tosa.conv2d %arg0, %arg1, %arg2, %zp, %zp {acc_type = i32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, local_bound = true} : (tensor<1x4x4x4x!quant.any<i8<-8:7>>>, tensor<8x1x1x4x!quant.any<i8<-8:7>>>, tensor<8x!quant.any<i32<-8:7>>>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x4x4x8x!quant.any<i32<-8:7>>>
return %0 : tensor<1x4x4x8x!quant.any<i32<-8:7>>>
}

// -----

func.func @test_concat(%arg0 : tensor<2x1xf32>, %arg1 : tensor<2x2xf32>) -> tensor<?x?xf32> {
Expand Down