webmachinelearning / webnn

🧠 Web Neural Network API
https://www.w3.org/TR/webnn/
Other
397 stars 48 forks source link

Swap parameters of scalar constant() operand method #650

Closed inexorabletash closed 6 months ago

inexorabletash commented 7 months ago

Make MLGraphBuilder's constant() operand-vending methods consistent and take the data type as the first parameter. This implicitly makes the type required instead of optional.

Use of constant() in decompositions are updated as well, and now use "input" consistently instead of "x" sometimes.

Fixes #475


Preview | Diff

inexorabletash commented 7 months ago

FYI, I ran clang-format --assume-filename=.js --style=Chromium over the decompositions that were significantly touched. I'll write a script to apply that to all of the sample JS blocks in the script and put that up as a separate CL.

inexorabletash commented 7 months ago

I'm going to drop this to "draft" to take it off people's radar. This would be a breaking change for lots of content, so we'll want to approach it carefully.

inexorabletash commented 6 months ago

I didn't realize until last week that Chromium didn't implement the scalar version of constant(), so this should be safe to change - no content should be relying on it, right?

inexorabletash commented 6 months ago

@huningxin & @fdwr - please take a look?

inexorabletash commented 6 months ago

You may also want to update the code sample of explainer https://github.com/webmachinelearning/webnn/blob/main/explainer.md?plain=1#L38

Done in 1d9fb59

fdwr commented 6 months ago

All suggestions moot because addressed elsewhere. So merging...

inexorabletash commented 6 months ago

I realized too late that the updated decompositions all use input.dataType not input.dataType(). I guess that's a vote in favor of that change proposed in #666 but it was unintentional!