Closed mei1127 closed 6 months ago
Makes sense to me - I put up a PR
also fails if the input rank is zero
(repeating here too)
Nop reductions are valid (where axes
are empty), and scalars are just another instance of a nop:
x = tensorflow.constant([3,3,3], dtype=tensorflow.float32)
y = tensorflow.reduce_sum(x, axis=[])
# value: tf.Tensor([3. 3. 3.], shape=(3,), dtype=float32)
# shape: (3,)
x = tensorflow.constant([], dtype=tensorflow.float32)
y = tensorflow.reduce_sum(x, axis=[])
# value: tf.Tensor([], shape=(0,), dtype=float32)
# shape: (0,)
What's not valid is a scalar reduction with non-empty axes, because that would index axes beyond the rank, but the existing check that each axis < inputRank already validates that condition, and so checking input rank is redundant and unnecessarily exclusionary. So, we should remove that line in Chromium.
Groovy. I have a Chromium CL (with WPT changes) up to remove the rank check crrev.com/c/5529350 but I'm a bit rusty so it may not land for a bit.
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt
Oh interesting. So making the change in Chromium land actually pushes it back into web-platform-tests/wpt
.
Yeah, we have two-way sync set up with WPT. Mozilla and Apple have something similar. It's not perfect and requires some babysitting, but it's super great when it works.
(This was raised by @a-sully in Chromium CL-5496412 review.)
For WebNN's reduction operator: Austion proposed to update the spec to add constraints on the axes and the input rank.
/cc @a-sully