[Mlir-commits] [mlir] [mlir][python] remove various caching mechanism (PR #70831)

Maksim Levental llvmlistbot at llvm.org
Thu Nov 2 07:46:12 PDT 2023


================
@@ -57,15 +57,18 @@ void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
     break;
   }
 
+  if (loaded.is_none())
+    return false;
   // Note: Iterator cannot be shared from prior to loading, since re-entrancy
   // may have occurred, which may do anything.
-  loadedDialectModulesCache.insert(dialectNamespace);
+  loadedDialectModules.insert(dialectNamespace);
+  return true;
----------------
makslevental wrote:

> I don't see any previous negative caching at module level, am I missing something?

The negative cache currently works in that when a dialect is "looked up" but fails to have its module found (for lack of existence or lack of prefix search path) will still be `loadedDialectModulesCache.insert(dialectNamespace);` (the loop just finishes silently).

> Several lookup functions are calling this

That's true but there's only one (under reasonable circumstances) that could possibly actually trigger a load that doesn't succeed (as far as I can imagine): `lookupOperationClass` during `Operation.create` and only if you're creating an operation with/from an unregistered dialect.

> absence of the module for a specific dialect prefix

This is what the added test code below exercises, demonstrates (although obliquely). In the absense of the added `custom_dialect.custom.py`, it's exactly as you say (the lookup happens over and over) but with the addition of that module it only happens once.



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


More information about the Mlir-commits mailing list