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_packing.cpp 9.0 kB

adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2020 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 "testutil.h"
  15. #include "layer/packing.h"
  16. static int test_packing_cpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  17. {
  18. ncnn::ParamDict pd;
  19. pd.set(0, out_elempack);
  20. std::vector<ncnn::Mat> weights(0);
  21. ncnn::Option opt;
  22. opt.num_threads = 1;
  23. opt.use_vulkan_compute = false;
  24. opt.use_int8_inference = false;
  25. opt.use_packing_layout = false;
  26. ncnn::Layer* op = ncnn::create_layer("Packing");
  27. op->load_param(pd);
  28. ncnn::ModelBinFromMatArray mb(weights.data());
  29. op->load_model(mb);
  30. op->create_pipeline(opt);
  31. ncnn::Mat ap;
  32. ncnn::convert_packing(a, ap, in_elempack);
  33. ncnn::Mat b;
  34. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  35. ncnn::Mat c;
  36. op->forward(ap, c, opt);
  37. op->destroy_pipeline(opt);
  38. delete op;
  39. if (CompareMat(b, c, 0.001) != 0)
  40. {
  41. fprintf(stderr, "test_packing_cpu failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  42. return -1;
  43. }
  44. return 0;
  45. }
  46. #if NCNN_VULKAN
  47. static int test_packing_gpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  48. {
  49. ncnn::ParamDict pd;
  50. pd.set(0, out_elempack);
  51. std::vector<ncnn::Mat> weights(0);
  52. ncnn::Option opt;
  53. opt.num_threads = 1;
  54. opt.use_vulkan_compute = true;
  55. opt.use_int8_inference = false;
  56. opt.use_fp16_packed = false;
  57. opt.use_fp16_storage = false;
  58. opt.use_fp16_arithmetic = false;
  59. opt.use_int8_storage = false;
  60. opt.use_int8_arithmetic = false;
  61. opt.use_packing_layout = true;
  62. opt.use_shader_pack8 = true;
  63. opt.use_image_storage = false;
  64. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  65. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  66. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  67. opt.blob_vkallocator = blob_vkallocator;
  68. opt.workspace_vkallocator = blob_vkallocator;
  69. opt.staging_vkallocator = staging_vkallocator;
  70. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  71. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  72. ncnn::Layer* op = ncnn::create_layer("Packing");
  73. op->vkdev = vkdev;
  74. op->load_param(pd);
  75. ncnn::ModelBinFromMatArray mb(weights.data());
  76. op->load_model(mb);
  77. op->create_pipeline(opt);
  78. ncnn::Mat ap;
  79. ncnn::convert_packing(a, ap, in_elempack);
  80. ncnn::Mat b;
  81. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  82. ncnn::Mat d;
  83. // forward
  84. ncnn::VkCompute cmd(vkdev);
  85. // upload
  86. ncnn::VkMat a_gpu;
  87. cmd.record_clone(ap, a_gpu, opt);
  88. ncnn::VkMat d_gpu;
  89. if (op->support_inplace)
  90. {
  91. op->forward_inplace(a_gpu, cmd, opt);
  92. d_gpu = a_gpu;
  93. }
  94. else
  95. {
  96. op->forward(a_gpu, d_gpu, cmd, opt);
  97. }
  98. // download
  99. cmd.record_clone(d_gpu, d, opt);
  100. cmd.submit_and_wait();
  101. op->destroy_pipeline(opt);
  102. delete op;
  103. vkdev->reclaim_blob_allocator(blob_vkallocator);
  104. vkdev->reclaim_staging_allocator(staging_vkallocator);
  105. if (CompareMat(b, d, 0.001) != 0)
  106. {
  107. fprintf(stderr, "test_packing_gpu failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  108. return -1;
  109. }
  110. return 0;
  111. }
  112. static int test_packing_gpu_image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  113. {
  114. ncnn::ParamDict pd;
  115. pd.set(0, out_elempack);
  116. std::vector<ncnn::Mat> weights(0);
  117. ncnn::Option opt;
  118. opt.num_threads = 1;
  119. opt.use_vulkan_compute = true;
  120. opt.use_int8_inference = false;
  121. opt.use_fp16_packed = true;
  122. opt.use_fp16_storage = false;
  123. opt.use_fp16_arithmetic = false;
  124. opt.use_int8_storage = false;
  125. opt.use_int8_arithmetic = false;
  126. opt.use_packing_layout = true;
  127. opt.use_shader_pack8 = true;
  128. opt.use_image_storage = true;
  129. opt.use_image_fp16_packed = false;
  130. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  131. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  132. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  133. opt.blob_vkallocator = blob_vkallocator;
  134. opt.workspace_vkallocator = blob_vkallocator;
  135. opt.staging_vkallocator = staging_vkallocator;
  136. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  137. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  138. ncnn::Layer* op = ncnn::create_layer("Packing");
  139. op->vkdev = vkdev;
  140. op->load_param(pd);
  141. ncnn::ModelBinFromMatArray mb(weights.data());
  142. op->load_model(mb);
  143. op->create_pipeline(opt);
  144. ncnn::Mat ap;
  145. ncnn::convert_packing(a, ap, in_elempack);
  146. ncnn::Mat b;
  147. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  148. ncnn::Mat d;
  149. // forward
  150. ncnn::VkCompute cmd(vkdev);
  151. // upload
  152. ncnn::VkImageMat a_gpu;
  153. cmd.record_clone(ap, a_gpu, opt);
  154. ncnn::VkImageMat d_gpu;
  155. if (op->support_inplace)
  156. {
  157. op->forward_inplace(a_gpu, cmd, opt);
  158. d_gpu = a_gpu;
  159. }
  160. else
  161. {
  162. op->forward(a_gpu, d_gpu, cmd, opt);
  163. }
  164. // download
  165. cmd.record_clone(d_gpu, d, opt);
  166. cmd.submit_and_wait();
  167. op->destroy_pipeline(opt);
  168. delete op;
  169. vkdev->reclaim_blob_allocator(blob_vkallocator);
  170. vkdev->reclaim_staging_allocator(staging_vkallocator);
  171. if (CompareMat(b, d, 0.001) != 0)
  172. {
  173. fprintf(stderr, "test_packing_gpu_image failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  174. return -1;
  175. }
  176. return 0;
  177. }
  178. #endif
  179. static int test_packing_0()
  180. {
  181. ncnn::Mat a = RandomMat(3, 5, 16);
  182. return 0
  183. || test_packing_cpu(a, 1, 4)
  184. || test_packing_cpu(a, 4, 1)
  185. || test_packing_cpu(a, 1, 8)
  186. || test_packing_cpu(a, 8, 1)
  187. || test_packing_cpu(a, 4, 8)
  188. || test_packing_cpu(a, 8, 4)
  189. #if NCNN_VULKAN
  190. || test_packing_gpu(a, 1, 4)
  191. || test_packing_gpu(a, 4, 1)
  192. || test_packing_gpu(a, 1, 8)
  193. || test_packing_gpu(a, 8, 1)
  194. || test_packing_gpu(a, 4, 8)
  195. || test_packing_gpu(a, 8, 4)
  196. || test_packing_gpu_image(a, 1, 4)
  197. || test_packing_gpu_image(a, 4, 1)
  198. || test_packing_gpu_image(a, 1, 8)
  199. || test_packing_gpu_image(a, 8, 1)
  200. || test_packing_gpu_image(a, 4, 8)
  201. || test_packing_gpu_image(a, 8, 4)
  202. #endif // NCNN_VULKAN
  203. ;
  204. }
  205. static int test_packing_1()
  206. {
  207. ncnn::Mat a = RandomMat(3, 16);
  208. return 0
  209. || test_packing_cpu(a, 1, 4)
  210. || test_packing_cpu(a, 4, 1)
  211. || test_packing_cpu(a, 1, 8)
  212. || test_packing_cpu(a, 8, 1)
  213. || test_packing_cpu(a, 4, 8)
  214. || test_packing_cpu(a, 8, 4)
  215. #if NCNN_VULKAN
  216. || test_packing_gpu(a, 1, 4)
  217. || test_packing_gpu(a, 4, 1)
  218. || test_packing_gpu(a, 1, 8)
  219. || test_packing_gpu(a, 8, 1)
  220. || test_packing_gpu(a, 4, 8)
  221. || test_packing_gpu(a, 8, 4)
  222. || test_packing_gpu_image(a, 1, 4)
  223. || test_packing_gpu_image(a, 4, 1)
  224. || test_packing_gpu_image(a, 1, 8)
  225. || test_packing_gpu_image(a, 8, 1)
  226. || test_packing_gpu_image(a, 4, 8)
  227. || test_packing_gpu_image(a, 8, 4)
  228. #endif // NCNN_VULKAN
  229. ;
  230. }
  231. static int test_packing_2()
  232. {
  233. ncnn::Mat a = RandomMat(16);
  234. return 0
  235. || test_packing_cpu(a, 1, 4)
  236. || test_packing_cpu(a, 4, 1)
  237. || test_packing_cpu(a, 1, 8)
  238. || test_packing_cpu(a, 8, 1)
  239. || test_packing_cpu(a, 4, 8)
  240. || test_packing_cpu(a, 8, 4)
  241. #if NCNN_VULKAN
  242. || test_packing_gpu(a, 1, 4)
  243. || test_packing_gpu(a, 4, 1)
  244. || test_packing_gpu(a, 1, 8)
  245. || test_packing_gpu(a, 8, 1)
  246. || test_packing_gpu(a, 4, 8)
  247. || test_packing_gpu(a, 8, 4)
  248. || test_packing_gpu_image(a, 1, 4)
  249. || test_packing_gpu_image(a, 4, 1)
  250. || test_packing_gpu_image(a, 1, 8)
  251. || test_packing_gpu_image(a, 8, 1)
  252. || test_packing_gpu_image(a, 4, 8)
  253. || test_packing_gpu_image(a, 8, 4)
  254. #endif // NCNN_VULKAN
  255. ;
  256. }
  257. int main()
  258. {
  259. SRAND(7767517);
  260. return 0
  261. || test_packing_0()
  262. || test_packing_1()
  263. || test_packing_2()
  264. ;
  265. }