ncnn.cmake 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. function(download_ncnn)
  2. include(FetchContent)
  3. # We use a modified version of NCNN.
  4. # The changed code is in
  5. # https://github.com/csukuangfj/ncnn/pull/7
  6. # Please also change ../pack-for-embedded-systems.sh
  7. set(ncnn_URL "https://github.com/csukuangfj/ncnn/archive/refs/tags/sherpa-0.9.tar.gz")
  8. set(ncnn_HASH "SHA256=a5fe1f69c75c06d6de858c7c660c43395b6ed3df9ee59d6e2fe621211e6928cd")
  9. # If you don't have access to the Internet, please download it to your
  10. # local drive and modify the following line according to your needs.
  11. if(EXISTS "/star-fj/fangjun/download/github/ncnn-sherpa-0.9.tar.gz")
  12. set(ncnn_URL "file:///star-fj/fangjun/download/github/ncnn-sherpa-0.9.tar.gz")
  13. elseif(EXISTS "/Users/fangjun/Downloads/ncnn-sherpa-0.9.tar.gz")
  14. set(ncnn_URL "file:///Users/fangjun/Downloads/ncnn-sherpa-0.9.tar.gz")
  15. elseif(EXISTS "/tmp/ncnn-sherpa-0.9.tar.gz")
  16. set(ncnn_URL "file:///tmp/ncnn-sherpa-0.9.tar.gz")
  17. elseif(EXISTS "$ENV{HOME}/asr/ncnn-sherpa-0.9.tar.gz")
  18. set(ncnn_URL "file://$ENV{HOME}/asr/ncnn-sherpa-0.9.tar.gz")
  19. endif()
  20. FetchContent_Declare(ncnn
  21. URL ${ncnn_URL}
  22. URL_HASH ${ncnn_HASH}
  23. )
  24. set(NCNN_PIXEL OFF CACHE BOOL "" FORCE)
  25. set(NCNN_PIXEL_ROTATE OFF CACHE BOOL "" FORCE)
  26. set(NCNN_PIXEL_AFFINE OFF CACHE BOOL "" FORCE)
  27. set(NCNN_PIXEL_DRAWING OFF CACHE BOOL "" FORCE)
  28. set(NCNN_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
  29. set(NCNN_SHARED_LIB ${BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
  30. set(NCNN_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
  31. set(NCNN_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  32. set(NCNN_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  33. # For RNN-T with ScaledLSTM, the following operators are not sued,
  34. # so we keep them from compiling.
  35. #
  36. # CAUTION: If you switch to a different model, please change
  37. # the following disabled layers accordingly; otherwise, you
  38. # will get segmentation fault during runtime.
  39. set(disabled_layers
  40. AbsVal
  41. ArgMax
  42. BatchNorm
  43. Bias
  44. BNLL
  45. # Concat
  46. # Convolution
  47. # Crop
  48. Deconvolution
  49. # Dropout
  50. Eltwise
  51. ELU
  52. # Embed
  53. Exp
  54. # Flatten # needed by innerproduct
  55. # InnerProduct
  56. # Input
  57. Log
  58. LRN
  59. # MemoryData
  60. MVN
  61. Pooling
  62. Power
  63. PReLU
  64. Proposal
  65. # Reduction
  66. # ReLU
  67. # Reshape
  68. ROIPooling
  69. Scale
  70. # Sigmoid
  71. # Slice
  72. # Softmax
  73. # Split
  74. SPP
  75. # TanH
  76. Threshold
  77. Tile
  78. # RNN
  79. # LSTM
  80. # BinaryOp
  81. # UnaryOp
  82. ConvolutionDepthWise
  83. # Padding # required by innerproduct and convolution
  84. Squeeze
  85. # ExpandDims
  86. Normalize
  87. # Permute
  88. PriorBox
  89. DetectionOutput
  90. Interp
  91. DeconvolutionDepthWise
  92. ShuffleChannel
  93. InstanceNorm
  94. Clip
  95. Reorg
  96. YoloDetectionOutput
  97. # Quantize
  98. # Dequantize
  99. Yolov3DetectionOutput
  100. PSROIPooling
  101. ROIAlign
  102. # Packing
  103. # Requantize
  104. # Cast # needed InnerProduct
  105. HardSigmoid
  106. SELU
  107. HardSwish
  108. Noop
  109. PixelShuffle
  110. DeepCopy
  111. Mish
  112. StatisticsPooling
  113. Swish
  114. # Gemm
  115. GroupNorm
  116. LayerNorm
  117. Softplus
  118. GRU
  119. MultiHeadAttention
  120. GELU
  121. # Convolution1D
  122. Pooling1D
  123. # ConvolutionDepthWise1D
  124. Convolution3D
  125. ConvolutionDepthWise3D
  126. Pooling3D
  127. # MatMul
  128. Deconvolution1D
  129. # DeconvolutionDepthWise1D
  130. Deconvolution3D
  131. DeconvolutionDepthWise3D
  132. Einsum
  133. DeformableConv2D
  134. RelPositionalEncoding
  135. MakePadMask
  136. RelShift
  137. # GLU
  138. Fold
  139. Unfold
  140. GridSample
  141. CumulativeSum
  142. )
  143. foreach(layer IN LISTS disabled_layers)
  144. string(TOLOWER ${layer} name)
  145. set(WITH_LAYER_${name} OFF CACHE BOOL "" FORCE)
  146. endforeach()
  147. FetchContent_GetProperties(ncnn)
  148. if(NOT ncnn_POPULATED)
  149. message(STATUS "Downloading ncnn ${ncnn_URL}")
  150. FetchContent_Populate(ncnn)
  151. endif()
  152. message(STATUS "ncnn is downloaded to ${ncnn_SOURCE_DIR}")
  153. message(STATUS "ncnn's binary dir is ${ncnn_BINARY_DIR}")
  154. add_subdirectory(${ncnn_SOURCE_DIR} ${ncnn_BINARY_DIR})
  155. install(TARGETS ncnn DESTINATION lib)
  156. endfunction()
  157. download_ncnn()