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

Method bufferSync

tfjs-backend-webgl/src/backend_webgl.ts:473–488  ·  view source on GitHub ↗
(t: TensorInfo)

Source from the content-addressed store, hash-verified

471 }
472
473 bufferSync<R extends Rank, D extends DataType>(t: TensorInfo):
474 TensorBuffer<R, D> {
475 const data = this.readSync(t.dataId);
476 if (t.dtype === 'string') {
477 try {
478 // Decode the bytes into string.
479 const strings = (data as Uint8Array[]).map(d => util.decodeString(d));
480 return buffer(t.shape as ShapeMap[R], t.dtype, strings) as
481 TensorBuffer<R, D>;
482 } catch {
483 throw new Error('Failed to decode encoded string bytes into utf-8');
484 }
485 }
486 return buffer(t.shape as ShapeMap[R], t.dtype, data as TypedArray) as
487 TensorBuffer<R, D>;
488 }
489
490 private checkNumericalProblems(values: BackendValues): void {
491 if (values == null) {

Callers 4

gatherNdFunction · 0.45
denseBincountFunction · 0.45
gatherV2Function · 0.45
sparseToDenseFunction · 0.45

Calls 2

readSyncMethod · 0.95
bufferFunction · 0.90

Tested by

no test coverage detected