onnx-mlir icon indicating copy to clipboard operation
onnx-mlir copied to clipboard

Add Python interface for compilation and one single interface for compilation and running process

Open Jiaqing-ASU opened this issue 2 years ago • 36 comments

An ONNX model can be compiled directly using the onnx-mlir -O3 --EmitLib command. The resulting library can then be executed using Python. At times, it might be convenient to also compile a model directly in Python. We explores the Python methods to do so. And we also design an interface to package the compilation and operation of the model.

Jiaqing-ASU avatar Sep 12 '22 17:09 Jiaqing-ASU

Can one of the admins verify this patch?

jenkins-droid avatar Sep 12 '22 17:09 jenkins-droid

@Jiaqing-ASU great, will review once #1683 has landed... thanks for working on this

AlexandreEichenberger avatar Sep 12 '22 20:09 AlexandreEichenberger

@Jiaqing-ASU great, will review once #1683 has landed... thanks for working on this

Please allow some time for me to modify some of the code in this PR after #1683 has landed. I will make this PR Ready to review once I am done. Many thanks!

Jiaqing-ASU avatar Sep 12 '22 20:09 Jiaqing-ASU

PR landed now, so you can update your changes with the latest main branch.

AlexandreEichenberger avatar Sep 13 '22 00:09 AlexandreEichenberger

Can one of the admins verify this patch?

jenkins-droid avatar Sep 13 '22 17:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 13 '22 17:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 13 '22 17:09 jenkins-droid

@jenkins-droid test this please

AlexandreEichenberger avatar Sep 13 '22 17:09 AlexandreEichenberger

Can one of the admins verify this patch?

jenkins-droid avatar Sep 13 '22 23:09 jenkins-droid

updating branch

AlexandreEichenberger avatar Sep 14 '22 14:09 AlexandreEichenberger

Can one of the admins verify this patch?

jenkins-droid avatar Sep 18 '22 17:09 jenkins-droid

updated the branch to run all cis

AlexandreEichenberger avatar Sep 19 '22 14:09 AlexandreEichenberger

updated the branch to run all cis

@AlexandreEichenberger Thanks for the merge. I guess this will pass the tests since it works in my environment. However, this are still several things of the new constructor need to be modify. I am working on this. Maybe you could review this later. Many thanks.

Jiaqing-ASU avatar Sep 19 '22 15:09 Jiaqing-ASU

yes, ping me when you feel its in a state where reviewing it make sense.

AlexandreEichenberger avatar Sep 19 '22 15:09 AlexandreEichenberger

Can one of the admins verify this patch?

jenkins-droid avatar Sep 20 '22 01:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 20 '22 01:09 jenkins-droid

updated to restart also the jenkins

AlexandreEichenberger avatar Sep 20 '22 13:09 AlexandreEichenberger

Can one of the admins verify this patch?

jenkins-droid avatar Sep 28 '22 15:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 28 '22 21:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 28 '22 21:09 jenkins-droid

The "undefined symbol" issues have been fixed by making the new class a subclass of onnx_mlir::ExecutionSession instead of onnx_mlir::PyExecutionSession. It now works very well. However, for now, there are about 150 lines of redundant code in onnx_mlir::PyExecutionSession and onnx_mlir::PyCompileExecutionSession. I think this can be fixed later or maybe there are other better solutions to solve this problem. @AlexandreEichenberger Please take a look at all the code and let me know if there is anything that needs to be fixed or you have any suggestions. Many thanks!

Jiaqing-ASU avatar Sep 28 '22 21:09 Jiaqing-ASU

Gave you comments on the interface itself. Will review code a bit later

No problem. Thanks for the helpful comments! I will fix all those comments one by one tomorrow. BTW, do you know why one of the checks MLIR-Windows-CI failing? How should I fix that?

Jiaqing-ASU avatar Sep 30 '22 03:09 Jiaqing-ASU

Can one of the admins verify this patch?

jenkins-droid avatar Sep 30 '22 17:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 30 '22 17:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 30 '22 17:09 jenkins-droid

Can one of the admins verify this patch?

jenkins-droid avatar Sep 30 '22 21:09 jenkins-droid

No problem. Thanks for the helpful comments! I will fix all those comments one by one tomorrow. BTW, do you know why one of the checks MLIR-Windows-CI failing? How should I fix that?

I don't have access to a window machine; I usually try to see from the failure log, if one is lucky, it is a compile error that one can typically google to find an answer. If one needs to run it, I ask some of the Microsoft folks to help. They can often tell you "oh, this is a well known difference, try this" type of comments

AlexandreEichenberger avatar Oct 03 '22 17:10 AlexandreEichenberger

I don't have access to a window machine; I usually try to see from the failure log, if one is lucky, it is a compile error that one can typically google to find an answer. If one needs to run it, I ask some of the Microsoft folks to help. They can often tell you "oh, this is a well known difference, try this" type of comments

Hello @AlexandreEichenberger I took a look at the errors and also searched on Google. The error is from a warning (it shows the following warning is treated as an error) which is called Compiler Warning (level 1) C4530. This warning is from the beginning of PYBIND11_MODULE(PyCompile, m). I have compared this part with the PyRuntime and they use exactly the same format. I am not sure whether I need to add /EHsc to compile to resolve the warning or not because I did not see this stuff in the previous Runtime CMakeLists. Another interesting thing is that this kind of warning is typically from some code using C++ exception handling but I do not think PyOMCompileSession.hpp has this kind of exception handling. I guess I need some hints or help on this error. Many thanks!

Jiaqing-ASU avatar Oct 04 '22 20:10 Jiaqing-ASU

Can one of the admins verify this patch?

jenkins-droid avatar Oct 04 '22 20:10 jenkins-droid

@Jiaqing-ASU if you still have the error, ask @sstamenova to help you, there are ways to disable the warning as errors for sections of the code.

AlexandreEichenberger avatar Oct 12 '22 16:10 AlexandreEichenberger