heterocl.tvm.target module¶
-
class
Target
(target_name, options=None)[source]¶ Bases:
object
Target device information, use through TVM API.
- Parameters
target_name ({"llvm", "cuda", "opencl", "metal", "rocm", "stackvm", "opengl", "ext_dev", "rv64_ppac"}) –
- The major target name.
{“merlinc”, “soda”, “soda_xhls”, “vhls”}
The HeteroCL specific target name for FPGAs.
options (list of str, optional) – Additional arguments appended to the target.
Note
Do not use class constructor, you can create target using the following functions
tvm.target.create
create target from stringtvm.target.rasp
create raspberry pi targettvm.target.cuda
create CUDA targettvm.target.rocm
create ROCM targettvm.target.mali
create Mali target
-
current
= None¶
-
create
(target_str)[source]¶ Get a target given target string.
- Parameters
target_str (str) – The target string.
- Returns
target – The target object
- Return type
Note
See the note on
tvm.target
on target string format.
-
cuda
(options=None)[source]¶ Returns a cuda target.
- Parameters
options (list of str) – Additional options
-
current_target
(allow_none=True)[source]¶ Returns the current target.
- Parameters
allow_none (bool) – Whether allow the current target to be none
- Raises
ValueError if current target is not set. –
-
generic_func
(fdefault)[source]¶ Wrap a target generic function.
Generic function allows registeration of further functions that can be dispatched on current target context. If no registered dispatch is matched, the fdefault will be called.
- Parameters
fdefault (function) – The default function.
- Returns
fgeneric – A wrapped generic function.
- Return type
function
Example
import tvm # wrap function as target generic @tvm.target.generic_func def my_func(a): return a + 1 # register specialization of my_func under target cuda @my_func.register("cuda") def my_func_cuda(a): return a + 2 # displays 3, because my_func is called print(my_func(2)) # displays 4, because my_func_cuda is called with tvm.target.cuda(): print(my_func(2))
-
mali
(options=None)[source]¶ Returns a ARM Mali GPU target.
- Parameters
options (list of str) – Additional options
-
opengl
(options=None)[source]¶ Returns a OpenGL target.
- Parameters
options (list of str) – Additional options