taichi.lang._ndarray
¶
Module Contents¶
Classes¶
Taichi ndarray class implemented with a torch tensor. |
|
Taichi ndarray with scalar elements. |
|
Class for accessing VectorNdarray/MatrixNdarray in Python scope. |
- class taichi.lang._ndarray.Ndarray(dtype, arr_shape)¶
Taichi ndarray class implemented with a torch tensor.
- Parameters
dtype (DataType) – Data type of each value.
shape (Tuple[int]) – Shape of the torch tensor.
- property element_shape(self)¶
Gets ndarray element shape.
- Returns
Ndarray element shape.
- Return type
Tuple[Int]
- property data_handle(self)¶
Gets the pointer to underlying data.
- Returns
The pointer to underlying data.
- Return type
int
- fill(self, val)¶
Fills ndarray with a specific scalar value.
- Parameters
val (Union[int, float]) – Value to fill.
- ndarray_to_numpy(self)¶
Converts ndarray to a numpy array.
- Returns
The result numpy array.
- Return type
numpy.ndarray
- ndarray_matrix_to_numpy(self, as_vector)¶
Converts matrix ndarray to a numpy array.
- Returns
The result numpy array.
- Return type
numpy.ndarray
- ndarray_from_numpy(self, arr)¶
Loads all values from a numpy array.
- Parameters
arr (numpy.ndarray) – The source numpy array.
- ndarray_matrix_from_numpy(self, arr, as_vector)¶
Loads all values from a numpy array.
- Parameters
arr (numpy.ndarray) – The source numpy array.
- get_element_size(self)¶
Returns the size of one element in bytes.
- Returns
Size in bytes.
- get_nelement(self)¶
Returns the total number of elements.
- Returns
Total number of elements.
- copy_from(self, other)¶
Copies all elements from another ndarray.
The shape of the other ndarray needs to be the same as self.
- Parameters
other (Ndarray) – The source ndarray.
- abstract fill_by_kernel(self, val)¶
Fills ndarray with a specific scalar value using a ti.kernel.
- Parameters
val (Union[int, float]) – Value to fill.
- pad_key(self, key)¶
- initialize_host_accessor(self)¶
- class taichi.lang._ndarray.ScalarNdarray(dtype, arr_shape)¶
Bases:
Ndarray
Taichi ndarray with scalar elements.
- Parameters
dtype (DataType) – Data type of each value.
shape (Tuple[int]) – Shape of the ndarray.
- property element_shape(self)¶
Gets ndarray element shape.
- Returns
Ndarray element shape.
- Return type
Tuple[Int]
- to_numpy(self)¶
- from_numpy(self, arr)¶
- fill_by_kernel(self, val)¶
Fills ndarray with a specific scalar value using a ti.kernel.
- Parameters
val (Union[int, float]) – Value to fill.
- class taichi.lang._ndarray.NdarrayHostAccessor(ndarray)¶
- class taichi.lang._ndarray.NdarrayHostAccess(arr, indices_first, indices_second)¶
Class for accessing VectorNdarray/MatrixNdarray in Python scope. :param arr: See above. :type arr: Union[VectorNdarray, MatrixNdarray] :param indices_first: Indices of first-level access (coordinates in the field). :type indices_first: Tuple[Int] :param indices_second: Indices of second-level access (indices in the vector/matrix). :type indices_second: Tuple[Int]