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_r192605853
 
 

 ##########
 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:
   It's working now, send the PR...

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to