Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hardSwish #32

Merged
merged 1 commit into from
Mar 13, 2023
Merged

Conversation

BruceDai
Copy link
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
Contributor Author

@fdwr Please also help review this PR, thanks.

4.453125, -4.453125, -6.875, 0.78125, 0.859375,
];
const expectedData = [
4.53125, 3.90625, 3.046875, -0.0, -0.3700764973958333,
Copy link

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)

function testHardSwish(input, expected) {
const inputTensor = new Tensor(input.shape, input.value);
const outputTensor = hardSwish(inputTensor);
utils.checkValue(outputTensor, expected);
Copy link

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
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

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