[Mlir-commits] [mlir] [mlir][tosa] Add F32 to F16 type narrowing pass (PR #218900)
Luke Hutton
llvmlistbot at llvm.org
Tue Sep 1 07:57:58 PDT 2026
================
@@ -247,11 +255,16 @@ FailureOr<Attribute> convertDenseResourceElementsAttr(
ShapedType type, DenseResourceElementsAttr attr,
const TypeConverter &typeConverter, bool allowLossyConversion) {
static_assert(Kind == TosaNarrowKind::Int64ToInt32 ||
- Kind == TosaNarrowKind::Float64ToFloat32);
- using From =
- std::conditional_t<Kind == TosaNarrowKind::Int64ToInt32, int64_t, double>;
- using To =
- std::conditional_t<Kind == TosaNarrowKind::Int64ToInt32, int32_t, float>;
+ Kind == TosaNarrowKind::Float64ToFloat32 ||
+ Kind == TosaNarrowKind::Float32ToFloat16);
+ using From = std::conditional_t<
+ Kind == TosaNarrowKind::Int64ToInt32, int64_t,
+ std::conditional_t<Kind == TosaNarrowKind::Float64ToFloat32, double,
+ float>>;
+ using To = std::conditional_t<
+ Kind == TosaNarrowKind::Int64ToInt32, int32_t,
+ std::conditional_t<Kind == TosaNarrowKind::Float64ToFloat32, float,
+ uint16_t>>;
----------------
lhutton1 wrote:
Is it possible to use an APFloat as the underlying type for FP16 as opposed to uint16_t? I'm thinking this will make things slightly more readable
https://github.com/llvm/llvm-project/pull/218900
More information about the Mlir-commits
mailing list