-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Revert "[mlir] Python: Parse ModuleOp from file path" #126482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 4e14b8a.
@llvm/pr-subscribers-mlir Author: Mehdi Amini (joker-eph) ChangesReverts llvm/llvm-project#125736 The gcc7 Bot is broken at the moment. Full diff: https://github.com/llvm/llvm-project/pull/126482.diff 6 Files Affected:
diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 14ccae650606af8..7d2fd89e8560fc9 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -309,10 +309,6 @@ MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateEmpty(MlirLocation location);
MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateParse(MlirContext context,
MlirStringRef module);
-/// Parses a module from file and transfers ownership to the caller.
-MLIR_CAPI_EXPORTED MlirModule
-mlirModuleCreateParseFromFile(MlirContext context, MlirStringRef fileName);
-
/// Gets the context that a module was created with.
MLIR_CAPI_EXPORTED MlirContext mlirModuleGetContext(MlirModule module);
diff --git a/mlir/include/mlir/Bindings/Python/Nanobind.h b/mlir/include/mlir/Bindings/Python/Nanobind.h
index bc8bddf4caf7e77..ca942c83d3e2fad 100644
--- a/mlir/include/mlir/Bindings/Python/Nanobind.h
+++ b/mlir/include/mlir/Bindings/Python/Nanobind.h
@@ -23,7 +23,6 @@
#endif
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
-#include <nanobind/stl/filesystem.h>
#include <nanobind/stl/function.h>
#include <nanobind/stl/optional.h>
#include <nanobind/stl/pair.h>
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 2e4b6d1ce35c1b6..47a85c2a486fd46 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include <filesystem>
#include <optional>
#include <utility>
@@ -300,7 +299,7 @@ struct PyAttrBuilderMap {
return *builder;
}
static void dunderSetItemNamed(const std::string &attributeKind,
- nb::callable func, bool replace) {
+ nb::callable func, bool replace) {
PyGlobals::get().registerAttributeBuilder(attributeKind, std::move(func),
replace);
}
@@ -3050,19 +3049,6 @@ void mlir::python::populateIRCore(nb::module_ &m) {
},
nb::arg("asm"), nb::arg("context").none() = nb::none(),
kModuleParseDocstring)
- .def_static(
- "parse",
- [](const std::filesystem::path &path,
- DefaultingPyMlirContext context) {
- PyMlirContext::ErrorCapture errors(context->getRef());
- MlirModule module = mlirModuleCreateParseFromFile(
- context->get(), toMlirStringRef(path.string()));
- if (mlirModuleIsNull(module))
- throw MLIRError("Unable to parse module assembly", errors.take());
- return PyModule::forModule(module).releaseObject();
- },
- nb::arg("asm"), nb::arg("context").none() = nb::none(),
- kModuleParseDocstring)
.def_static(
"create",
[](DefaultingPyLocation loc) {
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index 999e8cbda1295a1..f27af0ca9a2c78b 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -22,7 +22,6 @@
#include "mlir/IR/Location.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
-#include "mlir/IR/OwningOpRef.h"
#include "mlir/IR/Types.h"
#include "mlir/IR/Value.h"
#include "mlir/IR/Verifier.h"
@@ -329,15 +328,6 @@ MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module) {
return MlirModule{owning.release().getOperation()};
}
-MlirModule mlirModuleCreateParseFromFile(MlirContext context,
- MlirStringRef fileName) {
- OwningOpRef<ModuleOp> owning =
- parseSourceFile<ModuleOp>(unwrap(fileName), unwrap(context));
- if (!owning)
- return MlirModule{nullptr};
- return MlirModule{owning.release().getOperation()};
-}
-
MlirContext mlirModuleGetContext(MlirModule module) {
return wrap(unwrap(module).getContext());
}
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi b/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
index 096b87b36244368..fb7efb8cd28a5eb 100644
--- a/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
+++ b/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
@@ -46,7 +46,6 @@ import abc
import collections
from collections.abc import Callable, Sequence
import io
-from pathlib import Path
from typing import Any, ClassVar, TypeVar, overload
__all__ = [
@@ -2124,7 +2123,7 @@ class Module:
Creates an empty module
"""
@staticmethod
- def parse(asm: str | bytes | Path, context: Context | None = None) -> Module:
+ def parse(asm: str | bytes, context: Context | None = None) -> Module:
"""
Parses a module's assembly format from a string.
diff --git a/mlir/test/python/ir/module.py b/mlir/test/python/ir/module.py
index 441916b38ee73bb..ecafcb46af2175d 100644
--- a/mlir/test/python/ir/module.py
+++ b/mlir/test/python/ir/module.py
@@ -1,8 +1,6 @@
# RUN: %PYTHON %s | FileCheck %s
import gc
-from pathlib import Path
-from tempfile import NamedTemporaryFile
from mlir.ir import *
@@ -29,24 +27,6 @@ def testParseSuccess():
print(str(module))
-# Verify successful parse from file.
-# CHECK-LABEL: TEST: testParseFromFileSuccess
-# CHECK: module @successfulParse
-@run
-def testParseFromFileSuccess():
- ctx = Context()
- with NamedTemporaryFile(mode="w") as tmp_file:
- tmp_file.write(r"""module @successfulParse {}""")
- tmp_file.flush()
- module = Module.parse(Path(tmp_file.name), ctx)
- assert module.context is ctx
- print("CLEAR CONTEXT")
- ctx = None # Ensure that module captures the context.
- gc.collect()
- module.operation.verify()
- print(str(module))
-
-
# Verify parse error.
# CHECK-LABEL: TEST: testParseError
# CHECK: testParseError: <
|
Icohedron
pushed a commit
to Icohedron/llvm-project
that referenced
this pull request
Feb 11, 2025
Reverts llvm#125736 The gcc7 Bot is broken at the moment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
mlir:python
MLIR Python bindings
mlir
skip-precommit-approval
PR for CI feedback, not intended for review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts #125736
The gcc7 Bot is broken at the moment.