[Mlir-commits] [mlir] [mlir][spirv] Convert `bf16` to `spirv` as a `i16` (PR #76114)
Rob Suderman
llvmlistbot at llvm.org
Wed Dec 20 17:24:42 PST 2023
https://github.com/rsuderman created https://github.com/llvm/llvm-project/pull/76114
`bf16` is not support currently in `spirv`. Current conversions treat it as an `i16` with bit-shifting, extending, and other manipulations. Change to `i16` appropriately.
>From 1bddf3e07bb95d6a71da56fb66a44e678f45cc74 Mon Sep 17 00:00:00 2001
From: Rob Suderman <rob.suderman at gmail.com>
Date: Wed, 20 Dec 2023 17:18:13 -0800
Subject: [PATCH] [mlir][spirv] Convert `bf16` to `spirv` as a `i16`
`bf16` is not support currently in `spirv`. Current conversions
treat it as an `i16` with bit-shifting, extending, and other
manipulations. Change to `i16` appropriately.
---
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index 2b79c8022b8e85..87f85314afad06 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -713,6 +713,9 @@ SPIRVTypeConverter::SPIRVTypeConverter(spirv::TargetEnvAttr targetAttr,
});
addConversion([this](FloatType floatType) -> std::optional<Type> {
+ if (floatType.isBF16())
+ return convertType(IntegerType::get(floatType.getContext(), 16));
+
if (auto scalarType = dyn_cast<spirv::ScalarType>(floatType))
return convertScalarType(this->targetEnv, this->options, scalarType);
return Type();
More information about the Mlir-commits
mailing list