-
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
Clarify the usage of 32 bit floating point type and consider using double #325
Comments
FWIW, double is not a considered a mainstream native data type on the GPU. Although there is a shader model extension for it, it's not until recently (e.g. HLSL shader model 5) |
Just an additional note that extending |
For some MLGraphBuilder methods the type of a numeric input can vary - e.g. for constant() an explicit MLOperandDataType is provided; for clamp() and pad() the data type is implied by input operands. In these cases, specifying the numeric value as either a float/double or int64 type runs into accuracy or range issues - you can't accurately represent all int64 values as a double, and you can't represent the full range of floats as int64. (You also can't represent all int64 values as an long long either - over 2^53 things get wierd. But that's a digression.) Per discussion in whatwg/webidl#1388 this change introduces a union between a bigint type and unrestricted double called MLNumber. Callers can pass a JS number (1234, 1.1234e38) or a JS bigint (9007199254740993n), and the implementation will treat it properly based on the explicit or implicit MLOperandDataType. Usage of this type should be limited to only those cases. Fixes webmachinelearning#442 Note that webmachinelearning#492 proposes changes to the constant sequential filling operation; this just adds IDL to match the current spec prose. Some of the concerns raised in webmachinelearning#325 are addressed (e.g. clamp()'s options). However, several other options are still specified as "float", and should maybe be "double" - but MLNumber is likely not appropriate for those, so they are not updated here.
Discussion here and elsewhere hasn't explicitly mentioned the resample2d() |
This issue was raised during Chromium CL review. Thanks Jiewei @wacky6 for the valuable feedback!
The WebIDL 32 bit floating point type
float
is widely used by WebNN spec, such as for setting min and max value of clamp operator:However, WebIDL spec has a warning of using
float
and the recommendation is to usedouble
.According to that, Jiewei suggested that the spec should mention reason of using
float
(at least an informative note) and propose usingdouble
instead. The reasons include (pasted from the CL thread):The text was updated successfully, but these errors were encountered: