Skip to content
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

[python] Add an iree.build package with API/tooling for program building. #18630

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
build/
build-*/
Testing/
# Include iree.build package
!compiler/bindings/python/iree/compiler/build/

# Bazel artifacts
**/bazel-*
Expand Down
31 changes: 31 additions & 0 deletions compiler/bindings/python/CMakeLists.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to test this locally on Windows since MLIR Python bindings tend to break in weird ways there. Bumped into an unrelated error first though: #18910 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will also require followons I expect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't want our 6 hour nightly Windows build to fail if we merge this before testing on Windows. (#18813 will get faster builds running more frequently)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm still reconstructing my Windows build environment... but I think I got enough signal from a partial build to trust this.

Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,37 @@ add_mlir_python_modules(IREECompilerPythonModules
)


################################################################################
# iree.build package
# This is a pure Python part of the namespace, not rooted under iree.compiler
# like the above. It is only using the same build support for compatibility
# with the existing development flow.
# If the build system for Python code is ever redone, this can just be
# source namespace in the project definition.
################################################################################

# The iree.build package.
declare_mlir_python_sources(IREECompilerBuildPythonPackage
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/build"
SOURCES
__init__.py
__main__.py
executor.py
lang.py
main.py
net_actions.py
onnx_actions.py
)

add_mlir_python_modules(IREECompilerBuildPythonModules
ROOT_PREFIX "${_PYTHON_BUILD_PREFIX}/iree/build"
INSTALL_PREFIX "${_PYTHON_INSTALL_PREFIX}/iree/build"
DECLARED_SOURCES
IREECompilerBuildPythonPackage
)

add_dependencies(IREECompilerPythonModules IREECompilerBuildPythonModules)

################################################################################
# Tools linked against the shared CAPI library
################################################################################
Expand Down
12 changes: 12 additions & 0 deletions compiler/bindings/python/iree/build/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import argparse

from iree.build.lang import *
from iree.build.main import *
from iree.build.net_actions import *
from iree.build.onnx_actions import *
11 changes: 11 additions & 0 deletions compiler/bindings/python/iree/build/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .main import CliMain


if __name__ == "__main__":
CliMain().run()
Loading
Loading