You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug 1933012 [wpt PR 49343] - webnn: Support gatherElements in tflite converter, a=testonly
Automatic update from web-platform-tests
webnn: Support gatherElements in tflite converter
There is no TFLite operator to map directly WebNN gatherElements, but
it can be supported with tfl.gather_nd, the test cases[1] and the
doc[2] show the gather_nd can gether not only slices but also elements,
but gather_nd can't gather along the axis, so the indices used by
gather_nd need to be calculated by unravelling the flat index and
adjusting value with the axis.
The coordinates are calculated by the stride of each dimension. For
example a shape (3, 2) array can map to the following coordinates:
// index row, col
// [[0, 1,] [[0, 0], [0, 1],
// [2, 3,] => [1, 0], [1, 1]
// [4, 5,]] [2, 0], [2, 1]]
Adjusting the coordinates with WebNN indices operand along the axis,
// unravelled index WebNN indices axis = 0 TFLite indices
// [[0, 0], [0, 1], [[1, 0], [[1 ,0], [0, 1],
// [1, 0], [1, 1] [2, 1], => [2, 0], [1, 1],
// [2, 0], [2, 1]] [0, 2]] [0, 0], [2, 1]]
[1] https://www.tensorflow.org/mlir/tfl_ops#tflgather_nd_tflgatherndop
[2] https://www.tensorflow.org/guide/tensor_slicing#insert_data_into_tensors
Bug: 40206287
Change-Id: I61ad75585405039da10af05f3300799fe8f32855
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6000111
Reviewed-by: ningxin hu <ningxin.huintel.com>
Reviewed-by: Reilly Grant <reillygchromium.org>
Commit-Queue: Junwei Fu <junwei.fuintel.com>
Cr-Commit-Position: refs/heads/main{#1387213}
--
wpt-commits: 038b09dd678084a3fdc828316da9a2f2a03981cf
wpt-pr: 49343
UltraBlame original commit: edbd32557d5a79f628cad8f6f7b2a85003e0f334
0 commit comments