lanking520 commented on a change in pull request #11126: [MXNET-386] ongoing 
maintenance on NDArray
URL: https://github.com/apache/incubator-mxnet/pull/11126#discussion_r192967726
 
 

 ##########
 File path: scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
 ##########
 @@ -105,6 +105,57 @@ object NDArray {
     })
   }
 
+  /**
+    * Used by NDArrayMacro for New Scala NDArray API.
+    * Invoke this function by passing in parameters.
+    * Parameters
+    * ----------
+    * @param kwargs Key-value arguments of input scalars
+    * @return The result NDArrays of result of computation.
+    */
+  private[mxnet] def genericNewAPINDArrayFunctionInvoke(
+    funcName: String, kwargs: Map[String, Any] = null) : NDArrayFuncReturn = {
+    val function = functions(funcName)
+    val ndArgs = ArrayBuffer.empty[NDArray]
+    val updatedKwargs: Map[String, String] =
+      Option(kwargs).getOrElse(Map.empty[String, String]).filter{ case (key, 
value) =>
+        !value.isInstanceOf[NDArray] && !value.isInstanceOf[NDArrayFuncReturn]
+      } .map { case (k, v) => k -> v.toString }
+
+    Option(kwargs).getOrElse(Map.empty[String, String]).filter{ case (key, 
value) =>
+          value.isInstanceOf[NDArray] || value.isInstanceOf[NDArrayFuncReturn]
+        } .filter{ case (key, value) => key != "out"}.foreach{
+      case (key, value) => value match {
+        case nd : NDArray =>
+          ndArgs.append(nd.asInstanceOf[NDArray])
+        case arrFunRet: NDArrayFuncReturn =>
+          
arrFunRet.asInstanceOf[NDArrayFuncReturn].arr.foreach(ndArgs.append(_))
+      }
+    }
 
 Review comment:
   I see your idea, two ways come in my mind. Change Macros design using Ndargs 
to store all NDArray element to match the order and store others into kv store. 
Second way I think we may need to find another C function to handle this method 
to ensure the correct order

----------------------------------------------------------------
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