Skip to content

Implement hardSwish#32

Merged
huningxin merged 1 commit intowebmachinelearning:mainfrom
BruceDai:support_hardSwish
Mar 13, 2023
Merged

Implement hardSwish#32
huningxin merged 1 commit intowebmachinelearning:mainfrom
BruceDai:support_hardSwish

Conversation

@BruceDai
Copy link
Copy Markdown
Contributor

@BruceDai BruceDai commented Feb 8, 2023

fix #11
@huningxin Please review implementation and tests of hardSwish , thanks.
Two new tests of hardSwish were referred to NNAPI CTS tests of HARD_SWISH using their input data. The expected data of -0.0 having signed flag are different from native ones 0.0, since JavaScript has signed zeroes which implements the IEEE Standard for Floating-Point Arithmetic (IEEE 754).

@BruceDai
Copy link
Copy Markdown
Contributor Author

@fdwr Please also help review this PR, thanks.

Comment thread test/hard_swish_test.js
4.453125, -4.453125, -6.875, 0.78125, 0.859375,
];
const expectedData = [
4.53125, 3.90625, 3.046875, -0.0, -0.3700764973958333,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Interesting that math.Max(0, -8) returns -0 instead of 0, but it should make no difference either way. (no change requested)

Comment thread test/hard_swish_test.js
function testHardSwish(input, expected) {
const inputTensor = new Tensor(input.shape, input.value);
const outputTensor = hardSwish(inputTensor);
utils.checkValue(outputTensor, expected);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Where's the 4 ULP value? (webmachinelearning/webnn#338 (comment)) It appears checkValue(tensor, expected, nulp = 0) defaults to zero in https://github.com/webmachinelearning/webnn-baseline/blob/main/test/utils.js.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Where's the 4 ULP value?

This result data computed by pure JavaScript is for baseline data, so it's 0 ULP here .
And 4 ULP is the tolerance for the results computed by WebNN API comparing with baseline data, this 4 ULP is used by WPT hardSwish tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Okie dokie 👍.

@huningxin huningxin merged commit aa860c9 into webmachinelearning:main Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement hardSwish

3 participants