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
18 changes: 17 additions & 1 deletion onnxruntime/core/providers/webgpu/webgpu_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,29 @@ std::vector<const char*> WebGpuContext::GetEnabledDeviceToggles() const {
// Enable / disable other toggles that may affect the performance.
// Other toggles that may be useful: "dump_shaders", "disable_symbol_renaming"
constexpr const char* toggles[] = {
"skip_validation", // only use "skip_validation" when ValidationMode is set to "Disabled"
"skip_validation",
"disable_robustness",
"d3d_disable_ieee_strictness",
};
#ifndef NDEBUG
// validation_mode_explicitly_set_ only changes release behavior; mark it used in debug builds
// to avoid -Wunused-private-field on toolchains that treat warnings as errors.
ORT_UNUSED_PARAMETER(validation_mode_explicitly_set_);
return std::vector<const char*>(ValidationMode() >= ValidationMode::WGPUOnly
? std::begin(toggles) + 1
: std::begin(toggles),
std::end(toggles));
#else
// In release/relwithdebinfo builds, default to skip_validation for performance,
// but honor explicit validationMode overrides.
if (!validation_mode_explicitly_set_) {
return std::vector<const char*>(std::begin(toggles), std::end(toggles));
}
return std::vector<const char*>(ValidationMode() >= ValidationMode::WGPUOnly
? std::begin(toggles) + 1
: std::begin(toggles),
std::end(toggles));
#endif
}

std::vector<const char*> WebGpuContext::GetDisabledDeviceToggles() const {
Expand Down Expand Up @@ -1006,6 +1021,7 @@ WebGpuContext& WebGpuContextFactory::CreateContext(const WebGpuContextConfig& co
auto context = std::unique_ptr<WebGpuContext>(new WebGpuContext(instance,
device,
config.validation_mode,
config.validation_mode_explicitly_set,
config.preserve_device,
config.max_storage_buffer_binding_size));
it = contexts_->emplace(context_id, WebGpuContextFactory::WebGpuContextInfo{std::move(context), 0}).first;
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/providers/webgpu/webgpu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct WebGpuContextConfig {
webgpu::ValidationMode::Basic // for release build, enable basic validation by default
#endif // !NDEBUG
};
bool validation_mode_explicitly_set{false};
bool preserve_device{false};
uint64_t max_storage_buffer_binding_size{0};
WebGpuBufferCacheConfig buffer_cache_config{};
Expand Down Expand Up @@ -278,11 +279,13 @@ class WebGpuContext final {
WebGpuContext(WGPUInstance instance,
WGPUDevice device,
webgpu::ValidationMode validation_mode,
bool validation_mode_explicitly_set,
bool preserve_device,
uint64_t max_storage_buffer_binding_size)
: instance_{instance},
device_{device},
validation_mode_{validation_mode},
validation_mode_explicitly_set_{validation_mode_explicitly_set},
query_type_{TimestampQueryType::None},
preserve_device_{preserve_device},
max_storage_buffer_binding_size_{max_storage_buffer_binding_size} {
Expand Down Expand Up @@ -327,6 +330,7 @@ class WebGpuContext final {
wgpu::Device device_;

webgpu::ValidationMode validation_mode_;
bool validation_mode_explicitly_set_;

wgpu::Queue device_queue_;
wgpu::AdapterInfo adapter_info_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ WebGpuContextConfig ParseWebGpuContextConfig(const ConfigOptions& config_options

if (std::string validation_mode_str;
config_options.TryGetConfigEntry(kValidationMode, validation_mode_str)) {
config.validation_mode_explicitly_set = true;
if (validation_mode_str == kValidationMode_Disabled) {
config.validation_mode = ValidationMode::Disabled;
} else if (validation_mode_str == kValidationMode_wgpuOnly) {
Expand Down
Loading