[Mlir-commits] [mlir] 270a336 - [mlir] Fix Python bindings tests failure in Debug mode after D98474
Mehdi Amini
llvmlistbot at llvm.org
Thu Mar 18 22:32:50 PDT 2021
Author: Vladislav Vinogradov
Date: 2021-03-19T05:32:32Z
New Revision: 270a336ff46204acf887def32c92ad695f767471
URL: https://github.com/llvm/llvm-project/commit/270a336ff46204acf887def32c92ad695f767471
DIFF: https://github.com/llvm/llvm-project/commit/270a336ff46204acf887def32c92ad695f767471.diff
LOG: [mlir] Fix Python bindings tests failure in Debug mode after D98474
Add extra `type.isa<FloatType>()` check to `FloatAttr::get(Type, double)` method.
Otherwise it tries to call `type.cast<FloatType>()`, which fails with assertion in Debug mode.
The `!type.isa<FloatType>()` case just redirercts the call to `FloatAttr::get(Type, APFloat)`,
which will perform the actual check and emit appropriate error.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D98764
Added:
Modified:
mlir/include/mlir/IR/BuiltinAttributes.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index 433c33521a7a..45214535b1f8 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -406,7 +406,7 @@ def Builtin_FloatAttr : Builtin_Attr<"Float"> {
return $_get(type.getContext(), type, value);
}]>,
AttrBuilderWithInferredContext<(ins "Type":$type, "double":$value), [{
- if (type.isF64())
+ if (type.isF64() || !type.isa<FloatType>())
return $_get(type.getContext(), type, APFloat(value));
// This handles, e.g., F16 because there is no APFloat constructor for it.
More information about the Mlir-commits
mailing list