Committed by
GitHub
Use a single thread when loading models (#703)
正在显示
4 个修改的文件
包含
12 行增加
和
0 行删除
| @@ -34,6 +34,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | @@ -34,6 +34,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | ||
| 34 | bool debug) { | 34 | bool debug) { |
| 35 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); | 35 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); |
| 36 | Ort::SessionOptions sess_opts; | 36 | Ort::SessionOptions sess_opts; |
| 37 | + sess_opts.SetIntraOpNumThreads(1); | ||
| 38 | + sess_opts.SetInterOpNumThreads(1); | ||
| 37 | 39 | ||
| 38 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, | 40 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, |
| 39 | sess_opts); | 41 | sess_opts); |
| @@ -40,6 +40,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create( | @@ -40,6 +40,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create( | ||
| 40 | Ort::Env env(ORT_LOGGING_LEVEL_ERROR); | 40 | Ort::Env env(ORT_LOGGING_LEVEL_ERROR); |
| 41 | 41 | ||
| 42 | Ort::SessionOptions sess_opts; | 42 | Ort::SessionOptions sess_opts; |
| 43 | + sess_opts.SetIntraOpNumThreads(1); | ||
| 44 | + sess_opts.SetInterOpNumThreads(1); | ||
| 45 | + | ||
| 43 | std::string model_filename; | 46 | std::string model_filename; |
| 44 | if (!config.model_config.transducer.encoder_filename.empty()) { | 47 | if (!config.model_config.transducer.encoder_filename.empty()) { |
| 45 | model_filename = config.model_config.transducer.encoder_filename; | 48 | model_filename = config.model_config.transducer.encoder_filename; |
| @@ -167,6 +170,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create( | @@ -167,6 +170,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create( | ||
| 167 | Ort::Env env(ORT_LOGGING_LEVEL_ERROR); | 170 | Ort::Env env(ORT_LOGGING_LEVEL_ERROR); |
| 168 | 171 | ||
| 169 | Ort::SessionOptions sess_opts; | 172 | Ort::SessionOptions sess_opts; |
| 173 | + sess_opts.SetIntraOpNumThreads(1); | ||
| 174 | + sess_opts.SetInterOpNumThreads(1); | ||
| 175 | + | ||
| 170 | std::string model_filename; | 176 | std::string model_filename; |
| 171 | if (!config.model_config.transducer.encoder_filename.empty()) { | 177 | if (!config.model_config.transducer.encoder_filename.empty()) { |
| 172 | model_filename = config.model_config.transducer.encoder_filename; | 178 | model_filename = config.model_config.transducer.encoder_filename; |
| @@ -39,6 +39,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | @@ -39,6 +39,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | ||
| 39 | bool debug) { | 39 | bool debug) { |
| 40 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); | 40 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); |
| 41 | Ort::SessionOptions sess_opts; | 41 | Ort::SessionOptions sess_opts; |
| 42 | + sess_opts.SetIntraOpNumThreads(1); | ||
| 43 | + sess_opts.SetInterOpNumThreads(1); | ||
| 42 | 44 | ||
| 43 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, | 45 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, |
| 44 | sess_opts); | 46 | sess_opts); |
| @@ -25,6 +25,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | @@ -25,6 +25,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, | ||
| 25 | bool debug) { | 25 | bool debug) { |
| 26 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); | 26 | Ort::Env env(ORT_LOGGING_LEVEL_WARNING); |
| 27 | Ort::SessionOptions sess_opts; | 27 | Ort::SessionOptions sess_opts; |
| 28 | + sess_opts.SetIntraOpNumThreads(1); | ||
| 29 | + sess_opts.SetInterOpNumThreads(1); | ||
| 28 | 30 | ||
| 29 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, | 31 | auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length, |
| 30 | sess_opts); | 32 | sess_opts); |
-
请 注册 或 登录 后发表评论