Class JTensor
java.lang.Object
smile.tensor.AbstractTensor
smile.tensor.JTensor
- All Implemented Interfaces:
Tensor
A simple on-heap Tensor implementation.
-
Method Summary
Modifier and TypeMethodDescriptionget
(int... index) Returns a portion of tensor given the index.boolean
getBoolean
(int... index) Returns the boolean value of element at given index.byte
getByte
(int... index) Returns the byte value of element at given index.double
getDouble
(int... index) Returns the double value of element at given index.float
getFloat
(int... index) Returns the float value of element at given index.int
getInt
(int... index) Returns the int value of element at given index.long
getLong
(int... index) Returns the long value of element at given index.short
getShort
(int... index) Returns the short value of element at given index.memory()
Returns the memory segment of underlying data.reshape
(int... shape) Returns a tensor with the same data and number of elements but with the specified shape.Returns the element data type.set
(boolean value, int... index) Updates an element in place.set
(byte value, int... index) Updates an element in place.set
(double value, int... index) Updates an element in place.set
(float value, int... index) Updates an element in place.set
(int value, int... index) Updates an element in place.set
(long value, int... index) Updates an element in place.set
(short value, int... index) Updates an element in place.Updates a sub-tensor in place.toString()
Returns the layout that models values of basic data types.Methods inherited from class AbstractTensor
dim, shape, size
-
Method Details
-
valueLayout
Returns the layout that models values of basic data types.- Returns:
- the layout that models values of basic data types.
-
memory
Returns the memory segment of underlying data.- Returns:
- the memory segment.
-
toString
-
scalarType
Description copied from interface:Tensor
Returns the element data type.- Returns:
- the element data type.
-
reshape
Description copied from interface:Tensor
Returns a tensor with the same data and number of elements but with the specified shape. This method returns a view if shape is compatible with the current shape.- Parameters:
shape
- the new shape of tensor.- Returns:
- the tensor with the specified shape.
-
set
-
get
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
set
Updates an element in place.- Parameters:
value
- the new element value.index
- the element index.- Returns:
- this tensor.
-
getBoolean
public boolean getBoolean(int... index) Returns the boolean value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getByte
public byte getByte(int... index) Returns the byte value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getShort
public short getShort(int... index) Returns the short value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getInt
public int getInt(int... index) Returns the int value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getLong
public long getLong(int... index) Returns the long value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getFloat
public float getFloat(int... index) Returns the float value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-
getDouble
public double getDouble(int... index) Returns the double value of element at given index.- Parameters:
index
- the index along the dimensions.- Returns:
- the element value.
-