[Mlir-commits] [mlir] [mlir][python] fix `replace=True` for `register_operation` and `register_type_caster` (PR #70264)

Maksim Levental llvmlistbot at llvm.org
Wed Oct 25 17:33:09 PDT 2023


================
@@ -510,6 +510,17 @@ def type_caster(pytype):
         except RuntimeError as e:
             print(e)
 
+        def type_caster(pytype):
+            return RankedTensorType(pytype)
+
+        register_type_caster(c.typeid, type_caster, replace=True)
+
+        d = tensor.EmptyOp([10, 10], IntegerType.get_signless(5)).result
+        # CHECK: tensor<10x10xi5>
+        print(d.type)
+        # CHECK: ranked tensor type RankedTensorType(tensor<10x10xi5>)
+        print("ranked tensor type", repr(d.type))
----------------
makslevental wrote:

`python_test` dialect registers a caster for `RankedTensorType` in [its extension](https://github.com/llvm/llvm-project/blob/bfb1ba752655bf09b35c486f6cc9817dbedfb1bb/mlir/test/python/lib/PythonTestModule.cpp#L72).

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


More information about the Mlir-commits mailing list