This commit verifies the magiccode in npubinfmt's metadata.
Also, it updates related unitttests to use the default magiccode.
Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
memcpy (meta, binary, NPUBIN_META_SIZE);
+ /* check the metadata is really for SRNPU HW */
+ if (!CHECK_NPUBIN(meta->magiccode)) {
+ logerr (TAG, "invalid magiccode %llx\n", meta->magiccode);
+ return -EINVAL;
+ }
+
return 0;
}
hpriv.model_size += hwmem->size;
} else {
/* set dummy metadata */
+ mpriv->meta.magiccode = NPUBIN_MAGICCODE | 0x1;
mpriv->meta.type = SMODEL_OPS_NPU_ASR;
mpriv->meta.size = 0;
mpriv->meta.buffer_size = 4096;
/* make dummy model data */
npubin_meta meta = {
/* below are compiler stuff */
+ .magiccode = NPUBIN_MAGICCODE | 0x1,
.name = "dummy model",
.model_id = 1,
.model_version = 1,
#include "../../core/ne-conf.h"
/** @brief compare output result with the golden data */
-static int
+static int
compare_result (const void *data, uint32_t size)
{
/* @todo */
- return 0;
+ return 0;
}
/** @brief inference entry */
/* make dummy model data */
npubin_meta meta = {
/* below are compiler stuff */
+ .magiccode = NPUBIN_MAGICCODE | 0x1,
.name = "dummy model",
.model_id = 1,
.model_version = 1,
#include "../../core/ne-conf.h"
/** @brief compare output result with the golden data */
-static int
+static int
compare_result (const void *data, uint32_t size)
{
/* @todo */
- return 0;
+ return 0;
}
/** @brief inference entry */
/* make dummy model data */
npubin_meta meta = {
/* below are compiler stuff */
+ .magiccode = NPUBIN_MAGICCODE | 0x1,
.name = "dummy model",
.model_id = 1,
.model_version = 1,
#include "../ne_test_utils.h"
/** @brief compare output result with the golden data */
-static int
+static int
compare_result (const void *data, uint32_t size)
{
/* @todo */
- return 0;
+ return 0;
}
/** @brief inference entry */
/* make dummy model data */
npubin_meta meta = {
/* below are compiler stuff */
+ .magiccode = NPUBIN_MAGICCODE | 0x1,
.name = "dummy model",
.model_id = 1,
.model_version = 1,
static int total_fails;
/** @brief compare output result with the golden data */
-static int
+static int
compare_result (const char *golden_path, const char *output_data, uint64_t output_size)
{
FILE *fp = fopen (golden_path, "r");
}
total_succs = total_fails = 0;
-
+
result = run_inference (dev, argv[1]);
fprintf(stderr, "[APPTEST] %s: %s (%d/%d)\n", argv[0],
result == 0 ? "PASSED" : "FAILED",
total_succs, total_succs + total_fails);
-
+
free (dev);
return result;
* @param[in] name a string to be set to the name member of this meta
*/
static inline void set_default_val_to_meta (npubin_meta *meta, const char *name) {
+ meta->magiccode = NPUBIN_MAGICCODE | 0x1;
if (!name) {
strncpy (meta->name, "", max_len_model_name - 1);
} else {
}
/** configuration to fill the model meta */
-#define MAGICCODE 0x10101101
+#define MAGICCODE (NPUBIN_MAGICCODE | 0x1)
static const hostHandlerInfo *host_handle = NULL;
}
/** configuration to fill the model meta */
-#define MAGICCODE 0x10101101
+#define MAGICCODE (NPUBIN_MAGICCODE | 0x1)
#define STOP_SLEEP 1
#define SLEEP_DURATION 2