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 @@ -566,6 +566,19 @@ return rewriter.create(loc, resultTypes, args, mlir::None); + // Unsigned integers need an unrealized cast so that they can be passed + // to UIToFP. + if (srcTy.isUnsignedInteger() && dstTy.isa()) { + auto unrealizedCast = + rewriter + .create( + loc, rewriter.getIntegerType(srcTy.getIntOrFloatBitWidth()), + args[0]) + .getResult(0); + return rewriter.create(loc, resultTypes[0], + unrealizedCast); + } + // Casting to boolean, floats need to only be checked as not-equal to zero. if (srcTy.isa() && dstTy.isInteger(1)) { Value zero =