ncnn.cmake 3.4 KB

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