![]() |
TensorBolt
|
File containing ndarray aka tensors metadata. This file can be extended to support multiple backends. More...
#include <stdint.h>#include <stdarg.h>

Go to the source code of this file.
Typedefs | |
| typedef float | tb_float |
| typedef enum NDArrayLocation | NDArrayLocation |
Enumerations | |
| enum | NDArrayLocation { NDA_LOC_HOST_MEM =0, NDA_LOC_DEVICE_MEM =0 } |
Functions | |
| void | nda_ShapeStackInit (struct NDShapeStack *stack, struct NDShape *shape) |
| Unline other factory pattern object, the stack is usually allocated on the stack (in contrast to heap) So we do need dynamically allocate it, this function only initializes the values of a fresh allocated stack. More... | |
| uint8_t | nda_ShapeStackCanPop (struct NDShapeStack *stack) |
| Checks if a shape stack can still popped further more. More... | |
| uint64_t | nda_ShapeStackPop (struct NDShapeStack *stack) |
| Pops the next element in the stack, does not modify the shape but updates the index in the stack. More... | |
| struct NDShape * | nda_newShape (uint64_t rank,...) |
| struct NDShape * | nda_newShapeFromArray (uint64_t rank, uint64_t *dims) |
| struct NDShape * | nda_newShapeFromArrayCopy (uint64_t rank, uint64_t *dims) |
| void | nda_debugShape (struct NDShape *shape) |
| Prints tensor shape to stdout. More... | |
| struct NDShape * | nda_copyShape (struct NDShape *shape) |
| Creates and Allocates a shape with the same properties of the given one. More... | |
| uint8_t | nda_shapeCanBroadCast (struct NDShape *shape1, struct NDShape *shape2) |
| Verifies if two shapes can be broadcasted Broadcast verifications follows numpy rules: More... | |
| char * | nda_shapeToString (struct NDShape *shape) |
| Generate a string representation of the shape, which can be used for debugging or generating errors. More... | |
| void | nda_debugValue (struct NDArray *tensor) |
| Prints tensor value to stdout. More... | |
| uint64_t | nda_getTotalSize (struct NDShape *shape) |
| Calculate the total number of elements in a tensor shape. More... | |
| struct NDArray * | nda_alloc (struct NDShape *shape) |
| Creates an empty zeroed tensor. More... | |
| struct NDArray * | nda_randomNormal (struct NDShape *shape, float mu, float sig) |
| Creates an array from a Guassian Distribution. More... | |
| struct NDArray * | nda_linspace (tb_float a, tb_float b, uint64_t n) |
| Return evenly spaced numbers over a specified interval. More... | |
| struct NDArray * | nda_ones (struct NDShape *shape) |
| Creates an One initialized tensor. More... | |
| struct NDArray * | nda_fill (struct NDShape *shape, tb_float value) |
| Creates an array initialized with one value. More... | |
| struct NDArray * | nda_copy (struct NDArray *x) |
| copies an existent tensor, memory must be explicitly freed. More... | |
| void | nda_reshape (struct NDArray *x, struct NDShape *shape) |
| reshape an ndarray, old shape is freed. More... | |
| void | nda_free (struct NDArray *array) |
| frees an NDArray alongside its shape More... | |
| tb_float | nda_get (struct NDArray *array, uint64_t *index) |
| Returns the value of an array. More... | |
| struct NDArray * | nda_slice (struct NDArray *array, uint64_t *index) |
| Returns a slice of an array. More... | |
| tb_float | nda_vget (struct NDArray *array, uint64_t *index, struct NDShape *vshape) |
| Returns the value of array throughout a virtual shape. The virtual shape has the same size of the original, but padded with ones to match another shape during broadcasting. If an index has a value higher than the padded virtual shape, the index 0 is then used. #deal_with_it. More... | |
| tb_float | nda_get1D (struct NDArray *array, uint64_t index) |
| Returns the value of an array through 1d Inde. More... | |
| tb_float | nda_vget1D (struct NDArray *array, uint64_t index) |
| Returns the value of array throughout a 1D index. If the index has a value higher than the original size, mod is used. More... | |
File containing ndarray aka tensors metadata. This file can be extended to support multiple backends.
File containing ndarray standard backend implementation aka tensors metadata.
| typedef enum NDArrayLocation NDArrayLocation |
Array location
| enum NDArrayLocation |
Creates an empty zeroed tensor.
| shape | initial shape |
copies an existent tensor, memory must be explicitly freed.
| [in] | x | tensor to copy |
Creates and Allocates a shape with the same properties of the given one.
| shape | Shape to copy |
| void nda_debugShape | ( | struct NDShape * | shape | ) |
Prints tensor shape to stdout.
| [in] | shape | TensorShape to display |
| void nda_debugValue | ( | struct NDArray * | tensor | ) |
Prints tensor value to stdout.
| [in] | tensor | Tensor to display |
Creates an array initialized with one value.
| shape[in] | initial shape |
| value[in] | value to initialize the array with |
| void nda_free | ( | struct NDArray * | array | ) |
frees an NDArray alongside its shape
| [in/out] | array data to free |
| tb_float nda_get | ( | struct NDArray * | array, |
| uint64_t * | index | ||
| ) |
Returns the value of an array.
| [in] | array | NDArray to access |
| [in] | index | Array of dims of the element, len(index) must be equal to to the rank of the array |
| tb_float nda_get1D | ( | struct NDArray * | array, |
| uint64_t | index | ||
| ) |
Returns the value of an array through 1d Inde.
| [in] | array | NDArray to access |
| [in] | index | 1D index to fetch |
| uint64_t nda_getTotalSize | ( | struct NDShape * | shape | ) |
Calculate the total number of elements in a tensor shape.
| [in] | shape | Tensor shape to process |
| struct NDArray* nda_linspace | ( | tb_float | a, |
| tb_float | b, | ||
| uint64_t | n | ||
| ) |
Return evenly spaced numbers over a specified interval.
| [in] | a | start element |
| [in] | b | end element |
| [in] | n | number of elements |
| struct NDShape* nda_newShape | ( | uint64_t | rank, |
| ... | |||
| ) |
Creates a new shape from the given elements dimensions
| [in] | rank | number of dimensions |
| [in] | ... | list of dimensions (variadic parameters) |
| struct NDShape* nda_newShapeFromArray | ( | uint64_t | rank, |
| uint64_t * | dims | ||
| ) |
Creates a new shape from the given elements dimensions as array
| [in] | rank | number of dimensions |
| [in] | array | of dims, should be dynamically allocated as it will be freed when the shape is destroyed. len(array) must be equal to rank |
| struct NDShape* nda_newShapeFromArrayCopy | ( | uint64_t | rank, |
| uint64_t * | dims | ||
| ) |
Creates a new shape from the given elements dimensions as array
| [in] | rank | number of dimensions |
| [in] | array | of dims, this array will be copied and the copy will be assigned to the new shape. len(array) must be equal to rank |
Creates an One initialized tensor.
| shape[in] | initial shape |
Creates an array from a Guassian Distribution.
| shape | initial shape | |
| [in] | mu | Gussian's Mu parameters |
| [in] | sig | Guaussian\s Sigma parameter |
reshape an ndarray, old shape is freed.
| [in/out] | x ndarray to reshape | |
| [in] | shape | new shape |
Verifies if two shapes can be broadcasted Broadcast verifications follows numpy rules:
| [in] | shape1 | Shape of the first array |
| [in] | shape2 | Shape of the second array |
| uint8_t nda_ShapeStackCanPop | ( | struct NDShapeStack * | stack | ) |
Checks if a shape stack can still popped further more.
| [in] | stack | Stack to check |
| void nda_ShapeStackInit | ( | struct NDShapeStack * | stack, |
| struct NDShape * | shape | ||
| ) |
Unline other factory pattern object, the stack is usually allocated on the stack (in contrast to heap) So we do need dynamically allocate it, this function only initializes the values of a fresh allocated stack.
| [in/out] | stack Allocated stack to initialize | |
| [in] | shape | Shape to bind to the stack |
| uint64_t nda_ShapeStackPop | ( | struct NDShapeStack * | stack | ) |
Pops the next element in the stack, does not modify the shape but updates the index in the stack.
| [in/out] | stack Stack from which to pop the element |
| char* nda_shapeToString | ( | struct NDShape * | shape | ) |
Generate a string representation of the shape, which can be used for debugging or generating errors.
| [in] | shape | NDShape to process |
Returns a slice of an array.
| [in] | array | NDArray to access |
| [in] | index | Array of slices of the elements, must be in the format start_dim_1, end_dim_1, start_dim_2, end_dim_2, ... start_dim_n, end_dim_n |
Returns the value of array throughout a virtual shape. The virtual shape has the same size of the original, but padded with ones to match another shape during broadcasting. If an index has a value higher than the padded virtual shape, the index 0 is then used. #deal_with_it.
| [in] | array | NDArray to access |
| [in] | index | Array of dims of the element, len(index) must be equal to to the rank of the array |
| [in] | vshape | Virtual padded shape |
1.8.15