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

Maksim Levental llvmlistbot at llvm.org
Tue Oct 31 16:37:12 PDT 2023


================
@@ -88,6 +88,20 @@ void PyGlobals::registerTypeCaster(MlirTypeID mlirTypeID,
   }
 }
 
+void PyGlobals::registerValueCaster(MlirTypeID mlirTypeID,
+                                    pybind11::function valueCaster,
+                                    bool replace) {
+  pybind11::object &found = valueCasterMap[mlirTypeID];
+  if (found && !found.is_none() && !replace)
+    throw std::runtime_error("Value caster is already registered: " +
+                             py::repr(found).cast<std::string>());
+  found = std::move(valueCaster);
+  const auto foundIt = valueCasterMapCache.find(mlirTypeID);
+  if (foundIt != valueCasterMapCache.end() && !foundIt->second.is_none()) {
----------------
makslevental wrote:

Mooted by removal of caches

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


More information about the Mlir-commits mailing list