Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -138,10 +138,10 @@ void WebGpuContext::Initialize(const WebGpuContextConfig& config) {
config.buffer_cache_config.uniform.mode,
config.buffer_cache_config.query_resolve.mode);

// create initializer buffer manager. cache is always disabled for initializer buffer manager
// create initializer buffer manager.
initializer_buffer_mgr_ = BufferManagerFactory::Create(*this,
BufferCacheMode::Disabled,
BufferCacheMode::Disabled,
BufferCacheMode::LazyRelease,
BufferCacheMode::LazyRelease,
BufferCacheMode::Disabled);

// create program manager
Expand Down
6 changes: 6 additions & 0 deletions onnxruntime/core/providers/webgpu/webgpu_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ Status WebGpuKernel::PrePack(const Tensor& tensor, int input_idx, AllocatorPtr /

Status s = PrePackInternal(context, tensor, input_idx, ep_.PrepackAllocator(), is_packed);

if (is_packed) {
// Flush pending commands to ensure GPU buffer creations are completed.
// This allows the initializer buffer manager to release temporary buffers and reduce memory usage.
webgpu_context_.Flush(webgpu_context_.InitializerBufferManager());
}

if (webgpu_context_.ValidationMode() >= ValidationMode::Full) {
ORT_RETURN_IF_ERROR(webgpu_context_.PopErrorScope());
}
Expand Down
Loading