Append a custom target for TVM Context

We have a custom accelerator that uses the OpenCL frontend. We want to include this as a custom type like the aocl within the TVM pipeline. How do we go about introducing a new target for the same? (we aim to give our custom accelerator as the target parameter for tvm.context)

1 Like

You can first register a target using TVM_REGISTER_TARGET_KIND macro in Then register OpenCL codegen as your backend.

This doc can help you get familiar with the compilation flow, and you can add corresponding compoents for your accelerator:

Hey @comaniac Thanks that was helpful. So if i register a new target “newName” for example like


.add_attr_option<Integer>("max_num_threads", Integer(256))
.set_default_keys({"opencl", "accelerator"})

when I call tvm.context(“newName”) now will it directly use opencl backend or am I supposed to add more files for newName in the src/runtime folder ?

Also Once I added the files for for my new target called rsim I got the folowing error

File “”, line 1, in import tvm File “/home/akhil/Downloads/TVM/tvm/python/tvm/”, line 25, in from ._ffi.base import TVMError, version File “/home/akhil/Downloads/TVM/tvm/python/tvm/_ffi/”, line 28, in from .base import register_error File “/home/akhil/Downloads/TVM/tvm/python/tvm/_ffi/”, line 62, in _LIB, _LIB_NAME = _load_lib() File “/home/akhil/Downloads/TVM/tvm/python/tvm/_ffi/”, line 50, in _load_lib lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL) File “/usr/lib/python3.6/ctypes/”, line 348, in init self._handle = _dlopen(self._name, mode) OSError: /home/akhil/Downloads/TVM/tvm/build/ undefined symbol: ZN3tvm7runtime16RSIMModuleCreateENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_St13unordered_mapIS6_NS0_12FunctionInfoESt4hashIS6_ESt8equal_toIS6_ESaISt4pairIKS6_S8_EEES6

@junrushao1994 do you have an idea for this error before diving into it?

I saw FunctionInfo in the unmangled symbol name, so it looks like there are some missing pieces in the build. Seems like some linking issues or some symbols are missing.

Is it working if you build on HEAD?