ncnn.cmake 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. function(download_ncnn)
  2. if(CMAKE_VERSION VERSION_LESS 3.11)
  3. # FetchContent is available since 3.11,
  4. # we've copied it to ${CMAKE_SOURCE_DIR}/cmake/Modules
  5. # so that it can be used in lower CMake versions.
  6. message(STATUS "Use FetchContent provided by sherpa-ncnn")
  7. list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
  8. endif()
  9. include(FetchContent)
  10. set(ncnn_URL "https://github.com/csukuangfj/ncnn/archive/refs/tags/sherpa-0.5.tar.gz")
  11. set(ncnn_HASH "SHA256=73ddc84406bc8fd8aa98fc05284534e3fdfbee39ee2ec8592dfbbfad28717bfd")
  12. FetchContent_Declare(ncnn
  13. URL ${ncnn_URL}
  14. URL_HASH ${ncnn_HASH}
  15. )
  16. set(NCNN_INSTALL_SDK OFF CACHE BOOL "" FORCE)
  17. set(NCNN_PIXEL OFF CACHE BOOL "" FORCE)
  18. set(NCNN_PIXEL_ROTATE OFF CACHE BOOL "" FORCE)
  19. set(NCNN_PIXEL_AFFINE OFF CACHE BOOL "" FORCE)
  20. set(NCNN_PIXEL_DRAWING OFF CACHE BOOL "" FORCE)
  21. set(NCNN_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
  22. set(NCNN_INT8 OFF CACHE BOOL "" FORCE) # TODO(fangjun): enable it
  23. set(NCNN_BF16 OFF CACHE BOOL "" FORCE) # TODO(fangjun): enable it
  24. set(NCNN_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
  25. set(NCNN_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  26. set(NCNN_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  27. # For RNN-T with ScaledLSTM, the following operators are not sued,
  28. # so we keep them from compiling.
  29. #
  30. # CAUTION: If you switch to a different model, please change
  31. # the following disabled layers accordingly; otherwise, you
  32. # will get segmentation fault during runtime.
  33. set(disabled_layers
  34. AbsVal
  35. ArgMax
  36. BatchNorm
  37. Bias
  38. BNLL
  39. # Concat
  40. # Convolution
  41. # Crop
  42. Deconvolution
  43. # Dropout
  44. Eltwise
  45. ELU
  46. # Embed
  47. Exp
  48. # Flatten # needed by innerproduct
  49. # InnerProduct
  50. # Input
  51. Log
  52. LRN
  53. MemoryData
  54. MVN
  55. Pooling
  56. Power
  57. PReLU
  58. Proposal
  59. # Reduction
  60. # ReLU
  61. # Reshape
  62. ROIPooling
  63. Scale
  64. # Sigmoid
  65. Slice
  66. Softmax
  67. # Split
  68. SPP
  69. # TanH
  70. Threshold
  71. Tile
  72. RNN
  73. LSTM
  74. # BinaryOp
  75. # UnaryOp
  76. ConvolutionDepthWise
  77. # Padding # required by innerproduct and convolution
  78. Squeeze
  79. # ExpandDims
  80. Normalize
  81. # Permute
  82. PriorBox
  83. DetectionOutput
  84. Interp
  85. DeconvolutionDepthWise
  86. ShuffleChannel
  87. InstanceNorm
  88. Clip
  89. Reorg
  90. YoloDetectionOutput
  91. Quantize
  92. Dequantize
  93. Yolov3DetectionOutput
  94. PSROIPooling
  95. ROIAlign
  96. Packing
  97. Requantize
  98. # Cast # needed InnerProduct
  99. HardSigmoid
  100. SELU
  101. HardSwish
  102. Noop
  103. PixelShuffle
  104. DeepCopy
  105. Mish
  106. StatisticsPooling
  107. Swish
  108. Gemm
  109. GroupNorm
  110. LayerNorm
  111. Softplus
  112. GRU
  113. MultiHeadAttention
  114. GELU
  115. Convolution1D
  116. Pooling1D
  117. # ConvolutionDepthWise1D
  118. Convolution3D
  119. ConvolutionDepthWise3D
  120. Pooling3D
  121. MatMul
  122. Deconvolution1D
  123. DeconvolutionDepthWise1D
  124. Deconvolution3D
  125. DeconvolutionDepthWise3D
  126. Einsum
  127. DeformableConv2D
  128. RelPositionalEncoding
  129. MakePadMask
  130. RelShift
  131. GLU
  132. )
  133. foreach(layer IN LISTS disabled_layers)
  134. string(TOLOWER ${layer} name)
  135. set(WITH_LAYER_${name} OFF CACHE BOOL "" FORCE)
  136. endforeach()
  137. FetchContent_GetProperties(ncnn)
  138. if(NOT ncnn_POPULATED)
  139. message(STATUS "Downloading ncnn ${ncnn_URL}")
  140. FetchContent_Populate(ncnn)
  141. endif()
  142. message(STATUS "ncnn is downloaded to ${ncnn_SOURCE_DIR}")
  143. message(STATUS "ncnn's binary dir is ${ncnn_BINARY_DIR}")
  144. add_subdirectory(${ncnn_SOURCE_DIR} ${ncnn_BINARY_DIR} EXCLUDE_FROM_ALL)
  145. endfunction()
  146. download_ncnn()