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_r192571898
 
 

 ##########
 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:
   Last time when I try to combine them, some strange issue appeared. It breaks 
the original api. I will try a second time to combine them and send error log 
if I failed again.

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