Skip to content

Commit 26dc765

Browse files
authored
[mlir][python] remove eager loading of dialect module (for type and value casting) (llvm#72338)
1 parent 525396a commit 26dc765

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

mlir/lib/Bindings/Python/IRModule.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ PyGlobals::lookupAttributeBuilder(const std::string &attributeKind) {
132132

133133
std::optional<py::function> PyGlobals::lookupTypeCaster(MlirTypeID mlirTypeID,
134134
MlirDialect dialect) {
135-
// Make sure dialect module is loaded.
136-
if (!loadDialectModule(unwrap(mlirDialectGetNamespace(dialect))))
137-
return std::nullopt;
138-
135+
// Try to load dialect module.
136+
(void)loadDialectModule(unwrap(mlirDialectGetNamespace(dialect)));
139137
const auto foundIt = typeCasterMap.find(mlirTypeID);
140138
if (foundIt != typeCasterMap.end()) {
141139
assert(foundIt->second && "type caster is defined");
@@ -146,7 +144,8 @@ std::optional<py::function> PyGlobals::lookupTypeCaster(MlirTypeID mlirTypeID,
146144

147145
std::optional<py::function> PyGlobals::lookupValueCaster(MlirTypeID mlirTypeID,
148146
MlirDialect dialect) {
149-
loadDialectModule(unwrap(mlirDialectGetNamespace(dialect)));
147+
// Try to load dialect module.
148+
(void)loadDialectModule(unwrap(mlirDialectGetNamespace(dialect)));
150149
const auto foundIt = valueCasterMap.find(mlirTypeID);
151150
if (foundIt != valueCasterMap.end()) {
152151
assert(foundIt->second && "value caster is defined");

0 commit comments

Comments
 (0)