|
LBANN
0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
|
Functions | |
| size_t | compute_cnpy_array_offset (const cnpy::NpyArray &na, std::vector< size_t > indices) |
| template<typename T > | |
| size_t | ptr_offset (const cnpy::NpyArray &na, std::vector< size_t > indices) |
| template<typename T > | |
| T & | data (const cnpy::NpyArray &na, const std::vector< size_t > indices) |
| template<typename T > | |
| T * | data_ptr (const cnpy::NpyArray &na, const std::vector< size_t > indices) |
| template<> | |
| void * | data_ptr< void > (const cnpy::NpyArray &na, const std::vector< size_t > indices) |
| void | shrink_to_fit (cnpy::NpyArray &na, size_t sz) |
| std::string | show_shape (const cnpy::NpyArray &na) |
| Show the dimensions of loaded data. More... | |
| size_t lbann::cnpy_utils::compute_cnpy_array_offset | ( | const cnpy::NpyArray & | na, |
| std::vector< size_t > | indices | ||
| ) |
Return the offset to the element (in terms of the number of elements from the beginning of the array) of a loaded numpy array na specified by indices If the number of indices is less than the dimension of na array, the indices vector is appended with zeros to match the dimension.
|
inline |
Allow the access to the data element identified by the indices and the word_size of the array na, but present it as a type T element at the address.
Definition at line 75 of file cnpy_utils.hpp.
|
inline |
Return the address of the data element identified by the indices and the word_size of the array na, but present it as the address of a type T element
Definition at line 86 of file cnpy_utils.hpp.
|
inline |
|
inline |
If the type T of the numpy array element is something larger than 1 byte in size, the word_size of the numpy array must be the same as sizeof(T). In such a case, offset to add to a type T pointer is computed as the number of elements up to the position pointed by the indices. If sizeof(T) is 1 byte, then the array may be of char string, or the pointer may be cast to a byte-long type. In such a case, the offset is computed as the number of elements scaled by the word_size of the array. cnpy treats an array of strings as a 1D array, for which the word_size is equal to the length of the largest string.
Definition at line 59 of file cnpy_utils.hpp.
| std::string lbann::cnpy_utils::show_shape | ( | const cnpy::NpyArray & | na | ) |
Show the dimensions of loaded data.
| void lbann::cnpy_utils::shrink_to_fit | ( | cnpy::NpyArray & | na, |
| size_t | sz | ||
| ) |
Shrink the first dimension of cnpy::NpyArray to the given size. This is used to choose only first sz samples in data.