[Mlir-commits] [mlir] [mlir][AMDGPU] Add scaled floating point conversion ops fp8 (PR #141554)
Krzysztof Drewniak
llvmlistbot at llvm.org
Mon Jun 9 08:28:17 PDT 2025
================
@@ -139,6 +171,36 @@ def AMDGPU_PackedTrunc2xFp8Op :
let hasVerifier = 1;
}
+def AMDGPU_PackedScaledTruncOp
+ : AMDGPU_Op<"packed_scaled_trunc", [Pure]>,
+ Arguments<(ins VectorOfLengthAndType<[2], [F32, F16, BF16]>:$source,
+ F32:$scale,
+ ConfinedAttr<I32Attr, [IntNonNegative, IntMaxValue<7>]>:$index,
+ Optional<AnyTypeOf<
+ [FixedVectorOfLengthAndType<[4], [F8E5M2, F8E4M3FN]>,
+ FixedVectorOfLengthAndType<[8], [F4E2M1FN]>]>>:$existing)>,
+ Results<(
+ outs AnyTypeOf<[FixedVectorOfLengthAndType<[4], [F8E5M2, F8E4M3FN]>,
+ FixedVectorOfLengthAndType<[8], [F4E2M1FN]>]>:$res)> {
+ let summary = "Round two floats into a packed vector of floats";
+ let description = [{
+ Scale and round the inputs `sourceA` and `sourceB` (which is undefined if not
+ specified) into the low or high word (bottom two or top two) elements
+ of the returned vector, keeping the other two elements of `existing`
+ unchanged if present (or undefined if it was not passed in).
+
+ The reason for this odd signature is that AMD GPUs cannot easily work with
+ sub-registers, and so the conversion intrinsics take 32-bit wide
+ packed vectors of float values.
+ }];
+ let assemblyFormat = [{
+ attr-dict $source `into` ($existing^):(`undef`)? `[` `index` $index `]`
----------------
krzysz00 wrote:
I'm not sure we need the word "index" in the assembly format, especially since it's confusable with a type
https://github.com/llvm/llvm-project/pull/141554
More information about the Mlir-commits
mailing list