taichi.types

Submodules

Package Contents

Classes

CompoundType

Functions

ext_arr()

Type annotation for external arrays.

matrix(n, m, dtype)

struct(**kwargs)

vector(n, dtype)

Attributes

any_arr

Alias for ArgAnyArray.

template

Alias for Template.

float32

32-bit single precision floating point data type.

f32

Alias for float32

float64

64-bit double precision floating point data type.

f64

Alias for float64

float16

f16

int8

i8

int16

i16

int32

32-bit signed integer data type.

i32

Alias for int32

int64

64-bit signed integer data type.

i64

Alias for int64

uint8

u8

uint16

u16

uint32

32-bit unsigned integer data type.

u32

Alias for uint32

uint64

64-bit unsigned integer data type.

u64

Alias for uint64

real_types

integer_types

is_signed

is_integral

taichi.types.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.
taichi.types.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.template

Alias for Template.

class taichi.types.CompoundType
taichi.types.matrix(n, m, dtype)
taichi.types.struct(**kwargs)
taichi.types.vector(n, dtype)
taichi.types.float32

32-bit single precision floating point data type.

taichi.types.f32

Alias for float32

taichi.types.float64

64-bit double precision floating point data type.

taichi.types.f64

Alias for float64

taichi.types.float16
taichi.types.f16
taichi.types.int8
taichi.types.i8
taichi.types.int16
taichi.types.i16
taichi.types.int32

32-bit signed integer data type.

taichi.types.i32

Alias for int32

taichi.types.int64

64-bit signed integer data type.

taichi.types.i64

Alias for int64

taichi.types.uint8
taichi.types.u8
taichi.types.uint16
taichi.types.u16
taichi.types.uint32

32-bit unsigned integer data type.

taichi.types.u32

Alias for uint32

taichi.types.uint64

64-bit unsigned integer data type.

taichi.types.u64

Alias for uint64

taichi.types.real_types
taichi.types.integer_types
taichi.types.is_signed
taichi.types.is_integral