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_option.py 4.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. import pytest
  15. import ncnn
  16. def test_option():
  17. allocator = ncnn.PoolAllocator()
  18. opt = ncnn.Option()
  19. opt.lightmode = True
  20. assert opt.lightmode == True
  21. opt.lightmode = False
  22. assert opt.lightmode == False
  23. assert opt.num_threads == ncnn.get_cpu_count()
  24. opt.num_threads = 1
  25. assert opt.num_threads == 1
  26. assert opt.blob_allocator is None
  27. opt.blob_allocator = allocator
  28. assert opt.blob_allocator == allocator
  29. assert opt.workspace_allocator is None
  30. opt.workspace_allocator = allocator
  31. assert opt.workspace_allocator == allocator
  32. assert opt.openmp_blocktime == 20
  33. opt.openmp_blocktime = 40
  34. assert opt.openmp_blocktime == 40
  35. opt.use_winograd_convolution = True
  36. assert opt.use_winograd_convolution == True
  37. opt.use_winograd_convolution = False
  38. assert opt.use_winograd_convolution == False
  39. opt.use_sgemm_convolution = True
  40. assert opt.use_sgemm_convolution == True
  41. opt.use_sgemm_convolution = False
  42. assert opt.use_sgemm_convolution == False
  43. opt.use_int8_inference = True
  44. assert opt.use_int8_inference == True
  45. opt.use_int8_inference = False
  46. assert opt.use_int8_inference == False
  47. opt.use_vulkan_compute = True
  48. assert opt.use_vulkan_compute == True
  49. opt.use_vulkan_compute = False
  50. assert opt.use_vulkan_compute == False
  51. opt.use_bf16_storage = True
  52. assert opt.use_bf16_storage == True
  53. opt.use_bf16_storage = False
  54. assert opt.use_bf16_storage == False
  55. opt.use_fp16_packed = True
  56. assert opt.use_fp16_packed == True
  57. opt.use_fp16_packed = False
  58. assert opt.use_fp16_packed == False
  59. opt.use_fp16_storage = True
  60. assert opt.use_fp16_storage == True
  61. opt.use_fp16_storage = False
  62. assert opt.use_fp16_storage == False
  63. opt.use_fp16_arithmetic = True
  64. assert opt.use_fp16_arithmetic == True
  65. opt.use_fp16_arithmetic = False
  66. assert opt.use_fp16_arithmetic == False
  67. opt.use_int8_packed = True
  68. assert opt.use_int8_packed == True
  69. opt.use_int8_packed = False
  70. assert opt.use_int8_packed == False
  71. opt.use_int8_storage = True
  72. assert opt.use_int8_storage == True
  73. opt.use_int8_storage = False
  74. assert opt.use_int8_storage == False
  75. opt.use_int8_arithmetic = True
  76. assert opt.use_int8_arithmetic == True
  77. opt.use_int8_arithmetic = False
  78. assert opt.use_int8_arithmetic == False
  79. opt.use_packing_layout = True
  80. assert opt.use_packing_layout == True
  81. opt.use_packing_layout = False
  82. assert opt.use_packing_layout == False
  83. opt.use_shader_pack8 = True
  84. assert opt.use_shader_pack8 == True
  85. opt.use_shader_pack8 = False
  86. assert opt.use_shader_pack8 == False
  87. opt.use_subgroup_basic = True
  88. assert opt.use_subgroup_basic == True
  89. opt.use_subgroup_basic = False
  90. assert opt.use_subgroup_basic == False
  91. opt.use_subgroup_vote = True
  92. assert opt.use_subgroup_vote == True
  93. opt.use_subgroup_vote = False
  94. assert opt.use_subgroup_vote == False
  95. opt.use_subgroup_ballot = True
  96. assert opt.use_subgroup_ballot == True
  97. opt.use_subgroup_ballot = False
  98. assert opt.use_subgroup_ballot == False
  99. opt.use_subgroup_shuffle = True
  100. assert opt.use_subgroup_shuffle == True
  101. opt.use_subgroup_shuffle = False
  102. assert opt.use_subgroup_shuffle == False
  103. opt.use_image_storage = True
  104. assert opt.use_image_storage == True
  105. opt.use_image_storage = False
  106. assert opt.use_image_storage == False
  107. opt.use_tensor_storage = True
  108. assert opt.use_tensor_storage == True
  109. opt.use_tensor_storage = False
  110. assert opt.use_tensor_storage == False
  111. opt.use_weight_fp16_storage = True
  112. assert opt.use_weight_fp16_storage == True
  113. opt.use_weight_fp16_storage = False
  114. assert opt.use_weight_fp16_storage == False