[Mlir-commits] [mlir] c7676d9 - [mlir][tosa] Update Tosa conv verifier to handle IntegerType input

Rob Suderman llvmlistbot at llvm.org
Mon Jun 28 10:24:04 PDT 2021


Author: Rob Suderman
Date: 2021-06-28T10:18:45-07:00
New Revision: c7676d9993183f7041b1d79cc672ff14961c8777

URL: https://github.com/llvm/llvm-project/commit/c7676d9993183f7041b1d79cc672ff14961c8777
DIFF: https://github.com/llvm/llvm-project/commit/c7676d9993183f7041b1d79cc672ff14961c8777.diff

LOG: [mlir][tosa] Update Tosa conv verifier to handle IntegerType input

Input/output types can be integers, which represent a quantized convolution.
Update verifier to expect this behavior.

Reviewed By: sjarus

Differential Revision: https://reviews.llvm.org/D104949

Added: 
    

Modified: 
    mlir/lib/Dialect/Tosa/IR/TosaOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index e50dab12aaf14..83a89f3af80d6 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -121,19 +121,20 @@ static LogicalResult verifyConvOp(T op) {
   if (!inputType || !weightType)
     return failure();
 
-  auto inputQType =
-      inputType.getElementType().template isa<mlir::quant::QuantizedType>();
-  auto weightQType =
-      weightType.getElementType().template isa<mlir::quant::QuantizedType>();
+  auto inputEType = inputType.getElementType();
+  auto weightEType = weightType.getElementType();
+
+  bool inputIsQuant = !inputEType.template isa<FloatType>();
+  bool weightIsQuant = !weightEType.template isa<FloatType>();
 
   // Either both must be quantized or both unquantized.
-  if (inputQType != weightQType)
+  if (inputIsQuant != weightIsQuant)
     return failure();
 
   // Quantized type must have constructed the quantizationattr, and unquantized
   // types should not have a quantizationattr.
-  if ((inputQType && !op.quantization_info()) ||
-      (!inputQType && op.quantization_info()))
+  if ((inputIsQuant && !op.quantization_info()) ||
+      (!inputIsQuant && op.quantization_info()))
     return failure();
 
   return success();


        


More information about the Mlir-commits mailing list