diff options
author | Tai Ly <tai.ly@arm.com> | 2024-04-05 01:19:31 +0000 |
---|---|---|
committer | Tai Ly <tai.ly@arm.com> | 2024-04-15 14:28:29 +0000 |
commit | 5d0e9c7f3748e80d6f14a3eeaef858eeb912e1fd (patch) | |
tree | d9dddba756207cee68b948d434502801be93d6c4 /reference_model/include | |
parent | 6dc755bf141726a7582ad1a844f97cb3f50c9b21 (diff) | |
download | reference_model-5d0e9c7f3748e80d6f14a3eeaef858eeb912e1fd.tar.gz |
[ref model] fix const/pad/clamp attribute serialization
This changes to use native type serialization and deserialization
for pad_const, clamp min_val/max_val and const data attribute values
whereby fp16 values are stored as 2 bytes each, fp8 values are stored
in 1 byte each, etc.
Signed-off-by: Tai Ly <tai.ly@arm.com>
Change-Id: Ia95d320fe8c546ce1d1ccc035d6e9bcaadcc9ca3
Diffstat (limited to 'reference_model/include')
-rw-r--r-- | reference_model/include/dtype.h | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/reference_model/include/dtype.h b/reference_model/include/dtype.h index a283f39..3463af9 100644 --- a/reference_model/include/dtype.h +++ b/reference_model/include/dtype.h @@ -89,26 +89,8 @@ inline const char* EnumNameTOSAREFTYPE(TOSA_REF_TYPE e) } // return corresponding TOSA_REF_TYPE for DType -inline TOSA_REF_TYPE ConvertDType(const DType dtype) +inline TOSA_REF_TYPE DType2RefType(const DType dtype) { - assert(DType_MAX == DType_FP8E5M2); // must update whenever DType_MAX changes - - if (g_func_config.precise_mode) - { - // in precise mode, convert all floating DType to TOSA_REF_TYPE_FP64 - switch (dtype) - { - case DType_FP16: - case DType_FP32: - case DType_BF16: - case DType_FP8E4M3: - case DType_FP8E5M2: - return TOSA_REF_TYPE_FP64; - default: - break; - } - } - switch (dtype) { case DType_BOOL: @@ -145,6 +127,31 @@ inline TOSA_REF_TYPE ConvertDType(const DType dtype) return TOSA_REF_TYPE_UNKNOWN; } +// return corresponding TOSA_REF_TYPE for DType +// if precise_mode, convert all floating dtype to FP64 +inline TOSA_REF_TYPE ConvertDType(const DType dtype) +{ + assert(DType_MAX == DType_FP8E5M2); // must update whenever DType_MAX changes + + if (g_func_config.precise_mode) + { + // in precise mode, convert all floating DType to TOSA_REF_TYPE_FP64 + switch (dtype) + { + case DType_FP16: + case DType_FP32: + case DType_BF16: + case DType_FP8E4M3: + case DType_FP8E5M2: + return TOSA_REF_TYPE_FP64; + default: + break; + } + } + + return DType2RefType(dtype); +} + template <TOSA_REF_TYPE Dtype> bool IsSignedInt() { |