You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_paramdict.cpp 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2025 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #include <stdio.h>
  15. #include "datareader.h"
  16. #include "paramdict.h"
  17. class ParamDictTest : public ncnn::ParamDict
  18. {
  19. public:
  20. int load_param(const char* str);
  21. int load_param_bin(const unsigned char* mem);
  22. };
  23. int ParamDictTest::load_param(const char* str)
  24. {
  25. const unsigned char* mem = (const unsigned char*)str;
  26. ncnn::DataReaderFromMemory dr(mem);
  27. return ncnn::ParamDict::load_param(dr);
  28. }
  29. int ParamDictTest::load_param_bin(const unsigned char* mem)
  30. {
  31. ncnn::DataReaderFromMemory dr(mem);
  32. return ncnn::ParamDict::load_param_bin(dr);
  33. }
  34. static int test_paramdict_0()
  35. {
  36. ParamDictTest pdt;
  37. pdt.load_param("0=100 1=1,-1,4,5,1,4 2=1.250000 -23303=5,0.1,0.2,-0.4,0.8,1.0 -23304=3,-1,10,-88");
  38. // int
  39. int typei = pdt.type(0);
  40. if (typei != 2)
  41. {
  42. fprintf(stderr, "test_paramdict int type failed %d != 2\n", typei);
  43. return -1;
  44. }
  45. int i = pdt.get(0, 0);
  46. if (i != 100)
  47. {
  48. fprintf(stderr, "test_paramdict int value failed %d != 100\n", i);
  49. return -1;
  50. }
  51. // int array
  52. int typeai = pdt.type(1);
  53. if (typeai != 5)
  54. {
  55. fprintf(stderr, "test_paramdict int array type failed %d != 5\n", typeai);
  56. return -1;
  57. }
  58. ncnn::Mat ai = pdt.get(1, ncnn::Mat());
  59. if (ai.w != 6)
  60. {
  61. fprintf(stderr, "test_paramdict int array size failed %d != 6\n", ai.w);
  62. return -1;
  63. }
  64. const int* p = ai;
  65. if (p[0] != 1 || p[1] != -1 || p[2] != 4 || p[3] != 5 || p[4] != 1 || p[5] != 4)
  66. {
  67. fprintf(stderr, "test_paramdict int array value failed %d %d %d %d %d %d\n", p[0], p[1], p[2], p[3], p[4], p[5]);
  68. return -1;
  69. }
  70. // float
  71. int typef = pdt.type(2);
  72. if (typef != 3)
  73. {
  74. fprintf(stderr, "test_paramdict float type failed %d != 3\n", typef);
  75. return -1;
  76. }
  77. float f = pdt.get(2, 0.f);
  78. if (f != 1.25f)
  79. {
  80. fprintf(stderr, "test_paramdict float value failed %f != 1.25f\n", f);
  81. return -1;
  82. }
  83. // float array
  84. int typeaf = pdt.type(3);
  85. if (typeaf != 6)
  86. {
  87. fprintf(stderr, "test_paramdict float array type failed %d != 6\n", typeaf);
  88. return -1;
  89. }
  90. ncnn::Mat af = pdt.get(3, ncnn::Mat());
  91. if (af.w != 5)
  92. {
  93. fprintf(stderr, "test_paramdict float array size failed %d != 5\n", af.w);
  94. return -1;
  95. }
  96. if (af[0] != 0.1f || af[1] != 0.2f || af[2] != -0.4f || af[3] != 0.8f || af[4] != 1.0f)
  97. {
  98. fprintf(stderr, "test_paramdict float array value failed %f %f %f %f %f\n", af[0], af[1], af[2], af[3], af[4]);
  99. return -1;
  100. }
  101. // int array
  102. typeai = pdt.type(4);
  103. if (typeai != 5)
  104. {
  105. fprintf(stderr, "test_paramdict int array type failed %d != 5\n", typeai);
  106. return -1;
  107. }
  108. ai = pdt.get(4, ncnn::Mat());
  109. if (ai.w != 3)
  110. {
  111. fprintf(stderr, "test_paramdict int array size failed %d != 3\n", ai.w);
  112. return -1;
  113. }
  114. p = ai;
  115. if (p[0] != -1 || p[1] != 10 || p[2] != -88)
  116. {
  117. fprintf(stderr, "test_paramdict int array value failed %d %d %d\n", p[0], p[1], p[2]);
  118. return -1;
  119. }
  120. return 0;
  121. }
  122. static int test_paramdict_1()
  123. {
  124. ParamDictTest pdt;
  125. pdt.load_param("0=-1 1=4, 2=0.01 3=-1.45e-2,3.14");
  126. // int
  127. int typei = pdt.type(0);
  128. if (typei != 2)
  129. {
  130. fprintf(stderr, "test_paramdict int type failed %d != 2\n", typei);
  131. return -1;
  132. }
  133. int i = pdt.get(0, 0);
  134. if (i != -1)
  135. {
  136. fprintf(stderr, "test_paramdict int value failed %d != -1\n", i);
  137. return -1;
  138. }
  139. // int array
  140. int typeai = pdt.type(1);
  141. if (typeai != 5)
  142. {
  143. fprintf(stderr, "test_paramdict int array type failed %d != 5\n", typeai);
  144. return -1;
  145. }
  146. ncnn::Mat ai = pdt.get(1, ncnn::Mat());
  147. if (ai.w != 1)
  148. {
  149. fprintf(stderr, "test_paramdict int array size failed %d != 1\n", ai.w);
  150. return -1;
  151. }
  152. const int* p = ai;
  153. if (p[0] != 4)
  154. {
  155. fprintf(stderr, "test_paramdict int array value failed %d\n", p[0]);
  156. return -1;
  157. }
  158. // float
  159. int typef = pdt.type(2);
  160. if (typef != 3)
  161. {
  162. fprintf(stderr, "test_paramdict float type failed %d != 3\n", typef);
  163. return -1;
  164. }
  165. float f = pdt.get(2, 0.f);
  166. if (f != 0.01f)
  167. {
  168. fprintf(stderr, "test_paramdict float value failed %f != 0.01f\n", f);
  169. return -1;
  170. }
  171. // float array
  172. int typeaf = pdt.type(3);
  173. if (typeaf != 6)
  174. {
  175. fprintf(stderr, "test_paramdict float array type failed %d != 6\n", typeaf);
  176. return -1;
  177. }
  178. ncnn::Mat af = pdt.get(3, ncnn::Mat());
  179. if (af.w != 2)
  180. {
  181. fprintf(stderr, "test_paramdict float array size failed %d != 2\n", af.w);
  182. return -1;
  183. }
  184. if (af[0] != -0.0145f || af[1] != 3.14f)
  185. {
  186. fprintf(stderr, "test_paramdict float array value failed %f %f\n", af[0], af[1]);
  187. return -1;
  188. }
  189. return 0;
  190. }
  191. static int test_paramdict_2()
  192. {
  193. ParamDictTest pdt;
  194. pdt.load_param("0=bij,bjk->bik 1=This_is_a_very_long_long_string 3=\"1,2,3 and 6.667 zzz\" 2=\"X\"");
  195. // string
  196. int types = pdt.type(0);
  197. if (types != 7)
  198. {
  199. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  200. return -1;
  201. }
  202. std::string s = pdt.get(0, "");
  203. if (s != "bij,bjk->bik")
  204. {
  205. fprintf(stderr, "test_paramdict string text failed %s != bij,bjk->bik\n", s.c_str());
  206. return -1;
  207. }
  208. // string
  209. types = pdt.type(1);
  210. if (types != 7)
  211. {
  212. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  213. return -1;
  214. }
  215. s = pdt.get(1, "");
  216. if (s != "This_is_a_very_long_long_string")
  217. {
  218. fprintf(stderr, "test_paramdict string text failed %s != This_is_a_very_long_long_string\n", s.c_str());
  219. return -1;
  220. }
  221. // string
  222. types = pdt.type(2);
  223. if (types != 7)
  224. {
  225. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  226. return -1;
  227. }
  228. s = pdt.get(2, "");
  229. if (s != "X")
  230. {
  231. fprintf(stderr, "test_paramdict string text failed %s != X\n", s.c_str());
  232. return -1;
  233. }
  234. // string
  235. types = pdt.type(3);
  236. if (types != 7)
  237. {
  238. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  239. return -1;
  240. }
  241. s = pdt.get(3, "");
  242. if (s != "1,2,3 and 6.667 zzz")
  243. {
  244. fprintf(stderr, "test_paramdict string text failed %s != \"1,2,3 and 6.667 zzz\"\n", s.c_str());
  245. return -1;
  246. }
  247. return 0;
  248. }
  249. static int test_paramdict_3()
  250. {
  251. const unsigned char mem[] = {
  252. 0x00, 0x00, 0x00, 0x00,
  253. 0x64, 0x00, 0x00, 0x00,
  254. 0xfb, 0xa4, 0xff, 0xff,
  255. 0x06, 0x00, 0x00, 0x00,
  256. 0x01, 0x00, 0x00, 0x00,
  257. 0xff, 0xff, 0xff, 0xff,
  258. 0x04, 0x00, 0x00, 0x00,
  259. 0x05, 0x00, 0x00, 0x00,
  260. 0x01, 0x00, 0x00, 0x00,
  261. 0x04, 0x00, 0x00, 0x00,
  262. 0x02, 0x00, 0x00, 0x00,
  263. 0x00, 0x00, 0xa0, 0x3f,
  264. 0xf9, 0xa4, 0xff, 0xff,
  265. 0x05, 0x00, 0x00, 0x00,
  266. 0xcd, 0xcc, 0xcc, 0x3d,
  267. 0xcd, 0xcc, 0x4c, 0x3e,
  268. 0xcd, 0xcc, 0xcc, 0xbe,
  269. 0xcd, 0xcc, 0x4c, 0x3f,
  270. 0x00, 0x00, 0x80, 0x3f,
  271. 0x17, 0xff, 0xff, 0xff
  272. };
  273. ParamDictTest pdt;
  274. pdt.load_param_bin(mem);
  275. // int
  276. int typei = pdt.type(0);
  277. if (typei != 1)
  278. {
  279. fprintf(stderr, "test_paramdict int type failed %d != 1\n", typei);
  280. return -1;
  281. }
  282. int i = pdt.get(0, 0);
  283. if (i != 100)
  284. {
  285. fprintf(stderr, "test_paramdict int value failed %d != 100\n", i);
  286. return -1;
  287. }
  288. // int array
  289. int typeai = pdt.type(1);
  290. if (typeai != 4)
  291. {
  292. fprintf(stderr, "test_paramdict int array type failed %d != 4\n", typeai);
  293. return -1;
  294. }
  295. ncnn::Mat ai = pdt.get(1, ncnn::Mat());
  296. if (ai.w != 6)
  297. {
  298. fprintf(stderr, "test_paramdict int array size failed %d != 6\n", ai.w);
  299. return -1;
  300. }
  301. const int* p = ai;
  302. if (p[0] != 1 || p[1] != -1 || p[2] != 4 || p[3] != 5 || p[4] != 1 || p[5] != 4)
  303. {
  304. fprintf(stderr, "test_paramdict int array value failed %d %d %d %d %d %d\n", p[0], p[1], p[2], p[3], p[4], p[5]);
  305. return -1;
  306. }
  307. // float
  308. int typef = pdt.type(2);
  309. if (typef != 1)
  310. {
  311. fprintf(stderr, "test_paramdict float type failed %d != 1\n", typef);
  312. return -1;
  313. }
  314. float f = pdt.get(2, 0.f);
  315. if (f != 1.25f)
  316. {
  317. fprintf(stderr, "test_paramdict float value failed %f != 1.25f\n", f);
  318. return -1;
  319. }
  320. // float array
  321. int typeaf = pdt.type(3);
  322. if (typeaf != 4)
  323. {
  324. fprintf(stderr, "test_paramdict float array type failed %d != 4\n", typeaf);
  325. return -1;
  326. }
  327. ncnn::Mat af = pdt.get(3, ncnn::Mat());
  328. if (af.w != 5)
  329. {
  330. fprintf(stderr, "test_paramdict float array size failed %d != 5\n", af.w);
  331. return -1;
  332. }
  333. if (af[0] != 0.1f || af[1] != 0.2f || af[2] != -0.4f || af[3] != 0.8f || af[4] != 1.0f)
  334. {
  335. fprintf(stderr, "test_paramdict float array value failed %f %f %f %f %f\n", af[0], af[1], af[2], af[3], af[4]);
  336. return -1;
  337. }
  338. return 0;
  339. }
  340. static int test_paramdict_4()
  341. {
  342. const unsigned char mem[] = {
  343. 0x00, 0x00, 0x00, 0x00,
  344. 0xff, 0xff, 0xff, 0xff,
  345. 0xfb, 0xa4, 0xff, 0xff,
  346. 0x01, 0x00, 0x00, 0x00,
  347. 0x04, 0x00, 0x00, 0x00,
  348. 0x02, 0x00, 0x00, 0x00,
  349. 0x0a, 0xd7, 0x23, 0x3c,
  350. 0xf9, 0xa4, 0xff, 0xff,
  351. 0x02, 0x00, 0x00, 0x00,
  352. 0x68, 0x91, 0x6d, 0xbc,
  353. 0xc3, 0xf5, 0x48, 0x40,
  354. 0x17, 0xff, 0xff, 0xff
  355. };
  356. ParamDictTest pdt;
  357. pdt.load_param_bin(mem);
  358. // int
  359. int typei = pdt.type(0);
  360. if (typei != 1)
  361. {
  362. fprintf(stderr, "test_paramdict int type failed %d != 1\n", typei);
  363. return -1;
  364. }
  365. int i = pdt.get(0, 0);
  366. if (i != -1)
  367. {
  368. fprintf(stderr, "test_paramdict int value failed %d != -1\n", i);
  369. return -1;
  370. }
  371. // int array
  372. int typeai = pdt.type(1);
  373. if (typeai != 4)
  374. {
  375. fprintf(stderr, "test_paramdict int array type failed %d != 4\n", typeai);
  376. return -1;
  377. }
  378. ncnn::Mat ai = pdt.get(1, ncnn::Mat());
  379. if (ai.w != 1)
  380. {
  381. fprintf(stderr, "test_paramdict int array size failed %d != 1\n", ai.w);
  382. return -1;
  383. }
  384. const int* p = ai;
  385. if (p[0] != 4)
  386. {
  387. fprintf(stderr, "test_paramdict int array value failed %d\n", p[0]);
  388. return -1;
  389. }
  390. // float
  391. int typef = pdt.type(2);
  392. if (typef != 1)
  393. {
  394. fprintf(stderr, "test_paramdict float type failed %d != 1\n", typef);
  395. return -1;
  396. }
  397. float f = pdt.get(2, 0.f);
  398. if (f != 0.01f)
  399. {
  400. fprintf(stderr, "test_paramdict float value failed %f != 0.01f\n", f);
  401. return -1;
  402. }
  403. // float array
  404. int typeaf = pdt.type(3);
  405. if (typeaf != 4)
  406. {
  407. fprintf(stderr, "test_paramdict float array type failed %d != 4\n", typeaf);
  408. return -1;
  409. }
  410. ncnn::Mat af = pdt.get(3, ncnn::Mat());
  411. if (af.w != 2)
  412. {
  413. fprintf(stderr, "test_paramdict float array size failed %d != 2\n", af.w);
  414. return -1;
  415. }
  416. if (af[0] != -0.0145f || af[1] != 3.14f)
  417. {
  418. fprintf(stderr, "test_paramdict float array value failed %f %f\n", af[0], af[1]);
  419. return -1;
  420. }
  421. return 0;
  422. }
  423. static int test_paramdict_5()
  424. {
  425. const unsigned char mem[] = {
  426. 0x98, 0xa4, 0xff, 0xff,
  427. 0x0c, 0x00, 0x00, 0x00,
  428. 0x62, 0x69, 0x6a, 0x2c,
  429. 0x62, 0x6a, 0x6b, 0x2d,
  430. 0x3e, 0x62, 0x69, 0x6b,
  431. 0x97, 0xa4, 0xff, 0xff,
  432. 0x1f, 0x00, 0x00, 0x00,
  433. 0x54, 0x68, 0x69, 0x73,
  434. 0x5f, 0x69, 0x73, 0x5f,
  435. 0x61, 0x5f, 0x76, 0x65,
  436. 0x72, 0x79, 0x5f, 0x6c,
  437. 0x6f, 0x6e, 0x67, 0x5f,
  438. 0x6c, 0x6f, 0x6e, 0x67,
  439. 0x5f, 0x73, 0x74, 0x72,
  440. 0x69, 0x6e, 0x67, 0x00,
  441. 0x96, 0xa4, 0xff, 0xff,
  442. 0x01, 0x00, 0x00, 0x00,
  443. 0x58, 0x00, 0x00, 0x00,
  444. 0x17, 0xff, 0xff, 0xff
  445. };
  446. ParamDictTest pdt;
  447. pdt.load_param_bin(mem);
  448. // string
  449. int types = pdt.type(0);
  450. if (types != 7)
  451. {
  452. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  453. return -1;
  454. }
  455. std::string s = pdt.get(0, "");
  456. if (s != "bij,bjk->bik")
  457. {
  458. fprintf(stderr, "test_paramdict string text failed %s != bij,bjk->bik\n", s.c_str());
  459. return -1;
  460. }
  461. // string
  462. types = pdt.type(1);
  463. if (types != 7)
  464. {
  465. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  466. return -1;
  467. }
  468. s = pdt.get(1, "");
  469. if (s != "This_is_a_very_long_long_string")
  470. {
  471. fprintf(stderr, "test_paramdict string text failed %s != This_is_a_very_long_long_string\n", s.c_str());
  472. return -1;
  473. }
  474. // string
  475. types = pdt.type(2);
  476. if (types != 7)
  477. {
  478. fprintf(stderr, "test_paramdict string type failed %d != 7\n", types);
  479. return -1;
  480. }
  481. s = pdt.get(2, "");
  482. if (s != "X")
  483. {
  484. fprintf(stderr, "test_paramdict string text failed %s != X\n", s.c_str());
  485. return -1;
  486. }
  487. return 0;
  488. }
  489. static int compare_paramdict(const ncnn::ParamDict& pd, const ncnn::ParamDict& pd0)
  490. {
  491. for (int id = 0;; id++)
  492. {
  493. const int type0 = pd0.type(id);
  494. if (type0 == 0)
  495. {
  496. break;
  497. }
  498. else if (type0 == 2)
  499. {
  500. const int i0 = pd0.get(id, 0);
  501. int i = pd.get(id, 0);
  502. if (i != i0)
  503. {
  504. fprintf(stderr, "compare_paramdict int failed %d != %d\n", i, i0);
  505. return -1;
  506. }
  507. }
  508. else if (type0 == 3)
  509. {
  510. const float f0 = pd0.get(id, 0.f);
  511. int f = pd.get(id, 0.f);
  512. if (f != f0)
  513. {
  514. fprintf(stderr, "compare_paramdict float failed %f != %f\n", f, f0);
  515. return -1;
  516. }
  517. }
  518. else if (type0 == 5)
  519. {
  520. const ncnn::Mat ai0 = pd0.get(id, ncnn::Mat());
  521. ncnn::Mat ai = pd.get(id, ncnn::Mat());
  522. if (ai.w != ai0.w)
  523. {
  524. fprintf(stderr, "compare_paramdict int array size failed %d != %d\n", ai.w, ai0.w);
  525. return -1;
  526. }
  527. for (int q = 0; q < ai0.w; q++)
  528. {
  529. int i0 = ((const int*)ai0)[q];
  530. int i = ((const int*)ai)[q];
  531. if (i != i0)
  532. {
  533. fprintf(stderr, "compare_paramdict int array element %d failed %d != %d\n", q, i, i0);
  534. return -1;
  535. }
  536. }
  537. }
  538. else if (type0 == 6)
  539. {
  540. const ncnn::Mat af0 = pd0.get(id, ncnn::Mat());
  541. ncnn::Mat af = pd.get(id, ncnn::Mat());
  542. if (af.w != af0.w)
  543. {
  544. fprintf(stderr, "compare_paramdict float array size failed %d != %d\n", af.w, af0.w);
  545. return -1;
  546. }
  547. for (int q = 0; q < af0.w; q++)
  548. {
  549. float f0 = af0[q];
  550. float f = af[q];
  551. if (f != f0)
  552. {
  553. fprintf(stderr, "compare_paramdict float array element %d failed %f != %f\n", q, f, f0);
  554. return -1;
  555. }
  556. }
  557. }
  558. else if (type0 == 7)
  559. {
  560. const std::string s0 = pd0.get(id, "");
  561. std::string s = pd.get(id, "");
  562. if (s != s0)
  563. {
  564. fprintf(stderr, "compare_paramdict string failed %s != %s\n", s.c_str(), s0.c_str());
  565. return -1;
  566. }
  567. }
  568. else
  569. {
  570. fprintf(stderr, "unexpected paramdict type %d\n", type0);
  571. return -1;
  572. }
  573. }
  574. return 0;
  575. }
  576. static int test_paramdict_6()
  577. {
  578. const int i0 = 11;
  579. const float f0 = -2.2f;
  580. const std::string s0 = "qwqwqwq";
  581. ncnn::Mat ai0(1);
  582. {
  583. int* p = ai0;
  584. p[0] = 233;
  585. }
  586. ncnn::Mat af0(4);
  587. {
  588. float* p = af0;
  589. p[0] = 2.33f;
  590. p[1] = -0.2f;
  591. p[2] = 0.f;
  592. p[3] = 9494.f;
  593. }
  594. ncnn::ParamDict pd0;
  595. pd0.set(1, i0);
  596. pd0.set(2, ai0);
  597. pd0.set(3, f0);
  598. pd0.set(4, af0);
  599. pd0.set(5, s0);
  600. // copy
  601. {
  602. ncnn::ParamDict pd(pd0);
  603. int ret = compare_paramdict(pd, pd0);
  604. if (ret != 0)
  605. {
  606. fprintf(stderr, "paramdict copy failed\n");
  607. return -1;
  608. }
  609. }
  610. // assign
  611. {
  612. ncnn::ParamDict pd;
  613. pd = pd0;
  614. int ret = compare_paramdict(pd, pd0);
  615. if (ret != 0)
  616. {
  617. fprintf(stderr, "paramdict assign failed\n");
  618. return -1;
  619. }
  620. }
  621. return 0;
  622. }
  623. int main()
  624. {
  625. return 0
  626. || test_paramdict_0()
  627. || test_paramdict_1()
  628. || test_paramdict_2()
  629. || test_paramdict_3()
  630. || test_paramdict_4()
  631. || test_paramdict_5()
  632. || test_paramdict_6();
  633. }