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

NNotepad: Infer argument type for dictionary members #302

Merged

Conversation

inexorabletash
Copy link
Member

Extend the WebNNUtil.argumentType() helper to handle option dictionary members, to improve the user experience.

Previously, number and array literals were serialized as JS numbers and arrays of numbers. This was great for linear(1, {alpha: 2, beta: 3}) and transpose(T, {permutation: [0,2,1]}). But it meant MLOperand dict members required passing via variables or using identity(), e.g. gemm(A, B, {c: identity(123)})

Now you can just write gemm(A, B, {c: 123}), but linear() and transpose() still work as before.

Extend the WebNNUtil.argumentType() helper to handle option dictionary
members, to improve the user experience.

Previously, number and array literals were serialized as JS numbers
and arrays of numbers. This was great for `linear(1, {alpha: 2, beta:
3})` and `transpose(T, {permutation: [0,2,1]})`. But it meant
MLOperand dict members required passing via variables or using
identity(), e.g. `gemm(A, B, {c: identity(123)})`

Now you can just write `gemm(A, B, {c: 123})`, but `linear()` and
`transpose()` still work as before.
@inexorabletash
Copy link
Member Author

Not urgent - just a minor improvement to the sample.

Copy link
Collaborator

@Honry Honry left a comment

Choose a reason for hiding this comment

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

👍

@inexorabletash inexorabletash merged commit fae1916 into webmachinelearning:master Jan 16, 2025
3 checks passed
@inexorabletash inexorabletash deleted the nnotepad-dicttypes branch January 16, 2025 18:56
@huningxin
Copy link
Contributor

👍

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