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 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(const ncnn::Mat& a, int out_elempack)
  17. {
  18. ncnn::ParamDict pd;
  19. pd.set(0, out_elempack);//out_elempack
  20. std::vector<ncnn::Mat> weights(0);
  21. ncnn::ModelBinFromMatArray mb(weights.data());
  22. ncnn::Option opt;
  23. opt.num_threads = 1;
  24. opt.use_vulkan_compute = true;
  25. opt.use_fp16_packed = false;
  26. opt.use_fp16_storage = false;
  27. opt.use_fp16_arithmetic = false;
  28. opt.use_int8_storage = false;
  29. opt.use_int8_arithmetic = false;
  30. opt.use_packing_layout = false;
  31. int ret = test_layer<ncnn::Packing>("Packing", pd, mb, opt, a);
  32. if (ret != 0)
  33. {
  34. fprintf(stderr, "test_packing failed a.dims=%d a=(%d %d %d) out_elempack=%d\n", a.dims, a.w, a.h, a.c, out_elempack);
  35. }
  36. return ret;
  37. }
  38. static int test_packing_0()
  39. {
  40. ncnn::Mat a = RandomMat(3, 5, 16);
  41. return 0
  42. || test_packing(a, 1)
  43. || test_packing(a, 4)
  44. ;
  45. }
  46. static int test_packing_1()
  47. {
  48. ncnn::Mat a = RandomMat(3, 16);
  49. return 0
  50. || test_packing(a, 1)
  51. || test_packing(a, 4)
  52. ;
  53. }
  54. static int test_packing_2()
  55. {
  56. ncnn::Mat a = RandomMat(16);
  57. return 0
  58. || test_packing(a, 1)
  59. || test_packing(a, 4)
  60. ;
  61. }
  62. int main()
  63. {
  64. SRAND(7767517);
  65. return 0
  66. || test_packing_0()
  67. || test_packing_1()
  68. || test_packing_2()
  69. ;
  70. }