AI-MXNetCAPI
view release on metacpan or search on metacpan
},
"name" : "AI-MXNetCAPI",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"version" : "1.0102"
}
---
abstract: 'Swig interface to mxnet c api'
author:
- 'Sergey Kolychev <sergeykolychev.github@gmail.com>'
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.143240'
license: apache
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: AI-MXNetCAPI
no_index:
directory:
- t
- inc
requires:
Test::More: '0'
version: '1.0102'
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires mxnet http://mxnet.io
It's used by AI::MXNet
COPYRIGHT AND LICENCE
Copyright (C) 2017 by Sergey Kolychev <sergeykolychev.github@gmail.com>
This library is licensed under Apache 2.0 license https://www.apache.org/licenses/LICENSE-2.0
/*! \brief Set the number of OMP threads to use */
int MXSetNumOMPThreads(int thread_num);
//-------------------------------------
// Part 1: NDArray creation and deletion
//-------------------------------------
/*!
* \brief create a NDArray handle that is not initialized
* can be used to pass in as mutate variables
* to hold the result of NDArray
* \param out the returning handle
* \return 0 when success, -1 when failure happens
*/
int MXNDArrayCreateNone(NDArrayHandle *out);
/*!
* \brief create a NDArray with specified shape
* \param shape the pointer to the shape
* \param ndim the dimension of the shape
* \param dev_type device type, specify device we want to take
* \param dev_id the device id of the specific device
* 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
*/
* \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
* most user can use it to list all the needed functions
* \param out_size the size of returned array
* \param out_array the output function array
* \return 0 when success, -1 when failure happens
*/
int MXListFunctions(mx_uint *out_size,
FunctionHandle **out_array);
/*!
* \brief get the function handle by name
* \param name the name of the function
* \param out the corresponding function handle
* \return 0 when success, -1 when failure happens
*/
int MXGetFunction(const char *name,
FunctionHandle *out);
/*!
* \brief Get the information of the function handle.
* \param fun The function handle.
* \param name The returned name of the function.
* \param description The returned description of the function.
* \param num_args Number of arguments.
int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out);
/*!
* \brief Free the symbol handle.
* \param symbol the symbol
* \return 0 when success, -1 when failure happens
*/
int MXSymbolFree(SymbolHandle symbol);
/*!
* \brief Copy the symbol to another handle
* \param symbol the source symbol
* \param out used to hold the result of copy
* \return 0 when success, -1 when failure happens
*/
int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out);
/*!
* \brief Print the content of symbol, used for debug.
* \param symbol the symbol
* \param out_str pointer to hold the output string of the printing.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolPrint(SymbolHandle symbol, const char **out);
/*!
* \brief Get string name from symbol
* \param symbol the source symbol
* \param out The result name.
* \param success Whether the result is contained in out.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolGetName(SymbolHandle symbol,
const char** out,
int *out);
/*!
* \brief Get string attribute from symbol
* \param symbol the source symbol
* \param key The key of the symbol.
* \param out The result attribute, can be NULL if the attribute do not exist.
* \param success Whether the result is contained in out.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolGetAttr(SymbolHandle symbol,
const char* key,
const char** out,
int *out);
/*!
* \brief Set string attribute from symbol.
* NOTE: Setting attribute to a symbol can affect the semantics(mutable/immutable) of symbolic graph.
*
* \param value The value to be saved.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolSetAttr(SymbolHandle symbol,
const char* in,
const char* in);
/*!
* \brief Get all attributes from symbol, including all descendents.
* \param symbol the source symbol
* \param out_size The number of output attributes
* \param out 2*out_size strings representing key value pairs.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolListAttr(SymbolHandle symbol,
mx_uint *out_size,
const char*** out_array2);
/*!
* \brief Get all attributes from symbol, excluding descendents.
* \param symbol the source symbol
* \param out_size The number of output attributes
* \param out 2*out_size strings representing key value pairs.
* \return 0 when success, -1 when failure happens
*/
int MXSymbolListAttrShallow(SymbolHandle symbol,
mx_uint *out_size,
const char*** out_array2);
/*!
* \brief List arguments in the symbol.
* \param symbol the symbol
* \param out_size output size
* \param out_str_array pointer to hold the output string array
* \param wrt the name of the arguments to get gradient
* \param out the returned symbol that has gradient
* \return 0 when success, -1 when failure happens
*/
int MXSymbolGrad(SymbolHandle sym,
mx_uint num_wrt,
const char** in,
SymbolHandle* out);
/*!
* \brief infer shape of unknown input shapes given the known one.
* The shapes are packed into a CSR matrix represented by arg_ind_ptr and arg_shape_data
* The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.
*
* \param sym symbol handle
* \param num_args numbe of input arguments.
* \param keys the key of keyword args (optional)
* \param arg_ind_ptr the head pointer of the rows in CSR
* \param arg_shape_data the content of the CSR
* \param in_shape_size sizeof the returning array of in_shapes
* \param in_shape_ndim returning array of shape dimensions of eachs input shape.
* \param in_shape_data returning array of pointers to head of the input shape.
mx_uint *out_shape_size,
const mx_uint **out_shape_ndim,
const mx_uint ***out_shape_data,
mx_uint *aux_shape_size,
const mx_uint **aux_shape_ndim,
const mx_uint ***aux_shape_data,
int *out);
/*!
* \brief partially infer shape of unknown input shapes given the known one.
*
* Return partially inferred results if not all shapes could be inferred.
* The shapes are packed into a CSR matrix represented by arg_ind_ptr and arg_shape_data
* The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.
*
* \param sym symbol handle
* \param num_args numbe of input arguments.
* \param keys the key of keyword args (optional)
* \param arg_ind_ptr the head pointer of the rows in CSR
* \param arg_shape_data the content of the CSR
* \param in_shape_size sizeof the returning array of in_shapes
* \param in_shape_ndim returning array of shape dimensions of eachs input shape.
* \param in_shape_data returning array of pointers to head of the input shape.
mx_uint *out_shape_size,
const mx_uint **out_shape_ndim,
const mx_uint ***out_shape_data,
mx_uint *aux_shape_size,
const mx_uint **aux_shape_ndim,
const mx_uint ***aux_shape_data,
int *out);
/*!
* \brief infer type of unknown input types given the known one.
* The types are packed into a CSR matrix represented by arg_ind_ptr and arg_type_data
* The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.
*
* \param sym symbol handle
* \param num_args numbe of input arguments.
* \param keys the key of keyword args (optional)
* \param arg_type_data the content of the CSR
* \param in_type_size sizeof the returning array of in_types
* \param in_type_data returning array of pointers to head of the input type.
* \param out_type_size sizeof the returning array of out_types
* \param out_type_data returning array of pointers to head of the input type.
*/
int MXListDataIters(mx_uint *out_size,
DataIterCreator **out_array);
/*!
* \brief Init an iterator, init with parameters
* the array size of passed in arguments
* \param handle of the iterator creator
* \param num_param number of parameter
* \param keys parameter keys
* \param vals parameter values
* \param out resulting iterator
* \return 0 when success, -1 when failure happens
*/
int MXDataIterCreateIter(DataIterCreator handle,
mx_uint num_param,
const char **keys,
const char **vals,
DataIterHandle *out);
/*!
* \brief Get the detailed information about data iterator.
* \param creator the DataIterCreator.
* \param priority the priority of the action
* \return 0 when success, -1 when failure happens
*/
int MXKVStorePullEx(KVStoreHandle handle,
mx_uint num,
const char** in,
NDArrayHandle* in,
int priority);
/*!
* \brief user-defined updater for the kvstore
* It's this updater's responsibility to delete \a recv and \a local
* \param the key
* \param recv the pushed value on this key
* \param local the value stored on local on this key
* \param handle The additional handle to the updater
*/
typedef void (MXKVStoreUpdater)(int key,
NDArrayHandle recv,
NDArrayHandle local,
void *handle);
/*!
const char* cmd_body);
/**
* \brief Get the number of ps dead node(s) specified by {node_id}
*
* \param handle handle to the KVStore
* \param node_id Can be a node group or a single node.
* kScheduler = 1, kServerGroup = 2, kWorkerGroup = 4
* \param number Ouptut number of dead nodes
* \param timeout_sec A node fails to send heartbeart in {timeout_sec} seconds
* will be presumed as 'dead'
*/
int MXKVStoreGetNumDeadNode(KVStoreHandle handle,
const int node_id,
int *out,
const int timeout_sec = 60);
/**
* \brief Create a RecordIO writer object
* \param uri path to file
* \param out handle pointer to the created object
mxnet_typemaps.i view on Meta::CPAN
}
%typemap(in,numinputs=0) (const char **out) (char *temp)
{
temp = NULL;
$1 = &temp;
}
%typemap(argout) (const char **out)
{
if(!result)
{
$result = newSVpv(*$1, 0);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (int *out) (int temp)
{
temp = 0;
$1 = &temp;
}
%typemap(argout) (int *out)
{
if(!result)
{
$result = newSViv(*$1);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (nn_uint *out_size, const char ***out_array) (nn_uint temp_size, char** temp),
(mx_uint *out_size, const char ***out_array) (mx_uint temp_size, char** temp)
{
$1 = &temp_size;
$2 = &temp;
}
%typemap(argout) (nn_uint *out_size, const char ***out_array),
(mx_uint *out_size, const char ***out_array)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = newSVpv((*$2)[i],0);
sv_2mortal(svs[i]);
};
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *out_size, const char ***out_array2) (mx_uint temp_size, char** temp)
{
$1 = &temp_size;
$2 = &temp;
}
%typemap(argout) (mx_uint *out_size, const char ***out_array2)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *)*2);
for (i = 0; i < *$1*2 ; i++) {
svs[i] = newSVpv((*$2)[i],0);
sv_2mortal(svs[i]);
};
myav = av_make(*$1*2,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in) (FunctionHandle in)
{
int res;
void **void_ptrptr = const_cast< void** >(&$1);
res = SWIG_ConvertPtr($input,void_ptrptr, 0, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "FunctionHandle""'");
}
}
%typemap(in) (AtomicSymbolCreator in)
{
int res = SWIG_ConvertPtr($input,&$1, 0, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "AtomicSymbolCreator""'");
}
}
%typemap(in) (const void *in), (void *in)
{
STRLEN len;
$1 = (void *)SvPV($input, len);
}
%typemap(in) (const char *in)
mxnet_typemaps.i view on Meta::CPAN
%typemap(freearg) (const int *in), (int *in) {
Safefree($1);
}
%typemap(in) (NDArrayHandle* in), (SymbolHandle* in)
{
AV *tempav;
int i;
SV **tv;
int res;
int av_len;
if (!SvROK($input))
croak("Argument $argnum is not a reference.");
if (SvTYPE(SvRV($input)) != SVt_PVAV)
croak("Argument $argnum is not an array.");
tempav = (AV*)SvRV($input);
av_len = av_top_index(tempav) + 1;
if(av_len)
{
$1 = ($1_type)safemalloc(av_len*sizeof($*1_type));
for (i = 0; i < av_len; i++) {
tv = av_fetch(tempav, i, 0);
res = SWIG_ConvertPtr(*tv,SWIG_as_voidptrptr(&$1[i]), $*1_descriptor, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$*1_type""'");
}
}
}
else
{
$1 = NULL;
}
}
%typemap(freearg) (NDArrayHandle* in), (SymbolHandle* in) {
Safefree($1);
mxnet_typemaps.i view on Meta::CPAN
(KVStoreHandle *out) (KVStoreHandle temp),
(RecordIOHandle *out) (RecordIOHandle temp),
(RtcHandle *out) (RtcHandle temp),
(CachedOpHandle *out) (CachedOpHandle temp)
{
$1 = &temp;
}
%typemap(argout) (NDArrayHandle *out), (FunctionHandle* out), (SymbolHandle *out), (ExecutorHandle *out), (DataIterHandle *out),
(KVStoreHandle *out), (RecordIOHandle *out), (RtcHandle *out) (RtcHandle temp), (CachedOpHandle *out) (CachedOpHandle temp)
{
if(!result)
{
$result = SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*1_descriptor, 0); argvi++;
}
}
%typemap(in) (mx_float **out_pdata) (mx_float *temp_pdata)
{
$1 = &temp_pdata;
}
%typemap(argout) (mx_float **out_pdata)
{
if(!result)
{
AV *myav;
SV **svs;
int len;
int i = 0;
len = SvIV($input);
svs = (SV **)safemalloc(len*sizeof(SV *));
for (i = 0; i < len ; i++) {
svs[i] = newSVnv((*$1)[i]);
sv_2mortal(svs[i]);
}
myav = av_make(len,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (char const **out_array, size_t *out_size) (char * temp, size_t temp_size)
{
$2 = &temp_size;
$1 = &temp;
}
%typemap(argout) (char const **out_array, size_t *out_size)
{
if(!result)
{
$result = newSVpvn(*$1, *$2);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (size_t *out_size, char const **out_array) (size_t temp_size, char *temp)
{
$1 = &temp_size;
$2 = &temp;
}
%typemap(argout) (size_t *out_size, char const **out_array)
{
if(!result)
{
$result = newSVpvn(*$2, *$1);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *out_dim, const mx_uint **out_pdata) (mx_uint temp_dim, mx_uint *temp_pdata)
{
$1 = &temp_dim;
$2 = &temp_pdata;
}
%typemap(argout) (mx_uint *out_dim, const mx_uint **out_pdata)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = newSViv((*$2)[i]);
sv_2mortal(svs[i]);
}
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (uint64_t **out_index, uint64_t *out_size) (uint64_t *temp1, uint64_t temp2)
{
$1 = &temp1;
$2 = &temp2;
}
%typemap(argout) (uint64_t **out_index, uint64_t *out_size)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$2*sizeof(SV *));
for (i = 0; i < *$2 ; i++) {
svs[i] = newSViv((*$1)[i]);
sv_2mortal(svs[i]);
}
myav = av_make(*$2,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *out_size, FunctionHandle** out_array) (mx_uint temp_size, FunctionHandle* temp),
(mx_uint *out_size, AtomicSymbolCreator** out_array) (mx_uint temp_size, AtomicSymbolCreator* temp),
(mx_uint *out_size, DataIterCreator **out_array) (mx_uint temp_size, DataIterCreator* temp),
(mx_uint *out_size, NDArrayHandle** out_array) (mx_uint temp_size, NDArrayHandle* temp)
{
$1 = &temp_size;
$2 = &temp;
}
// many argouts needed because SWIG can't $**2_mangle
%typemap(argout) (mx_uint *out_size, AtomicSymbolCreator** out_array)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXAtomicSymbolCreator, 0);
}
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(argout) (mx_uint *out_size, FunctionHandle** out_array)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXFunction, 0);
}
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(argout) (mx_uint *out_size, DataIterCreator **out_array)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXDataIterCreator, 0);
}
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(argout) (mx_uint *out_size, NDArrayHandle** out_array)
{
if(!result)
{
AV *myav;
SV **svs;
int i = 0;
svs = (SV **)safemalloc(*$1*sizeof(SV *));
for (i = 0; i < *$1 ; i++) {
svs[i] = SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXNDArray, 0);
}
myav = av_make(*$1,svs);
Safefree(svs);
$result = newRV_noinc((SV*)myav);
sv_2mortal($result);
argvi++;
}
}
%typemap(in) (int *out_size, NDArrayHandle** out_array) (int temp, NDArrayHandle* temp_array)
{
AV *tempav;
int i;
SV **tv;
int res;
int av_len;
if (!SvROK($input))
croak("Argument $argnum is not a reference.");
if (SvTYPE(SvRV($input)) != SVt_PVAV)
croak("Argument $argnum is not an array.");
tempav = (AV*)SvRV($input);
av_len = av_top_index(tempav) + 1;
temp_array = NULL;
if(av_len)
{
temp_array = (void**)safemalloc(av_len*sizeof(void*));
for (i = 0; i < av_len; i++) {
tv = av_fetch(tempav, i, 0);
res = SWIG_ConvertPtr(*tv,SWIG_as_voidptrptr(&(temp_array[i])), 0, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "NDArray""'");
}
}
}
temp = av_len;
$1 = &temp;
$2 = &temp_array;
}
%typemap(freearg) (int *out_size, NDArrayHandle** out_array) {
if(av_top_index((AV*)SvRV(ST(3))) > -1)
mxnet_typemaps.i view on Meta::CPAN
Safefree(*$2);
}
}
%typemap(argout) (int *out_size, NDArrayHandle** out_array)
{
SV **svs;
int i = 0;
if(av_top_index((AV*)SvRV(ST(3))) == -1)
{
if(!result)
{
AV *container = newAV();
for (i = 0; i < *$1 ; i++) {
av_push(container, SvREFCNT_inc(SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXNDArray, 0)));
}
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
}
%typemap(in,numinputs=0) (const char **name,
const char **description,
mx_uint *num_args,
const char ***arg_names,
const char ***arg_type_infos,
mxnet_typemaps.i view on Meta::CPAN
}
%typemap(argout) (const char **name,
const char **description,
mx_uint *num_args,
const char ***arg_names,
const char ***arg_type_infos,
const char ***arg_descriptions
)
{
if(!result)
{
AV *container, *names, *types, *descs;
int i;
container = newAV();
names = newAV();
types = newAV();
descs = newAV();
if($1) av_push(container, newSVpv(*$1,0));
if($2) av_push(container, newSVpv(*$2,0));
if($3)
{
for (i = 0; i < *$3 ; i++) {
av_push(names, newSVpv((*$4)[i],0));
av_push(types, newSVpv((*$5)[i],0));
av_push(descs, newSVpv((*$6)[i],0));
}
}
av_push(container, newRV_noinc((SV*)names));
av_push(container, newRV_noinc((SV*)types));
av_push(container, newRV_noinc((SV*)descs));
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (const char **name,
const char **description,
mx_uint *num_args,
const char ***arg_names,
const char ***arg_type_infos,
const char ***arg_descriptions,
mxnet_typemaps.i view on Meta::CPAN
%typemap(argout) (const char **name,
const char **description,
mx_uint *num_args,
const char ***arg_names,
const char ***arg_type_infos,
const char ***arg_descriptions,
const char **key_var_num_args
)
{
if(!result)
{
AV *container, *names, *types, *descs;
int i;
container = newAV();
names = newAV();
types = newAV();
descs = newAV();
if($1) av_push(container, newSVpv(*$1,0));
if($2) av_push(container, newSVpv(*$2,0));
if($3)
mxnet_typemaps.i view on Meta::CPAN
for (i = 0; i < *$3 ; i++) {
av_push(names, newSVpv((*$4)[i],0));
av_push(types, newSVpv((*$5)[i],0));
av_push(descs, newSVpv((*$6)[i],0));
}
}
av_push(container, newRV_noinc((SV*)names));
av_push(container, newRV_noinc((SV*)types));
av_push(container, newRV_noinc((SV*)descs));
if($7) av_push(container, newSVpv(*$7,0));
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *out) (mx_uint temp), (size_t *out) (size_t temp)
{
$1 = &temp;
}
%typemap(argout) (mx_uint *out), (size_t *out)
{
if(!result)
{
$result = newSViv(*$1);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data)
(mx_uint temp1, mx_uint *temp2, mx_uint **temp3),
(mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data)
(mx_uint temp1, mx_uint *temp2, mx_uint **temp3),
(mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data)
(mx_uint temp1, mx_uint *temp2, mx_uint **temp3)
mxnet_typemaps.i view on Meta::CPAN
$1 = &temp1;
$2 = &temp2;
$3 = &temp3;
*$1 = 0;
}
%typemap(argout) (mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data),
(mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data),
(mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data)
{
if(!result && *arg15)
{
AV *container;
AV *tmp;
int i, j;
container = newAV();
for (i = 0; i < *$1 ; i++)
{
tmp = newAV();
int len = (*$2)[i];
for (j = 0; j < len ; j++)
{
av_push(tmp, newSViv((*$3)[i][j]));
}
av_push(container, newRV((SV*)tmp));
}
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint *in_type_size, const int **in_type_data)
(mx_uint temp1, int *temp2),
(mx_uint *out_type_size, const int **out_type_data)
(mx_uint temp1, int *temp2),
(mx_uint *aux_type_size, const int **aux_type_data)
(mx_uint temp1, int *temp2)
mxnet_typemaps.i view on Meta::CPAN
$1 = &temp1;
$2 = &temp2;
*$1 = 0;
}
%typemap(argout) (mx_uint *in_type_size, const int **in_type_data),
(mx_uint *out_type_size, const int **out_type_data),
(mx_uint *aux_type_size, const int **aux_type_data)
{
if(!result && *arg11)
{
AV *container;
int i;
container = newAV();
for (i = 0; i < *$1 ; i++)
{
av_push(container, newSViv((*$2)[i]));
}
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint* num_in_args,
NDArrayHandle** in_args,
NDArrayHandle** arg_grads)
(mx_uint temp1,
NDArrayHandle* temp2,
NDArrayHandle* temp3)
mxnet_typemaps.i view on Meta::CPAN
$1 = &temp1;
$2 = &temp2;
$3 = &temp3;
*$1 = 0;
}
%typemap(argout) (mx_uint* num_in_args,
NDArrayHandle** in_args,
NDArrayHandle** arg_grads)
{
if(!result)
{
AV *container1 = newAV();
AV *container2 = newAV();
for (int i = 0; i < *$1 ; i++)
{
av_push(container1, SvREFCNT_inc(SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXNDArray, 0)));
av_push(container2, (*$3)[i] ? SvREFCNT_inc(SWIG_NewPointerObj(SWIG_as_voidptr((*$3)[i]), SWIGTYPE_p_MXNDArray, 0)) : newSV(0));
}
$result = newRV_noinc((SV*)container1);
sv_2mortal($result);
argvi++;
$result = newRV_noinc((SV*)container2);
sv_2mortal($result);
argvi++;
}
}
%typemap(in,numinputs=0) (mx_uint* num_aux_states,
NDArrayHandle** aux_states)
(mx_uint temp1,
NDArrayHandle* temp2)
{
$1 = &temp1;
$2 = &temp2;
*$1 = 0;
}
%typemap(argout) (mx_uint* num_aux_states,
NDArrayHandle** aux_states)
{
if(!result)
{
AV *container = newAV();
for (int i = 0; i < *$1 ; i++)
{
av_push(container, SvREFCNT_inc(SWIG_NewPointerObj(SWIG_as_voidptr((*$2)[i]), SWIGTYPE_p_MXNDArray, 0)));
}
$result = newRV_noinc((SV*)container);
sv_2mortal($result);
argvi++;
}
}
%typemap(in) (int* shared_buffer_len,
const char** shared_buffer_name_list,
NDArrayHandle* shared_buffer_handle_list,
const char*** updated_shared_buffer_name_list,
NDArrayHandle** updated_shared_buffer_handle_list)
(int temp1,
char* temp2,
NDArrayHandle temp3,
char** temp4,
NDArrayHandle* temp5)
{
HV *temphv;
char *key;
SV *val;
I32 len;
int res;
int i = 0;
int hash_len;
$1 = &temp1;
$2 = &temp2;
$3 = &temp3;
$4 = &temp4;
$5 = &temp5;
if (!SvROK($input))
{
*$1 = -1;
mxnet_typemaps.i view on Meta::CPAN
croak("Argument $argnum is not a hash.");
temphv = (HV*)SvRV($input);
*$1 = hv_iterinit(temphv);
if(*$1)
{
$2 = (char**)safemalloc((*$1)*sizeof(char*));
$3 = (void**)safemalloc((*$1)*sizeof(void*));
while ((val = hv_iternextsv(temphv, &key, &len)))
{
$2[i] = key;
res = SWIG_ConvertPtr(val,SWIG_as_voidptrptr(&($3[i])), 0, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "NDArray""'");
}
i++;
}
}
else
{
$2 = NULL;
$3 = NULL;
}
}
mxnet_typemaps.i view on Meta::CPAN
Safefree($3);
}
%typemap(argout) (int* shared_buffer_len,
const char** shared_buffer_name_list,
NDArrayHandle* shared_buffer_handle_list,
const char*** updated_shared_buffer_name_list,
NDArrayHandle** updated_shared_buffer_handle_list)
{
if(!result)
{
HV* hash = newHV();
for(int j = 0; j < *$1; j++)
{
hv_store(hash, (*$4)[j], strlen((*$4)[j]), SvREFCNT_inc(SWIG_NewPointerObj(SWIG_as_voidptr((*$5)[j]), SWIGTYPE_p_MXNDArray, 0)), 0);
}
$result = newRV_noinc((SV*)hash);
sv_2mortal($result);
argvi++;
}
}
%typemap(in) (uint32_t x)
{
union fbits u;
u.f = SvNV($input);
$1 = u.x;
}
%typemap(out) (uint16_t)
{
$result = newSViv($1);
sv_2mortal($result);
argvi++;
}
%typemap(in) (uint16_t x)
{
$1 = SvIV($input);
}
%typemap(out) (uint32_t)
{
union fbits u;
u.x = $1;
$result = newSVnv(u.f);
sv_2mortal($result);
argvi++;
}
%typemap(in,numinputs=0) (MXKVStoreUpdater* updater)
{
$1 = KVStore_callback;
}
%typemap(in,numinputs=0) (MXKVStoreServerController* controller)
{
( run in 0.250 second using v1.01-cache-2.11-cpan-0a987023a57 )