Skip to content

Commit

Permalink
replace OrtMutex
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed Oct 22, 2024
1 parent 26ff482 commit 872149b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions onnxruntime/core/providers/webgpu/webgpu_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ void WebGpuContext::Flush() {
}

std::unordered_map<int32_t, std::unique_ptr<WebGpuContext>> WebGpuContextFactory::contexts_;
OrtMutex WebGpuContextFactory::mutex_;
std::mutex WebGpuContextFactory::mutex_;

WebGpuContext& WebGpuContextFactory::CreateContext(int context_id,
WGPUInstance instance,
Expand All @@ -642,7 +642,7 @@ WebGpuContext& WebGpuContextFactory::CreateContext(int context_id,
"WebGPU EP custom context (contextId>0) must have custom WebGPU instance, adapter and device.");
}

std::lock_guard<OrtMutex> lock(mutex_);
std::lock_guard<std::mutex> lock(mutex_);

auto it = contexts_.find(context_id);
if (it == contexts_.end()) {
Expand All @@ -656,7 +656,7 @@ WebGpuContext& WebGpuContextFactory::CreateContext(int context_id,
}

WebGpuContext& WebGpuContextFactory::GetContext(int context_id) {
std::lock_guard<OrtMutex> lock(mutex_);
std::lock_guard<std::mutex> lock(mutex_);

auto it = contexts_.find(context_id);
ORT_ENFORCE(it != contexts_.end(), "WebGPU EP context ID ", context_id, " is not found.");
Expand Down
3 changes: 1 addition & 2 deletions onnxruntime/core/providers/webgpu/webgpu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <webgpu/webgpu_cpp.h>

#include "core/common/common.h"
#include "core/platform/ort_mutex.h"
#include "core/providers/webgpu/webgpu_execution_provider.h"
#include "core/providers/webgpu/buffer_manager.h"
#include "core/providers/webgpu/program_manager.h"
Expand All @@ -39,7 +38,7 @@ class WebGpuContextFactory {
WebGpuContextFactory() {}

static std::unordered_map<int32_t, std::unique_ptr<WebGpuContext>> contexts_;
static OrtMutex mutex_;
static std::mutex mutex_;
};

// Class WebGpuContext includes all necessary resources for the context.
Expand Down

0 comments on commit 872149b

Please sign in to comment.