Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/Runtime/python/OMPyCompile/.gitignore
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__/
53 changes: 53 additions & 0 deletions src/Runtime/python/OMPyCompile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--- SPDX-License-Identifier: Apache-2.0 -->
# OMPyInfer
Copy link
Copy Markdown
Member

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.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this.

# © 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.

3 changes: 3 additions & 0 deletions src/Runtime/python/OMPyCompile/VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# IBM Confidential
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this.

# © Copyright IBM Corp. 2025
1.0.0
38 changes: 38 additions & 0 deletions src/Runtime/python/OMPyCompile/pyproject.toml
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/*"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Which libraries do we need?

]


5 changes: 5 additions & 0 deletions src/Runtime/python/OMPyCompile/src/OMPyCompile/__init__.py
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"]
Loading
Loading