123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- function(download_ncnn)
- if(CMAKE_VERSION VERSION_LESS 3.11)
- # FetchContent is available since 3.11,
- # we've copied it to ${CMAKE_SOURCE_DIR}/cmake/Modules
- # so that it can be used in lower CMake versions.
- message(STATUS "Use FetchContent provided by sherpa-ncnn")
- list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
- endif()
- include(FetchContent)
- set(ncnn_URL "https://github.com/csukuangfj/ncnn/archive/refs/tags/sherpa-0.5.tar.gz")
- set(ncnn_HASH "SHA256=73ddc84406bc8fd8aa98fc05284534e3fdfbee39ee2ec8592dfbbfad28717bfd")
- FetchContent_Declare(ncnn
- URL ${ncnn_URL}
- URL_HASH ${ncnn_HASH}
- )
- set(NCNN_INSTALL_SDK OFF CACHE BOOL "" FORCE)
- set(NCNN_PIXEL OFF CACHE BOOL "" FORCE)
- set(NCNN_PIXEL_ROTATE OFF CACHE BOOL "" FORCE)
- set(NCNN_PIXEL_AFFINE OFF CACHE BOOL "" FORCE)
- set(NCNN_PIXEL_DRAWING OFF CACHE BOOL "" FORCE)
- set(NCNN_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
- set(NCNN_INT8 OFF CACHE BOOL "" FORCE) # TODO(fangjun): enable it
- set(NCNN_BF16 OFF CACHE BOOL "" FORCE) # TODO(fangjun): enable it
- set(NCNN_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
- set(NCNN_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
- set(NCNN_BUILD_TESTS OFF CACHE BOOL "" FORCE)
- # For RNN-T with ScaledLSTM, the following operators are not sued,
- # so we keep them from compiling.
- #
- # CAUTION: If you switch to a different model, please change
- # the following disabled layers accordingly; otherwise, you
- # will get segmentation fault during runtime.
- set(disabled_layers
- AbsVal
- ArgMax
- BatchNorm
- Bias
- BNLL
- # Concat
- # Convolution
- # Crop
- Deconvolution
- # Dropout
- Eltwise
- ELU
- # Embed
- Exp
- # Flatten # needed by innerproduct
- # InnerProduct
- # Input
- Log
- LRN
- MemoryData
- MVN
- Pooling
- Power
- PReLU
- Proposal
- # Reduction
- # ReLU
- # Reshape
- ROIPooling
- Scale
- # Sigmoid
- Slice
- Softmax
- # Split
- SPP
- # TanH
- Threshold
- Tile
- RNN
- LSTM
- # BinaryOp
- # UnaryOp
- ConvolutionDepthWise
- # Padding # required by innerproduct and convolution
- Squeeze
- # ExpandDims
- Normalize
- # Permute
- PriorBox
- DetectionOutput
- Interp
- DeconvolutionDepthWise
- ShuffleChannel
- InstanceNorm
- Clip
- Reorg
- YoloDetectionOutput
- Quantize
- Dequantize
- Yolov3DetectionOutput
- PSROIPooling
- ROIAlign
- Packing
- Requantize
- # Cast # needed InnerProduct
- HardSigmoid
- SELU
- HardSwish
- Noop
- PixelShuffle
- DeepCopy
- Mish
- StatisticsPooling
- Swish
- Gemm
- GroupNorm
- LayerNorm
- Softplus
- GRU
- MultiHeadAttention
- GELU
- Convolution1D
- Pooling1D
- # ConvolutionDepthWise1D
- Convolution3D
- ConvolutionDepthWise3D
- Pooling3D
- MatMul
- Deconvolution1D
- DeconvolutionDepthWise1D
- Deconvolution3D
- DeconvolutionDepthWise3D
- Einsum
- DeformableConv2D
- RelPositionalEncoding
- MakePadMask
- RelShift
- GLU
- )
- foreach(layer IN LISTS disabled_layers)
- string(TOLOWER ${layer} name)
- set(WITH_LAYER_${name} OFF CACHE BOOL "" FORCE)
- endforeach()
- FetchContent_GetProperties(ncnn)
- if(NOT ncnn_POPULATED)
- message(STATUS "Downloading ncnn ${ncnn_URL}")
- FetchContent_Populate(ncnn)
- endif()
- message(STATUS "ncnn is downloaded to ${ncnn_SOURCE_DIR}")
- message(STATUS "ncnn's binary dir is ${ncnn_BINARY_DIR}")
- add_subdirectory(${ncnn_SOURCE_DIR} ${ncnn_BINARY_DIR} EXCLUDE_FROM_ALL)
- endfunction()
- download_ncnn()
|