-
Notifications
You must be signed in to change notification settings - Fork 48
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
Use web spec best practices #450
Comments
Signed-off-by: Zoltan Kis <[email protected]>
Another example: in |
Also (and this is not new), dictionary members are more normally references in prose using the infra ordered map syntax: options[" By the time an algorithm "sees" the dictionary, it's gone through the bindings layer and is an ordered map - https://webidl.spec.whatwg.org/#idl-dictionaries |
Just write: throw a TypeError. In bikeshed markdown:
|
And (this new is in PR 446) the entire "check linear options" algorithm is unnecessary; the dictionary bindings for ECMAScript take care of all of that, including default values. |
(apologies for random feedback; I may have more time later this week to do a more thorough pass) |
Signed-off-by: Zoltan Kis <[email protected]>
Not new: In "create MLActivation" steps
It looks like all call sites are internal to the spec and so this could just be an assert. And this is more off topic, but: none of the call sites for "create MLActivation" actually pass builder - that should be fixed at the call sites. I also don't see any of the call sites passing init-steps but maybe I'm missing something. |
Not new: in input(name, descriptor):
(This is a gotcha for web developers since an error would be better, but that's how the Web IDL bindings work.) |
Not new: in conv2d(input, filter, options)
The options argument is defined as
It's more correct to write:
in Bikeshed markdown:
|
Not new:
This is unnecessary, arguments are named. I see 5 uses of "first argument", and 2 of "second argument". Just drop these. |
…d by WebIDL bindings Signed-off-by: Zoltan Kis <[email protected]>
…ove default inits Signed-off-by: Zoltan Kis <[email protected]>
Not new: Similar to a nitpick above, for "create MLOperand", the second step is:
Since this is called internally with this everywhere, the validation is unnecessary. Also, total nitpick, I noticed that some of the call sites are phrased as:
and some are:
This applies to other invocations as well ("with" vs. "given") - ideally the phrasing would be consistent, but there's not consistency in phrasing across specs so either is fine. |
Optional style suggestion: If you rename the algorithms from (for example) "create MLOperand" to "create an MLOperand" (which is better grammar anyway), then you can use simplified phrasing when invoking algorithms. Before:
After:
Note that Bikeshed is smart enough to link "creating an MLOperand" to a definition named "create an MLOperand". More and more specs are using the shorter form - less text is generally more readable. |
Not new: There are a couple checks for "... is not an an object that implements MLOperandDescriptor ..." - in both cases, the value is supplied from an internal slot or explicitly passed via the algorithm, so this validation seems unnecessary. |
New (mostly) in 446: When initializing lists:
Technically at this point the Web IDL sequence has become a Infra list and should be initialized using this literal syntax:
Super nitpicky but it can make it clearer to implementers that by this point we're talking about abstract types, not a Javascript Array. |
Meta: if reporting style issues that I don't think should hold up PR 446 here is working for you, I'm happy to keep doing so. But I'm also happy to leave comments directly on the PR, file separate issues, etc. |
Not new: There are a few places where a record is being iterated, with:
This should use a proper right arrow (→) instead of the digraph, and can be written in markdown as:
Or use a literal → in the source if you don't mind non-ASCII. |
Not new: Many places use "... throw ... and stop." or "... throw ... and abort these steps." Per https://infra.spec.whatwg.org/#algorithm-control-flow this isn't necessary - throwing terminates the algorithm. I know it's tempting to be explicit, but shorter is usually better! |
Signed-off-by: Zoltan Kis <[email protected]>
Thanks a lot for all these suggestions, they are much appreciated! So far I applied all of these, except for:
|
Originally posted by @inexorabletash in #446 (comment)
|
Yeah, we can discuss. But queuing up thoughts, it helps to distinguish when you're referencing an interface member - usually only via named slots - vs. a dictionary member. And when things get wordy like: options["bias"].[[descriptor]]["dimensions"] it usually helps to use a temporary, e.g "Let bias be options["bias"]" |
Some more things that can be linkified to make the meaning clear:
|
reshape() is defined as: MLOperand reshape(MLOperand input, sequence<unsigned long?> newShape); The steps have:
That won't apply - newShape will always be a list, where the items are unsigned long or null. EDIT to add: Same thing applies to transpose() and permutation; this definition: sequence<unsigned long> permutation; ...means this is unnecessary:
And constant() has: MLOperand constant(double value, optional MLOperandType type = "float32"); ... which means neither of these are needed:
gru() is defined as: MLRecurrentNetworkDirection direction = "forward";
MLGruWeightLayout layout = "zrn"; ... which means these are not necessary:
There are similar unnecessary enum value checks throughout that can all be removed. (The whole point of Web IDL is that these checks are taken care of for you automatically!) |
In the "create an MLOperand", "copy an MLOperand", and "create an MLActivation" steps there are lines:
This should reference the specific type, e.g. "new MLOperand" Right now, the term "object" is linking to FileAPI, which is probably not desired. It's worth looking at the Terms defined by reference section Bikeshed generates for you, to ensure you're getting the dependencies you expect (e.g. you probably aren't meaning to use CSS4's definition for "number") |
* MLConvTranspose2dFilterOperandLayout * MLConv2dFilterOperandLayout For webmachinelearning#450
* MLDeviceType * MLGruWeightLayout * MLInterpolationMode * MLLstmWeightLayout * MLOperandDataType * MLPaddingMode * MLRecurrentNetworkDirection * MLRoundingType For webmachinelearning#450
Rather than `"opname"` just use "opname" consistently, which was more common. These are internal identifiers, not exposed to script. In the future it might be worth introducing a typographic convention and/or just a markup/markdown style for op names, just to make it easier to distinguish them. For webmachinelearning#450
E.g. if the key is a name, use |name| For webmachinelearning#450
With Bikeshed and autolinks you can just write "result of xxxing" For webmachinelearning#450
If Bikeshed [=autolinks=] are used instead of HTML <a>markup</a> then Bikeshed can do a better job of consistency checking. For webmachinelearning#450
I lied - I put up a PR. But I'm about to go out-of-office so I'll let the editors make use of it or wait until January. Happy Solstice, everyone! |
In algorithms that mint MLActivations and MLOperands, construct the actual type not a generic "object". Also, use Infra wording around optional paramters to those algorithms. For webmachinelearning#450
"Let ... be ..." is reserved for declaring variables. For webmachinelearning#450
In algorithms that mint MLActivations and MLOperands, construct the actual type not a generic "object". Also, use Infra wording around optional paramters to those algorithms. For webmachinelearning#450
In algorithms that mint MLActivations and MLOperands, construct the actual type not a generic "object". Also, use Infra wording around optional paramters to those algorithms. For #450
My skim of this issue - looking to see if we can close it yet - turns up these potentially unresolved issues:
Otherwise I think @zolkis and I have tackled it all, and so we can close this out now or soon. |
For operations defined in bulk - element-wise binary, unary, and logical ops, plus pooling and reduction ops - make the styling consistent: - A single <div class=algorithm-steps> around all definitions - A separate <div algorithm> around each op's steps. This was already done for the element-wise ops so already the majority style. Pooling ops now have just a single "Algorithm" watermark (instead of 3), and reduction ops now have a watermark instead of none. For webmachinelearning#450
For operations defined in bulk - element-wise binary, unary, and logical ops, plus pooling and reduction ops - make the styling consistent: - A single <div class=algorithm-steps> around all definitions - A separate <div algorithm> around each op's steps. This was already done for the element-wise ops so already the majority style. Pooling ops now have just a single "Algorithm" watermark (instead of 3), and reduction ops now have a watermark instead of none. For webmachinelearning#450
Closing out now that outstanding issues are tracked elsewhere. |
Originally posted by @inexorabletash in #446 (comment)
(Issue created to document this change).
The text was updated successfully, but these errors were encountered: