Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Instance

TVM runtime instance.

Hierarchy

  • Instance

Implements

Index

Constructors

constructor

  • new Instance(wasmModule: Module, importObject?: Record<string, any>, wasmInstance?: WebAssembly.Instance, env?: Environment): Instance
  • Constructor

    importObject can also be a LibraryProvider object, a WASI object, or an object containing wasmLibraryProvider field.

    see

    Please use the async version instantiate when targeting browsers.

    Parameters

    • wasmModule: Module

      The input module or instance.

    • Default value importObject: Record<string, any> = {}

      The imports to initialize the wasmInstance if it is not provided.

    • Optional wasmInstance: WebAssembly.Instance

      Additional wasm instance argument for deferred construction.

    • Optional env: Environment

      Directly specified environment module.

    Returns Instance

Properties

exports

exports: Record<string, Function>

memory

memory: Memory

Methods

cpu

createGraphExecutor

  • Create a new graph executor.

    Parameters

    • graphJson: string

      The graph executor json file.

    • lib: Module

      The underlying library.

    • dev: DLDevice

      The execution device of the graph.

    Returns GraphExecutor

device

  • device(deviceType: number | string, deviceId?: number): DLDevice
  • Create a new DLDevice

    Parameters

    • deviceType: number | string

      The device type.

    • Default value deviceId: number = 0

      The device index.

    Returns DLDevice

    The created device.

dispose

  • dispose(): void

empty

  • Create an empty NDArray with given shape and dtype.

    Parameters

    • shape: Array<number> | number

      The shape of the array.

    • Default value dtype: string | DLDataType = "float32"

      The data type of the array.

    • Default value dev: DLDevice = this.device("cpu", 0)

      The device of the ndarray.

    Returns NDArray

    The created ndarray.

getGlobalFunc

  • Get global PackedFunc from the runtime.

    Parameters

    • name: string

      The name of the function.

    Returns PackedFunc

    The result function.

initWebGPU

  • initWebGPU(device: GPUDevice): void
  • Initialize webgpu in the runtime.

    Parameters

    • device: GPUDevice

      The given GPU device.

    Returns void

isPackedFunc

  • isPackedFunc(func: unknown): boolean
  • Check if func is PackedFunc.

    Parameters

    • func: unknown

      The input.

    Returns boolean

    The check result.

listGlobalFuncNames

  • listGlobalFuncNames(): Array<string>
  • List all the global function names registered in the runtime.

    Returns Array<string>

    The name list.

registerAsyncServerFunc

  • registerAsyncServerFunc(name: string, func: Function, override?: boolean): void
  • Register an asyncfunction to be global function in the server.

    note

    The async function will only be used for serving remote calls in the rpc.

    Parameters

    • name: string

      The name of the function.

    • func: Function

      function to be registered.

    • Default value override: boolean = false

      Whether overwrite function in existing registry.

    Returns void

registerFunc

  • registerFunc(name: string, func: PackedFunc | Function, override?: boolean): void
  • Register function to be global function in tvm runtime.

    Parameters

    • name: string

      The name of the function.

    • func: PackedFunc | Function
    • Default value override: boolean = false

      Whether overwrite function in existing registry.

    Returns void

scalar

  • scalar(value: number, dtype: string): Scalar
  • Create a new Scalar that can be passed to a PackedFunc.

    Parameters

    • value: number

      The number value.

    • dtype: string

      The dtype string.

    Returns Scalar

    The created scalar.

setPackedArguments

  • Set packed function arguments into the location indicated by argsValue and argsCode. Allocate new temporary space from the stack if necessary.

    parma

    stack The call stack

    Parameters

    Returns void

systemLib

  • Get system-wide library module in the wasm. System lib is a global module that contains self register functions in startup.

    Returns Module

    The system library module.

toDLDataType

toPackedFunc

  • Convert func to PackedFunc

    Parameters

    • func: Function

      Input function.

    Returns PackedFunc

    The converted function.

webgpu

Generated using TypeDoc