Documentation
¶
Overview ¶
Package gotvm is TVM runtime interface definition for golang.
Application need to import this package to access the c_runtime_api exposed by TVM.
Index ¶
- Variables
- func FuncListGlobalNames() (retVal []string, err error)
- func RegisterFunction(args ...interface{}) (err error)
- type Array
- func (parray Array) AsSlice() (retVal interface{}, err error)
- func (parray Array) CopyFrom(val interface{}) (err error)
- func (parray Array) GetDType() (retVal string)
- func (parray Array) GetDevice() (retVal Device)
- func (parray Array) GetNdim() (retVal int32)
- func (parray Array) GetShape() (retVal []int64)
- type ByteArray
- type Device
- func CPU(index int32) Device
- func CUDA(index int32) Device
- func CUDAHost(index int32) Device
- func Metal(index int32) Device
- func OpenCL(index int32) Device
- func OpenGL(index int32) Device
- func ROCM(index int32) Device
- func SDAccel(index int32) Device
- func VPI(index int32) Device
- func Vulkan(index int32) Device
- type Function
- type Module
- type Value
Constants ¶
This section is empty.
Variables ¶
var DLPackVersion = int(C.DLPACK_VERSION)
DLPackVersion is the dlpack version of tvm runtime.
var KArrayHandle = int32(C.kTVMDLTensorHandle)
KArrayHandle is golang type code for TVM kTVMDLTensorHandle.
var KBytes = int32(C.kTVMBytes)
KBytes is golang type code for TVM kTVMBytes.
var KDLCPU = int32(C.kDLCPU)
KDLCPU is golang enum correspond to TVM device type kDLCPU.
var KDLDevice = int32(C.kDLDevice)
KDLDevice is golang type code for TVM kDLDevice.
var KDLFloat = int32(C.kDLFloat)
KDLFloat is golang type code for TVM kDLFloat.
var KDLInt = int32(C.kDLInt)
KDLInt is golang type code for TVM kDLInt.
var KDLMetal = int32(C.kDLMetal)
KDLMetal is golang enum correspond to TVM device type kDLMetal.
var KDLOpenCL = int32(C.kDLOpenCL)
KDLOpenCL is golang enum correspond to TVM device type kDLOpenCL.
var KDLROCM = int32(C.kDLROCM)
KDLROCM is golang enum correspond to TVM device type kDLROCM.
var KDLSDAccel = int32(C.kDLSDAccel)
KDLSDAccel is golang enum correspond to TVM device type kDLSDAccel.
var KDLUInt = int32(C.kDLUInt)
KDLUInt is golang type code for TVM kDLUInt.
var KDLVPI = int32(C.kDLVPI)
KDLVPI is golang enum correspond to TVM device type kDLVPI.
var KDLVulkan = int32(C.kDLVulkan)
KDLVulkan is golang enum correspond to TVM device type kDLVulkan.
var KExtBegin = int32(C.kTVMExtBegin)
KExtBegin is golang enum corresponding to TVM kTVMExtBegin.
var KExtDev = int32(C.kDLExtDev)
KExtDev is golang enum correspond to TVM device type kDLExtDev.
var KExtEnd = int32(C.kTVMExtEnd)
KExtEnd is golang enum corresponding to TVM kExtEnd.
var KExtReserveEnd = int32(C.kTVMExtReserveEnd)
KExtReserveEnd is golang enum corresponding to TVM kExtReserveEnd.
var KFuncHandle = int32(C.kTVMPackedFuncHandle)
KFuncHandle is gonalg type code for TVM kTVMPackedFuncHandle.
var KHandle = int32(C.kTVMOpaqueHandle)
KHandle is golang type code for TVM enum kTVMOpaqueHandle.
var KModuleHandle = int32(C.kTVMModuleHandle)
KModuleHandle is gonag type code for TVM kTVMModuleHandle.
var KNDArrayContainer = int32(C.kTVMNDArrayHandle)
KNDArrayContainer is golang typecode for kTVMNDArrayHandle.
var KNNVMFirst = int32(C.kTVMNNVMFirst)
KNNVMFirst is golang enum corresponding to TVM kNNVMFirst.
var KNNVMLast = int32(C.kTVMNNVMLast)
KNNVMLast is golang enum corresponding to TVM kNNVMLast.
var KNull = int32(C.kTVMNullptr)
KNull is golang type code for TVM kTVMNullptr.
var KObjectHandle = int32(C.kTVMObjectHandle)
KObjectHandle is golang type code for TVM kTVMObjectHandle.
var KOpenGL = int32(C.kOpenGL)
KOpenGL is golang enum correspond to TVM device type kOpenGL.
var KStr = int32(C.kTVMStr)
KStr is golang type code for TVM kTVMStr.
var KTVMType = int32(C.kTVMDataType)
KTVMType is golang type code for TVM kTVMDataType.
var TVMVersion = getTVMVersion()
TVMVersion is the TVM runtime version.
Functions ¶
func FuncListGlobalNames ¶
FuncListGlobalNames is used to query global callable packed function names from TVM.
returns slice of string holding function names and error if any.
func RegisterFunction ¶
func RegisterFunction(args ...interface{}) (err error)
RegisterFunction registers the golang func in TVM runtime global space.
`args[0]` function pointer for a type ```func (args ...interface{}) (interface{})```
`args[1]` Optional argument of function name with which it will be registered.
If not passed we use function name from reflection.
Returns err indicating native error if any.
Types ¶
type Array ¶
type Array uintptr
Array type in golang hold pointer for the TVMArray object from dlpack.
Array initialization happen through Empty api
func Empty ¶
Empty is used to allocate TVM empty array of given epecification.
`shape` is int64 slice holding shape of the Array
`args` is variadic args for
`args[0]` is string for data type. Default value is 'float32' `args[1]` is Device. Default value is '{KDLCPU, 0}'
returns pointer to Array on successful execution and error if any.
func (Array) AsSlice ¶
AsSlice returns the unitptr of for the data inside Array.
returns the slice of array inside Array and err of any. TOD: Use reflections for better handling
func (Array) CopyFrom ¶
CopyFrom copies given golang data slice into Array.
`val` is interface homding a slice of Array data type.
returns err is any. TOD: Use reflections for better handling
type ByteArray ¶
type ByteArray uintptr
ByteArray type wraps the TVMByteArray of C runtime API.
This can be used to hold raw data like params of a model.
type Device ¶
Device dtype corresponding to Device aka DLDevice
type Function ¶
type Function uintptr
Function type in golang hold pointer for the TVMFunction handle.
func ConvertFunction ¶
ConvertFunction converts given golang function to TVM packed function.
`args[0]` function pointer for a type ```func (args ...interface{}) (interface{})```
Returns Function handle and err if any.
func GetGlobalFunction ¶
GetGlobalFunction is to get handle to the given global function name.
`funcname` is the name of global packed function.
returns a function closure with signature
func (args ...interface{}) (interface{}, error) and error if any.
The closure function can be used to call Function with arguments directly.
Variadic arguments can be any type which can be embed into Value.
type Module ¶
type Module uintptr
Module type in golang hold pointer for the TVMModule handle.
Module initialization happen through TVMModLoadFromFile api in TVM runtime.
func LoadModuleFromFile ¶
LoadModuleFromFile loads the given module in TVM runtime.
`modpath` is the path to tvm module.
`args` is an optional arguments of ["dll", "dylib", "dso", "so"] with default value "so"
returns pointer to Module and err or if any.
func (*Module) GetFunction ¶
func (tvmmodule *Module) GetFunction( funcname string, args ...interface{}) ( retVal *Function, err error)
GetFunction returns the function pointer from the module for given function name.
`tvmmodule` is handle for Module
`funcname` function name in module.
`args` variadic args of `queryImport`
returns function closure with signature
func (args ...interface{}) (interface{}, error) and error if any.
The closure function can be used to call Function with arguments directly.
Variadic arguments can be any type which can be embed into Value.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value Typemap for union exposed by TVM runtime API.
gotvm maps it to a uintptr and then dynamically allocates memory by newTVMValue method.
func (*Value) AsFunction ¶
AsFunction returns the Function inside the Value.