@@ -35,7 +35,6 @@ PyGlobals::PyGlobals() {
35
35
PyGlobals::~PyGlobals () { instance = nullptr ; }
36
36
37
37
void PyGlobals::loadDialectModule (llvm::StringRef dialectNamespace) {
38
- py::gil_scoped_acquire ();
39
38
if (loadedDialectModulesCache.contains (dialectNamespace))
40
39
return ;
41
40
// Since re-entrancy is possible, make a copy of the search prefixes.
@@ -46,7 +45,6 @@ void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
46
45
moduleName.append (dialectNamespace.data (), dialectNamespace.size ());
47
46
48
47
try {
49
- py::gil_scoped_release ();
50
48
loaded = py::module::import (moduleName.c_str ());
51
49
} catch (py::error_already_set &e) {
52
50
if (e.matches (PyExc_ModuleNotFoundError)) {
@@ -64,7 +62,6 @@ void PyGlobals::loadDialectModule(llvm::StringRef dialectNamespace) {
64
62
65
63
void PyGlobals::registerDialectImpl (const std::string &dialectNamespace,
66
64
py::object pyClass) {
67
- py::gil_scoped_acquire ();
68
65
py::object &found = dialectClassMap[dialectNamespace];
69
66
if (found) {
70
67
throw SetPyError (PyExc_RuntimeError, llvm::Twine (" Dialect namespace '" ) +
@@ -77,7 +74,6 @@ void PyGlobals::registerDialectImpl(const std::string &dialectNamespace,
77
74
void PyGlobals::registerOperationImpl (const std::string &operationName,
78
75
py::object pyClass,
79
76
py::object rawOpViewClass) {
80
- py::gil_scoped_acquire ();
81
77
py::object &found = operationClassMap[operationName];
82
78
if (found) {
83
79
throw SetPyError (PyExc_RuntimeError, llvm::Twine (" Operation '" ) +
@@ -90,7 +86,6 @@ void PyGlobals::registerOperationImpl(const std::string &operationName,
90
86
91
87
llvm::Optional<py::object>
92
88
PyGlobals::lookupDialectClass (const std::string &dialectNamespace) {
93
- py::gil_scoped_acquire ();
94
89
loadDialectModule (dialectNamespace);
95
90
// Fast match against the class map first (common case).
96
91
const auto foundIt = dialectClassMap.find (dialectNamespace);
@@ -109,7 +104,6 @@ PyGlobals::lookupDialectClass(const std::string &dialectNamespace) {
109
104
llvm::Optional<pybind11::object>
110
105
PyGlobals::lookupRawOpViewClass (llvm::StringRef operationName) {
111
106
{
112
- py::gil_scoped_acquire ();
113
107
auto foundIt = rawOpViewClassMapCache.find (operationName);
114
108
if (foundIt != rawOpViewClassMapCache.end ()) {
115
109
if (foundIt->second .is_none ())
@@ -126,7 +120,6 @@ PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) {
126
120
127
121
// Attempt to find from the canonical map and cache.
128
122
{
129
- py::gil_scoped_acquire ();
130
123
auto foundIt = rawOpViewClassMap.find (operationName);
131
124
if (foundIt != rawOpViewClassMap.end ()) {
132
125
if (foundIt->second .is_none ())
@@ -143,7 +136,6 @@ PyGlobals::lookupRawOpViewClass(llvm::StringRef operationName) {
143
136
}
144
137
145
138
void PyGlobals::clearImportCache () {
146
- py::gil_scoped_acquire ();
147
139
loadedDialectModulesCache.clear ();
148
140
rawOpViewClassMapCache.clear ();
149
141
}
0 commit comments