piyushghai commented on a change in pull request #12690: [MXNET-1000] get 
Ndarray real value and form it from a NDArray
URL: https://github.com/apache/incubator-mxnet/pull/12690#discussion_r250422997
 
 

 ##########
 File path: scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
 ##########
 @@ -763,6 +823,56 @@ class NDArray private[mxnet](private[mxnet] val handle: 
NDArrayHandle,
     checkCall(_LIB.mxFloat64NDArraySyncCopyFromCPU(handle, source, 
source.length))
   }
 
+  /**
+    * Visualize the internal structure of NDArray
+    * @return String that show the structure
+    */
+  override def toString: String = {
+    val abstractND = buildStringHelper(this, this.shape.length)
+    val otherInfo = s"<NDArray ${this.shape} ${this.context} ${this.dtype}>"
+    s"$abstractND\n$otherInfo"
+  }
+
+  /**
+    * Helper function to create formatted NDArray output
+    * The NDArray will be represented in a reduced version if too large
+    * @param nd NDArray as the input
+    * @param totalSpace totalSpace of the lowest dimension
+    * @return String format of NDArray
+    */
+  private def buildStringHelper(nd : NDArray, totalSpace : Int) : String = {
+    var result = ""
+    val THRESHOLD = 10      // longest NDArray[NDArray[...]] to show in full
 
 Review comment:
   Can this be MAX_SIZE_THRESHOLD ?

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