ncnn.cmake 3.8 KB

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