Tensors & Vectors
Tensor and vector math, including similarity measures and norms.
Scalar Functions
| Function | Summary |
|---|---|
spql.tensor.cosine_similarity | Compute the row-wise cosine similarity between two vectors. |
spql.tensor.inner_product | Compute the row-wise inner product between two vectors. |
spql.tensor.l2_norm | Compute the row-wise Euclidean norm of a vector. |
spql.tensor.resize | Resize the spatial dimensions of a Tensor. |
spql.vector.dequantize | Decode a TurboQuant value into a vector. |
spql.vector.rabitq | Quantize a vector into the RaBitQ representation. |
spql.vector.turboquant | Encode a vector into the lossy TurboQuant representation. |
spql.tensor.cosine_similarity
Compute the row-wise cosine similarity between two vectors.
- Kind:
scalar function - Volatility:
immutable
spql.tensor.cosine_similarity(lhs, rhs) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
lhs | yes | vortex.tensor.vector | Left tensor-like value. |
rhs | yes | vortex.tensor.vector | Right tensor-like value. |
Returns
A float scalar value.
spql.tensor.cosine_similarity(lhs, rhs) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Compute the row-wise cosine similarity between two static tensors.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
lhs | yes | vortex.tensor.fixed_shape_tensor | Left tensor-like value. |
rhs | yes | vortex.tensor.fixed_shape_tensor | Right tensor-like value. |
Returns
A float scalar value.
spql.tensor.inner_product
Compute the row-wise inner product between two vectors.
- Kind:
scalar function - Volatility:
immutable
spql.tensor.inner_product(lhs, rhs) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
lhs | yes | vortex.tensor.vector | Left tensor-like value. |
rhs | yes | vortex.tensor.vector | Right tensor-like value. |
Returns
A float scalar value.
spql.tensor.inner_product(lhs, rhs) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Compute the row-wise Frobenius inner product between two static tensors.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
lhs | yes | vortex.tensor.fixed_shape_tensor | Left tensor-like value. |
rhs | yes | vortex.tensor.fixed_shape_tensor | Right tensor-like value. |
Returns
A float scalar value.
spql.tensor.l2_norm
Compute the row-wise Euclidean norm of a vector.
- Kind:
scalar function - Volatility:
immutable
spql.tensor.l2_norm(value) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
value | yes | vortex.tensor.vector | Tensor-like value. |
Returns
A float scalar value.
spql.tensor.l2_norm(value) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Compute the row-wise Euclidean norm of a static tensor.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
value | yes | vortex.tensor.fixed_shape_tensor | Tensor-like value. |
Returns
A float scalar value.
spql.tensor.resize
Resize the spatial dimensions of a Tensor.
- Kind:
scalar function - Volatility:
immutable
spql.tensor.resize(tensor, 1, 1, 'method'?) -> type(tensor)Same type and nullability as tensor. Literal arguments can refine the result type, including its units, shape or element type.
Accepts contiguous u8 or f32 variable Tensor rows in height:width, height:width:channel, or channel:height:width layout. Uses half-pixel coordinates and preserves element type, nullability, permutation, and non-spatial dimensions. Execution defaults to Host; explicit MPS execution is native for direct Tensor fields and exact tensor.resize(image.to_tensor(...)) regions. In a CUDA-enabled build with NPP 13 or later runtime libraries, explicit CUDA execution is native for direct Tensor fields and supports nearest for u8 or f32, bilinear for f32, HWC with 1, 3, or 4 channels, and CHW with any channel count. Bilinear is the default method, so u8 CUDA calls must select nearest explicitly. Other computed Tensor inputs are rejected rather than staged through Host.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
tensor | yes | spql.Tensor | Tensor with named height and width dimensions. |
width | yes | i32 | Nonzero output width. |
height | yes | i32 | Nonzero output height. |
method | no | utf8 | Interpolation method: nearest or bilinear. |
Returns
A Tensor with the requested spatial dimensions.
spql.vector.dequantize
Decode a TurboQuant value into a vector.
- Kind:
scalar function - Volatility:
immutable
spql.vector.dequantize(value) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
value | yes | vortex.turboquant | TurboQuant value to decode. |
Returns
A decoded vector value.
spql.vector.rabitq
Quantize a vector into the RaBitQ representation.
- Kind:
scalar function - Volatility:
immutable
spql.vector.rabitq(value) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
value | yes | vortex.tensor.vector | Floating vector to quantize. |
Returns
A spql.RaBitQ value.
spql.vector.turboquant
Encode a vector into the lossy TurboQuant representation.
- Kind:
scalar function - Volatility:
immutable
spql.vector.turboquant(value) -> inferredThe result type and nullability are inferred from the argument types when the call is bound.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
value | yes | vortex.tensor.vector | Vector value to encode. |
Returns
A TurboQuant extension value.