diff options
author | Tai Ly <tai.ly@arm.com> | 2023-05-05 18:04:36 +0000 |
---|---|---|
committer | Tai Ly <tai.ly@arm.com> | 2023-05-06 21:49:39 +0000 |
commit | 04992e45ad982ce34edacea9f9275ca122e47a75 (patch) | |
tree | 6843f96a84d9e07f220117949bd9faff64bfd4c3 /include | |
parent | 8ffce6d63372ea93f3e060571137bce11d4735d8 (diff) | |
download | tosa_mlir_translator-04992e45ad982ce34edacea9f9275ca122e47a75.tar.gz |
Add BuildMlirFromTosaFile API
This BuildMlirFromTosaFile API deserializes a tosa fbs or
json file and returns a mlir module as OwningOpRef<ModuleOp>
This also refactors the existing deserialization passes
to use the new API, and then copy the deserialized module's
main function into the existing function, and copy all
attributes of the new function and new module into the
existing function and module.
This allows testing of the new API by running deserialization
passes.
Here is an example showing the attributes on the deserialized
module and functions:
module attributes {tf_saved_model.semantics, tosa.description = "Tosa FBS Converted", tosa.fbs_version = "0.70.0d"} {
func.func @main(%arg0: tensor<1x256x256x3xui8> {tf_saved_model.index_path = ["input_0"]}) -> (tensor<1x1x17x3xf32> {tf_saved_model.index_path = ["output_0"]}) attributes {tf.entry_function = {inputs = "tosa_de
serialized_input_0:0", outputs = "tosa_deserialized_output_0:0"}, tf_saved_model.exported_names = ["tosa_deserialized"]} {
Signed-off-by: Tai Ly <tai.ly@arm.com>
Change-Id: Ia6c0202ef43ce5d37788cd459ed7c3f8424dd619
Diffstat (limited to 'include')
-rw-r--r-- | include/DeserializationPasses.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/DeserializationPasses.h b/include/DeserializationPasses.h index 1bc195a..1a38814 100644 --- a/include/DeserializationPasses.h +++ b/include/DeserializationPasses.h @@ -19,6 +19,8 @@ #include <memory> #include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project +#include "mlir/IR/BuiltinOps.h" // from @llvm-project +#include "mlir/IR/OwningOpRef.h" // from @llvm-project #include "mlir/Pass/Pass.h" // from @llvm-project namespace mlir { @@ -27,6 +29,13 @@ namespace tosa { std::unique_ptr<Pass> createTosaDeserializePass(); std::unique_ptr<Pass> createTosaDeserializeJSONPass(); +// deserializes a tosa file and return an mlir module +// if file_is_fbs is true, then treat file_name as a tosa flatbuffer file +// otherwise, treat file_name as a tosa json file +mlir::OwningOpRef<mlir::ModuleOp> +BuildMlirFromTosaFile(const char *file_name, mlir::MLIRContext *context, + bool file_is_fbs = true); + #define GEN_PASS_REGISTRATION #define GEN_PASS_CLASSES #include "include/DeserializationPasses.h.inc" |