view release on metacpan or search on metacpan
Changes
Makefile.PL
MANIFEST
README
META.json
META.yml
t/AI-MXNetCAPI.t
lib/AI/MXNetCAPI.pm
mxnet.i
mxnet_typemaps.i
%module "AI::MXNetCAPI"
%rename("%(strip:[MX])s") "";
%include typemaps.i
%include mxnet_typemaps.i
%inline %{
#include <c_api.h>
// Taken as is from http://cpansearch.perl.org/src/COLEMINOR/Games-EternalLands-Binary-Float16-0.01/Float16.xs
/* This method is faster than the OpenEXR implementation (very often
* used, eg. in Ogre), with the additional benefit of rounding, inspired
* by James Tursa's half-precision code. */
static inline uint16_t _float_to_half(uint32_t x) {
uint16_t bits = (x >> 16) & 0x8000;
uint16_t m = (x >> 12) & 0x07ff;
int dev_id,
mx_uint len,
NDArrayHandle *in,
NDArrayHandle *in,
mx_uint *in,
mx_uint aux_states_len,
NDArrayHandle *in,
ExecutorHandle *out);
/*!
* \brief Generate Executor from symbol,
* This is advanced function, allow specify group2ctx map.
* The user can annotate "ctx_group" attribute to name each group.
*
* \param symbol_handle symbol handle
* \param dev_type device type of default context
* \param dev_id device id of default context
* \param num_map_keys size of group2ctx map
* \param map_keys keys of group2ctx map
* \param map_dev_types device type of group2ctx map
* \param map_dev_ids device id of group2ctx map
* \param len length
* \param in_args in args array
* \param arg_grad_store arg grads handle array
* \param grad_req_type grad req array
* \param aux_states_len length of auxiliary states
* \param aux_states auxiliary states array
* \param out output executor handle
* \return 0 when success, -1 when failure happens
*/
int MXExecutorBindX(SymbolHandle symbol_handle,
int dev_type,
int dev_id,
mx_uint num_map_keys,
const char** in,
const int* in,
const int* in,
mx_uint len,
NDArrayHandle *in,
NDArrayHandle *in,
mx_uint *in,
mx_uint aux_states_len,
NDArrayHandle *in,
ExecutorHandle *out);
/*!
* \brief Generate Executor from symbol,
* This is advanced function, allow specify group2ctx map.
* The user can annotate "ctx_group" attribute to name each group.
*
* \param symbol_handle symbol handle
* \param dev_type device type of default context
* \param dev_id device id of default context
* \param num_map_keys size of group2ctx map
* \param map_keys keys of group2ctx map
* \param map_dev_types device type of group2ctx map
* \param map_dev_ids device id of group2ctx map
* \param len length
* \param in_args in args array
* \param arg_grad_store arg grads handle array
* \param grad_req_type grad req array
* \param aux_states_len length of auxiliary states
* \param aux_states auxiliary states array
* \param shared_exec input executor handle for memory sharing
* \param out output executor handle
* \return 0 when success, -1 when failure happens
*/
int MXExecutorBindEX(SymbolHandle symbol_handle,
int dev_type,
int dev_id,
mx_uint num_map_keys,
const char** in,
const int* in,
const int* in,
mx_uint len,
NDArrayHandle *in,
NDArrayHandle *in,
mx_uint *in,
mx_uint aux_states_len,
NDArrayHandle *in,
ExecutorHandle shared_exec,
mxnet_typemaps.i view on Meta::CPAN
%typemap(in) (const char** in), (char** in)
{
AV *tempav;
I32 len;
int i;
SV **tv;
STRLEN len2;
if (!SvROK($input))
croak("Argument $argnum is not a reference.");
if (SvTYPE(SvRV($input)) != SVt_PVAV)
croak("Argument $argnum is not an array.");
mxnet_typemaps.i view on Meta::CPAN
for (i = 0; i < len; i++) {
tv = av_fetch(tempav, i, 0);
$1[i] = (char *) SvPV(*tv,len2);
}
}
else
{
$1 = NULL;
}
}
%typemap(freearg) (const char** in), (char** in) {
Safefree($1);
}
%typemap(in) (const char **keys, const char **vals), (char **keys, char **vals)
{
HV *temphv;
char *key;
SV *val;
I32 len;
STRLEN len2;
int hash_len;
int i = 0;
if (!SvROK($input))
croak("Argument $argnum is not a reference.");
mxnet_typemaps.i view on Meta::CPAN
$2[i] = SvPV(val, len2);
++i;
}
}
else
{
$1 = NULL;
$2 = NULL;
}
}
%typemap(freearg) (const char **keys, const char **vals), (char **keys, char **vals)
{
Safefree($1);
Safefree($2);
}
%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)
{
STRLEN len;
$1 = SvPV($input, len);
}
%typemap(in) (const mx_uint *in), (mx_uint *in)
{
AV *tempav;
int i;
SV **tv;
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);
mxnet_typemaps.i view on Meta::CPAN
tv = av_fetch(tempav, i, 0);
$1[i] = (mx_uint)SvIV(*tv);
}
}
else
{
$1 = NULL;
}
}
%typemap(freearg) (const mx_uint *in), (mx_uint *in) {
Safefree($1);
}
%typemap(in) (const int *in), (int *in)
{
AV *tempav;
int i;
SV **tv;
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);
mxnet_typemaps.i view on Meta::CPAN
$1[i] = (int)SvIV(*tv);
}
}
else
{
$1 = NULL;
}
}
%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.");
mxnet_typemaps.i view on Meta::CPAN
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);
}
%typemap(in) (mx_float *in)
{
AV *tempav;
int i, len;
SV **tv;
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);
len = av_top_index(tempav) + 1;
mxnet_typemaps.i view on Meta::CPAN
tv = av_fetch(tempav, i, 0);
$1[i] = (mx_float)SvNV(*tv);
}
}
else
{
$1 = NULL;
}
}
%typemap(freearg) (mx_float *in) {
Safefree($1);
}
%typemap(in,numinputs=0) (NDArrayHandle *out) (NDArrayHandle temp),
(FunctionHandle* out) (FunctionHandle temp),
(SymbolHandle *out) (SymbolHandle temp),
(ExecutorHandle *out) (ExecutorHandle temp),
(DataIterHandle *out) (ExecutorHandle temp),
(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++) {
mxnet_typemaps.i view on Meta::CPAN
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.");
mxnet_typemaps.i view on Meta::CPAN
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)
{
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,
const char ***arg_descriptions
)
(char *name_temp,
char *desc_temp,
mx_uint num_args_temp,
char **names_temp,
mxnet_typemaps.i view on Meta::CPAN
)
{
$1 = &name_temp;
$2 = &desc_temp;
$3 = &num_args_temp;
$4 = &names_temp;
$5 = &types_temp;
$6 = &descs_temp;
}
%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;
mxnet_typemaps.i view on Meta::CPAN
}
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,
const char **key_var_num_args
)
(char *name_temp,
char *desc_temp,
mx_uint num_args_temp,
mxnet_typemaps.i view on Meta::CPAN
{
$1 = &name_temp;
$2 = &desc_temp;
$3 = &num_args_temp;
$4 = &names_temp;
$5 = &types_temp;
$6 = &descs_temp;
$7 = &key_temp;
}
%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)
{
mxnet_typemaps.i view on Meta::CPAN
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)
{
$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++)
mxnet_typemaps.i view on Meta::CPAN
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)
{
$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)
{
$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)));
mxnet_typemaps.i view on Meta::CPAN
}
$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)
{
mxnet_typemaps.i view on Meta::CPAN
}
}
else
{
$2 = NULL;
$3 = NULL;
}
}
}
%typemap(freearg) (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)
{
Safefree($2);
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)
{
$1 = KVStoreServer_callback;
}
%typemap(in,numinputs=0) (ExecutorMonitorCallback callback)
{
$1 = ExecutorMonitor_callback;
}
%typemap(in) (void* callback_handle)
{
$1 = (void*)$input;
}