aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Liardet <frederick.liardet@arm.com>2022-08-24 10:07:25 +0100
committerFrederick Liardet <frederick.liardet@arm.com>2022-08-31 16:47:30 +0100
commit62c1e95dc2f438e027f94e1dd2f486631489b189 (patch)
tree4460d880bcd6bbfe155a279c869de659e0e22116
parent545a508429afe1d22760563d252839e13ecd12a3 (diff)
downloadserialization_lib-experimental/tf28_compat.tar.gz
Add tosa identification numbersexperimental/tf28_compat
Signed-off-by: Frederick Liardet <frederick.liardet@arm.com> Change-Id: Idc5668fb01dc8dd657beb911d2cb9295f9275ac6
-rw-r--r--python/tosa_serializer.py5
-rw-r--r--src/tosa_serialization_handler.cpp6
2 files changed, 9 insertions, 2 deletions
diff --git a/python/tosa_serializer.py b/python/tosa_serializer.py
index 6915c83..b11f9cd 100644
--- a/python/tosa_serializer.py
+++ b/python/tosa_serializer.py
@@ -60,6 +60,9 @@ DTypeNames = [
"FLOAT",
]
+# File identifier needs to be kept in sync with schema/tosa.fbs
+TOSA_GRAPH_IDENTIFIER = b"\x54\x4F\x53\x41"
+
ByteMask = np.uint64(0xFF)
@@ -713,7 +716,7 @@ class TosaSerializer:
TosaGraph.TosaGraphAddBlocks(builder, fbv_bb)
graph = TosaGraph.TosaGraphEnd(builder)
- self.builder.Finish(graph)
+ self.builder.Finish(graph, TOSA_GRAPH_IDENTIFIER)
return self.builder.Output()
def writeJson(self, tosa_filename):
diff --git a/src/tosa_serialization_handler.cpp b/src/tosa_serialization_handler.cpp
index 547c3db..6799d71 100644
--- a/src/tosa_serialization_handler.cpp
+++ b/src/tosa_serialization_handler.cpp
@@ -354,6 +354,10 @@ tosa_err_t TosaSerializationHandler::Clear()
tosa_err_t TosaSerializationHandler::Deserialize(const uint8_t* buf)
{
+ if (!TosaGraphBufferHasIdentifier(buf))
+ {
+ printf("WARNING: TOSA file does not have TOSA file identifier\n");
+ }
auto fb_tosa_graph = GetTosaGraph(buf);
auto fb_tosa_version = fb_tosa_graph->version();
auto fb_tosa_blocks = fb_tosa_graph->blocks();
@@ -764,7 +768,7 @@ tosa_err_t TosaSerializationHandler::Serialize()
CreateVersion(_builder, TOSA_VERSION_MAJOR, TOSA_VERSION_MINOR, TOSA_VERSION_PATCH, TOSA_VERSION_DRAFT);
auto fb_graph = CreateTosaGraph(_builder, fb_version, fb_blocks);
- _builder.Finish(fb_graph);
+ _builder.Finish(fb_graph, TosaGraphIdentifier());
return TOSA_OK;
}