#include <NDArray.h>
Public Member Functions | |
NDArrayPool (int maxBuffers, size_t maxMemory) | |
NDArrayPool constructor. | |
NDArray * | alloc (int ndims, int *dims, NDDataType_t dataType, int dataSize, void *pData) |
Allocates a new NDArray object; the first 3 arguments are required. | |
NDArray * | copy (NDArray *pIn, NDArray *pOut, int copyData) |
This method makes a copy of an NDArray object. | |
int | reserve (NDArray *pArray) |
This method increases the reference count for the NDArray object. | |
int | release (NDArray *pArray) |
This method decreases the reference count for the NDArray object. | |
int | convert (NDArray *pIn, NDArray **ppOut, NDDataType_t dataTypeOut, NDDimension_t *outDims) |
Creates a new output NDArray from an input NDArray, performing conversion operations. | |
int | convert (NDArray *pIn, NDArray **ppOut, NDDataType_t dataTypeOut) |
Creates a new output NDArray from an input NDArray, performing conversion operations. | |
int | report (int details) |
Reports on the free list size and other properties of the NDArrayPool object. | |
int | maxBuffers () |
Returns maximum number of buffers this object is allowed to allocate; -1=unlimited. | |
int | numBuffers () |
Returns number of buffers this object has currently allocated. | |
size_t | maxMemory () |
Returns maximum bytes of memory this object is allowed to allocate; -1=unlimited. | |
size_t | memorySize () |
Returns mumber of bytes of memory this object has currently allocated. | |
int | numFree () |
Returns number of NDArray objects in the free list. |
Drivers allocate NDArray objects from the pool, and pass these objects to plugins. Plugins increase the reference count on the object when they place the object on their queue, and decrease the reference count when they are done processing the array. When the reference count reaches 0 again the NDArray object is placed back on the free list. This mechanism minimizes the copying of array data in plugins.
NDArrayPool::NDArrayPool | ( | int | maxBuffers, | |
size_t | maxMemory | |||
) |
NDArrayPool constructor.
NDArray * NDArrayPool::alloc | ( | int | ndims, | |
int * | dims, | |||
NDDataType_t | dataType, | |||
int | dataSize, | |||
void * | pData | |||
) |
Allocates a new NDArray object; the first 3 arguments are required.
[in] | ndims | The number of dimensions in the NDArray. |
[in] | dims | Array of dimensions, whose size must be at least ndims. |
[in] | dataType | Data type of the NDArray data. |
[in] | dataSize | Number of bytes to allocate for the array data; if 0 then alloc() will compute the size required from ndims, dims, and dataType. |
[in] | pData | Pointer to a data buffer; if NULL then alloc will allocate a new array buffer; if not NULL then it is assumed to point to a valid buffer. |
int NDArrayPool::convert | ( | NDArray * | pIn, | |
NDArray ** | ppOut, | |||
NDDataType_t | dataTypeOut | |||
) |
Creates a new output NDArray from an input NDArray, performing conversion operations.
This form of the function is for changing the data type only, not the dimensions, which are preserved.
[in] | pIn | The input array, source of the conversion. |
[out] | ppOut | The output array, result of the conversion. |
[in] | dataTypeOut | The data type of the output array. |
int NDArrayPool::convert | ( | NDArray * | pIn, | |
NDArray ** | ppOut, | |||
NDDataType_t | dataTypeOut, | |||
NDDimension_t * | dimsOut | |||
) |
Creates a new output NDArray from an input NDArray, performing conversion operations.
The conversion can change the data type if dataTypeOut is different from pIn->dataType. It can also change the dimensions. outDims may have different values of size, binning, offset and reverse for each of its dimensions from input array dimensions (pIn->dims).
[in] | pIn | The input array, source of the conversion. |
[out] | ppOut | The output array, result of the conversion. |
[in] | dataTypeOut | The data type of the output array. |
[in] | dimsOut | The dimensions of the output array. |
This method makes a copy of an NDArray object.
[in] | pIn | The input array to be copied. |
[in] | pOut | The output array that will be copied to. |
[in] | copyData | If this flag is 1 then everything including the array data is copied; if 0 then everything except the data (including attributes) is copied. |
int NDArrayPool::maxBuffers | ( | ) |
Returns maximum number of buffers this object is allowed to allocate; -1=unlimited.
size_t NDArrayPool::maxMemory | ( | ) |
Returns maximum bytes of memory this object is allowed to allocate; -1=unlimited.
size_t NDArrayPool::memorySize | ( | ) |
Returns mumber of bytes of memory this object has currently allocated.
int NDArrayPool::numBuffers | ( | ) |
Returns number of buffers this object has currently allocated.
int NDArrayPool::numFree | ( | ) |
Returns number of NDArray objects in the free list.
int NDArrayPool::release | ( | NDArray * | pArray | ) |
This method decreases the reference count for the NDArray object.
[in] | pArray | The array on which to decrease the reference count. |
int NDArrayPool::report | ( | int | details | ) |
Reports on the free list size and other properties of the NDArrayPool object.
[in] | details | Level of report details desired; does nothing at present. |
int NDArrayPool::reserve | ( | NDArray * | pArray | ) |