Basics: Transformer Neural Networks: A Step-by-Step Breakdown
-
clone the repo, go the folder
-
Create a python venv
python3.11 -m venv .transformersEnv
-
source the venv
source .transformersEnv/bin/activate
-
install dependencies
pip install -r requirements.txt
-
run convert script
python bert-convert.py
orpython bert_pretrained.py
bert-convert.py script creates a onnx folder with Bert onnx modelbert-base-cased.onnx
with precision (float32)
bert_pretrained.py script creates a onnx_models folder with Bert onnx model i.e.,bert-base-cased-squad.onnx
Use Netron to verify and visualise onnx model
Use onnx-mlir to convert onnx models to LLVM dialect.
- Build on local or for quick conversions use Docker img Instructions
- Follow Environment Variables Setup
- To generate LLVM Dialect
onnx-mlir -O3 --EmitLLVMIR <onnx model file>
- (optional) creating executable binary example
- Build MLIR on local (preffered debug version) MLIR getting started
- (Optional) set path variable to mlir project bin folder
- use
mlir-translate <input-file-LLVM-dialect> --mlir-to-llvmir -o <output.ll>
to get LLVM IR.