taichi.lang.field
#
- class taichi.lang.field.BitpackedFields(max_num_bits)#
Taichi bitpacked fields, where fields with quantized types are packed together.
- Parameters:
max_num_bits (int) – Maximum number of bits all fields inside can occupy in total. Only 32 or 64 is allowed.
- class taichi.lang.field.Field(_vars)#
Taichi field class.
A field is constructed by a list of field members. For example, a scalar field has 1 field member, while a 3x3 matrix field has 9 field members. A field member is a Python Expr wrapping a C++ FieldExpression.
- Parameters:
vars (List[Expr]) – Field members.
- copy_from(self, other)#
Copies all elements from another field.
The shape of the other field needs to be the same as self.
- Parameters:
other (Field) – The source field.
- from_paddle(self, arr)#
Loads all elements from a paddle tensor.
The shape of the paddle tensor needs to be the same as self.
- Parameters:
arr (paddle.Tensor) – The source paddle tensor.
- from_torch(self, arr)#
Loads all elements from a torch tensor.
The shape of the torch tensor needs to be the same as self.
- Parameters:
arr (torch.tensor) – The source torch tensor.
- class taichi.lang.field.ScalarField(var)#
Bases:
Field
Taichi scalar field with SNode implementation.
- Parameters:
var (Expr) – Field member.
- copy_from(self, other)#
Copies all elements from another field.
The shape of the other field needs to be the same as self.
- Parameters:
other (Field) – The source field.
- fill(self, val)#
Fills this scalar field with a specified value.
- from_numpy(self, arr)#
Copies the data from a numpy.ndarray into this field.
- from_paddle(self, arr)#
Loads all elements from a paddle tensor.
The shape of the paddle tensor needs to be the same as self.
- Parameters:
arr (paddle.Tensor) – The source paddle tensor.
- from_torch(self, arr)#
Loads all elements from a torch tensor.
The shape of the torch tensor needs to be the same as self.
- Parameters:
arr (torch.tensor) – The source torch tensor.
- parent(self, n=1)#
Gets an ancestor of the representative SNode in the SNode tree.
- Parameters:
n (int) – the number of levels going up from the representative SNode.
- Returns:
The n-th parent of the representative SNode.
- Return type:
- to_numpy(self, dtype=None)#
Converts this field to a numpy.ndarray.
- to_paddle(self, place=None)#
Converts this field to a paddle.Tensor.
- to_torch(self, device=None)#
Converts this field to a torch.tensor.