MCPcopy
hub / github.com/apache/tvm / VirtualMachine

Class VirtualMachine

web/src/runtime.ts:781–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779 * of underlying module functions
780 */
781export class VirtualMachine implements Disposable {
782 private mod: Module;
783 /**
784 * Constructor
785 * @param mod The underlying module, need to be detached.
786 * @param device The main device ro run VM on.
787 */
788 constructor(mod: Module, device: DLDevice) {
789 this.mod = mod;
790 this.mod.getFunction("vm_initialization")(
791 new Scalar(device.deviceType, "int"),
792 new Scalar(device.deviceId, "int"),
793 new Scalar(VMAllocatorKind.POOLED_ALLOCATOR, "int"),
794 // explicitly specify host device type
795 new Scalar(DeviceStrToEnum.cpu, "int"),
796 new Scalar(0, "int"),
797 new Scalar(VMAllocatorKind.POOLED_ALLOCATOR, "int"),
798 );
799 }
800
801 dispose(): void {
802 this.mod.dispose();
803 }
804 /**
805 * Get a function in the VM module.
806 * @param name The name of the function.
807 * @returns The result function.
808 */
809 getFunction(name: string): PackedFunc {
810 return this.mod.getFunction(name);
811 }
812
813 /**
814 * Get the internal module.
815 */
816 getInternalModule(): Module {
817 return this.mod;
818 }
819}
820
821/** Code used as the first argument of the async callback. */
822enum AsyncCallbackCode {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…