libpressio 0.93.0
|
#include <data.h>
Public Member Functions | |
pressio_data & | operator= (pressio_data const &rhs) |
pressio_data (pressio_data const &rhs) | |
pressio_data (pressio_data &&rhs) noexcept | |
pressio_data & | operator= (pressio_data &&rhs) noexcept |
template<class T > | |
pressio_data (std::initializer_list< T > il) | |
void * | data () const |
bool | has_data () const |
pressio_dtype | dtype () const |
void | set_dtype (pressio_dtype dtype) |
pressio_data | cast (pressio_dtype dtype) const |
size_t | num_dimensions () const |
std::vector< size_t > const & | dimensions () const |
std::vector< size_t > | normalized_dims (compat::optional< size_t > n={}, size_t fill=0) const |
size_t | set_dimensions (std::vector< size_t > &&dims) |
size_t | get_dimension (size_t idx) const |
size_t | size_in_bytes () const |
size_t | capacity_in_bytes () const |
size_t | num_elements () const |
pressio_data | select (std::vector< size_t > const &start={}, std::vector< size_t > const &stride={}, std::vector< size_t > const &count={}, std::vector< size_t > const &block={}) const |
int | reshape (std::vector< size_t > const &new_dimensions) |
template<class T > | |
std::vector< T > | to_vector () const |
template<class ForwardIt > | |
pressio_data (ForwardIt begin, ForwardIt end) | |
pressio_data | transpose (std::vector< size_t > const &axis={}) const |
bool | operator== (pressio_data const &rhs) const |
Static Public Member Functions | |
static pressio_data | empty (const pressio_dtype dtype, std::vector< size_t > const &dimensions) |
static pressio_data | nonowning (const pressio_dtype dtype, void *data, std::vector< size_t > const &dimensions) |
static pressio_data | copy (const enum pressio_dtype dtype, const void *src, std::vector< size_t > const &dimensions) |
static pressio_data | owning (const pressio_dtype dtype, std::vector< size_t > const &dimensions) |
static pressio_data | move (const pressio_dtype dtype, void *data, std::vector< size_t > const &dimensions, pressio_data_delete_fn deleter, void *metadata) |
static pressio_data | empty (const pressio_dtype dtype, size_t const num_dimensions, size_t const dimensions[]) |
static pressio_data | nonowning (const pressio_dtype dtype, void *data, size_t const num_dimensions, size_t const dimensions[]) |
static pressio_data | copy (const enum pressio_dtype dtype, const void *src, size_t const num_dimensions, size_t const dimensions[]) |
static pressio_data | owning (const pressio_dtype dtype, size_t const num_dimensions, size_t const dimensions[]) |
static pressio_data | move (const pressio_dtype dtype, void *data, size_t const num_dimensions, size_t const dimensions[], pressio_data_delete_fn deleter, void *metadata) |
static pressio_data | clone (pressio_data const &src) |
represents a data buffer that may or may not be owned by the class
|
inline |
|
inlinenoexcept |
move-constructor
[in] | rhs | the data buffer to move from |
|
inline |
construct a literal pressio_data object from a initializer list
[in] | il | initializer list to use to create the data object |
|
inline |
convert a iterable type into a pressio_data object
[in] | begin | iterator to the beginning of the data |
[in] | end | iterator to the end of the data |
|
inline |
pressio_data pressio_data::cast | ( | pressio_dtype | dtype | ) | const |
[in] | dtype | the new datatype to assign |
|
inlinestatic |
clones a existing data buffer
Does not use the copy constructor to enforce strict semantics around copies
[in] | src | the object |
|
inlinestatic |
creates a copy of a data buffer
[in] | dtype | the type of the buffer |
[in] | src | the buffer to copy |
[in] | num_dimensions | the number of entries in dimensions |
[in] | dimensions | the dimensions of the data |
|
inlinestatic |
creates a copy of a data buffer
[in] | dtype | the type of the buffer |
[in] | src | the buffer to copy |
[in] | dimensions | the dimensions of the buffer |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
allocates a new empty data buffer
[in] | dtype | the type the buffer will contain |
[in] | num_dimensions | the length of dimensions |
[in] | dimensions | the dimensions of the expected buffer |
|
inlinestatic |
allocates a new empty data buffer
[in] | dtype | the type the buffer will contain |
[in] | dimensions | the dimensions of the expected buffer |
|
inline |
idx | the specific index to query |
|
inline |
|
inlinestatic |
takes ownership of an existing data buffer
[in] | dtype | the type of the buffer |
[in] | data | the buffer |
[in] | num_dimensions | the number of entries in dimensions |
[in] | dimensions | the dimensions of the data |
[in] | deleter | the method to call to free the buffer or null to not free the data |
[in] | metadata | the metadata passed to the deleter function |
|
inlinestatic |
takes ownership of an existing data buffer
[in] | dtype | the type of the buffer |
[in] | data | the buffer |
[in] | dimensions | the dimensions of the buffer |
[in] | deleter | the method to call to free the buffer or null to not free the data |
[in] | metadata | the metadata passed to the deleter function |
|
inlinestatic |
creates a non-owning reference to data
[in] | dtype | the type of the buffer |
[in] | data | the buffer |
[in] | num_dimensions | the number of entries in dimensions |
[in] | dimensions | the dimensions of the data |
|
inlinestatic |
creates a non-owning reference to data
[in] | dtype | the type of the buffer |
[in] | data | the buffer |
[in] | dimensions | the dimensions of the buffer |
std::vector< size_t > pressio_data::normalized_dims | ( | compat::optional< size_t > | n = {} , |
size_t | fill = 0 |
||
) | const |
returns the dimensions normalized to remove 1's
|
inline |
|
inline |
|
inlinenoexcept |
move-assignment operator
[in] | rhs | the data buffer to move from |
|
inline |
bool pressio_data::operator== | ( | pressio_data const & | rhs | ) | const |
[in] | rhs | the object to compare against |
|
inlinestatic |
creates a copy of a data buffer
[in] | dtype | the type of the buffer |
[in] | num_dimensions | the number of entries in dimensions |
[in] | dimensions | the dimensions of the data |
|
inlinestatic |
creates a copy of a data buffer
[in] | dtype | the type of the buffer |
[in] | dimensions | the dimensions of the buffer |
|
inline |
modifies the dimensions of this pressio_data structure in-place.
This API does not change the size of the underlying buffer. A future version of this API may change this.
[in] | new_dimensions | the new dimensions to use |
pressio_data pressio_data::select | ( | std::vector< size_t > const & | start = {} , |
std::vector< size_t > const & | stride = {} , |
||
std::vector< size_t > const & | count = {} , |
||
std::vector< size_t > const & | block = {} |
||
) | const |
Copies a set of blocks of data from the data stream to a new pressio_data structure
[in] | start | the position in the array to start iterating, start[i]>=0 |
[in] | stride | the number of blocks to skip in each direction, stride[i] >=1 |
[in] | count | the number of blocks to copy, count[i] >= 1 |
[in] | block | the dimensions of the block to copy, block[i] >= 1 |
|
inline |
changes the dimensions of the size of the memory if the resulting buffer is smaller than the current buffer capacity in bytes, nothing else is done if the resulting buffer is larger than the current buffer capacity in bytes, a realloc-like operation is performed
[in] | dims | the new dimensions to use |
|
inline |
[in] | dtype | the data type for the buffer |
|
inline |
|
inline |
convert a pressio_data structure into a 1d c++ standard vector. If the type doesn't match, it will be casted first
pressio_data pressio_data::transpose | ( | std::vector< size_t > const & | axis = {} | ) | const |
Permutes the dimensions of an array
[in] | axis | by default reverses the axis, otherwise permutes the axes according to the dimensions |