Skip to content

Commit

Permalink
[python] Add an iree.build package with API/tooling for program build…
Browse files Browse the repository at this point in the history
…ing.

Signed-off-by: Stella Laurenzo <stellaraccident@gmail.com>
  • Loading branch information
stellaraccident committed Oct 31, 2024
1 parent 2ec9017 commit 8502cdd
Show file tree
Hide file tree
Showing 13 changed files with 908 additions and 0 deletions.
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
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

0 comments on commit 8502cdd

Please sign in to comment.