[Mlir-commits] [mlir] [mlir][python] value casting (PR #69644)

Maksim Levental llvmlistbot at llvm.org
Mon Oct 30 12:22:09 PDT 2023


================
@@ -1124,6 +1122,8 @@ class PyValue {
   /// Gets a capsule wrapping the void* within the MlirValue.
   pybind11::object getCapsule();
 
+  virtual pybind11::object maybeDownCast();
----------------
makslevental wrote:

This was a fun "whodoneit"; if you want RTTI to work correctly for `ConcreteValue` i.e., you want pybind to be able to figure out the correct thing to `py::cast` to (`OpResult` or `BlockArgument`), then you need at least [one virtual member](https://stackoverflow.com/a/11484105). Thanks @zero9178 for the tip!

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


More information about the Mlir-commits mailing list