Skip to content

Commit

Permalink
Create thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco Wong committed Feb 2, 2025
1 parent daefbd4 commit 4338da2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions onnxruntime/test/wasm/test_inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@
#include "core/session/onnxruntime_cxx_api.h"

TEST(WebAssemblyTest, test) {
Ort::Env ort_env;
auto numIntraOpsThreads = 10;
// OrtThreadingOptions *threadingOptions;
// Ort::SessionOptions sessionOptions;
// sessionOptions.DisablePerSessionThreads();
// Ort::Env ort_env(threadingOptions, ORT_LOGGING_LEVEL_WARNING, "test");

OrtEnv* environment;
OrtThreadingOptions* envOpts = nullptr;
Ort::GetApi().CreateThreadingOptions(&envOpts);
Ort::GetApi().SetGlobalIntraOpNumThreads(envOpts, numIntraOpsThreads);
Ort::GetApi().SetGlobalInterOpNumThreads(envOpts, numInterOpsThreads);
Ort::GetApi().SetGlobalSpinControl(envOpts, 1);
Ort::GetApi().CreateEnvWithGlobalThreadPools(ORT_LOGGING_LEVEL_WARNING, "test", envOpts, &environment);
env = Ort::Env(environment);

// Ort::Env ort_env;
Ort::Session session{ort_env, "testdata/mul_1.onnx", Ort::SessionOptions{nullptr}};
auto memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);

Expand Down Expand Up @@ -39,4 +54,4 @@ TEST(WebAssemblyTest, test) {
for (size_t i = 0; i != total_len; ++i) {
ASSERT_EQ(expected_data[i], result[i]);
}
}
}

0 comments on commit 4338da2

Please sign in to comment.