taichi.types.annotations
#
- taichi.types.annotations.any_arr#
Alias for
ArgAnyArray
.Example:
>>> @ti.kernel
>>> def to_numpy(x: ti.any_arr(), y: ti.any_arr()):
>>> for i in range(n):
>>> x[i] = y[i]
>>>
>>> y = ti.ndarray(ti.f64, shape=n)
>>> ... # calculate y
>>> x = numpy.zeros(n)
>>> to_numpy(x, y) # `x` will be filled with `y`'s data.
- taichi.types.annotations.ext_arr()#
Type annotation for external arrays.
External arrays are formally defined as the data from other Python frameworks. For now, Taichi supports numpy and pytorch.
Example:
>>> @ti.kernel
>>> def to_numpy(arr: ti.ext_arr()):
>>> for i in x:
>>> arr[i] = x[i]
>>>
>>> arr = numpy.zeros(...)
>>> to_numpy(arr) # `arr` will be filled with `x`'s data.
- class taichi.types.annotations.sparse_matrix_builder#
- taichi.types.annotations.template#
Alias for
Template
.