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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Copyright 2020 Tencent
  2. # SPDX-License-Identifier: BSD-3-Clause
  3. import pytest
  4. import ncnn
  5. def test_option():
  6. allocator = ncnn.PoolAllocator()
  7. opt = ncnn.Option()
  8. opt.lightmode = True
  9. assert opt.lightmode == True
  10. opt.lightmode = False
  11. assert opt.lightmode == False
  12. assert opt.num_threads == ncnn.get_physical_big_cpu_count()
  13. opt.num_threads = 1
  14. assert opt.num_threads == 1
  15. assert opt.blob_allocator is None
  16. opt.blob_allocator = allocator
  17. assert opt.blob_allocator == allocator
  18. assert opt.workspace_allocator is None
  19. opt.workspace_allocator = allocator
  20. assert opt.workspace_allocator == allocator
  21. assert opt.openmp_blocktime == 20
  22. opt.openmp_blocktime = 40
  23. assert opt.openmp_blocktime == 40
  24. opt.use_winograd_convolution = True
  25. assert opt.use_winograd_convolution == True
  26. opt.use_winograd_convolution = False
  27. assert opt.use_winograd_convolution == False
  28. opt.use_sgemm_convolution = True
  29. assert opt.use_sgemm_convolution == True
  30. opt.use_sgemm_convolution = False
  31. assert opt.use_sgemm_convolution == False
  32. opt.use_int8_inference = True
  33. assert opt.use_int8_inference == True
  34. opt.use_int8_inference = False
  35. assert opt.use_int8_inference == False
  36. opt.use_vulkan_compute = True
  37. assert opt.use_vulkan_compute == True
  38. opt.use_vulkan_compute = False
  39. assert opt.use_vulkan_compute == False
  40. opt.use_bf16_storage = True
  41. assert opt.use_bf16_storage == True
  42. opt.use_bf16_storage = False
  43. assert opt.use_bf16_storage == False
  44. opt.use_fp16_packed = True
  45. assert opt.use_fp16_packed == True
  46. opt.use_fp16_packed = False
  47. assert opt.use_fp16_packed == False
  48. opt.use_fp16_storage = True
  49. assert opt.use_fp16_storage == True
  50. opt.use_fp16_storage = False
  51. assert opt.use_fp16_storage == False
  52. opt.use_fp16_arithmetic = True
  53. assert opt.use_fp16_arithmetic == True
  54. opt.use_fp16_arithmetic = False
  55. assert opt.use_fp16_arithmetic == False
  56. opt.use_int8_packed = True
  57. assert opt.use_int8_packed == True
  58. opt.use_int8_packed = False
  59. assert opt.use_int8_packed == False
  60. opt.use_int8_storage = True
  61. assert opt.use_int8_storage == True
  62. opt.use_int8_storage = False
  63. assert opt.use_int8_storage == False
  64. opt.use_int8_arithmetic = True
  65. assert opt.use_int8_arithmetic == True
  66. opt.use_int8_arithmetic = False
  67. assert opt.use_int8_arithmetic == False
  68. opt.use_packing_layout = True
  69. assert opt.use_packing_layout == True
  70. opt.use_packing_layout = False
  71. assert opt.use_packing_layout == False
  72. opt.use_shader_pack8 = True
  73. assert opt.use_shader_pack8 == True
  74. opt.use_shader_pack8 = False
  75. assert opt.use_shader_pack8 == False
  76. opt.use_subgroup_ops = True
  77. assert opt.use_subgroup_ops == True
  78. opt.use_subgroup_ops = False
  79. assert opt.use_subgroup_ops == False
  80. opt.use_tensor_storage = True
  81. assert opt.use_tensor_storage == True
  82. opt.use_tensor_storage = False
  83. assert opt.use_tensor_storage == False