[Mlir-commits] [mlir] [mlir][tosa] support NegateOp with dynamic extension in TosaToLinalg (PR #158782)
Luke Hutton
llvmlistbot at llvm.org
Fri Sep 19 08:39:25 PDT 2025
================
@@ -186,56 +186,61 @@ static Value createLinalgBodyCalculationForElementwiseOp(
if (isa<tosa::NegateOp>(op)) {
auto negate = cast<tosa::NegateOp>(op);
+ int64_t inZp = 0, outZp = 0;
FailureOr<int64_t> maybeInZp = negate.getInput1ZeroPoint();
- if (failed(maybeInZp)) {
- (void)rewriter.notifyMatchFailure(
- op, "input1 zero point cannot be statically determined");
- return nullptr;
- }
-
FailureOr<int64_t> maybeOutZp = negate.getOutputZeroPoint();
- if (failed(maybeOutZp)) {
- (void)rewriter.notifyMatchFailure(
- op, "output zero point cannot be statically determined");
- return nullptr;
- }
-
- int64_t inZp = *maybeInZp;
- int64_t outZp = *maybeOutZp;
+ if (!failed(maybeInZp))
+ inZp = *maybeInZp;
+ if (!failed(maybeOutZp))
+ outZp = *maybeOutZp;
if (isa<FloatType>(elementTy))
return arith::NegFOp::create(rewriter, loc, resultTypes, args[0]);
if (isa<IntegerType>(elementTy)) {
- if (!inZp && !outZp) {
+ if (!failed(maybeInZp) && !failed(maybeOutZp) && !inZp && !outZp) {
----------------
lhutton1 wrote:
nit: rather than reuse the result of `failed(maybeInZp)` and `failed(maybeOutZp)`, could we define variable such as `hasInZp`, `hasOutZp` instead?
https://github.com/llvm/llvm-project/pull/158782
More information about the Mlir-commits
mailing list