[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
This commit is contained in:
Vladislav Vinogradov 2021-03-19 05:32:19 +00:00 committed by Mehdi Amini
parent 16370e02a7
commit 270a336ff4

View File

@ -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.