[Mlir-commits] [mlir] [mlir][ArithToAMDGPU] Add option for saturating truncation to fp8 (PR #74153)

Jakub Kuderski llvmlistbot at llvm.org
Tue Jan 9 20:36:25 PST 2024


================
@@ -127,6 +130,60 @@ static Value castToF32(Value value, Location loc, PatternRewriter &rewriter) {
   llvm_unreachable("The only 32-bit float type is f32");
 }
 
+static Value getMaybeVectorConstant(PatternRewriter &rewriter, Location loc,
+                                    const APFloat &value, Type type) {
+  if (isa<FloatType>(type))
+    return rewriter.createOrFold<arith::ConstantOp>(
+        loc, type, rewriter.getFloatAttr(type, value));
+  TypedAttr splat = DenseElementsAttr::get(cast<ShapedType>(type), value);
----------------
kuhar wrote:

```suggestion
  TypedAttr splat = SplatElementsAttr::get(cast<ShapedType>(type), value);
```

https://github.com/llvm/llvm-project/pull/74153


More information about the Mlir-commits mailing list