Skip to content

Commit 71d7d27

Browse files
dsharletgcopybara-github
authored andcommitted
Don't handle special case of reductions for scalar inputs and "empty" reduction axes
TFlite has a wierd thing where it allows specifying that the shape `{0}` (not `{}`) means "scalar" or empty. XNNPACK does not have this special case, and I don't think we should support it. PiperOrigin-RevId: 882225739
1 parent 85d3747 commit 71d7d27

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tflite/delegates/xnnpack/xnnpack_delegate.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4918,7 +4918,9 @@ class Subgraph {
49184918
const int32_t* axes_data =
49194919
reinterpret_cast<const int32_t*>(axes_tensor.data.data);
49204920
const int num_reduction_axes = NumElements(&axes_tensor);
4921-
if (num_reduction_axes <= 0) {
4921+
if (num_reduction_axes <= 0 ||
4922+
(num_reduction_axes == 1 && axes_data[0] == 0 &&
4923+
input_tensor.dims->size == 0)) {
49224924
TF_LITE_MAYBE_KERNEL_LOG(
49234925
logging_context,
49244926
"Not handling ill defined empty reduction in node #%d", node_index);

0 commit comments

Comments
 (0)