[npubinfmt] Add extended metasize to npubinfmt.h
authorDongju Chae <dongju.chae@samsung.com>
Fri, 9 Jul 2021 05:58:39 +0000 (14:58 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 12 Jul 2021 09:17:08 +0000 (18:17 +0900)
This patch explicltly adds extended metasize to npubinfmt.h.
The related macros are deprecated when the size is larger than 1MB.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
include/common/npubinfmt.h

index 47e8d29..a597e01 100644 (file)
 
 /* size of metadata */
 
-/* unit size of metadata (minimal size) */
+/* @brief unit size of metadata (minimal size) */
 #define NPUBIN_META_SIZE (4096)
-/* number of extended metadata */
+
+/**
+ * @deprecated valid if extended metasize < 1MB. otherwise, use 'extended_metasize' field.
+ * @brief number of extended metadata
+ */
 #define NPUBIN_META_NUM_EXTENDED(magiccode) (((magiccode) >> 8) & 0xFFULL)
 
-/* @brief return extended metadata size of npu binary */
+/**
+ * @deprecated valid if extended metasize < 1MB. otherwise, use 'extended_metasize' field.
+ * @brief return extended metadata size of npu binary
+ */
 static inline uint64_t
 NPUBIN_META_EXTENDED_SIZE (uint64_t magiccode) {
   uint64_t num_extended = NPUBIN_META_NUM_EXTENDED (magiccode);
@@ -36,7 +43,10 @@ NPUBIN_META_EXTENDED_SIZE (uint64_t magiccode) {
   return num_extended * NPUBIN_META_SIZE;
 }
 
-/* @brief return total metadata size of npu binary, including extended data */
+/**
+ * @deprecated valid if extended metasize < 1MB. otherwise, use 'extended_metasize' field.
+ * @brief return total metadata size of npu binary, including extended data
+ */
 static inline uint64_t
 NPUBIN_META_TOTAL_SIZE (uint64_t magiccode) {
   uint64_t size_extended = NPUBIN_META_EXTENDED_SIZE (magiccode);
@@ -103,6 +113,9 @@ typedef struct {
        * CHECK_NPUBIN(magiccode) should be true. Also, its least significant byte indicates
        * the npubinfmt's version. E.g., if npubinfmt is v2, NPUBIN_VERSION(magiccode) == 2.
        *
+       * CAUTION: the following descriptions for extended metadata are valid only when
+       * 'extended_metasize' field is zero. Otherwise, 'EXTENDED' bits are ignored.
+       *
        * Also, the size of metadata can be extended depending on the 'EXTENDED' field. E.g.,
        * if 'EXTENDED' is 0, the size of metadata is NPUBIN_META_SIZE. If it's larger than 0,
        * the actual size of metadata is NPUBIN_META_SIZE + NPUBIN_META_EXTENDED_SIZE(magiccode),
@@ -133,8 +146,8 @@ typedef struct {
       /**< Size of this model, including this meta */
       model_opmode type;
       /**< Type of the model, consistent with model_opmode. Refer to typedef.h */
-      uint32_t dummy;
-      /**< FIXME: Dummy field to keep an aligned offset */
+      uint32_t extended_metasize;
+      /**< The size of extended metadata */
 
       /**
        * If input comes from host, the buffer may be filled with input data.