From de69646b9b10845d912ac3196dc379802211bd8d Mon Sep 17 00:00:00 2001 From: nihuini Date: Thu, 20 Feb 2025 17:01:15 +0800 Subject: [PATCH] w --- .../param-and-model-file-structure.md | 5 +++++ tests/test_paramdict.cpp | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/developer-guide/param-and-model-file-structure.md b/docs/developer-guide/param-and-model-file-structure.md index 5f5c74d6865..676bacca160 100644 --- a/docs/developer-guide/param-and-model-file-structure.md +++ b/docs/developer-guide/param-and-model-file-structure.md @@ -43,6 +43,11 @@ the meaning of existing param key index can be looked up at [operation-param-wei * integer array value : [array size],int,int,...,int * float array value : [array size],float,float,...,float +In modern ncnn param file + +* array could be represented as `3=2.0,3.0` that is much more human friendly +* string typed value: `4=hello` and the string is no longer than 255 + ## net.bin ``` +---------+---------+---------+---------+---------+---------+ diff --git a/tests/test_paramdict.cpp b/tests/test_paramdict.cpp index 476fc1c3eea..219f07bb3b5 100644 --- a/tests/test_paramdict.cpp +++ b/tests/test_paramdict.cpp @@ -115,7 +115,7 @@ static int test_paramdict_0() static int test_paramdict_1() { ParamDictTest pdt; - pdt.load_param("0=-1 1=4, 2=0.01 3=-1.45e-2,"); + pdt.load_param("0=-1 1=4, 2=0.01 3=-1.45e-2,3.14"); // int int typei = pdt.type(0); @@ -173,14 +173,14 @@ static int test_paramdict_1() return -1; } ncnn::Mat af = pdt.get(3, ncnn::Mat()); - if (af.w != 1) + if (af.w != 2) { - fprintf(stderr, "test_paramdict float array size failed %d != 1\n", af.w); + fprintf(stderr, "test_paramdict float array size failed %d != 2\n", af.w); return -1; } - if (af[0] != -0.0145f) + if (af[0] != -0.0145f || af[1] != 3.14f) { - fprintf(stderr, "test_paramdict float array value failed %f\n", af[0]); + fprintf(stderr, "test_paramdict float array value failed %f %f\n", af[0], af[1]); return -1; } @@ -346,8 +346,9 @@ static int test_paramdict_4() 0x02, 0x00, 0x00, 0x00, 0x0a, 0xd7, 0x23, 0x3c, 0xf9, 0xa4, 0xff, 0xff, - 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x68, 0x91, 0x6d, 0xbc, + 0xc3, 0xf5, 0x48, 0x40, 0x17, 0xff, 0xff, 0xff }; @@ -410,14 +411,14 @@ static int test_paramdict_4() return -1; } ncnn::Mat af = pdt.get(3, ncnn::Mat()); - if (af.w != 1) + if (af.w != 2) { - fprintf(stderr, "test_paramdict float array size failed %d != 1\n", af.w); + fprintf(stderr, "test_paramdict float array size failed %d != 2\n", af.w); return -1; } - if (af[0] != -0.0145f) + if (af[0] != -0.0145f || af[1] != 3.14f) { - fprintf(stderr, "test_paramdict float array value failed %f\n", af[0]); + fprintf(stderr, "test_paramdict float array value failed %f %f\n", af[0], af[1]); return -1; }