MCPcopy
hub / github.com/tensorflow/tfjs / bufferSync

Method bufferSync

tfjs-backend-webgpu/src/backend_webgpu.ts:632–647  ·  view source on GitHub ↗
(t: TensorInfo)

Source from the content-addressed store, hash-verified

630 }
631
632 bufferSync<R extends Rank, D extends DataType>(t: TensorInfo):
633 TensorBuffer<R, D> {
634 const data = this.readSync(t.dataId);
635 if (t.dtype === 'string') {
636 try {
637 // Decode the bytes into string.
638 const strings = (data as Uint8Array[]).map(d => util.decodeString(d));
639 return buffer(t.shape as ShapeMap[R], t.dtype, strings) as
640 TensorBuffer<R, D>;
641 } catch {
642 throw new Error('Failed to decode encoded string bytes into utf-8');
643 }
644 }
645 return buffer(t.shape as ShapeMap[R], t.dtype, data as TypedArray) as
646 TensorBuffer<R, D>;
647 }
648
649 override async time(f: () => void): Promise<WebGPUTimingInfo> {
650 if (!this.supportTimestampQuery && !this.hasTimestampQueryWarned) {

Callers 2

gatherNdFunction · 0.45
sparseToDenseFunction · 0.45

Calls 2

readSyncMethod · 0.95
bufferFunction · 0.90

Tested by

no test coverage detected