Skip to content

Commit 3252320

Browse files
[Native WebGPU] Handle corner cases in naive kernel. (microsoft#24438)
### Description Handle empty input cases in the native reduce kernel. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
1 parent 9db4b10 commit 3252320

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

onnxruntime/core/providers/webgpu/reduction/reduction_ops.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ Status ReduceKernel<allow_multi_axes>::ComputeInternal(ComputeContext& context)
367367
}
368368
}
369369
TensorShape output_shape(output_shape_vector);
370-
if (output_size == 0 || is_input_empty || input_tensor->Shape().NumDimensions() == 0) {
370+
if (output_size == 0) {
371371
ORT_IGNORE_RETURN_VALUE(context.Output(0, output_shape));
372372
return Status::OK();
373373
}
374374

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

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

0 commit comments

Comments
 (0)