From 6cf698b16b7ce9f004867b56e549de4cccb6db67 Mon Sep 17 00:00:00 2001 From: Miao Bin Date: Wed, 17 Jul 2024 01:12:13 -0700 Subject: [PATCH] WebNN: Remove argmin/max selectLastIndex parameter This CL removes the selectLastIndex parameter from argMin and argMax to align with the spec change [1]. The changes include the definition of IDL and mojo, the implementation of DirectML and TfLite backend and the related unit tests and WPT tests. [1] https://github.com/webmachinelearning/webnn/pull/722 Bug: 352314071, 40206287 Change-Id: Ifbb1c5b8c5eef41f87b279c2b1018d2d5d0198ea Cq-Include-Trybots: luci.chromium.try:win11-blink-rel,mac14.arm64-blink-rel,mac14-blink-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5700708 Reviewed-by: Phillis Tang Reviewed-by: Elly FJ Reviewed-by: ningxin hu Commit-Queue: Bin Miao Cr-Commit-Position: refs/heads/main@{#1328688} --- webnn/resources/test_data/arg_max.json | 209 +------------------------ webnn/resources/test_data/arg_min.json | 209 +------------------------ 2 files changed, 14 insertions(+), 404 deletions(-) diff --git a/webnn/resources/test_data/arg_max.json b/webnn/resources/test_data/arg_max.json index c66f785f416c73..d65939d0477b7c 100644 --- a/webnn/resources/test_data/arg_max.json +++ b/webnn/resources/test_data/arg_max.json @@ -471,98 +471,6 @@ "type": "int32" } }, - { - "name": "argMax float32 4D tensor options.selectLastIndex=true", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955, - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955 - ], - "type": "float32" - } - }, - "options": { - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [], - "data": [ - 20 - ], - "type": "int32" - } - }, - { - "name": "argMax float32 4D tensor options.selectLastIndex=false", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955, - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955 - ], - "type": "float32" - } - }, - "options": { - "selectLastIndex": false - }, - "expected": { - "name": "output", - "shape": [], - "data": [ - 3 - ], - "type": "int32" - } - }, { "name": "argMax float32 4D tensor options.axes=[0, 2] options.keepDimensions=false", "inputs": { @@ -663,7 +571,7 @@ } }, { - "name": "argMax float32 4D tensor options.axes=[0, 2] options.selectLastIndex=false", + "name": "argMax float32 4D tensor options.axes=[0, 2]", "inputs": { "input": { "shape": [2, 1, 4, 3], @@ -697,8 +605,7 @@ } }, "options": { - "axes": [0, 2], - "selectLastIndex": false + "axes": [0, 2] }, "expected": { "name": "output", @@ -712,7 +619,7 @@ } }, { - "name": "argMax float32 4D tensor options.axes=[0, 2] options.selectLastIndex=true", + "name": "argMax float32 4D tensor options.axes=[3, 0, 1]", "inputs": { "input": { "shape": [2, 1, 4, 3], @@ -746,57 +653,7 @@ } }, "options": { - "axes": [0, 2], - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [1, 3], - "data": [ - 5, - 6, - 6 - ], - "type": "int32" - } - }, - { - "name": "argMax float32 4D tensor options.axes=[3, 0, 1] options.selectLastIndex=false", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955, - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955 - ], - "type": "float32" - } - }, - "options": { - "axes": [3, 0, 1], - "selectLastIndex": false + "axes": [3, 0, 1] }, "expected": { "name": "output", @@ -810,56 +667,6 @@ "type": "int32" } }, - { - "name": "argMax float32 4D tensor options.axes=[3, 0, 1] options.selectLastIndex=true", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955, - -51.0936194154457, - -6.5397018645619625, - 73.81338015899149, - 88.46114630531724, - -5.294266751122791, - -79.20668057325759, - -41.70176598864654, - 73.81338015899149, - 88.46114630531724, - -84.939998758247, - -61.488942502520906, - -98.33874402761955 - ], - "type": "float32" - } - }, - "options": { - "axes": [3, 0, 1], - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [4], - "data": [ - 5, - 3, - 5, - 4 - ], - "type": "int32" - } - }, { "name": "argMax float32 4D tensor all options", "inputs": { @@ -896,8 +703,7 @@ }, "options": { "axes": [3, 0], - "keepDimensions": true, - "selectLastIndex": false + "keepDimensions": true }, "expected": { "name": "output", @@ -935,7 +741,7 @@ } }, { - "name": "argMax float32 0D scalar options.axes=[] no effect by both keepDimensions and selectLastIndex being true", + "name": "argMax float32 0D scalar options.axes=[] no effect by keepDimensions being true", "inputs": { "input": { "shape": [], @@ -947,8 +753,7 @@ }, "options": { "axes": [], - "keepDimensions": true, - "selectLastIndex": true + "keepDimensions": true }, "expected": { "name": "output", diff --git a/webnn/resources/test_data/arg_min.json b/webnn/resources/test_data/arg_min.json index eaf59f098cc281..f7b3f6d10d6239 100644 --- a/webnn/resources/test_data/arg_min.json +++ b/webnn/resources/test_data/arg_min.json @@ -471,98 +471,6 @@ "type": "int32" } }, - { - "name": "argMin float32 4D tensor options.selectLastIndex=true", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - 3.830124090690262, - -24.986487937638074, - 5.299982630691289, - -48.5486590218902, - 40.30886781808215, - 60.184293919409726, - -82.78385618759043, - -96.50904103637833, - 71.87028201591897, - 38.866394268784035, - -39.143725517854435, - 31.444366685561903, - -82.78385618759043, - -96.50904103637833, - -25.53388886326502, - -16.142265850469343, - 66.63677406472371, - 82.5119815304117, - -82.78385618759043, - -96.50904103637833, - 39.7687246127592, - 42.15040238450999, - 82.66863662444459, - 85.4526923278379 - ], - "type": "float32" - } - }, - "options": { - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [], - "data": [ - 19 - ], - "type": "int32" - } - }, - { - "name": "argMin float32 4D tensor options.selectLastIndex=false", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - 3.830124090690262, - -24.986487937638074, - 5.299982630691289, - -48.5486590218902, - 40.30886781808215, - 60.184293919409726, - -82.78385618759043, - -96.50904103637833, - 71.87028201591897, - 38.866394268784035, - -39.143725517854435, - 31.444366685561903, - -82.78385618759043, - -96.50904103637833, - -25.53388886326502, - -16.142265850469343, - 66.63677406472371, - 82.5119815304117, - -82.78385618759043, - -96.50904103637833, - 39.7687246127592, - 42.15040238450999, - 82.66863662444459, - 85.4526923278379 - ], - "type": "float32" - } - }, - "options": { - "selectLastIndex": false - }, - "expected": { - "name": "output", - "shape": [], - "data": [ - 7 - ], - "type": "int32" - } - }, { "name": "argMin float32 4D tensor options.axes=[0, 2] options.keepDimensions=false", "inputs": { @@ -663,7 +571,7 @@ } }, { - "name": "argMin float32 4D tensor options.axes=[0, 2] options.selectLastIndex=false", + "name": "argMin float32 4D tensor options.axes=[0, 2]", "inputs": { "input": { "shape": [2, 1, 4, 3], @@ -697,8 +605,7 @@ } }, "options": { - "axes": [0, 2], - "selectLastIndex": false + "axes": [0, 2] }, "expected": { "name": "output", @@ -712,56 +619,7 @@ } }, { - "name": "argMin float32 4D tensor options.axes=[0, 2] options.selectLastIndex=true", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - 3.830124090690262, - -24.986487937638074, - 5.299982630691289, - -48.5486590218902, - 40.30886781808215, - 60.184293919409726, - -82.78385618759043, - -96.50904103637833, - 71.87028201591897, - 38.866394268784035, - -39.143725517854435, - 31.444366685561903, - -82.78385618759043, - -96.50904103637833, - -25.53388886326502, - -16.142265850469343, - 66.63677406472371, - 82.5119815304117, - -82.78385618759043, - -96.50904103637833, - 39.7687246127592, - 42.15040238450999, - 82.66863662444459, - 85.4526923278379 - ], - "type": "float32" - } - }, - "options": { - "axes": [0, 2], - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [1, 3], - "data": [ - 6, - 6, - 4 - ], - "type": "int32" - } - }, - { - "name": "argMin float32 4D tensor options.axes=[3, 0, 1] options.selectLastIndex=false", + "name": "argMin float32 4D tensor options.axes=[3, 0, 1]", "inputs": { "input": { "shape": [2, 1, 4, 3], @@ -795,8 +653,7 @@ } }, "options": { - "axes": [3, 0, 1], - "selectLastIndex": false + "axes": [3, 0, 1] }, "expected": { "name": "output", @@ -810,56 +667,6 @@ "type": "int32" } }, - { - "name": "argMin float32 4D tensor options.axes=[3, 0, 1] options.selectLastIndex=true", - "inputs": { - "input": { - "shape": [2, 1, 4, 3], - "data": [ - 3.830124090690262, - -24.986487937638074, - 5.299982630691289, - -48.5486590218902, - 40.30886781808215, - 60.184293919409726, - -82.78385618759043, - -96.50904103637833, - 71.87028201591897, - 38.866394268784035, - -39.143725517854435, - 31.444366685561903, - -82.78385618759043, - -96.50904103637833, - -25.53388886326502, - -16.142265850469343, - 66.63677406472371, - 82.5119815304117, - -82.78385618759043, - -96.50904103637833, - 39.7687246127592, - 42.15040238450999, - 82.66863662444459, - 85.4526923278379 - ], - "type": "float32" - } - }, - "options": { - "axes": [3, 0, 1], - "selectLastIndex": true - }, - "expected": { - "name": "output", - "shape": [4], - "data": [ - 4, - 0, - 4, - 1 - ], - "type": "int32" - } - }, { "name": "argMin float32 4D tensor all options", "inputs": { @@ -896,8 +703,7 @@ }, "options": { "axes": [3, 0], - "keepDimensions": true, - "selectLastIndex": false + "keepDimensions": true }, "expected": { "name": "output", @@ -935,7 +741,7 @@ } }, { - "name": "argMin float32 0D scalar options.axes=[] no effect by both keepDimensions and selectLastIndex being true", + "name": "argMin float32 0D scalar options.axes=[] no effect by keepDimensions being true", "inputs": { "input": { "shape": [], @@ -947,8 +753,7 @@ }, "options": { "axes": [], - "keepDimensions": true, - "selectLastIndex": true + "keepDimensions": true }, "expected": { "name": "output",