Skip to content

Add the builder.input() method steps#364

Merged
huningxin merged 23 commits intowebmachinelearning:mainfrom
zolkis:builder-input-method
May 16, 2023
Merged

Add the builder.input() method steps#364
huningxin merged 23 commits intowebmachinelearning:mainfrom
zolkis:builder-input-method

Conversation

@zolkis
Copy link
Collaborator

@zolkis zolkis commented Mar 22, 2023

Add the input() method algorithm.
Depends on #337


Preview | Diff

@zolkis zolkis changed the title WiP: Add the builder.input() method steps Add the builder.input() method steps Apr 13, 2023
@zolkis
Copy link
Collaborator Author

zolkis commented Apr 20, 2023

@huningxin PTAL :)

index.bs Outdated
1. If |name| is `undefined` or an empty [=string=], then throw a "{{TypeError}}" {{DOMException}} and stop.
1. Let |descriptor| be the second argument.
1. If |descriptor| is not an an object that [=implements=] {{MLOperandDescriptor}}, then throw a "{{TypeError}}" {{DOMException}} and stop.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: one extra space before "If"

index.bs Outdated
1. Let |descriptor| be the second argument.
1. If |descriptor| is not an an object that [=implements=] {{MLOperandDescriptor}}, then throw a "{{TypeError}}" {{DOMException}} and stop.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop.
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if user code passes a descriptor for scalar operand (dimensions is undefined)? This input() algorithm seems only to support tensor operand now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the constant(descriptor, bufferView) algorithm in PR #365 should also address this issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. So this is where conventions about descriptor become important.
I am thinking if it's enough to distinguish between vector and scalar solely on the existence of a dimensions member. But for now let's continue with that working assumption and keep it in mind.

About constant(descriptor, bufferView): the descriptor.dimensions must be defined, otherwise it's an error. There is a polymorphic variant for specifying scalar constant. Should we change that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, please check if correct. Using an assert seemed better choice than just making a note.
Forgot to fix the white space error, such a small change that I amended the same commit and force-pushed.

Copy link
Contributor

Choose a reason for hiding this comment

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

About constant(descriptor, bufferView): the descriptor.dimensions must be defined, otherwise it's an error.

That's fine. No change needed.

@zolkis zolkis force-pushed the builder-input-method branch from 563ff94 to d6abd76 Compare May 10, 2023 09:12
index.bs Outdated
1. If |descriptor| is not an an object that [=implements=] {{MLOperandDescriptor}}, then throw a "{{TypeError}}" {{DOMException}} and stop.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
Copy link
Contributor

Choose a reason for hiding this comment

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

"byte length" algorithm also need to handle scalar operand descriptor. Its current definition would break if descriptor.dimensions is undefined.

index.bs Outdated
1. Let |descriptor| be the second argument.
1. If |descriptor| is not an an object that [=implements=] {{MLOperandDescriptor}}, then throw a "{{TypeError}}" {{DOMException}} and stop.
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop.
Copy link
Contributor

Choose a reason for hiding this comment

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

About constant(descriptor, bufferView): the descriptor.dimensions must be defined, otherwise it's an error.

That's fine. No change needed.

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 @zolkis !

@huningxin
Copy link
Contributor

@zolkis , you may also want to solve the conflicts, squash the commits and edit the commit log before merging. Thanks!

Zoltan Kis and others added 21 commits May 15, 2023 09:19
Squashed the following commits:
    Fix links in algorithm
    Enclose arg+return description as a note for better clarity
    Add reference to the platform operand object
    Handle the scalar case
    Move byte length check to vector section

Signed-off-by: Zoltan Kis <zoltan.kis@intel.com>
also provide SVG source
Reword and refine the text based on review feeedback
Make the text more concise to address review feedback
1. Change `starts` and `sizes` parameters to be sequence of unsigned long.
2. Remove `MLSliceOptions.axes`.

Fix webmachinelearning#369
* Draft

* More text.

* mote text

* Address PR feedbacks.
Squashed the following commits:
    Enclose arg + return descriptions to separate from normative algorithms
    Change manual link to autolink
    Use the 'get a copy' reference for buffer source
    Factor our validating bufferview with descriptor
    Fix initialization typo
    Add reference to the platform operand object  MLOperand/[[operand]]
    Lift dependency changes from webmachinelearning#337
    Fix typos, remove unneeded dependencies from webmachinelearning#337
    Add dependency for buffer validation from webmachinelearning#329
    Fix the scalar algorithm / comments
    Discern between scalar and tensor constant, fix typos
    Fix review comments. Add stylistic boxes for algorithm steps, informal steps, internal slots
    Fix typo. Remove stylistic boxes for now.
    Address reviews comments. Remove MLOperandKind typedef from the IDL.
    Move note to text. Make the check on kind an assert.
    Remove the MLOperand/[[kind]] internal slot and creation parameter.
    Remove back quotes from title

Signed-off-by: Zoltan Kis <zoltan.kis@intel.com>
@zolkis zolkis force-pushed the builder-input-method branch from 1a1a0d4 to c5f1574 Compare May 15, 2023 06:24
Signed-off-by: Zoltan Kis <zoltan.kis@intel.com>
@zolkis
Copy link
Collaborator Author

zolkis commented May 15, 2023

@huningxin
I rebased, squashed, fixed conflicts, verified with build, then force pushed.
Since there were a lot of other commits in between filing the PR and now, those commits appear here now.
Needed to add one more commit to merge with the main branch.

@huningxin huningxin merged commit 9774d49 into webmachinelearning:main May 16, 2023
github-actions bot added a commit that referenced this pull request May 16, 2023
SHA: 9774d49
Reason: push, by huningxin

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@zolkis zolkis deleted the builder-input-method branch May 16, 2023 14:53
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.

7 participants