Skip to content

Write example decompositions as complete functions#709

Merged
huningxin merged 4 commits into
webmachinelearning:mainfrom
inexorabletash:decomp-funcs
Jun 25, 2024
Merged

Write example decompositions as complete functions#709
huningxin merged 4 commits into
webmachinelearning:mainfrom
inexorabletash:decomp-funcs

Conversation

@inexorabletash

@inexorabletash inexorabletash commented Jun 18, 2024

Copy link
Copy Markdown
Contributor

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 inexorabletash requested review from fdwr and huningxin June 18, 2024 16:56
@inexorabletash

Copy link
Copy Markdown
Contributor Author

@huningxin & @fdwr - please take a look?

@fdwr fdwr left a comment

Copy link
Copy Markdown
Collaborator

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 🧼😎.

Comment thread index.bs
@inexorabletash

Copy link
Copy Markdown
Contributor 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

zolkis commented Jun 19, 2024

Copy link
Copy Markdown
Collaborator

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.

Comment thread index.bs Outdated
Comment thread index.bs Outdated
@inexorabletash

Copy link
Copy Markdown
Contributor Author

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

Comment thread index.bs Outdated
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops. :) Thanks.

Comment thread index.bs Outdated

@huningxin huningxin left a comment

Copy link
Copy Markdown
Contributor

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