AI-MXNetCAPI
view release on metacpan or search on metacpan
* \param delay_alloc whether to delay allocation until
* the ndarray is first mutated
* \param dtype data type of created array
* \param out the returning handle
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayCreateEx(const mx_uint *in,
mx_uint ndim,
int dev_type,
int dev_id,
int delay_alloc,
int dtype,
NDArrayHandle *out);
/*!
* \brief create a NDArray handle that is loaded from raw bytes.
* \param buf the head of the raw bytes
* \param size size of the raw bytes
* \param out the returning handle
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayLoadFromRawBytes(const void *in,
size_t size,
NDArrayHandle *out);
/*!
* \brief save the NDArray into raw bytes.
* \param handle the NDArray handle
* \param out_size size of the raw bytes
* \param out_buf the head of returning memory bytes.
* \return 0 when success, -1 when failure happens
*/
int MXNDArraySaveRawBytes(NDArrayHandle handle,
size_t *out_size,
const char **out_array);
/*!
* \brief Save list of ndarray into the file.
* \param fname name of the file.
* \param num_args number of arguments to save.
* \param args the array of NDArrayHandles to be saved.
* \param keys the name of the NDArray, optional, can be NULL
* \return 0 when success, -1 when failure happens
*/
int MXNDArraySave(const char* fname,
mx_uint num_args,
NDArrayHandle* in,
const char** in);
/*!
* \brief Load list of ndarray from the file.
* \param fname name of the file.
* \param out_size number of ndarray loaded.
* \param out_arr head of the returning ndarray handles.
* \param out_name_size size of output name arrray.
* \param out_names the names of returning NDArrays, can be NULL
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayLoad(const char* fname,
mx_uint *out_size,
NDArrayHandle** out_array,
mx_uint *out_size,
const char*** out_array);
/*!
* \brief Perform a synchronize copy from a continugous CPU memory region.
*
* This function will call WaitToWrite before the copy is performed.
* This is useful to copy data from existing memory region that are
* not wrapped by NDArray(thus dependency not being tracked).
*
* \param handle the NDArray handle
* \param data the data source to copy from.
* \param size the memory size we want to copy from.
*/
int MXNDArraySyncCopyFromCPU(NDArrayHandle handle,
const void *in,
size_t size);
/*!
* \brief Perform a synchronize copy to a continugous CPU memory region.
*
* This function will call WaitToRead before the copy is performed.
* This is useful to copy data from existing memory region that are
* not wrapped by NDArray(thus dependency not being tracked).
*
* \param handle the NDArray handle
* \param data the data source to copy into.
* \param size the memory size we want to copy into.
*/
int MXNDArraySyncCopyToCPU(NDArrayHandle handle,
void *in,
size_t size);
/*!
* \brief Wait until all the pending writes with respect NDArray are finished.
* Always call this before read data out synchronizely.
* \param handle the NDArray handle
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayWaitToRead(NDArrayHandle handle);
/*!
* \brief Wait until all the pending read/write with respect NDArray are finished.
* Always call this before write data into NDArray synchronizely.
* \param handle the NDArray handle
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayWaitToWrite(NDArrayHandle handle);
/*!
* \brief wait until all delayed operations in
* the system is completed
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayWaitAll();
/*!
* \brief free the ndarray handle
* \param handle the handle to be freed
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayFree(NDArrayHandle handle);
/*!
* \brief Slice the NDArray along axis 0.
* \param handle the handle to the NDArray
* \param slice_begin The beginning index of slice
* \param slice_end The ending index of slice
* \param out The NDArrayHandle of sliced NDArray
* \return 0 when success, -1 when failure happens
*/
int MXNDArraySlice(NDArrayHandle handle,
mx_uint slice_begin,
mx_uint slice_end,
NDArrayHandle *out);
/*!
* \brief Index the NDArray along axis 0.
* \param handle the handle to the NDArray
* \param idx the index
* \param out The NDArrayHandle of output NDArray
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayAt(NDArrayHandle handle,
mx_uint idx,
NDArrayHandle *out);
/*!
* \brief Reshape the NDArray.
* \param handle the handle to the ndarray
* \param ndim number of dimensions of new shape
* \param dims new shape
* \param out the NDArrayHandle of reshaped NDArray
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayReshape(NDArrayHandle handle,
int ndim,
int *in,
NDArrayHandle *out);
/*!
* \brief get the shape of the array
* \param handle the handle to the ndarray
* \param out_dim the output dimension
* \param out_pdata pointer holder to get data pointer of the shape
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayGetShape(NDArrayHandle handle,
mx_uint *out_dim,
const mx_uint **out_pdata);
( run in 1.400 second using v1.01-cache-2.11-cpan-ecdf5575e8d )