Tensor¶
Tensors are multi-dimension, dense arrays with more than 2 dimensions. Currently 3 - 5 dimension Tensors are supported.
Like Array and Matrix, Tensors can only be used in host code. In accelerator code, use DRAM (for off-chip) or SRAM (on-chip) memories for multi-dimensional array support.
Constructors
Spatial includes syntax for constructing Tensor instances from indexed functions.
The following returns a 16 x 32 x 8 Tensor3, with elements defined by func(i,j,k):
(0::16, 0::32, 0::8){(i,j,k) => func(i,j,k) }
A Tensor4 can be constructed in a similar way:
(0::4, 0::16, 0::8, 0::32){(a,b,c,d) => func(a,b,c,d) }
As can a Tensor5:
(0::2, 0::4, 0::5, 0::3, 0::32){(a,b,c,d,e) => func(a,b,c,d,e) }
More general Range forms can also be used, including strided (e.g. 0::2::8) and offset (e.g. 32::64). Iterators (e.g. i, j, k in the above examples) will iterate over all values in their respective ranges.
Static methods
object Tensor3 | |
---|---|
object Tensor4 | |
---|---|
object Tensor5 | |
---|---|
Infix methods
class Tensor3[T] | |
---|---|
def dim0: Index
Returns the first dimension of this Tensor3.
|
|
def dim1: Index
Returns the second dimension of this Tensor3.
|
|
def dim2: Index
Returns the third dimension of this Tensor3.
|
|
def reduce(rfunc: (T,T) => T): T
Reduces the elements in this Tensor3 into a single element using associative function rfunc.
|
class Tensor4[T] | |
---|---|
def dim0: Index
Returns the first dimension of this Tensor4.
|
|
def dim1: Index
Returns the second dimension of this Tensor4.
|
|
def dim2: Index
Returns the third dimension of this Tensor4.
|
|
def dim3: Index
Returns the fourth dimension of this Tensor4.
|
|
def reduce(rfunc: (T,T) => T): T
Reduces the elements in this Tensor4 into a single element using associative function rfunc.
|
class Tensor5[T] | |
---|---|
def dim0: Index
Returns the first dimension of this Tensor5.
|
|
def dim1: Index
Returns the second dimension of this Tensor5.
|
|
def dim2: Index
Returns the third dimension of this Tensor5.
|
|
def dim3: Index
Returns the fourth dimension of this Tensor5.
|
|
def dim4: Index
Returns the fifth dimension of this Tensor5.
|
|
def reduce(rfunc: (T,T) => T): T
Reduces the elements in this Tensor5 into a single element using associative function rfunc.
|