Class Tensor
java.lang.Object
com.codename1.ai.inference.Tensor
Immutable named tensor passed to or returned from an inference session.
The primitive data array and shape are copied on construction and by their
public getters, so callers can safely reuse or mutate their source arrays.
-
Constructor Summary
ConstructorsConstructorDescriptionTensor(String name, TensorType type, int[] shape, Object data) Creates a tensor and validates that its type, shape, and primitive array agree. -
Method Summary
-
Constructor Details
-
Tensor
Creates a tensor and validates that its type, shape, and primitive array agree. Dynamic dimensions may be negative and skip the element-count check; fixed shapes are overflow-checked.- Parameters:
name- model tensor name, ornullfor positional matchingtype- element typeshape- tensor dimensions; an empty shape represents a scalardata- matching primitive array
-
-
Method Details
-
floats
-
ints
-
bytes
Creates a byte-array tensor for UINT8, INT8, or BOOL data.- Returns:
- a tensor with defensively copied data
-
getName
- Returns:
- the model tensor name, or
nullfor an unnamed tensor
-
getType
- Returns:
- the element type
-
getShape
public int[] getShape()- Returns:
- a defensive copy of tensor dimensions
-
getData
- Returns:
- a defensive copy of the matching primitive data array
-