Module tvm::function::ffi[][src]

Expand description

The low-level C runtime FFI API for TVM.

Structs

\brief The data type the tensor can hold.

\brief A Device for Tensor and operator.

\brief C Tensor object, manage memory of DLTensor. This data structure is intended to facilitate the borrowing of DLTensor by another framework. It is not meant to transfer the tensor. When the borrowing framework doesn’t need the tensor, it should call the deleter to notify the host that the resource is no longer needed.

\brief Plain C Tensor object, does not manage memory.

\brief Byte array type used to pass in byte array When kTVMBytes is used as data type.

\brief Environment for TVM parallel task.

Constants

\brief bfloat16

\brief complex number (C/C++/Python layout: compact struct per complex number)

\brief IEEE floating point

\brief signed integer

\brief Opaque handle type, reserved for testing purposes. Frameworks need to agree on the handle data type for the exchange to be well-defined.

\brief unsigned integer

\brief CPU device

\brief CUDA GPU device

\brief Pinned CUDA CPU memory by cudaMallocHost

\brief Reserved extension device type, used for quickly test extension device The semantics can differ depending on the implementation.

\brief Metal for Apple GPU.

\brief OpenCL devices.

\brief ROCm GPUs for AMD GPUs

\brief Verilog simulator buffer

\brief Vulkan buffer for next generation graphics.

Functions

\brief Used for implementing C API function. Set last error message before return. \param msg The error message to be set.

\brief Allocate a nd-array’s memory, including space of shape, of given spec.

\brief Copy array data from CPU byte array. \param handle The array handle. \param data the data pointer \param nbytes The number of bytes to copy. \return 0 when success, nonzero when failure happens

\brief Copy the array, both from and to must be valid during the copy. \param from The array to be copied from. \param to The target space. \param stream The stream where the copy happens, can be NULL. \return 0 when success, nonzero when failure happens

\brief Copy array data to CPU byte array. \param handle The array handle. \param data the data pointer \param nbytes The number of bytes to copy. \return 0 when success, nonzero when failure happens

\brief Free the TVM Array. \param handle The array handle to be freed. \return 0 when success, nonzero when failure happens

\brief Produce an array from the DLManagedTensor that shares data memory with the DLManagedTensor. \param from The source DLManagedTensor. \param out The output array handle. \return 0 when success, nonzero when failure happens

\brief Produce a DLMangedTensor from the array that shares data memory with the array. \param from The source array. \param out The DLManagedTensor handle. \return 0 when success, nonzero when failure happens

\brief Backend function to allocate temporal workspace.

\brief Backend function to free temporal workspace.

\brief Backend function for modules to get function from its environment mod_node (its imports and global function). The user do should not call TVMFuncFree on func.

\brief BSP barrrier between parallel threads \param task_id the task id of the function. \param penv The parallel environment backs the execution. \return 0 when no error is thrown, -1 when failure happens

\brief Backend function for running parallel jobs.

\brief Backend function to register execution environment(e.g. python) specific C APIs.

\brief Backend function to register system-wide library symbol.

\brief Simple static initialization function. Run f once and set handle to be not null. This function is mainly used for test purpose.

\brief Free a TVMByteArray returned from TVMFuncCall, and associated memory. \param arr The TVMByteArray instance. \return 0 on success, -1 on failure.

\brief Set the return value of TVMPackedCFunc.

\brief Inplace translate callback argument value to return value. This is only needed for non-POD arguments.

\brief Delete (free) a DLManagedTensor’s data. \param dltensor Pointer to the DLManagedTensor.

\brief Allocate a data space on device. \param dev The device to perform operation. \param nbytes The number of bytes in memory. \param alignment The alignment of the memory. \param type_hint The type of elements. Only needed by certain backends such as nbytes & alignment are sufficient for most backends. \param out_data The allocated device pointer. \return 0 when success, nonzero when failure happens

\brief Allocate a data space on device with special memory scope. \note The memory could use a special multi-dimensional memory layout. That is why we pass shape and dtype instead of raw number of bytes. \param dev The device to perform operation. \param ndim The number of dimension of the tensor. \param shape The shape of the tensor. \param dtype The type of elements. \param mem_scope The memory scope of the tensor, can be nullptr, which indicate the default global DRAM \param out_data The allocated device pointer. \return 0 when success, nonzero when failure happens

\brief Copy data from one place to another. \note This API is designed to support special memory with shape dependent layout. We pass in DLTensor* with shape information to support these cases. \param from The source tensor. \param to The target tensor. \param stream Optional stream object. \return 0 when success, nonzero when failure happens.

\brief Free a data space on device. \param dev The device to perform operation. \param ptr The data space. \return 0 when success, nonzero when failure happens

\brief Call a Packed TVM Function.

\brief Wrap a TVMPackedCFunc to become a FunctionHandle.

\brief Free the function when it is no longer needed. \param func The function handle \return 0 when success, nonzero when failure happens

\brief Get a global function.

\brief List all the globally registered function name \param out_size The number of functions \param out_array The array of function names. \return 0 when success, nonzero when failure happens

\brief Register the function to runtime’s global table.

\brief Remove a global function. \param name The name of the function.

\brief return str message of the last error all function in this file will return 0 when success and nonzero when an error occurred, TVMGetLastError can be called to retrieve the error

\brief Free the Module \param mod The module to be freed.

\brief Get function from the module. \param mod The module handle. \param func_name The name of the function. \param query_imports Whether to query imported modules \param out The result function, can be NULL if it is not available. \return 0 when no error is thrown, nonzero when failure happens

\brief Add dep to mod’s dependency. This allows functions in this module to use modules.

\brief Load module from file. \param file_name The file name to load the module from. \param format The format of the module. \param out The result module

\brief Check that an object is derived from another. \param child_type_index The type index of the derived type. \param parent_type_index The type index of the parent type. \param is_derived A boolean representing whether this predicate holds. \return 0 when success, nonzero when failure happens.

\brief Free the object.

\brief Get the type_index from an object.

\brief Increase the reference count of an object.

\brief Convert type index to type key. \param tindex The type index. \param out_type_key The output type key. \return 0 when success, nonzero when failure happens

\brief Convert type key to type index. \param type_key The key of the type. \param out_tindex the corresponding type index. \return 0 when success, nonzero when failure happens

\brief Set the runtime stream of current thread to be stream. The subsequent calls to the same device_type will use the setted stream handle. The specific type of stream is runtime device dependent.

\brief Create a new runtime stream.

\brief Free a created stream handle.

\brief Synchronize two streams of execution.

\brief Wait until all computations on stream completes.

Type Definitions

\brief The type code options DLDataType.

\brief The device type in DLDevice.

\brief The callback function to execute a parallel lambda \param task_id the task id of the function. \param penv The parallel environment backs the execution. \param cdata The supporting closure data.

\brief The type code in used and only used in TVM FFI for argument passing.

\brief the array handle

\brief Signature for backend functions exported as DLL.

\brief Extension device types in TVM

\brief Signature for extension function declarer.

\brief Handle to packed function handle.

\brief Handle to TVM runtime modules.

\brief Handle to Object.

\brief C type of packed function.

\brief C callback to free the resource handle in C packed function. \param resource_handle The handle additional resouce handle from fron-end.

\brief Handle to hold return value.

\brief The stream that is specific to device can be NULL, which indicates the default one.

\brief type of array index.

Unions

\brief Union type of values being passed through API and function calls.