* Asynchronously downloads the values from the `tf.Tensor`. Returns a * promise of `TypedArray` that resolves when the computation has finished. * * @doc {heading: 'Tensors', subheading: 'Classes'}
()
| 348 | * @doc {heading: 'Tensors', subheading: 'Classes'} |
| 349 | */ |
| 350 | async data<D extends DataType = NumericDataType>(): Promise<DataTypeMap[D]> { |
| 351 | this.throwIfDisposed(); |
| 352 | const data = trackerFn().read(this.dataId); |
| 353 | if (this.dtype === 'string') { |
| 354 | const bytes = await data as Uint8Array[]; |
| 355 | try { |
| 356 | return bytes.map(b => util.decodeString(b)) as DataTypeMap[D]; |
| 357 | } catch { |
| 358 | throw new Error( |
| 359 | 'Failed to decode the string bytes into utf-8. ' + |
| 360 | 'To get the original bytes, call tensor.bytes().'); |
| 361 | } |
| 362 | } |
| 363 | return data as Promise<DataTypeMap[D]>; |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Copy the tensor's data to a new GPU resource. Comparing to the `dataSync()` |
no test coverage detected