[Mlir-commits] [mlir] [mlir][python] value casting (PR #69644)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed Oct 25 01:43:10 PDT 2023
================
@@ -123,3 +130,52 @@ def get_op_result_or_op_results(
if len(op.results) > 0
else op
)
+
+
+U = _TypeVar("U", bound=_cext.ir.Value)
+SubClassValueT = _Type[U]
+
+ValueCasterT = _Callable[
+ [_Union[_cext.ir.Value, _cext.ir.OpResult]], _Union[SubClassValueT, None]
+]
+
+_VALUE_CASTERS: defaultdict[
+ _cext.ir.TypeID,
+ _Sequence[ValueCasterT],
+] = defaultdict(list)
+
+
+def has_value_caster(typeid: _cext.ir.TypeID):
+ if not isinstance(typeid, _cext.ir.TypeID):
+ raise ValueError(f"{typeid=} is not a TypeID")
----------------
ftynse wrote:
Nit: I think this should be a `TypeError`.
https://github.com/llvm/llvm-project/pull/69644
More information about the Mlir-commits
mailing list