diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -1681,13 +1681,24 @@ dy = rewriter.create(loc, resultElementTy, dy); } + Value xScaleNExt = xScaleN; + Value yScaleNExt = yScaleN; + + if (xScaleN.getType() != resultElementTy) + xScaleNExt = + rewriter.create(loc, resultElementTy, xScaleN); + + if (yScaleN.getType() != resultElementTy) + yScaleNExt = + rewriter.create(loc, resultElementTy, yScaleN); + Value topAcc, bottomAcc; if (imageW == 1) { - topAcc = rewriter.create(loc, y0x0, xScaleN); - bottomAcc = rewriter.create(loc, y1x0, xScaleN); + topAcc = rewriter.create(loc, y0x0, xScaleNExt); + bottomAcc = rewriter.create(loc, y1x0, xScaleNExt); } else { Value rightPart = dx; - Value leftPart = rewriter.create(loc, xScaleN, dx); + Value leftPart = rewriter.create(loc, xScaleNExt, dx); y0x0 = rewriter.create(loc, y0x0, leftPart); y0x1 = rewriter.create(loc, y0x1, rightPart); @@ -1700,10 +1711,10 @@ Value result; if (imageH == 1) { - result = rewriter.create(loc, topAcc, yScaleN); + result = rewriter.create(loc, topAcc, yScaleNExt); } else { Value bottomPart = dy; - Value topPart = rewriter.create(loc, yScaleN, dy); + Value topPart = rewriter.create(loc, yScaleNExt, dy); topAcc = rewriter.create(loc, topAcc, topPart); bottomAcc = rewriter.create(loc, bottomAcc, bottomPart); diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir --- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir +++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir @@ -484,3 +484,11 @@ %output = "tosa.resize"(%input) { scale = [4, 2, 4, 2], offset = [-1, -1], border = [1, 1], mode = "BILINEAR" } : (tensor) -> (tensor) return } + +// ----- + +// CHECK-LABEL: @resize_bilinear_int48 +func.func @resize_bilinear_int48(%arg0: tensor<1x19x19x1xi16>) { + %0 = "tosa.resize"(%arg0) {mode = "BILINEAR", scale = [16, 1, 16, 1], offset = [0, 0], border = [0, 0]} : (tensor<1x19x19x1xi16>) -> tensor<1x289x289x1xi48> + return +}