diff options
author | James Ward <james.ward@arm.com> | 2022-12-07 15:38:01 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2023-01-18 01:04:54 +0000 |
commit | c15f7d52aa4f360eba2344449baa418b7608ac7c (patch) | |
tree | b0322cb02004e9e0a325c847c0bd332051b8389b /src | |
parent | 5e268097917825ddaa00a86ee95a4a6c4f50124b (diff) | |
download | serialization_lib-c15f7d52aa4f360eba2344449baa418b7608ac7c.tar.gz |
Schema changes for CLAMP, PAD float attributes
* Float attributes now serialized as uint8 vectors, but treated as floats at input/output to serialization
Signed-off-by: James Ward <james.ward@arm.com>
Change-Id: I417b0fabe0ef11fea263fe937b57d49bbfdb00da
Diffstat (limited to 'src')
-rw-r--r-- | src/tosa_serialization_handler.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tosa_serialization_handler.cpp b/src/tosa_serialization_handler.cpp index a4410f2..2062522 100644 --- a/src/tosa_serialization_handler.cpp +++ b/src/tosa_serialization_handler.cpp @@ -619,6 +619,14 @@ tosa_err_t TosaSerializationHandler::Deserialize(const uint8_t* buf) return TOSA_OK; } +std::vector<uint8_t> float_to_u8_wrapper(float f_in) +{ + const std::vector<float> f_vec{ f_in }; + std::vector<uint8_t> u8_out; + TosaSerializationHandler::ConvertF32toU8(f_vec, u8_out); + return u8_out; +} + tosa_err_t TosaSerializationHandler::Serialize() { // regions @@ -682,9 +690,11 @@ tosa_err_t TosaSerializationHandler::Serialize() fb_attribute = 0; break; #define DEF_ARGS_S_STR(NAME, V) , _builder.CreateString(reinterpret_cast<Tosa##NAME*>(op->GetAttribute())->V().c_str()) +#define DEF_ARGS_S_FP_as_U8(NAME, V) \ + , _builder.CreateVector<uint8_t>(float_to_u8_wrapper(reinterpret_cast<Tosa##NAME*>(op->GetAttribute())->V())) #define DEF_ARGS_S_DEFAULT(NAME, V) , reinterpret_cast<Tosa##NAME*>(op->GetAttribute())->V() #define DEF_ARGS_S_int32_t(NAME, V) DEF_ARGS_S_DEFAULT(NAME, V) -#define DEF_ARGS_S_float(NAME, V) DEF_ARGS_S_DEFAULT(NAME, V) +#define DEF_ARGS_S_float(NAME, V) DEF_ARGS_S_FP_as_U8(NAME, V) #define DEF_ARGS_S_bool(NAME, V) DEF_ARGS_S_DEFAULT(NAME, V) #define DEF_ARGS_S_ResizeMode(NAME, V) DEF_ARGS_S_DEFAULT(NAME, V) #define DEF_ARGS_S_DType(NAME, V) DEF_ARGS_S_DEFAULT(NAME, V) |