Sfoglia il codice sorgente

Disable unused layers to reduce executable size and compilation time. (#5)

Fangjun Kuang 2 anni fa
parent
commit
d8eb19e791
2 ha cambiato i file con 113 aggiunte e 3 eliminazioni
  1. 2 3
      cmake/kaldi-native-fbank.cmake
  2. 111 0
      cmake/ncnn.cmake

+ 2 - 3
cmake/kaldi-native-fbank.cmake

@@ -9,9 +9,8 @@ function(download_kaldi_native_fbank)
 
   include(FetchContent)
 
-  set(kaldi_native_fbank_URL  "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.2.tar.gz")
-  set(kaldi_native_fbank_HASH "SHA256=d4562be95b9d5e974258d3f7e8506b48e454b9b0930dcddf1db020b763418c86")
-
+  set(kaldi_native_fbank_URL  "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.4.tar.gz")
+  set(kaldi_native_fbank_HASH "SHA256=771e08cb7edf512c828f4577d0d071a7993991d7e5415b11a843975dcf3e4d2d")
 
   set(KALDI_NATIVE_FBANK_BUILD_TESTS OFF CACHE BOOL "" FORCE)
   set(KALDI_NATIVE_FBANK_BUILD_PYTHON OFF CACHE BOOL "" FORCE)

+ 111 - 0
cmake/ncnn.cmake

@@ -31,6 +31,117 @@ function(download_ncnn)
   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")