diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -868,7 +868,6 @@ mlirOpPrintingFlagsPrintGenericOpForm(flags); PyFileAccumulator accum(fileObject, binary); - py::gil_scoped_release(); mlirOperationPrintWithFlags(operation, flags, accum.getCallback(), accum.getUserData()); mlirOpPrintingFlagsDestroy(flags); diff --git a/mlir/lib/Bindings/Python/IRModule.cpp b/mlir/lib/Bindings/Python/IRModule.cpp --- a/mlir/lib/Bindings/Python/IRModule.cpp +++ b/mlir/lib/Bindings/Python/IRModule.cpp @@ -35,7 +35,6 @@ PyGlobals::~PyGlobals() { instance = nullptr; } void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) { - py::gil_scoped_acquire(); if (loadedDialectModulesCache.contains(dialectNamespace)) return; // Since re-entrancy is possible, make a copy of the search prefixes. @@ -46,7 +45,6 @@ moduleName.append(dialectNamespace.data(), dialectNamespace.size()); try { - py::gil_scoped_release(); loaded = py::module::import(moduleName.c_str()); } catch (py::error_already_set &e) { if (e.matches(PyExc_ModuleNotFoundError)) { @@ -64,7 +62,6 @@ void PyGlobals::registerDialectImpl(const std::string &dialectNamespace, py::object pyClass) { - py::gil_scoped_acquire(); py::object &found = dialectClassMap[dialectNamespace]; if (found) { throw SetPyError(PyExc_RuntimeError, llvm::Twine("Dialect namespace '") + @@ -77,7 +74,6 @@ void PyGlobals::registerOperationImpl(const std::string &operationName, py::object pyClass, py::object rawOpViewClass) { - py::gil_scoped_acquire(); py::object &found = operationClassMap[operationName]; if (found) { throw SetPyError(PyExc_RuntimeError, llvm::Twine("Operation '") + @@ -90,7 +86,6 @@ llvm::Optional PyGlobals::lookupDialectClass(const std::string &dialectNamespace) { - py::gil_scoped_acquire(); loadDialectModule(dialectNamespace); // Fast match against the class map first (common case). const auto foundIt = dialectClassMap.find(dialectNamespace); @@ -109,7 +104,6 @@ llvm::Optional PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) { { - py::gil_scoped_acquire(); auto foundIt = rawOpViewClassMapCache.find(operationName); if (foundIt != rawOpViewClassMapCache.end()) { if (foundIt->second.is_none()) @@ -126,7 +120,6 @@ // Attempt to find from the canonical map and cache. { - py::gil_scoped_acquire(); auto foundIt = rawOpViewClassMap.find(operationName); if (foundIt != rawOpViewClassMap.end()) { if (foundIt->second.is_none()) @@ -143,7 +136,6 @@ } void PyGlobals::clearImportCache() { - py::gil_scoped_acquire(); loadedDialectModulesCache.clear(); rawOpViewClassMapCache.clear(); }