How to generate the Executable File in x86-linux
I've finished the build add.onnx, and then step by step down the dialect, and finally down to llvm IR, get the llvm IR file. If I want to generate executable files on the x86-Linux platform, what should I do?
I try to use the tool chain in llvm ./mlir-translate. I want to talk about that llvm IR is first converted into an object file, then C program is used to call the C interface in the object file, and finally link and compile to generate an executable file.
Thank you in advance.
You might find this tutorial helpful: http://onnx.ai/onnx-mlir//doxygen_html/index.html
@tjingrant thanks a lot~
@tjingrant Thanks for the web link, I have successfully generated the executable file, and can run the correct results. However, this method can not see the whole process of gradual decline of dialect clearly. I also read your paper about this project. I still want to reduce dialect step by step, and be able to see the result of every decline. Do you have any suggestions? Thank you very much.
@CHUNERnubi i'm not sure what's stopping you from seeing the intermediate results of gradual lowering. Do you mean that you want to "edit" the intermediate results and then continue? (which is only possible currently using onnx-mlir-opt)
I just want to know is there any way or method can generate .so file from LLVM IR Dialect file, using the toolchain which is builded by this project. Thanks a lot.
@CHUNERnubi Starting with an onnx file, "fn", you can use "onnx-mlir --EmitLib fn.onnx" to generate a "fn.so". If you want to start from an arbitrary mlir file, you would need to use onnx-mlir-opt, specifying all the passes you want to run and ending with an LLVM IR bitcode file. You could then take the bitcode file and use llopt and llc to generate the .so. Currently the end-to-end compilation only starts from and onnx file. If you feed it an mlir file, it wouldn't in general know what passes to run on that.
If you want just to start from an onnx file and see the intermediate results after each pass, you can use these options: --print-ir-after=
I want to implement the end-to-end process with the following process, but there are some problems in the end.
First, use . /onnx-mlir -- EmitLLVMIR to generate LLVM IR dialect file from .onnx file.
Then, use ./mlir-translate --mlir-to-llvmir to generate the .ll file.
Then, use ./llvm-as to generate .ll into .bc file, which is bitcode file.
Then, use ./llc to generate the .so file.
Finally, the executable file add is generated by gcc and main.c. But there is a problem here: file format not recognized; treating as linker script. How can I solve it? Thank you in advance.
I am a novice in this area, do face some difficulties, I can not solve it myself, hope to get help, thank you very much.
It seems that this is really a question for MLIR as you are trying to merge your add to the mlir-generated path. However, you can look at what we do in onnx-mlir to find a solution to your problem. Look at our src/Runtime. This is exactly the same as you are trying to do. Onnx-mlir generates calls to our runtime functions, and then we link them towards the end. We invoke many of the calls you describe above in our src/Compiler/CompilerUtils.cpp
I suggest that you try compiling everything using LLVM.
See also issue #1530