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.

convolutiondepthwise.cpp 21 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2017 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 "convolutiondepthwise.h"
  15. #include "layer_type.h"
  16. #include "fused_activation.h"
  17. namespace ncnn {
  18. ConvolutionDepthWise::ConvolutionDepthWise()
  19. {
  20. one_blob_only = true;
  21. support_inplace = false;
  22. }
  23. int ConvolutionDepthWise::load_param(const ParamDict& pd)
  24. {
  25. num_output = pd.get(0, 0);
  26. kernel_w = pd.get(1, 0);
  27. kernel_h = pd.get(11, kernel_w);
  28. dilation_w = pd.get(2, 1);
  29. dilation_h = pd.get(12, dilation_w);
  30. stride_w = pd.get(3, 1);
  31. stride_h = pd.get(13, stride_w);
  32. pad_left = pd.get(4, 0);
  33. pad_right = pd.get(15, pad_left);
  34. pad_top = pd.get(14, pad_left);
  35. pad_bottom = pd.get(16, pad_top);
  36. pad_value = pd.get(18, 0.f);
  37. bias_term = pd.get(5, 0);
  38. weight_data_size = pd.get(6, 0);
  39. group = pd.get(7, 1);
  40. int8_scale_term = pd.get(8, 0);
  41. activation_type = pd.get(9, 0);
  42. activation_params = pd.get(10, Mat());
  43. dynamic_weight = pd.get(19, 0);
  44. if (dynamic_weight)
  45. {
  46. one_blob_only = false;
  47. }
  48. if (num_output % group != 0)
  49. {
  50. // reject invalid group
  51. return -100;
  52. }
  53. if (int8_scale_term)
  54. {
  55. #if NCNN_INT8
  56. support_int8_storage = true;
  57. #else
  58. NCNN_LOGE("please build ncnn with NCNN_INT8 enabled for int8 inference");
  59. return -1;
  60. #endif
  61. }
  62. return 0;
  63. }
  64. int ConvolutionDepthWise::load_model(const ModelBin& mb)
  65. {
  66. if (dynamic_weight)
  67. return 0;
  68. weight_data = mb.load(weight_data_size, 0);
  69. if (weight_data.empty())
  70. return -100;
  71. if (bias_term)
  72. {
  73. bias_data = mb.load(num_output, 1);
  74. if (bias_data.empty())
  75. return -100;
  76. }
  77. #if NCNN_INT8
  78. if (int8_scale_term == 1 || int8_scale_term == 101)
  79. {
  80. weight_data_int8_scales = mb.load(group, 1);
  81. bottom_blob_int8_scales = mb.load(1, 1);
  82. float bottom_blob_int8_scale = bottom_blob_int8_scales[0];
  83. bottom_blob_int8_scales = Mat(group);
  84. bottom_blob_int8_scales.fill(bottom_blob_int8_scale);
  85. }
  86. else if (int8_scale_term == 2 || int8_scale_term == 102)
  87. {
  88. weight_data_int8_scales = mb.load(1, 1);
  89. bottom_blob_int8_scales = mb.load(1, 1);
  90. // extend group if only one provided
  91. float weight_data_int8_scale = weight_data_int8_scales[0];
  92. weight_data_int8_scales = Mat(group);
  93. weight_data_int8_scales.fill(weight_data_int8_scale);
  94. float bottom_blob_int8_scale = bottom_blob_int8_scales[0];
  95. bottom_blob_int8_scales = Mat(group);
  96. bottom_blob_int8_scales.fill(bottom_blob_int8_scale);
  97. }
  98. if (int8_scale_term > 100)
  99. {
  100. top_blob_int8_scales = mb.load(1, 1);
  101. float top_blob_int8_scale = top_blob_int8_scales[0];
  102. top_blob_int8_scales = Mat(group);
  103. top_blob_int8_scales.fill(top_blob_int8_scale);
  104. }
  105. #endif // NCNN_INT8
  106. #if NCNN_INT8
  107. // runtime quantize the weight data
  108. if (weight_data.elemsize == (size_t)4u && int8_scale_term)
  109. {
  110. Mat int8_weight_data(weight_data_size, (size_t)1u);
  111. if (int8_weight_data.empty())
  112. return -100;
  113. const int weight_data_size_g = weight_data_size / group;
  114. for (int g = 0; g < group; g++)
  115. {
  116. Option opt_q;
  117. opt_q.num_threads = 1;
  118. opt_q.blob_allocator = int8_weight_data.allocator;
  119. opt_q.use_packing_layout = false;
  120. const Mat weight_data_g = weight_data.range(weight_data_size_g * g, weight_data_size_g);
  121. Mat int8_weight_data_g = int8_weight_data.range(weight_data_size_g * g, weight_data_size_g);
  122. const Mat weight_data_int8_scales_g = weight_data_int8_scales.range(g, 1);
  123. quantize_to_int8(weight_data_g, int8_weight_data_g, weight_data_int8_scales_g, opt_q);
  124. }
  125. weight_data = int8_weight_data;
  126. }
  127. #endif // NCNN_INT8
  128. return 0;
  129. }
  130. static int convolutiondepthwise(const Mat& bottom_blob, Mat& top_blob, const Mat& weight_data, const Mat& bias_data, int kernel_w, int kernel_h, int stride_w, int stride_h, int dilation_w, int dilation_h, int group, int activation_type, const Mat& activation_params, const Option& opt)
  131. {
  132. const int w = bottom_blob.w;
  133. const int inch = bottom_blob.c;
  134. const int outw = top_blob.w;
  135. const int outh = top_blob.h;
  136. const int outch = top_blob.c;
  137. const int bias_term = bias_data.empty() ? 0 : 1;
  138. const int maxk = kernel_w * kernel_h;
  139. // kernel offsets
  140. std::vector<int> _space_ofs(maxk);
  141. int* space_ofs = &_space_ofs[0];
  142. {
  143. int p1 = 0;
  144. int p2 = 0;
  145. int gap = w * dilation_h - kernel_w * dilation_w;
  146. for (int i = 0; i < kernel_h; i++)
  147. {
  148. for (int j = 0; j < kernel_w; j++)
  149. {
  150. space_ofs[p1] = p2;
  151. p1++;
  152. p2 += dilation_w;
  153. }
  154. p2 += gap;
  155. }
  156. }
  157. // depth-wise
  158. if (inch == group && group == outch)
  159. {
  160. #pragma omp parallel for num_threads(opt.num_threads)
  161. for (int g = 0; g < group; g++)
  162. {
  163. float* outptr = top_blob.channel(g);
  164. const float* kptr = (const float*)weight_data + maxk * g;
  165. const Mat m = bottom_blob.channel(g);
  166. for (int i = 0; i < outh; i++)
  167. {
  168. for (int j = 0; j < outw; j++)
  169. {
  170. float sum = 0.f;
  171. if (bias_term)
  172. sum = bias_data[g];
  173. const float* sptr = m.row(i * stride_h) + j * stride_w;
  174. for (int k = 0; k < maxk; k++)
  175. {
  176. float val = sptr[space_ofs[k]];
  177. float w = kptr[k];
  178. sum += val * w;
  179. }
  180. outptr[j] = activation_ss(sum, activation_type, activation_params);
  181. }
  182. outptr += outw;
  183. }
  184. }
  185. }
  186. else
  187. {
  188. // group convolution
  189. const int inch_g = inch / group;
  190. const int outch_g = outch / group;
  191. #ifdef _WIN32
  192. #pragma omp parallel for num_threads(opt.num_threads)
  193. #else
  194. #pragma omp parallel for collapse(2) num_threads(opt.num_threads)
  195. #endif
  196. for (int g = 0; g < group; g++)
  197. {
  198. for (int p = 0; p < outch_g; p++)
  199. {
  200. float* outptr = top_blob.channel(g * outch_g + p);
  201. const float* weight_data_ptr = (const float*)weight_data + maxk * inch_g * outch_g * g;
  202. // shadowed variable for less openmp task args
  203. const int outw = top_blob.w;
  204. const int outh = top_blob.h;
  205. for (int i = 0; i < outh; i++)
  206. {
  207. for (int j = 0; j < outw; j++)
  208. {
  209. float sum = 0.f;
  210. if (bias_term)
  211. sum = bias_data[outch_g * g + p];
  212. const float* kptr = weight_data_ptr + maxk * inch_g * p;
  213. for (int q = 0; q < inch_g; q++)
  214. {
  215. const Mat m = bottom_blob.channel(inch_g * g + q);
  216. const float* sptr = m.row(i * stride_h) + j * stride_w;
  217. for (int k = 0; k < maxk; k++)
  218. {
  219. float val = sptr[space_ofs[k]];
  220. float w = kptr[k];
  221. sum += val * w;
  222. }
  223. kptr += maxk;
  224. }
  225. outptr[j] = activation_ss(sum, activation_type, activation_params);
  226. }
  227. outptr += outw;
  228. }
  229. }
  230. }
  231. }
  232. return 0;
  233. }
  234. int ConvolutionDepthWise::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const
  235. {
  236. // convolv with NxN kernel
  237. // value = value + bias
  238. #if NCNN_INT8
  239. if (opt.use_int8_inference && weight_data.elemsize == (size_t)1u)
  240. {
  241. return forward_int8(bottom_blob, top_blob, opt);
  242. }
  243. #endif
  244. // NCNN_LOGE("ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h);
  245. Mat bottom_blob_bordered;
  246. make_padding(bottom_blob, bottom_blob_bordered, opt);
  247. if (bottom_blob_bordered.empty())
  248. return -100;
  249. const int w = bottom_blob_bordered.w;
  250. const int h = bottom_blob_bordered.h;
  251. const size_t elemsize = bottom_blob_bordered.elemsize;
  252. const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1;
  253. const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1;
  254. const int outw = (w - kernel_extent_w) / stride_w + 1;
  255. const int outh = (h - kernel_extent_h) / stride_h + 1;
  256. top_blob.create(outw, outh, num_output, elemsize, opt.blob_allocator);
  257. if (top_blob.empty())
  258. return -100;
  259. int ret = convolutiondepthwise(bottom_blob_bordered, top_blob, weight_data, bias_data, kernel_w, kernel_h, stride_w, stride_h, dilation_w, dilation_h, group, activation_type, activation_params, opt);
  260. if (ret != 0)
  261. return ret;
  262. return 0;
  263. }
  264. int ConvolutionDepthWise::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs, const Option& opt) const
  265. {
  266. const Mat& bottom_blob = bottom_blobs[0];
  267. const Mat& _weight_data = bottom_blobs[1];
  268. Mat& top_blob = top_blobs[0];
  269. const int _kernel_w = _weight_data.w;
  270. const int _kernel_h = _weight_data.h;
  271. const int _num_output = _weight_data.c;
  272. Mat weight_data_flattened;
  273. flatten(_weight_data, weight_data_flattened, opt);
  274. if (weight_data_flattened.empty())
  275. return -100;
  276. Mat bias_data_flattened;
  277. if (bias_term)
  278. {
  279. const Mat& _bias_data = bottom_blobs[2];
  280. flatten(_bias_data, bias_data_flattened, opt);
  281. if (bias_data_flattened.empty())
  282. return -100;
  283. }
  284. Mat bottom_blob_bordered;
  285. make_padding(bottom_blob, bottom_blob_bordered, _kernel_w, _kernel_h, opt);
  286. if (bottom_blob_bordered.empty())
  287. return -100;
  288. const int w = bottom_blob_bordered.w;
  289. const int h = bottom_blob_bordered.h;
  290. const size_t elemsize = bottom_blob_bordered.elemsize;
  291. const int kernel_extent_w = dilation_w * (_kernel_w - 1) + 1;
  292. const int kernel_extent_h = dilation_h * (_kernel_h - 1) + 1;
  293. const int outw = (w - kernel_extent_w) / stride_w + 1;
  294. const int outh = (h - kernel_extent_h) / stride_h + 1;
  295. top_blob.create(outw, outh, _num_output, elemsize, opt.blob_allocator);
  296. if (top_blob.empty())
  297. return -100;
  298. int ret = convolutiondepthwise(bottom_blob_bordered, top_blob, weight_data_flattened, bias_data_flattened, _kernel_w, _kernel_h, stride_w, stride_h, dilation_w, dilation_h, group, activation_type, activation_params, opt);
  299. if (ret != 0)
  300. return ret;
  301. return 0;
  302. }
  303. void ConvolutionDepthWise::make_padding(const Mat& bottom_blob, Mat& bottom_blob_bordered, const Option& opt) const
  304. {
  305. make_padding(bottom_blob, bottom_blob_bordered, kernel_w, kernel_h, opt);
  306. }
  307. void ConvolutionDepthWise::make_padding(const Mat& bottom_blob, Mat& bottom_blob_bordered, int _kernel_w, int _kernel_h, const Option& opt) const
  308. {
  309. int w = bottom_blob.w;
  310. int h = bottom_blob.h;
  311. const int kernel_extent_w = dilation_w * (_kernel_w - 1) + 1;
  312. const int kernel_extent_h = dilation_h * (_kernel_h - 1) + 1;
  313. bottom_blob_bordered = bottom_blob;
  314. if (pad_left > 0 || pad_right > 0 || pad_top > 0 || pad_bottom > 0)
  315. {
  316. Option opt_b = opt;
  317. opt_b.blob_allocator = opt.workspace_allocator;
  318. copy_make_border(bottom_blob, bottom_blob_bordered, pad_top, pad_bottom, pad_left, pad_right, BORDER_CONSTANT, pad_value, opt_b);
  319. }
  320. else if (pad_left == -233 && pad_right == -233 && pad_top == -233 && pad_bottom == -233)
  321. {
  322. // tensorflow padding=SAME or onnx padding=SAME_UPPER
  323. int wpad = kernel_extent_w + (w - 1) / stride_w * stride_w - w;
  324. int hpad = kernel_extent_h + (h - 1) / stride_h * stride_h - h;
  325. if (wpad > 0 || hpad > 0)
  326. {
  327. Option opt_b = opt;
  328. opt_b.blob_allocator = opt.workspace_allocator;
  329. copy_make_border(bottom_blob, bottom_blob_bordered, hpad / 2, hpad - hpad / 2, wpad / 2, wpad - wpad / 2, BORDER_CONSTANT, pad_value, opt_b);
  330. }
  331. }
  332. else if (pad_left == -234 && pad_right == -234 && pad_top == -234 && pad_bottom == -234)
  333. {
  334. // onnx padding=SAME_LOWER
  335. int wpad = kernel_extent_w + (w - 1) / stride_w * stride_w - w;
  336. int hpad = kernel_extent_h + (h - 1) / stride_h * stride_h - h;
  337. if (wpad > 0 || hpad > 0)
  338. {
  339. Option opt_b = opt;
  340. opt_b.blob_allocator = opt.workspace_allocator;
  341. copy_make_border(bottom_blob, bottom_blob_bordered, hpad - hpad / 2, hpad / 2, wpad - wpad / 2, wpad / 2, BORDER_CONSTANT, pad_value, opt_b);
  342. }
  343. }
  344. }
  345. #if NCNN_INT8
  346. static inline signed char float2int8(float v)
  347. {
  348. int int32 = static_cast<int>(round(v));
  349. if (int32 > 127) return 127;
  350. if (int32 < -127) return -127;
  351. return (signed char)int32;
  352. }
  353. int ConvolutionDepthWise::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const
  354. {
  355. // convolv with NxN kernel
  356. // value = value + bias
  357. int w = bottom_blob.w;
  358. int h = bottom_blob.h;
  359. int channels = bottom_blob.c;
  360. size_t elemsize = bottom_blob.elemsize;
  361. if (channels % group != 0 || num_output % group != 0)
  362. {
  363. // reject invalid group
  364. return -100;
  365. }
  366. // NCNN_LOGE("ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h);
  367. const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1;
  368. const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1;
  369. Mat bottom_blob_int8 = bottom_blob;
  370. if (elemsize != 1)
  371. {
  372. const int channels_g = channels / group;
  373. Mat scales(channels);
  374. {
  375. float* ps = scales;
  376. for (int g = 0; g < group; g++)
  377. {
  378. float scale = bottom_blob_int8_scales[g];
  379. for (int q = 0; q < channels_g; q++)
  380. {
  381. *ps++ = scale;
  382. }
  383. }
  384. }
  385. Option opt_q = opt;
  386. opt_q.blob_allocator = opt.workspace_allocator;
  387. quantize_to_int8(bottom_blob, bottom_blob_int8, scales, opt_q);
  388. }
  389. Mat bottom_blob_bordered;
  390. make_padding(bottom_blob_int8, bottom_blob_bordered, opt);
  391. if (bottom_blob_bordered.empty())
  392. return -100;
  393. w = bottom_blob_bordered.w;
  394. h = bottom_blob_bordered.h;
  395. int outw = (w - kernel_extent_w) / stride_w + 1;
  396. int outh = (h - kernel_extent_h) / stride_h + 1;
  397. const int maxk = kernel_w * kernel_h;
  398. // kernel offsets
  399. std::vector<int> _space_ofs(maxk);
  400. int* space_ofs = &_space_ofs[0];
  401. {
  402. int p1 = 0;
  403. int p2 = 0;
  404. int gap = w * dilation_h - kernel_w * dilation_w;
  405. for (int i = 0; i < kernel_h; i++)
  406. {
  407. for (int j = 0; j < kernel_w; j++)
  408. {
  409. space_ofs[p1] = p2;
  410. p1++;
  411. p2 += dilation_w;
  412. }
  413. p2 += gap;
  414. }
  415. }
  416. // int8
  417. bool use_int8_requantize = int8_scale_term > 100;
  418. size_t out_elemsize = use_int8_requantize ? 1u : 4u;
  419. top_blob.create(outw, outh, num_output, out_elemsize, opt.blob_allocator);
  420. if (top_blob.empty())
  421. return -100;
  422. // depth-wise
  423. if (channels == group && group == num_output)
  424. {
  425. #pragma omp parallel for num_threads(opt.num_threads)
  426. for (int g = 0; g < group; g++)
  427. {
  428. signed char* outptr = top_blob.channel(g);
  429. const signed char* kptr = (const signed char*)weight_data + maxk * g;
  430. const Mat m = bottom_blob_bordered.channel(g);
  431. for (int i = 0; i < outh; i++)
  432. {
  433. for (int j = 0; j < outw; j++)
  434. {
  435. int sum = 0;
  436. const signed char* sptr = m.row<signed char>(i * stride_h) + j * stride_w;
  437. for (int k = 0; k < maxk; k++)
  438. {
  439. signed char val = sptr[space_ofs[k]];
  440. signed char w = kptr[k];
  441. sum += val * w;
  442. }
  443. float scale_in;
  444. if (weight_data_int8_scales[g] == 0)
  445. scale_in = 0;
  446. else
  447. scale_in = 1.f / (bottom_blob_int8_scales[g] * weight_data_int8_scales[g]);
  448. float sumfp32 = sum * scale_in;
  449. if (bias_term)
  450. sumfp32 += bias_data[g];
  451. sumfp32 = activation_ss(sumfp32, activation_type, activation_params);
  452. if (use_int8_requantize)
  453. {
  454. // requantize
  455. float scale_out = top_blob_int8_scales[g];
  456. signed char sums8 = float2int8(sumfp32 * scale_out);
  457. outptr[0] = sums8;
  458. outptr += 1;
  459. }
  460. else
  461. {
  462. // dequantize
  463. ((float*)outptr)[0] = sumfp32;
  464. outptr += 4;
  465. }
  466. }
  467. }
  468. }
  469. }
  470. else
  471. {
  472. // group convolution
  473. const int channels_g = channels / group;
  474. const int num_output_g = num_output / group;
  475. #ifdef _WIN32
  476. #pragma omp parallel for num_threads(opt.num_threads)
  477. #else // _WIN32
  478. #pragma omp parallel for collapse(2) num_threads(opt.num_threads)
  479. #endif // _WIN32
  480. for (int g = 0; g < group; g++)
  481. {
  482. for (int p = 0; p < num_output_g; p++)
  483. {
  484. signed char* outptr = top_blob.channel(g * num_output_g + p);
  485. const signed char* weight_data_ptr = (const signed char*)weight_data + maxk * channels_g * num_output_g * g;
  486. for (int i = 0; i < outh; i++)
  487. {
  488. for (int j = 0; j < outw; j++)
  489. {
  490. int sum = 0;
  491. const signed char* kptr = weight_data_ptr + maxk * channels_g * p;
  492. // channels_g
  493. for (int q = 0; q < channels_g; q++)
  494. {
  495. const Mat m = bottom_blob_bordered.channel(channels_g * g + q);
  496. const signed char* sptr = m.row<signed char>(i * stride_h) + j * stride_w;
  497. for (int k = 0; k < maxk; k++)
  498. {
  499. signed char val = sptr[space_ofs[k]];
  500. signed char w = kptr[k];
  501. sum += val * w;
  502. }
  503. kptr += maxk;
  504. }
  505. float scale_in;
  506. if (weight_data_int8_scales[g] == 0)
  507. scale_in = 0;
  508. else
  509. scale_in = 1.f / (bottom_blob_int8_scales[g] * weight_data_int8_scales[g]);
  510. float sumfp32 = sum * scale_in;
  511. if (bias_term)
  512. sumfp32 += bias_data[g * num_output_g + p];
  513. sumfp32 = activation_ss(sumfp32, activation_type, activation_params);
  514. if (use_int8_requantize)
  515. {
  516. // requantize
  517. float scale_out = top_blob_int8_scales[g];
  518. signed char sums8 = float2int8(sumfp32 * scale_out);
  519. outptr[0] = sums8;
  520. outptr += 1;
  521. }
  522. else
  523. {
  524. // dequantize
  525. ((float*)outptr)[0] = sumfp32;
  526. outptr += 4;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. return 0;
  534. }
  535. #endif // NCNN_INT8
  536. } // namespace ncnn