Open
Conversation
tungld
reviewed
Feb 27, 2026
|
|
||
| [tool.hatch.build] | ||
| include = [ | ||
| "src/OMPyCompile/libs/*" |
| @@ -0,0 +1,53 @@ | |||
| <!--- SPDX-License-Identifier: Apache-2.0 --> | |||
| # OMPyInfer | |||
Member
There was a problem hiding this comment.
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 |
| @@ -0,0 +1,3 @@ | |||
| # IBM Confidential | |||
|
|
||
| ################# use_local_compiler.py ####################################### | ||
| # | ||
| # Copyright 2021-2025 The IBM Research Authors. |
| class CompileSession: | ||
| def __init__(self, model_path, **kwargs): | ||
| self.debug = False | ||
| # self.output_dir = tempfile.TemporaryDirectory() |
Member
There was a problem hiding this comment.
Could you initialize all members of this class here so that we know what are its members, e.g. self.compiler_image_name self.model_path, etc.?
| # Compiled library | ||
| if self.compile_options != "": | ||
| command_str += " " + self.compile_options | ||
| print(self.compile_options) |
Member
There was a problem hiding this comment.
Should we only print this in verbose/debug mode?
| self.container_model_dirname, self.model_basename | ||
| ) | ||
|
|
||
| print(command_str) |
Member
There was a problem hiding this comment.
Should we only print this in verbose/debug mode?
| def compile(model_path, **kwargs): | ||
| sess = CompileSession(model_path, **kwargs) | ||
| sess.Compile() | ||
| return sess.get_compiled_model_path() |
Member
There was a problem hiding this comment.
How about .constants.bin file or perhaps config file in the future? Do we need to return its path also?
| # Alternative implementation: use env variable ONNX_MLIR_HOME? | ||
| # compile_args is the flags passed to onnx-mlir | ||
| r = OMPyCompile.compile( | ||
| "./test_add.onnx", |
Member
There was a problem hiding this comment.
If we use test_add.mlir, we don't need to push test_add.onnx to the repository.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR refactored the previous onnxmlirdocker.py to keep only the compilation functionality. It provide a function, compile, to return the compiled model.
Though the compilation is provided simply with one python script file, I created a package for it. The reason is that it would be easier for user to install and use.
Examples can be found in the tests directory.
If container is used, change the compilation arguments to: