Skip to content

MLContext.compute() explicitly rejects promises where the sub-septs may currently throw #634

@huningxin

Description

@huningxin

Regarding to the existing MLContext.compute() algorithm, if input validation steps fail, it returns a rejected promise. However, in the following two steps, transferring an MLNamedArrayBufferViews steps may throw an exception because transfer an ArrayBuffer steps will throw a TypeError if DetachArrayBuffer fails.

  1. Let transferredInputs be the result of transferring MLNamedArrayBufferViews inputs with realm.
  1. Let transferredOutputs be the result of transferring MLNamedArrayBufferViews outputs with realm.

Although the exceptions thrown by step 7 and 8 should be converted to promise rejection automatically, according https://www.w3.org/2001/tag/doc/promises-guide#errors - that says

For Web IDL-based specs, this is taken care of automatically if you declare your operations to return a promise type. Any exceptions thrown by such operations, or by the Web IDL-level type conversions and overload resolution, are automatically converted into rejections.

@inexorabletash suggested

being explicit for subtle things like this is a good idea. Something like "If that throws an exception, return a promise rejected with the exception".

/cc @a-sully

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions