* Return a TypedArray copy of the Tensor, the specific type depends on * the dtype of the Tensor. * @returns The result array.
()
| 681 | * @returns The result array. |
| 682 | */ |
| 683 | toArray(): Float32Array | Float64Array | Int32Array | Int8Array | Uint8Array { |
| 684 | const stype = this.dtype; |
| 685 | if (stype === "float32") { |
| 686 | return new Float32Array(this.toRawBytes().buffer); |
| 687 | } else if (stype === "float64") { |
| 688 | return new Float64Array(this.toRawBytes().buffer); |
| 689 | } else if (stype === "int32") { |
| 690 | return new Int32Array(this.toRawBytes().buffer); |
| 691 | } else if (stype === "int8") { |
| 692 | return new Int8Array(this.toRawBytes().buffer); |
| 693 | } else if (stype === "uint8") { |
| 694 | return new Uint8Array(this.toRawBytes().buffer); |
| 695 | } else { |
| 696 | throw new Error("Unsupported data type " + this.dtype); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | private getDLTensorFromArrayHandle(handle: Pointer): Pointer { |
| 701 | return handle + SizeOf.ObjectHeader; |
no test coverage detected