taichi.types
#
This module defines data types in Taichi:
primitive: int, float, etc.
compound: matrix, vector, struct.
template: for reference types.
ndarray: for arbitrary arrays.
quant: for quantized types, see “https://yuanming.taichi.graphics/publication/2021-quantaichi/quantaichi.pdf”
- taichi.types.float16#
16-bit precision floating point data type.
- taichi.types.float32#
32-bit single precision floating point data type.
- taichi.types.float64#
64-bit double precision floating point data type.
- taichi.types.int16#
16-bit signed integer data type.
- taichi.types.int32#
32-bit signed integer data type.
- taichi.types.int64#
64-bit signed integer data type.
- taichi.types.int8#
8-bit signed integer data type.
- taichi.types.is_integral#
- taichi.types.is_real#
- taichi.types.is_signed#
- taichi.types.is_tensor#
- taichi.types.matrix(n=None, m=None, dtype=None)#
Creates a matrix type with given shape and data type.
- Parameters:
n (int) – number of rows of the matrix.
m (int) – number of columns of the matrix.
dtype (
primitive_types
) – matrix data type.
- Returns:
A matrix type.
Example:
>>> mat2x2 = ti.types.matrix(2, 2, ti.f32) # 2x2 matrix type >>> M = mat2x2([[1., 2.], [3., 4.]]) # an instance of this type
- taichi.types.ndarray#
Alias for
NdarrayType
.Example:
>>> @ti.kernel >>> def to_numpy(x: ti.types.ndarray(), y: ti.types.ndarray()): >>> 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.ref(tp)#
- taichi.types.rw_texture#
Alias for
TextureType
.
- class taichi.types.sparse_matrix_builder#
- taichi.types.struct(**kwargs)#
Creates a struct type with given members.
- Parameters:
kwargs (dict) – a dictionary contains the names and types of the struct members.
- Returns:
A struct type.
Example:
>>> vec3 = ti.types.vector(3, ti.f32) >>> sphere = ti.types.struct(center=vec3, radius=float) >>> s = sphere(center=vec3([0., 0., 0.]), radius=1.0)
- taichi.types.template#
Alias for
Template
.
- taichi.types.texture#
- taichi.types.uint1#
1-bit unsigned integer data type. Same as booleans.
- taichi.types.uint16#
16-bit unsigned integer data type.
- taichi.types.uint32#
32-bit unsigned integer data type.
- taichi.types.uint64#
64-bit unsigned integer data type.
- taichi.types.uint8#
8-bit unsigned integer data type.
- taichi.types.vector(n=None, dtype=None)#
Creates a vector type with given shape and data type.
- Parameters:
n (int) – dimension of the vector.
dtype (
primitive_types
) – vector data type.
- Returns:
A vector type.
Example:
>>> vec3 = ti.types.vector(3, ti.f32) # 3d vector type >>> v = vec3([1., 2., 3.]) # an instance of this type