Skip to content

Commit

Permalink
Use a single thread when loading models (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Mar 26, 2024
1 parent 305c373 commit d364610
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/offline-ctc-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length,
bool debug) {
Ort::Env env(ORT_LOGGING_LEVEL_WARNING);
Ort::SessionOptions sess_opts;
sess_opts.SetIntraOpNumThreads(1);
sess_opts.SetInterOpNumThreads(1);

auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length,
sess_opts);
Expand Down
6 changes: 6 additions & 0 deletions sherpa-onnx/csrc/offline-recognizer-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create(
Ort::Env env(ORT_LOGGING_LEVEL_ERROR);

Ort::SessionOptions sess_opts;
sess_opts.SetIntraOpNumThreads(1);
sess_opts.SetInterOpNumThreads(1);

std::string model_filename;
if (!config.model_config.transducer.encoder_filename.empty()) {
model_filename = config.model_config.transducer.encoder_filename;
Expand Down Expand Up @@ -167,6 +170,9 @@ std::unique_ptr<OfflineRecognizerImpl> OfflineRecognizerImpl::Create(
Ort::Env env(ORT_LOGGING_LEVEL_ERROR);

Ort::SessionOptions sess_opts;
sess_opts.SetIntraOpNumThreads(1);
sess_opts.SetInterOpNumThreads(1);

std::string model_filename;
if (!config.model_config.transducer.encoder_filename.empty()) {
model_filename = config.model_config.transducer.encoder_filename;
Expand Down
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/online-transducer-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length,
bool debug) {
Ort::Env env(ORT_LOGGING_LEVEL_WARNING);
Ort::SessionOptions sess_opts;
sess_opts.SetIntraOpNumThreads(1);
sess_opts.SetInterOpNumThreads(1);

auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length,
sess_opts);
Expand Down
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/speaker-embedding-extractor-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static ModelType GetModelType(char *model_data, size_t model_data_length,
bool debug) {
Ort::Env env(ORT_LOGGING_LEVEL_WARNING);
Ort::SessionOptions sess_opts;
sess_opts.SetIntraOpNumThreads(1);
sess_opts.SetInterOpNumThreads(1);

auto sess = std::make_unique<Ort::Session>(env, model_data, model_data_length,
sess_opts);
Expand Down

0 comments on commit d364610

Please sign in to comment.