tlby commented on a change in pull request #9988: [Perl] Sparse feature.
URL: https://github.com/apache/incubator-mxnet/pull/9988#discussion_r172405674
 
 

 ##########
 File path: perl-package/AI-MXNetCAPI/mxnet_typemaps.i
 ##########
 @@ -112,6 +112,32 @@
     }
 }
 
+%typemap(in,numinputs=0) (const int **out_stypes) (int* temp)
+{
+    temp = NULL;
+    $1 = &temp;
+}
+
+%typemap(argout) (const int **out_stypes)
+{
+    if(av_len((AV*)SvRV(ST(3))) == -1 && !result)
+    {
+        AV *myav;
+        SV **svs;
+        int i = 0;
+        svs = (SV **)safemalloc(*arg4*sizeof(SV *));
+        for (i = 0; i < *arg4 ; i++) {
+            svs[i] = newSViv((*$1)[i]);
+            sv_2mortal(svs[i]);
+        }
+        myav = av_make(*arg4, svs);
 
 Review comment:
   I don't think you can guarantee that "arg4" will be a stable variable name 
for the other parameter in the function that uses this typemap, so this might 
blow up at some time in the future, but I'll pester you elsewhere for more 
details.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to