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

Add more logical ops #109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

BruceDai
Copy link
Contributor

Fixed #108.

@fdwr @huningxin 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.

2 thoughts, else LGTM Bruce.

src/logical.js Outdated Show resolved Hide resolved
src/logical.js Outdated
@@ -28,4 +28,9 @@ export const greaterOrEqual =
export const lesser = (inputA, inputB) => binary(inputA, inputB, (a, b) => (a < b ? 1 : 0));
export const lesserOrEqual =
(inputA, inputB) => binary(inputA, inputB, (a, b) => (a <= b ? 1 : 0));
export const not = (input) => logicalNot(input);
export const logicalAnd =
(inputA, inputB) => binary(inputA, inputB, (a, b) => ((a > 0) && (b > 0) ? 1: 0));
Copy link

Choose a reason for hiding this comment

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

Technically it doesn't matter whether we use > 0 or != 0 here, since WebNN only takes unsigned inputs anyway, but for general correctness, any nonzero value would apply. So (!!a && !!b ? 1 : 0)) would be a little more correct (or the more verbose ((a != 0) && (b != 0) ? 1 : 0))).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I‘ve updated in new commit, please take another look, 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.

👍

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 logicalAnd / logicalOr / logicalXor ops
2 participants