Committed by
GitHub
Fix setting rknn core mask (#2594)
We need to set the core mask after `rknn_dup_context()`.
正在显示
5 个修改的文件
包含
13 行增加
和
19 行删除
| @@ -139,7 +139,7 @@ jobs: | @@ -139,7 +139,7 @@ jobs: | ||
| 139 | file: sherpa-onnx-*-android-rknn.tar.bz2 | 139 | file: sherpa-onnx-*-android-rknn.tar.bz2 |
| 140 | # repo_name: k2-fsa/sherpa-onnx | 140 | # repo_name: k2-fsa/sherpa-onnx |
| 141 | # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} | 141 | # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} |
| 142 | - # tag: v1.11.3 | 142 | + # tag: v1.12.13 |
| 143 | 143 | ||
| 144 | build-android-aar-rknn: | 144 | build-android-aar-rknn: |
| 145 | needs: [build-android-rknn-libs] | 145 | needs: [build-android-rknn-libs] |
| @@ -275,7 +275,7 @@ jobs: | @@ -275,7 +275,7 @@ jobs: | ||
| 275 | file: ./*.aar | 275 | file: ./*.aar |
| 276 | # repo_name: k2-fsa/sherpa-onnx | 276 | # repo_name: k2-fsa/sherpa-onnx |
| 277 | # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} | 277 | # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} |
| 278 | - # tag: v1.11.3 | 278 | + # tag: v1.12.13 |
| 279 | 279 | ||
| 280 | - name: Release android aar | 280 | - name: Release android aar |
| 281 | if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | 281 | if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| @@ -250,7 +250,7 @@ jobs: | @@ -250,7 +250,7 @@ jobs: | ||
| 250 | file: sherpa-onnx-*linux-aarch64*.tar.bz2 | 250 | file: sherpa-onnx-*linux-aarch64*.tar.bz2 |
| 251 | repo_name: k2-fsa/sherpa-onnx | 251 | repo_name: k2-fsa/sherpa-onnx |
| 252 | repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} | 252 | repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} |
| 253 | - tag: v1.12.0 | 253 | + tag: v1.12.13 |
| 254 | 254 | ||
| 255 | - name: Test offline Moonshine | 255 | - name: Test offline Moonshine |
| 256 | if: matrix.build_type != 'Debug' | 256 | if: matrix.build_type != 'Debug' |
| @@ -38,8 +38,6 @@ class OfflineSenseVoiceModelRknn::Impl { | @@ -38,8 +38,6 @@ class OfflineSenseVoiceModelRknn::Impl { | ||
| 38 | auto buf = ReadFile(config_.sense_voice.model); | 38 | auto buf = ReadFile(config_.sense_voice.model); |
| 39 | Init(buf.data(), buf.size()); | 39 | Init(buf.data(), buf.size()); |
| 40 | } | 40 | } |
| 41 | - | ||
| 42 | - SetCoreMask(ctx_, config_.num_threads); | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | template <typename Manager> | 43 | template <typename Manager> |
| @@ -48,8 +46,6 @@ class OfflineSenseVoiceModelRknn::Impl { | @@ -48,8 +46,6 @@ class OfflineSenseVoiceModelRknn::Impl { | ||
| 48 | auto buf = ReadFile(mgr, config_.sense_voice.model); | 46 | auto buf = ReadFile(mgr, config_.sense_voice.model); |
| 49 | Init(buf.data(), buf.size()); | 47 | Init(buf.data(), buf.size()); |
| 50 | } | 48 | } |
| 51 | - | ||
| 52 | - SetCoreMask(ctx_, config_.num_threads); | ||
| 53 | } | 49 | } |
| 54 | 50 | ||
| 55 | const OfflineSenseVoiceModelMetaData &GetModelMetadata() const { | 51 | const OfflineSenseVoiceModelMetaData &GetModelMetadata() const { |
| @@ -89,6 +85,8 @@ class OfflineSenseVoiceModelRknn::Impl { | @@ -89,6 +85,8 @@ class OfflineSenseVoiceModelRknn::Impl { | ||
| 89 | auto ret = rknn_dup_context(&ctx_, &ctx); | 85 | auto ret = rknn_dup_context(&ctx_, &ctx); |
| 90 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the ctx"); | 86 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the ctx"); |
| 91 | 87 | ||
| 88 | + SetCoreMask(ctx, config_.num_threads); | ||
| 89 | + | ||
| 92 | ret = rknn_inputs_set(ctx, inputs.size(), inputs.data()); | 90 | ret = rknn_inputs_set(ctx, inputs.size(), inputs.data()); |
| 93 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set inputs"); | 91 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set inputs"); |
| 94 | 92 |
| @@ -41,8 +41,6 @@ class OnlineZipformerCtcModelRknn::Impl { | @@ -41,8 +41,6 @@ class OnlineZipformerCtcModelRknn::Impl { | ||
| 41 | auto buf = ReadFile(config.zipformer2_ctc.model); | 41 | auto buf = ReadFile(config.zipformer2_ctc.model); |
| 42 | Init(buf.data(), buf.size()); | 42 | Init(buf.data(), buf.size()); |
| 43 | } | 43 | } |
| 44 | - | ||
| 45 | - SetCoreMask(ctx_, config_.num_threads); | ||
| 46 | } | 44 | } |
| 47 | 45 | ||
| 48 | template <typename Manager> | 46 | template <typename Manager> |
| @@ -51,8 +49,6 @@ class OnlineZipformerCtcModelRknn::Impl { | @@ -51,8 +49,6 @@ class OnlineZipformerCtcModelRknn::Impl { | ||
| 51 | auto buf = ReadFile(mgr, config.zipformer2_ctc.model); | 49 | auto buf = ReadFile(mgr, config.zipformer2_ctc.model); |
| 52 | Init(buf.data(), buf.size()); | 50 | Init(buf.data(), buf.size()); |
| 53 | } | 51 | } |
| 54 | - | ||
| 55 | - SetCoreMask(ctx_, config_.num_threads); | ||
| 56 | } | 52 | } |
| 57 | 53 | ||
| 58 | std::vector<std::vector<uint8_t>> GetInitStates() const { | 54 | std::vector<std::vector<uint8_t>> GetInitStates() const { |
| @@ -148,6 +144,8 @@ class OnlineZipformerCtcModelRknn::Impl { | @@ -148,6 +144,8 @@ class OnlineZipformerCtcModelRknn::Impl { | ||
| 148 | auto ret = rknn_dup_context(&ctx_, &ctx); | 144 | auto ret = rknn_dup_context(&ctx_, &ctx); |
| 149 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the ctx"); | 145 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the ctx"); |
| 150 | 146 | ||
| 147 | + SetCoreMask(ctx, config_.num_threads); | ||
| 148 | + | ||
| 151 | ret = rknn_inputs_set(ctx, inputs.size(), inputs.data()); | 149 | ret = rknn_inputs_set(ctx, inputs.size(), inputs.data()); |
| 152 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set inputs"); | 150 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set inputs"); |
| 153 | 151 |
| @@ -61,10 +61,6 @@ class OnlineZipformerTransducerModelRknn::Impl { | @@ -61,10 +61,6 @@ class OnlineZipformerTransducerModelRknn::Impl { | ||
| 61 | auto buf = ReadFile(config.transducer.joiner); | 61 | auto buf = ReadFile(config.transducer.joiner); |
| 62 | InitJoiner(buf.data(), buf.size()); | 62 | InitJoiner(buf.data(), buf.size()); |
| 63 | } | 63 | } |
| 64 | - | ||
| 65 | - SetCoreMask(encoder_ctx_, config_.num_threads); | ||
| 66 | - SetCoreMask(decoder_ctx_, config_.num_threads); | ||
| 67 | - SetCoreMask(joiner_ctx_, config_.num_threads); | ||
| 68 | } | 64 | } |
| 69 | 65 | ||
| 70 | template <typename Manager> | 66 | template <typename Manager> |
| @@ -83,10 +79,6 @@ class OnlineZipformerTransducerModelRknn::Impl { | @@ -83,10 +79,6 @@ class OnlineZipformerTransducerModelRknn::Impl { | ||
| 83 | auto buf = ReadFile(mgr, config.transducer.joiner); | 79 | auto buf = ReadFile(mgr, config.transducer.joiner); |
| 84 | InitJoiner(buf.data(), buf.size()); | 80 | InitJoiner(buf.data(), buf.size()); |
| 85 | } | 81 | } |
| 86 | - | ||
| 87 | - SetCoreMask(encoder_ctx_, config_.num_threads); | ||
| 88 | - SetCoreMask(decoder_ctx_, config_.num_threads); | ||
| 89 | - SetCoreMask(joiner_ctx_, config_.num_threads); | ||
| 90 | } | 82 | } |
| 91 | 83 | ||
| 92 | std::vector<std::vector<uint8_t>> GetEncoderInitStates() const { | 84 | std::vector<std::vector<uint8_t>> GetEncoderInitStates() const { |
| @@ -185,6 +177,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | @@ -185,6 +177,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | ||
| 185 | auto ret = rknn_dup_context(&encoder_ctx_, &encoder_ctx); | 177 | auto ret = rknn_dup_context(&encoder_ctx_, &encoder_ctx); |
| 186 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the encoder ctx"); | 178 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the encoder ctx"); |
| 187 | 179 | ||
| 180 | + SetCoreMask(encoder_ctx, config_.num_threads); | ||
| 181 | + | ||
| 188 | ret = rknn_inputs_set(encoder_ctx, inputs.size(), inputs.data()); | 182 | ret = rknn_inputs_set(encoder_ctx, inputs.size(), inputs.data()); |
| 189 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set encoder inputs"); | 183 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set encoder inputs"); |
| 190 | 184 | ||
| @@ -240,6 +234,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | @@ -240,6 +234,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | ||
| 240 | auto ret = rknn_dup_context(&decoder_ctx_, &decoder_ctx); | 234 | auto ret = rknn_dup_context(&decoder_ctx_, &decoder_ctx); |
| 241 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the decoder ctx"); | 235 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the decoder ctx"); |
| 242 | 236 | ||
| 237 | + SetCoreMask(decoder_ctx, config_.num_threads); | ||
| 238 | + | ||
| 243 | ret = rknn_inputs_set(decoder_ctx, 1, &input); | 239 | ret = rknn_inputs_set(decoder_ctx, 1, &input); |
| 244 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set decoder inputs"); | 240 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set decoder inputs"); |
| 245 | 241 | ||
| @@ -281,6 +277,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | @@ -281,6 +277,8 @@ class OnlineZipformerTransducerModelRknn::Impl { | ||
| 281 | auto ret = rknn_dup_context(&joiner_ctx_, &joiner_ctx); | 277 | auto ret = rknn_dup_context(&joiner_ctx_, &joiner_ctx); |
| 282 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the joiner ctx"); | 278 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to duplicate the joiner ctx"); |
| 283 | 279 | ||
| 280 | + SetCoreMask(joiner_ctx, config_.num_threads); | ||
| 281 | + | ||
| 284 | ret = rknn_inputs_set(joiner_ctx, inputs.size(), inputs.data()); | 282 | ret = rknn_inputs_set(joiner_ctx, inputs.size(), inputs.data()); |
| 285 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set joiner inputs"); | 283 | SHERPA_ONNX_RKNN_CHECK(ret, "Failed to set joiner inputs"); |
| 286 | 284 |
-
请 注册 或 登录 后发表评论