-
Notifications
You must be signed in to change notification settings - Fork 412
Create package of OMPyCompile #3399
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Ignore directories for build or install with -e | ||
| dist/ | ||
| src/OMPyCompile/__pycache__/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <!--- SPDX-License-Identifier: Apache-2.0 --> | ||
| # OMPyInfer | ||
| This package provides a python driver to run inference on ONNX model compiled onnx-mlir. | ||
| There is a helloworld example in the tests folder with the package: | ||
| ``` | ||
| # IBM Confidential | ||
|
||
| # © Copyright IBM Corp. 2025 | ||
|
|
||
| import numpy as np | ||
| import OMPyInfer | ||
|
|
||
| # Initialize the inference session | ||
| # The onnx model simply performs tensor add on two 3x4x5xf32 tensors | ||
| # It is compiled into test_add.so with zDLC | ||
| sess = OMPyInfer.InferenceSession("./test_add.so") | ||
|
|
||
| # Prepare the inputs | ||
| a = np.arange(3 * 4 * 5, dtype=np.float32).reshape((3, 4, 5)) | ||
| b = a + 4 | ||
|
|
||
| # Run inference | ||
| r = sess.run([a, b]) | ||
|
|
||
| # Print output | ||
| print(r) | ||
| ``` | ||
|
|
||
| ## Compile onnx model to shared library | ||
| TBD | ||
|
|
||
|
|
||
| ## Pre-requisites for OMPyInfer | ||
| These pre-requisities are currently provided as part of the OMPyInfer package for Python versions 3.9 until 3.13. | ||
| Prebuilt libraries for Linux on Z is provided. | ||
| Follow these instructions (TBD) to build the libraries for your own system. | ||
|
|
||
| ## Install | ||
| Currently, only local installation is supported. | ||
| Suppose you have onnx-mlir cloned on your machine. Install OMPyInfer with the following command: | ||
| ``` | ||
| python onnx-mlir/src/Runtime/python/OMPyInfer | ||
| ``` | ||
|
|
||
|
|
||
| ## Verify | ||
| ``` | ||
| cd OMPyInfer/tests | ||
| python helloworld.py | ||
| ``` | ||
|
|
||
| ## VERSIONS | ||
| Version 1.0.0 supports the model copied with onnx-mlir before 29bde823f, 2026-02-04. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # IBM Confidential | ||
|
||
| # © Copyright IBM Corp. 2025 | ||
| 1.0.0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
| [project] | ||
| name = "OMPyCompile" | ||
| version = "1.0.0" | ||
| authors = [ | ||
| { name="Tong Chen", email="chentong@us.ibm.com" }, | ||
| { name="Sunny Anand", email="sunny.anand79@ibm.com" }, | ||
| ] | ||
| description = "Python driver to run inference on onnx model compiled with zdlc" | ||
| readme = "README.md" | ||
| requires-python = ">=3.9" | ||
| license = "Apache-2.0" | ||
| classifiers = [ | ||
| "Programming Language :: Python :: 3", | ||
| "Operating System :: POSIX :: Linux", | ||
| ] | ||
|
|
||
| dependencies = [ | ||
| "docker" | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/onnx/onnx-mlir" | ||
| Issues = "https://github.com/onnx/onnx-mlir/issues" | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/OMPyCompile"] | ||
|
|
||
| [tool.hatch.build] | ||
| include = [ | ||
| "src/OMPyCompile/libs/*" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which libraries do we need? |
||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from .onnxmlirdockercompile import compile | ||
|
|
||
| __all__ = ["compile"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMPyCompile? Look like this file was copied from PyInfer.