Skip to content
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

Specify MLTensor #787

Merged
merged 11 commits into from
Nov 26, 2024
Prev Previous commit
Next Next commit
fix ambiguous ref error + split out BYOB readBuffer variant
a-sully committed Nov 20, 2024
commit 2d5d05ec23f0bc330ff0ee4855d249eb4ee9bfcf
25 changes: 14 additions & 11 deletions index.bs
Original file line number Diff line number Diff line change
@@ -1186,7 +1186,7 @@ Creates an {{MLTensor}} associated with this {{MLContext}}.
1. Return |promise|.
</details>

### {{MLContext/readTensor()}} ### {#api-mlcontext-readtensor}
### {{MLContext/readTensor(tensor)}} ### {#api-mlcontext-readtensor}

Reads back the {{MLTensor/[[data]]}} of an {{MLTensor}} from the {{MLContext}}'s {{MLContext/[[timeline]]}} to script.

@@ -1197,14 +1197,6 @@ Reads back the {{MLTensor/[[data]]}} of an {{MLTensor}} from the {{MLContext}}'s
**Returns:** Promise<ArrayBuffer>. A buffer containing the result of the read.
</div>

<div dfn-for="MLContext/readTensor(tensor, outputData)" dfn-type=argument>
**Arguments:**
- <dfn>tensor</dfn>: an {{MLTensor}}. The tensor to be read.
- <dfn>outputData</dfn>: an {{AllowSharedBufferSource}}. The buffer to read the result into.

**Returns:** Promise<undefined>.
</div>

<details open algorithm>
<summary>
The <dfn method for=MLContext>readTensor(|tensor|)</dfn> method steps are:
@@ -1221,6 +1213,18 @@ Reads back the {{MLTensor/[[data]]}} of an {{MLTensor}} from the {{MLContext}}'s
1. Return |promise|.
</details>

### {{MLContext/readTensor(tensor, outputData)}} ### {#api-mlcontext-readtensor-byob}

Bring-your-own-buffer variant of {{MLContext/readTensor(tensor)}}. Reads back the {{MLTensor/[[data]]}} of an {{MLTensor}} into the provided buffer.

<div dfn-for="MLContext/readTensor(tensor, outputData)" dfn-type=argument>
**Arguments:**
- <dfn>tensor</dfn>: an {{MLTensor}}. The tensor to be read.
- <dfn>outputData</dfn>: an {{AllowSharedBufferSource}}. The buffer to read the result into.

**Returns:** Promise<undefined>.
</div>

<details open algorithm>
<summary>
The <dfn method for=MLContext>readTensor(|tensor|, |outputData|)</dfn> method steps are:
@@ -1237,7 +1241,6 @@ Reads back the {{MLTensor/[[data]]}} of an {{MLTensor}} from the {{MLContext}}'s
1. Return |promise|.
</details>


### {{MLContext/writeTensor()}} ### {#api-mlcontext-writetensor}

Writes data to the {{MLTensor/[[data]]}} of an {{MLTensor}} on the {{MLContext}}'s {{MLContext/[[timeline]]}}.
@@ -1557,7 +1560,7 @@ dictionary MLTensorDescriptor : MLOperandDescriptor {

<dl dfn-type=dict-member dfn-for=MLTensorDescriptor>
: <dfn>readable</dfn>
:: Whether the tensor's contents can be read via {{MLContext/readTensor()}}.
:: Whether the tensor's contents can be read via {{MLContext/readTensor(tensor)}} or {{MLContext/readTensor(tensor, outputData)}}.

: <dfn>writable</dfn>
:: Whether the tensor's contents can be written to via {{MLContext/writeTensor()}}.