[npubinfmt/profile] New proposal for profile extra metadata
authorDongju Chae <dongju.chae@samsung.com>
Fri, 22 Jan 2021 04:45:22 +0000 (13:45 +0900)
committer파리차이카푸르/On-Device Lab(SR)/Engineer/삼성전자 <pk.kapoor@samsung.com>
Wed, 27 Jan 2021 09:54:36 +0000 (18:54 +0900)
This patch makes new proposal for profile extra metadata.
The two-level mapping table may be useful to users.

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

index fb8d371..210664f 100644 (file)
@@ -243,13 +243,26 @@ typedef struct {
  */
 typedef struct {
   uint32_t total_size;  /**< actual size of extended metadata, not 4K-multiplied one */
-  uint32_t entry_num;   /**< total number of entries (i.e., number of vISA insts) */
+
+  uint32_t node_table_size; /**< size of a node table (node ID to node name) */
+  uint32_t visa_table_size; /**< size of a visa table (visa ID to node ID) */
+
+  uint32_t node_entry_num;  /**< total number of node entries */
+  uint32_t visa_entry_num;  /**< total number of visa entries (i.e., number of vISA insts) */
+
   /**
-   * The below shows each entry's data format (little endian).
-   * - [ vISA ID : 4Bytes ][ length : 4Bytes ][ data : 'length' Bytes ]
+   * The below shows the data format that 'entry_data' should have (little endian).
+   *
+   * 'entry_data'
+   * - [ node_table : 'node_table_size' Bytes ][ visa_table : 'visa_table_size' Bytes ]
+   *
+   * 'node_table'
+   * - [ node_id : uint32_t ][ length : uint32_t ][ data : 'length' Bytes ]
+   * - if 'data' has a string type, it should be null-terminated and its 'length' includes it.
    *
-   * If 'data' is string type, it should be null-terminated and its 'length' includes it.
-   * Note that when 'length' is zero, the following 'data' is empty.
+   * 'visa_table'
+   * - [ visa_id : uint32_t ][ node_num : uint32_t ][ node_ids : node_num * uint32_t ]
+   * - if 'node_num' is zero, 'node_ids' would be empty.
    */
   char entry_data[];
 } __attribute__((packed, aligned)) npubin_meta_profile;
index f0433a7..bb6e762 100644 (file)
@@ -26,6 +26,7 @@
 #define ENV_PREFIX_SHARE "NE_PREFIX_SHARE"
 #define DEFAULT_PREFIX_SHARE "/opt/trinity/share"
 #define DEFAULT_PROFILE_PATH "/tmp"
+#define NEED_REVISION (0)
 
 class EmulTask {
   public:
@@ -654,6 +655,7 @@ TrinityEmulAPI::stop_target (int taskid) const
 void
 TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
 {
+#if NEED_REVISION
   std::vector<npu_profile_layer *> profile_layers;
   std::unordered_map<std::string, npu_profile_layer *> profile_layer_map;
   int dbuf_fd = task->get_extended_dbuf_fd ();
@@ -730,6 +732,7 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
     profile->layers = new_layers;
     profile->num_layers = num_layers;
   }
+#endif
 }
 
 int