webmachinelearning / webnn

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

WebIDL definition for constant(start, end, step, type) is missing #571

Closed inexorabletash closed 7 months ago

inexorabletash commented 9 months ago

The range-based constant(start, end, step, type) is defined with an algorithm, but there's no corresponding WebIDL declaration for it.

inexorabletash commented 9 months ago

The prose implies it would be:

    // Create an operand for a constant 1-D tensor of the specified type and range.
    MLOperand constant(float start, float end, float step, optional MLOperandDataType type = "float32");

... But I notice that constant(value, type) defines value as double in the IDL but float in the prose (which, as an aside, is a good reason to NOT duplicate definitions manually). I assume it is double so that int32/uint32 can be passed with full fidelity, so maybe this should be:

    // Create an operand for a constant 1-D tensor of the specified type and range.
    MLOperand constant(double start, double end, double step, optional MLOperandDataType type = "float32");

... and then update the prose for this and the other constant() to say double.

zolkis commented 9 months ago

SGTM. @huningxin WDYT?

huningxin commented 9 months ago

We may also need to consider the int64 (bigint), as being discussed in https://github.com/webmachinelearning/webnn/issues/492#issuecomment-1926419539.

inexorabletash commented 9 months ago

Yeah... we could merge this with #492 (i.e. defer spec changes until the issues over there are sorted) or put in IDL for now and revisit as the API shape and int64 handling is resolved. Whatever the editors want!

inexorabletash commented 7 months ago

Marking this as a duplicate of #492

(I had simply missed that other issue when filing this one, and it seems like we have traction there so a "quick fix" of just writing down the current IDL isn't needed.)