You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/02 18:42:46 UTC

[GitHub] piyushghai commented on a change in pull request #13678: [MXNET-1260] [WIP] Float64 support in NDArray in Scala

piyushghai commented on a change in pull request #13678: [MXNET-1260] [WIP] Float64 support in NDArray in Scala
URL: https://github.com/apache/incubator-mxnet/pull/13678#discussion_r244817126
 
 

 ##########
 File path: scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
 ##########
 @@ -262,16 +263,32 @@ object NDArray extends NDArrayBase {
     arr
   }
 
+  def full(shape: Shape, value: Double, ctx: Context): NDArray = {
+    val arr = empty(shape, ctx, DType.Float64)
+    arr.set(value)
+    arr
+  }
+
+  /**
+    * Create a new NDArray filled with given value, with specified shape.
+    * @param shape shape of the NDArray.
+    * @param value value to be filled with
+    */
+  def full(shape: Shape, value: Double): NDArray = {
+    full(shape, value, null)
+  }
+
+
   // Perform power operator
   def power(lhs: NDArray, rhs: NDArray): NDArray = {
     NDArray.genericNDArrayFunctionInvoke("_power", Seq(lhs, rhs))
   }
 
-  def power(lhs: NDArray, rhs: Float): NDArray = {
+  def power(lhs: NDArray, rhs: MX_PRIMITIVE_TYPE): NDArray = {
 
 Review comment:
   The input from the user perspective will be either a ```Double``` or a ```Float```. 
   The users in the scala docs would see a link to MX_PRIMITIVE_TYPE for support, which defines the primitives as Float or a Double.
   
   If an incompatible datatype is passed, the IDE/compiler would throw an error because it would not be able to resolve the appropriate implicit conversion for MX_PRIMITIVE_TYPE.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services