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 default values of scales into resample op #204

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

huningxin
Copy link
Contributor

@huningxin huningxin commented Aug 29, 2021

fix #192

@wchao1115 @pyu10055 @anssiko , PTAL. Thanks.


Preview | Diff

@huningxin huningxin requested review from anssiko, wchao1115 and pyu10055 and removed request for anssiko August 29, 2021 00:54
@@ -1702,7 +1702,7 @@ partial interface MLGraphBuilder {
- *options*: an optional {{MLResampleOptions}}. The optional parameters of the operation.
- *mode*: an {{MLInterpolationMode}}. The interpolation algorithm used to fill the output tensor values.
If not set, it is assumed to be the *Nearest Neighbor* interpolation.
- *scales*: a sequence of {{float}} of length 4. Each value represents the scaling factor used to scale in each input dimensions.
- *scales*: a sequence of {{float}} of length 4. Each value represents the scaling factor used to scale in each input dimensions. If not set, the values are assumed to be [1.0, 1.0, 1.0, 1.0].
Copy link
Member

Choose a reason for hiding this comment

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

I'll loop in @dontcallmedom for his advice, given this is an instantiation of #205 (comment)

We have a sequence in an IDL fragment, so we learned we cannot use the WebIDL default value shorthand ("=").

The custom prose the spec has been using is:

If X is not set, the values are assumed to be Y.

Should we use this or maybe something like the following:

The default value is Y.

Or perhaps a longer version that explicitly specifies the default value is used if the value is "not present" or "is invalid"? (I think we may want to branch into two in some cases.)

If X is not present or its value invalid, set X to [1.0, 1.0, 1.0, 1.0].

We expect to use the same pattern in many places so would like to identify the most concise way.

Some notes:

Copy link
Contributor

Choose a reason for hiding this comment

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

The custom prose the spec has been using is:

If X is not set, the values are assumed to be Y.

Should we use this or maybe something like the following:

The default value is Y.

This LGTM - paging @domenic and @TimothyXu to confirm the wording indeed works, and whether a non-empty array as a default value doesn't create other issues from an IDL perspective.

Or perhaps a longer version that explicitly specifies the default value is used if the value is "not present" or "is invalid"? (I think we may want to branch into two in some cases.)

The term "present" has been replaced by Infra's exists (in WebIDL and in specs that rely on this concept).

An "invalid" value would cause a TypeError so there is no need to describe that situation.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @dontcallmedom!

Copy link

Choose a reason for hiding this comment

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

This doesn't really work, no. You need to have a normative algorithm which checks if input["scales"] exists, and if not, use the defaults. I.e. something like

  1. Let scales be the list « 1.0, 1.0, 1.0, 1.0 ».
  2. If input["scales"] exists, then set scales to input["scales"].

(and maybe also validate that input["scales"] is of length 4, or whatever you need?)

This seems difficult since right now your spec has no algorithms (i.e. no method steps) for its operations, just a non-normative description of the inputs and return value.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @domenic! Your feedback is now captured in #211 so we track and address it properly.

Copy link
Contributor Author

@huningxin huningxin Sep 22, 2021

Choose a reason for hiding this comment

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

Thanks for your feedback @domenic . We'll fix #211 properly. To unblock the development of #205 , I would suggest to merge this one. @anssiko , what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@huningxin, I was just thinking of suggesting the same, given we track #211 separately.

Please go ahead and merge.

@huningxin huningxin merged commit 4fc42a4 into webmachinelearning:main Sep 22, 2021
github-actions bot added a commit that referenced this pull request Sep 22, 2021
SHA: 4fc42a4
Reason: push, by @huningxin

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

The scales and sizes of MLResampleOptions can't be both empty
5 participants