MCPcopy Index your code
hub / github.com/apache/tvm / toArray

Method toArray

web/src/runtime.ts:683–698  ·  view source on GitHub ↗

* Return a TypedArray copy of the Tensor, the specific type depends on * the dtype of the Tensor. * @returns The result array.

()

Source from the content-addressed store, hash-verified

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;

Callers 4

test_vm.jsFile · 0.80
testArrayCopyFunction · 0.80

Calls 1

toRawBytesMethod · 0.95

Tested by

no test coverage detected