Skip to content

Commit c5b08e2

Browse files
committed
Add Scaladoc for methods where data index order matters
1 parent 2c7f632 commit c5b08e2

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Tensors/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ libraryDependencies += "com.github.ghik" %% "silencer-lib" % "0.6"
2424
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" % Test
2525

2626
fork in Test := true
27+
28+
enablePlugins(Example)

Tensors/src/main/scala/com/thoughtworks/compute/Tensors.scala

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,18 @@ trait Tensors extends OpenCL {
768768
} with InlineTensor
769769
}
770770

771-
/**
771+
/** Returns a new [[Tensor]] of new shape and the same data of this [[Tensor]].
772+
*
773+
* @note The data in this [[Tensor]] is considered as row-major order when [[reshape]].
774+
*
775+
* You can create another column-major version reshape by reversing the shape:
776+
*
777+
* {{{
778+
* def columnMajorReshape[Category <: Tensors](tensor: Category#Tensor, newShape: Array[Int]): Category#Tensor = {
779+
* tensor.permute(tensor.shape.indices.reverse.toArray).reshape(newShape.reverse).permute(newShape.indices.reverse.toArray)
780+
* }
781+
* }}}
782+
*
772783
* @group delayed
773784
*/
774785
def reshape(newShape: Array[Int]): NonInlineTensor = {
@@ -996,7 +1007,9 @@ trait Tensors extends OpenCL {
9961007

9971008
private[compute] def doBuffer: Do[PendingBuffer[closure.JvmValue]]
9981009

999-
/**
1010+
/** Returns a RAII managed asynchronous task to read this [[Tensor]] into an off-heap memory,
1011+
* which is linearized in row-majoy order.
1012+
*
10001013
* @group slow
10011014
*/
10021015
def flatBuffer: Do[FloatBuffer] = {
@@ -1011,7 +1024,9 @@ trait Tensors extends OpenCL {
10111024
}
10121025
}
10131026

1014-
/**
1027+
/** Returns an asynchronous task to read this [[Tensor]] into a [[scala.Array]],
1028+
* which is linearized in row-majoy order.
1029+
*
10151030
* @group slow
10161031
*/
10171032
def flatArray: Future[Array[closure.JvmValue]] = {

0 commit comments

Comments
 (0)