Skip to content

Commit 67b7a25

Browse files
authored
Revert "[mlir] Python: Parse ModuleOp from file path" (llvm#126482)
Reverts llvm#125736 The gcc7 Bot is broken at the moment.
1 parent 30e7c10 commit 67b7a25

File tree

6 files changed

+2
-52
lines changed

6 files changed

+2
-52
lines changed

mlir/include/mlir-c/IR.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateEmpty(MlirLocation location);
309309
MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateParse(MlirContext context,
310310
MlirStringRef module);
311311

312-
/// Parses a module from file and transfers ownership to the caller.
313-
MLIR_CAPI_EXPORTED MlirModule
314-
mlirModuleCreateParseFromFile(MlirContext context, MlirStringRef fileName);
315-
316312
/// Gets the context that a module was created with.
317313
MLIR_CAPI_EXPORTED MlirContext mlirModuleGetContext(MlirModule module);
318314

mlir/include/mlir/Bindings/Python/Nanobind.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#endif
2424
#include <nanobind/nanobind.h>
2525
#include <nanobind/ndarray.h>
26-
#include <nanobind/stl/filesystem.h>
2726
#include <nanobind/stl/function.h>
2827
#include <nanobind/stl/optional.h>
2928
#include <nanobind/stl/pair.h>

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <filesystem>
109
#include <optional>
1110
#include <utility>
1211

@@ -300,7 +299,7 @@ struct PyAttrBuilderMap {
300299
return *builder;
301300
}
302301
static void dunderSetItemNamed(const std::string &attributeKind,
303-
nb::callable func, bool replace) {
302+
nb::callable func, bool replace) {
304303
PyGlobals::get().registerAttributeBuilder(attributeKind, std::move(func),
305304
replace);
306305
}
@@ -3050,19 +3049,6 @@ void mlir::python::populateIRCore(nb::module_ &m) {
30503049
},
30513050
nb::arg("asm"), nb::arg("context").none() = nb::none(),
30523051
kModuleParseDocstring)
3053-
.def_static(
3054-
"parse",
3055-
[](const std::filesystem::path &path,
3056-
DefaultingPyMlirContext context) {
3057-
PyMlirContext::ErrorCapture errors(context->getRef());
3058-
MlirModule module = mlirModuleCreateParseFromFile(
3059-
context->get(), toMlirStringRef(path.string()));
3060-
if (mlirModuleIsNull(module))
3061-
throw MLIRError("Unable to parse module assembly", errors.take());
3062-
return PyModule::forModule(module).releaseObject();
3063-
},
3064-
nb::arg("asm"), nb::arg("context").none() = nb::none(),
3065-
kModuleParseDocstring)
30663052
.def_static(
30673053
"create",
30683054
[](DefaultingPyLocation loc) {

mlir/lib/CAPI/IR/IR.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "mlir/IR/Location.h"
2323
#include "mlir/IR/Operation.h"
2424
#include "mlir/IR/OperationSupport.h"
25-
#include "mlir/IR/OwningOpRef.h"
2625
#include "mlir/IR/Types.h"
2726
#include "mlir/IR/Value.h"
2827
#include "mlir/IR/Verifier.h"
@@ -329,15 +328,6 @@ MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module) {
329328
return MlirModule{owning.release().getOperation()};
330329
}
331330

332-
MlirModule mlirModuleCreateParseFromFile(MlirContext context,
333-
MlirStringRef fileName) {
334-
OwningOpRef<ModuleOp> owning =
335-
parseSourceFile<ModuleOp>(unwrap(fileName), unwrap(context));
336-
if (!owning)
337-
return MlirModule{nullptr};
338-
return MlirModule{owning.release().getOperation()};
339-
}
340-
341331
MlirContext mlirModuleGetContext(MlirModule module) {
342332
return wrap(unwrap(module).getContext());
343333
}

mlir/python/mlir/_mlir_libs/_mlir/ir.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import abc
4646
import collections
4747
from collections.abc import Callable, Sequence
4848
import io
49-
from pathlib import Path
5049
from typing import Any, ClassVar, TypeVar, overload
5150

5251
__all__ = [
@@ -2124,7 +2123,7 @@ class Module:
21242123
Creates an empty module
21252124
"""
21262125
@staticmethod
2127-
def parse(asm: str | bytes | Path, context: Context | None = None) -> Module:
2126+
def parse(asm: str | bytes, context: Context | None = None) -> Module:
21282127
"""
21292128
Parses a module's assembly format from a string.
21302129

mlir/test/python/ir/module.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# RUN: %PYTHON %s | FileCheck %s
22

33
import gc
4-
from pathlib import Path
5-
from tempfile import NamedTemporaryFile
64
from mlir.ir import *
75

86

@@ -29,24 +27,6 @@ def testParseSuccess():
2927
print(str(module))
3028

3129

32-
# Verify successful parse from file.
33-
# CHECK-LABEL: TEST: testParseFromFileSuccess
34-
# CHECK: module @successfulParse
35-
@run
36-
def testParseFromFileSuccess():
37-
ctx = Context()
38-
with NamedTemporaryFile(mode="w") as tmp_file:
39-
tmp_file.write(r"""module @successfulParse {}""")
40-
tmp_file.flush()
41-
module = Module.parse(Path(tmp_file.name), ctx)
42-
assert module.context is ctx
43-
print("CLEAR CONTEXT")
44-
ctx = None # Ensure that module captures the context.
45-
gc.collect()
46-
module.operation.verify()
47-
print(str(module))
48-
49-
5030
# Verify parse error.
5131
# CHECK-LABEL: TEST: testParseError
5232
# CHECK: testParseError: <

0 commit comments

Comments
 (0)