[Mlir-commits] [mlir] [mlir[tosa] Switch zero point of avgpool2d to input variable type (PR #128983)
Jack Frankland
llvmlistbot at llvm.org
Thu Feb 27 06:42:14 PST 2025
================
@@ -629,27 +643,37 @@ static void buildMatMulOpWithQuantInfo(OpBuilder &builder,
}
/// Both the tosa.avg_pool2d and unary ops use the same
-/// UnaruOpQuantizationAttr but avg_pool operator has its own builder as it
+/// UnaryOpQuantizationAttr but avg_pool operator has its own builder as it
/// has additional parameters not part of the unary ops.
static void
buildAvgPool2dOpWithQuantInfo(OpBuilder &builder, OperationState &result,
Type outputType, Value input,
DenseArrayAttr kernel, DenseArrayAttr stride,
DenseArrayAttr pad, TypeAttr accType) {
- result.addOperands(input);
+ const Location loc{result.location};
+ int64_t inputZp{0};
+ int64_t outputZp{0};
+
+ auto quantAttr = buildUnaryOpQuantizationAttr(builder, input, outputType);
+ if (quantAttr) {
+ inputZp = quantAttr.getInputZp();
+ outputZp = quantAttr.getOutputZp();
+ }
+ const std::optional<Value> inputZpOp =
+ createZeroPointTensor(builder, loc, input.getType(), inputZp);
+ assert(
----------------
FranklandJack wrote:
Is there anyway to signal an error here and return from the function? On a release bulid this is going to fall through and we will have unchecked access to the optional below.
https://github.com/llvm/llvm-project/pull/128983
More information about the Mlir-commits
mailing list