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

Method dataSync

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

* Synchronously downloads the values from the `tf.Tensor`. This blocks the * UI thread until the values are ready, which can cause performance issues. * * @doc {heading: 'Tensors', subheading: 'Classes'}

()

Source from the content-addressed store, hash-verified

409 * @doc {heading: 'Tensors', subheading: 'Classes'}
410 */
411 dataSync<D extends DataType = NumericDataType>(): DataTypeMap[D] {
412 this.throwIfDisposed();
413 const data = trackerFn().readSync(this.dataId);
414 if (this.dtype === 'string') {
415 try {
416 return (data as Uint8Array[]).map(b => util.decodeString(b)) as
417 DataTypeMap[D];
418 } catch {
419 throw new Error(
420 'Failed to decode the string bytes into utf-8. ' +
421 'To get the original bytes, call tensor.bytes().');
422 }
423 }
424 return data as DataTypeMap[D];
425 }
426
427 /** Returns the underlying bytes of the tensor's data. */
428 async bytes(): Promise<Uint8Array[]|Uint8Array> {

Callers 3

bufferSyncMethod · 0.95
arraySyncMethod · 0.95
toStringMethod · 0.95

Calls 2

throwIfDisposedMethod · 0.95
readSyncMethod · 0.65

Tested by

no test coverage detected