MCPcopy Index your code
hub / github.com/tensorflow/tfjs / data

Method data

tfjs-core/src/tensor.ts:350–364  ·  view source on GitHub ↗

* 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'}

()

Source from the content-addressed store, hash-verified

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()`

Callers 1

arrayMethod · 0.95

Calls 2

throwIfDisposedMethod · 0.95
readMethod · 0.65

Tested by

no test coverage detected