Skip to content

[Native WebGPU] Handle corner cases in naive kernel. #24438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 17, 2025
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/webgpu/reduction/reduction_ops.cc
Original file line number Diff line number Diff line change
@@ -367,12 +367,12 @@ Status ReduceKernel<allow_multi_axes>::ComputeInternal(ComputeContext& context)
}
}
TensorShape output_shape(output_shape_vector);
if (output_size == 0 || is_input_empty || input_tensor->Shape().NumDimensions() == 0) {
if (output_size == 0) {
ORT_IGNORE_RETURN_VALUE(context.Output(0, output_shape));
return Status::OK();
}

bool use_naive_reduction = name_ == "ArgMin" || name_ == "ArgMax" || (reduce_size < 32 && output_size > 1024);
bool use_naive_reduction = name_ == "ArgMin" || name_ == "ArgMax" || (reduce_size < 32 && output_size > 1024) || is_input_empty || input_tensor->Shape().NumDimensions() == 0;

if (use_naive_reduction) {
ReduceNaiveProgram program(name_, reduce_op_type, keepdims_, noop_with_empty_axes_, input_axes, is_input_empty);