libpressio 0.93.0
|
an abstraction for a contagious memory region of a specified type More...
Go to the source code of this file.
Typedefs | |
typedef void(* | pressio_data_delete_fn) (void *data, void *metadata) |
Functions | |
void | pressio_data_libc_free_fn (void *data, void *metadata) |
struct pressio_data * | pressio_data_new_nonowning (const enum pressio_dtype dtype, void *data, size_t const num_dimensions, size_t const dimensions[]) |
struct pressio_data * | pressio_data_new_clone (const struct pressio_data *src) |
struct pressio_data * | pressio_data_new_copy (const enum pressio_dtype dtype, void *src, size_t const num_dimensions, size_t const dimensions[]) |
struct pressio_data * | pressio_data_new_owning (const enum pressio_dtype dtype, size_t const num_dimensions, size_t const dimensions[]) |
struct pressio_data * | pressio_data_new_empty (const enum pressio_dtype dtype, size_t const num_dimensions, size_t const dimensions[]) |
struct pressio_data * | pressio_data_new_move (const enum pressio_dtype dtype, void *data, size_t const num_dimensions, size_t const dimensions[], pressio_data_delete_fn deleter, void *metadata) |
struct pressio_data * | pressio_data_cast (const struct pressio_data *data, const enum pressio_dtype dtype) |
void | pressio_data_free (struct pressio_data *data) |
void * | pressio_data_copy (struct pressio_data const *data, size_t *out_bytes) |
void * | pressio_data_ptr (struct pressio_data const *data, size_t *out_bytes) |
struct pressio_data * | pressio_data_select (struct pressio_data const *data, const size_t *start, const size_t *stride, const size_t *count, const size_t *block) |
struct pressio_data * | pressio_data_transpose (struct pressio_data const *data, const size_t *axis) |
int | pressio_data_reshape (struct pressio_data *data, size_t const num_dimensions, size_t const dimensions[]) |
enum pressio_dtype | pressio_data_dtype (struct pressio_data const *data) |
bool | pressio_data_has_data (struct pressio_data const *data) |
size_t | pressio_data_num_dimensions (struct pressio_data const *data) |
size_t | pressio_data_get_dimension (struct pressio_data const *data, size_t const dimension) |
size_t | pressio_data_get_bytes (struct pressio_data const *data) |
size_t | pressio_data_get_capacity_in_bytes (struct pressio_data const *data) |
size_t | pressio_data_num_elements (struct pressio_data const *data) |
an abstraction for a contagious memory region of a specified type
typedef void(* pressio_data_delete_fn) (void *data, void *metadata) |
signature for a custom deleter for pressio_data
[in] | data | to be deallocated |
[in] | metadata | metadata passed to pressio_data_new_move, if allocated, it too should be freed |
struct pressio_data * pressio_data_cast | ( | const struct pressio_data * | data, |
const enum pressio_dtype | dtype | ||
) |
Creates a data buffer with the specified type from an existing buffer
[in] | data | the data to cast |
[in] | dtype | the datatype to cast to |
void * pressio_data_copy | ( | struct pressio_data const * | data, |
size_t * | out_bytes | ||
) |
allocates a buffer and then copies the underlying memory to the new buffer
[in] | data | the pressio data to copy from |
[out] | out_bytes | the number of bytes that were copied |
enum pressio_dtype pressio_data_dtype | ( | struct pressio_data const * | data | ) |
[in] | data | the pressio data to query |
void pressio_data_free | ( | struct pressio_data * | data | ) |
frees a pressio_data structure, but not the underlying data
[in] | data | data structure to free |
size_t pressio_data_get_bytes | ( | struct pressio_data const * | data | ) |
returns the number of bytes to represent the data
[in] | data | the pressio data to query |
size_t pressio_data_get_capacity_in_bytes | ( | struct pressio_data const * | data | ) |
returns the number of bytes of capacity
[in] | data | the pressio data to query |
size_t pressio_data_get_dimension | ( | struct pressio_data const * | data, |
size_t const | dimension | ||
) |
returns the value of a given dimension.
[in] | data | the pressio data to query |
[in] | dimension | zero indexed dimension |
bool pressio_data_has_data | ( | struct pressio_data const * | data | ) |
[in] | data | the pressio data to query |
void pressio_data_libc_free_fn | ( | void * | data, |
void * | metadata | ||
) |
a custom deleter that uses libc's free and ignores the metadata
[in] | data | to be deallocated with free() |
[in] | metadata | ignored |
struct pressio_data * pressio_data_new_clone | ( | const struct pressio_data * | src | ) |
allocates a new pressio_data structure and corresponding data and copies data from provided data structure
[in] | src | the pressio_data structure to be cloned |
struct pressio_data * pressio_data_new_copy | ( | const enum pressio_dtype | dtype, |
void * | src, | ||
size_t const | num_dimensions, | ||
size_t const | dimensions[] | ||
) |
allocates a new pressio_data structure and corresponding data and copies data in from the specified source use this function when the underlying data pointer may be deleted
[in] | dtype | type of the data stored by the pointer |
[in] | src | the data to be copied into the data structure |
[in] | num_dimensions | the number of dimensions; must match the length of dimensions |
[in] | dimensions | an array corresponding to the dimensions of the data, a copy is made of this on construction |
struct pressio_data * pressio_data_new_empty | ( | const enum pressio_dtype | dtype, |
size_t const | num_dimensions, | ||
size_t const | dimensions[] | ||
) |
allocates a new pressio_data without data.
[in] | dtype | type of the data stored by the pointer |
[in] | num_dimensions | the number of dimensions; must match the length of dimensions |
[in] | dimensions | an array corresponding to the dimensions of the data, a copy is made of this on construction |
struct pressio_data * pressio_data_new_move | ( | const enum pressio_dtype | dtype, |
void * | data, | ||
size_t const | num_dimensions, | ||
size_t const | dimensions[], | ||
pressio_data_delete_fn | deleter, | ||
void * | metadata | ||
) |
allocates a new pressio_data structure using data that was already allocated. data referenced by this structure will be deallocated using the function deleter when the pressio_data structure is freed.
[in] | dtype | the type of the data to store |
[in] | data | the pointer to be "moved" into the pressio_data structure |
[in] | num_dimensions | the number of dimensions; must match the length of dimensions |
[in] | dimensions | an array corresponding to the dimensions of the data, a copy is made of this on construction |
[in] | deleter | the function to be called when pressio_data_free is called on this structure |
[in] | metadata | passed to the deleter function when pressio_data_free is called, it may be null if unneeded |
struct pressio_data * pressio_data_new_nonowning | ( | const enum pressio_dtype | dtype, |
void * | data, | ||
size_t const | num_dimensions, | ||
size_t const | dimensions[] | ||
) |
allocates a new pressio_data structure, it does NOT take ownership of data.
[in] | dtype | type of the data stored by the pointer |
[in] | data | the actual data to be represented |
[in] | num_dimensions | the number of dimensions; must match the length of dimensions |
[in] | dimensions | an array corresponding to the dimensions of the data, a copy is made of this on construction |
struct pressio_data * pressio_data_new_owning | ( | const enum pressio_dtype | dtype, |
size_t const | num_dimensions, | ||
size_t const | dimensions[] | ||
) |
allocates a new pressio_data structure and corresponding data. The corresponding data is uninitialized
[in] | dtype | type of the data stored by the pointer |
[in] | num_dimensions | the number of dimensions; must match the length of dimensions |
[in] | dimensions | an array corresponding to the dimensions of the data, a copy is made of this on construction |
size_t pressio_data_num_dimensions | ( | struct pressio_data const * | data | ) |
[in] | data | the pressio data to query |
size_t pressio_data_num_elements | ( | struct pressio_data const * | data | ) |
returns the total number of elements to represent the data
[in] | data | the pressio data to query |
void * pressio_data_ptr | ( | struct pressio_data const * | data, |
size_t * | out_bytes | ||
) |
non-owning access to the first element of the raw data
[in] | data | the pressio data to query |
[out] | out_bytes | the number of bytes that follow this pointer (ignored if NULL is passed) |
int pressio_data_reshape | ( | struct pressio_data * | data, |
size_t const | num_dimensions, | ||
size_t const | dimensions[] | ||
) |
modifies the dimensions of a pressio_data structure inplace.
This API does not change the size of the underlying buffer. A future version of this API may change this.
[in] | data | the data structure to modify |
[in] | num_dimensions | the size of the new dimensions |
[in] | dimensions | the new dimensions to use |
struct pressio_data * pressio_data_select | ( | struct pressio_data const * | data, |
const size_t * | start, | ||
const size_t * | stride, | ||
const size_t * | count, | ||
const size_t * | block | ||
) |
Copies a possibly strided subset of from the data pointer
[in] | data | the data to copy from |
[in] | start | the coordinate to start at; must have the same dimension as data or null. if null is chosen the zero vector of size N is used. |
[in] | stride | how many elements from the first element in each block to skip in each directions before the next block if null is chosen the one vector of size N is used. |
[in] | count | how many blocks to copy in each direction. if null is chosen the one vector of size N is used. |
[in] | block | the dimentions of each block to copy if null is chosen the one vector of size N is used. |
struct pressio_data * pressio_data_transpose | ( | struct pressio_data const * | data, |
const size_t * | axis | ||
) |
Transposes a data-buffer
[in] | data | the data to copy from |
[in] | axis | the order of the dimensions if null is chosen the dimensions are reversed |