nswamy commented on a change in pull request #12536: [MXNET-913][WIP] Java API 
--- Scala NDArray Improvement
URL: https://github.com/apache/incubator-mxnet/pull/12536#discussion_r218540119
 
 

 ##########
 File path: scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
 ##########
 @@ -936,11 +996,51 @@ class NDArray private[mxnet](private[mxnet] val handle: 
NDArrayHandle,
     this
   }
 
+  /* Java Compatibility Functions
+     Function name with underscore means
+     it is going to do the operator as well as
+     update itself such as +=
+   */
+  def add(other : NDArray) : NDArray = this + other
+  def add(other : Float) : NDArray = this + other
+  def _add(other : NDArray) : NDArray = this += other
+  def _add(other : Float) : NDArray = this += other
+  def subtract(other : NDArray) : NDArray = this - other
+  def subtract(other : Float) : NDArray = this - other
+  def _subtract(other : NDArray) : NDArray = this -= other
+  def _subtract(other : Float) : NDArray = this -= other
+  def multiply(other : NDArray) : NDArray = this * other
+  def multiply(other : Float) : NDArray = this * other
+  def _multiply(other : NDArray) : NDArray = this *= other
+  def _multiply(other : Float) : NDArray = this *= other
+  def div(other : NDArray) : NDArray = this / other
+  def div(other : Float) : NDArray = this / other
+  def _div(other : NDArray) : NDArray = this /= other
+  def _div(other : Float) : NDArray = this /= other
+  def pow(other : NDArray) : NDArray = this ** other
+  def pow(other : Float) : NDArray = this ** other
+  def _pow(other : NDArray) : NDArray = this **= other
+  def _pow(other : Float) : NDArray = this **= other
+  def mod(other : NDArray) : NDArray = this % other
+  def mod(other : Float) : NDArray = this % other
+  def _mod(other : NDArray) : NDArray = this %= other
+  def _mod(other : Float) : NDArray = this %= other
+  def greater(other : NDArray) : NDArray = this > other
+  def greater(other : Float) : NDArray = this > other
+  def greaterEqual(other : NDArray) : NDArray = this >= other
+  def greaterEqual(other : Float) : NDArray = this >= other
+  def lesser(other : NDArray) : NDArray = this < other
+  def lesser(other : Float) : NDArray = this < other
+  def lesserEqual(other : NDArray) : NDArray = this <= other
+  def lesserEqual(other : Float) : NDArray = this <= other
+
   /**
    * Return a copied flat java array of current array (row-major).
    * @return  A copy of array content.
    */
   def toArray: Array[Float] = {
+    require(shape.toArray.product < 1000000,
 
 Review comment:
   we shouldn't add arbitrary limitations.

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