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 quantizeLinear #101

Merged

Conversation

BruceDai
Copy link
Contributor

@BruceDai BruceDai commented Sep 4, 2024

@huningxin @fdwr @lisa0314 PTAL, thanks.

Copy link

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

Small comments, else LGTM. 🫡

Comment on lines 22 to 23
const addOutput = add(div(input, scale), zeroPoint);
const roundOutput = unary(addOutput, (x) => roundToNearestEvens(x));
Copy link

Choose a reason for hiding this comment

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

Suggested change
const addOutput = add(div(input, scale), zeroPoint);
const roundOutput = unary(addOutput, (x) => roundToNearestEvens(x));
const dividedOutput = div(input, scale);
const roundedOutput = unary(dividedOutput, (x) => roundToNearestEvens(x));
const addedOutput = add(roundedOutput, zeroPoint);

Round before adding.

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.

}

it('quantizeLinear 1D to uint8 broadcasting scale and zeroPoint', function() {
testQuantizeLinear(
Copy link

Choose a reason for hiding this comment

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

A 0D case would complete the set.

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, thanks.

Copy link
Contributor Author

@BruceDai BruceDai left a comment

Choose a reason for hiding this comment

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

@fdwr I've submitted new commit, please take another look, thanks.

}

it('quantizeLinear 1D to uint8 broadcasting scale and zeroPoint', function() {
testQuantizeLinear(
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, thanks.

Comment on lines 22 to 23
const addOutput = add(div(input, scale), zeroPoint);
const roundOutput = unary(addOutput, (x) => roundToNearestEvens(x));
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.

Copy link

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍

@huningxin huningxin merged commit c386af8 into webmachinelearning:main Sep 8, 2024
3 checks passed
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.

3 participants