A tensor is a set of named dimensions defining its order
and a set of values located in the space of those dimensions:
Cell: A value located in the dimension space.
Consists of a cell address and the value at that address.
Address: A set of key-values
where each key is a dimension from the set of dimensions of the tensor,
and each value is a label (integer or string) determining the cell's location in that dimension.
The set of dimensions, cell values and cell address key-values can be of any size including zero.
A dimension can be either mapped or indexed.
Mapped dimensions use string identifiers as labels in the cell addresses (like a map),
while indexed dimensions use integers in the range [0,N> (like an array),
where N is the size of the dimension.
Tensor type spec
Contained in constant
or tensor field type.
The dimensions of a tensor and the cell type defines its type.
A tensor type contains a list of dimensions on the format:
Tensors where all dimensions are indexed can be written as numbers wrapped in square brackets in
right dimension adjacent order. If the type isn't declared already, this form requires
an explicit tensor type. Note: Dimensions should be alphabetically ordered.
Brackets must be nested according to the structure of the
type, where values in dimensions to the right are closer than
dimensions on the left. For backwards compatibility (not supported
in expressions), cell values may also be given in the same order
as a flat array.
Indexed short form examples:
A float 1d tensor in indexed form:
tensor<float>(x[3]):[3.0,5.0,7.0]
A matrix in indexed form. Since the values for the right-most dimension (y) are adjacent,
the value 3 is here assigned to the cell {x:0,y:2}:
Tensors representing binary data (indexed tensors with int8
cell value type) may be represented using a hexadecimal representation,
similar to the corresponding
JSON tensor feed format.
If the tensor type is declared as
tensor<int8>(x[2],y[3]) input could be just
0B22038405FF
which would be equivalent to:
[[11,34,3], [-124,5,-1]]
Mapped short form
Tensors with a single mapped dimension can be written by specifying
just the label in that implicit dimension instead of a full address map.
This form requires a type to be declared or explicitly specified.
Map short form example:
tensor<float>(key{}):{key1:1.0,key2:2.0}
Mixed short form
Tensors with a single mapped dimension and one or more indexed dimensions
can be written by specifying the mapped dimension in the map short form
and the values of each dense subspace on the indexed short form.
This form requires a type to be known (declared) or specified.
Tensors with a multiple mapped dimensions may use an extended
variant of the mixed short form, where labels are nested.
Again note that the type should be declared with dimensions
in alphabetic order, so the nesting will follow a consistent
ordering.
Tensor functions are listed in the expressions documentation.
Tensor rank features
The following rank features can be used to refer to or create tensors in ranking expressions.
The tensors can come from the document, the query or a constant in the application package: