Skip to content

Conversation

@BruceDai
Copy link
Contributor

@BruceDai BruceDai commented Dec 7, 2022

@fdwr @Honry @dontcallmedom PTAL, thanks.

}
},
"options": {
"axes": [-4, -2]
Copy link

@fdwr fdwr Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Higher level policy like negative axes in WebNN complicate implementations and testing :/ (and it's unnecessary since WebNN doesn't support arbitrary shape inference anyway). In future versions of WebNN, I'd like to see actual indices resolved by the higher level frameworks first.

-45.433313937995614,
20.781868403551314,
-66.96646315625907
],
Copy link

@fdwr fdwr Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to be careful summing mixed signs, due to subtraction of nearly equal numbers magnifying error. For reduceSum, I think it wiser to curate the input tensors to all positive values, all negative values, and/or all integers. Otherwise you'll chase down errors of catastrophic cancellation. The ULP values given are with this restriction in mind, as there are no reasonable tolerance values for nearly equal numbers - you either have to relax them (potentially greatly), which weakens the overall tolerance of all other cases, or you have to cross your fingers that you won't hit such a case (which is tough given the randomness of the values and the fact they can be added in any order depending on the implementation).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning applies to reduceMean too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I will add such tests as your suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added such tests for reduceMean and reduceSum ops, please have another look, thanks.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you added more test cases, but the existing problematic test cases of mixed signs in ReduceMean and ReduceSum remain and can encounter tolerance issues. So I was hoping those would be converted to consistent signs (or in light of the new test cases, be deleted).

      "name": "reduceMean float32 4D tensor default options",
      "inputs": {
        "input": {
          "shape": [2, 2, 2, 3],
          "data": [
            -1.913036787607325,
            95.38300711992477,
            -82.72358015843713,
            -32.94943032326678,
            91.42181191536278,
            -75.1219094678544,
            -70.81411336302938,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thanks.

}
},
{
"name": "reduceSum float32 4D tensor negtive options.axes with options.keepDimensions=true",
Copy link

@fdwr fdwr Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

negative

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updated.

let tolerance = sizes.reduce(
(accumulator, currentValue) => accumulator * currentValue
);
if (['reduceMean'].includes(operationName)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know Javascript well, but is this better than just a string comparison? operationName == 'reduceMean' is clearer to me. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I use this condition for extensibility, maybe other reduce operations need adopt this same tolerance later, so we just update array to solve this case, for example

if (['reduceMean', 'reduceXXXX'].includes(operationName)) 

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Putting the thing being tested after the things being tested against feels reversed :/. Alas, one would think you could readably say...

if (operationName in ['reduceMean', 'reduceXXXX'])

...but reading about JS's in operator, it behaves counterintuitively, returning true for things that are not in the list if an undefined value exists -_-. Oh well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thanks.

@BruceDai BruceDai force-pushed the add_webnn_reduce_tests branch 3 times, most recently from 96672ce to 4b784fa Compare December 10, 2022 06:29
@BruceDai
Copy link
Contributor Author

@fdwr Thanks for your reviewing, I've updated PR to address your comments.

        reduceMax/reduceMean/reduceMin/reduceProduct/reduceSum
@BruceDai BruceDai force-pushed the add_webnn_reduce_tests branch from ce4a53d to 0b25b16 Compare January 12, 2023 10:55
@BruceDai
Copy link
Contributor Author

@Honry All checks passed, PTAL, thanks.

@Honry Honry merged commit 499b80a into web-platform-tests:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants