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

Write example decompositions as complete functions #709

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

inexorabletash
Copy link
Member

@inexorabletash inexorabletash commented Jun 18, 2024

This makes it clearer how the example decompositions map to the methods they are defining - variables are explicitly named as parameters, or unpacked from the arguments.

Also fix code treating MLOperand's dataType() as a getter instead of a method.

No normative changes.


Preview | Diff

This makes it clearer how the example decompositions map to the
methods they are defining - variables are explicitly named as
parameters, or unpacked from the arguments.

No normative changes.
@inexorabletash
Copy link
Member Author

@huningxin & @fdwr - please take a look?

Copy link
Collaborator

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

Thank you for wrapping these all in named functions - that makes it clearer 🧼😎.

index.bs Show resolved Hide resolved
@inexorabletash
Copy link
Member Author

FYI I'll look into lint tooling to help enforce this, but I didn't want to block on it. The easiest might be pulling eslint in as another node dependency, if that doesn't seem too bad.

@zolkis
Copy link
Collaborator

zolkis commented Jun 19, 2024

Yes, that sets a nice and clear context to the code snippets.
Whether to enforce it... maybe not, as not every code snippet might be meant to be quoted as a full function.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@inexorabletash
Copy link
Member Author

@huningxin take another look, and merge if it looks good? Thanks!

index.bs Outdated
@@ -5950,8 +5945,9 @@ partial interface MLGraphBuilder {
function where(builder, condition, input, other) {
const c = builder.clamp(condition, {'minValue': 0, 'maxValue': 1});
builder.add(
builder.mul(input, builder.cast(c, input.dataType())),
builder.mul(other, builder.cast(builder.logicalNot(c), other.dataType())));
Copy link
Contributor

Choose a reason for hiding this comment

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

The above two lines were good and won't need to change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. :) Thanks.

index.bs Outdated Show resolved Hide resolved
Copy link
Contributor

@huningxin huningxin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

@huningxin huningxin merged commit 588a728 into webmachinelearning:main Jun 25, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Jun 25, 2024
SHA: 588a728
Reason: push, by huningxin

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@inexorabletash inexorabletash deleted the decomp-funcs branch June 25, 2024 03:14
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.

4 participants