(t: TensorInfo)
| 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) { |
no test coverage detected