heir
heir copied to clipboard
Tensorflow to TOSA Documentation
How would one compile a Tensorflow program to HEIR's TOSA frontend?
Hey! Good question. I will port over the docs from https://github.com/google/fully-homomorphic-encryption/tree/main/transpiler/tensorflow to HEIR, but here are the relevant lines
If you would like to transpile an existing TFLite model, you will also need to install the following tools:
git clone [email protected]:tensorflow/tensorflow.git && cd tensorflow
bazel build -c opt tensorflow/compiler/mlir/lite:flatbuffer_translate
See the instructions here to use a local LLVM build,
- tf-opt. For example, use
bazel build -c opt tensorflow/compiler/mlir:tf-opt
- Convert the TensorFlow Lite model to TOSA MLIR.
flatbuffer_translate --tflite-flatbuffer-to-mlir ${INPUT_TFLITE} | tf-opt --tf-tfl-to-tosa-pipeline --tosa-strip-quant-types -o ${OUTPUT_TOSA}
I think there should be a way to avoid tf-lite, and maybe these docs could give a head start https://discuss.tensorflow.org/t/conversion-of-tensorflow-graphdef-to-only-tosa-mlir-using-python-apis/21866/3