An intermediate expression of tensor that can be composed into a more complex expression.
An intermediate expression of tensor that can be composed into a more complex expression.
A Tensor that is associated with a non-inline kernel program (i.e.
There are three kinds of Tensor.
@inline def
,
which can be merged into a larger kernel
and will be recalculated whenever a slow action is performed.@noinline def
,
which is never merged into a larger kernel
and will be recalculated whenever a slow action is performed.lazy val
,
which has an associated data buffer on the compute device
and will be calculated only once even when slow actions are performed more than once.Returns an uninitialized buffer of Element
on device.
Returns an uninitialized buffer of Element
on device.
Returns a buffer of Element
on device whose content is copied from hostBuffer
.
Returns a buffer of Element
on device whose content is copied from hostBuffer
.
Creates single kernel from this Program.
Creates single kernel from this Program.
com.thoughtworks.compute.OpenCL.Exceptions.InvalidValue
if the this Program has more than one kernel.
Contains N-dimensional array types on CPU.
You may want to import Tensor, which is the base type of N-dimensional arrays:
import com.thoughtworks.compute.cpu.Tensor
A Tensor of scalar value can be broadcast to N-dimensional arrays.
Multiple
Tensor
s of the sameshape
can be merged into a largerTensor
via theTensor.join
function. Given aSeq
of three 2x2Tensor
s,when
join
ing them,val merged: Tensor = Tensor.join(mySubtensors)
then the result should be a 2x2x3
Tensor
.A
Tensor
can besplit
into smallTensor
s on the direction of a specific dimension. Given a 3D tensor whoseshape
is 2x3x4,when
split
it at the dimension #0,then the result should be a
Seq
of two 3x4 tensors.When
split
it at the dimension #1,then the result should be a
Seq
of three 2x4 tensors.In Compute.scala, an N-dimensional array is typed as Tensor, which can be created from scala.collection.Seq or scala.Array.