pub struct VectorBase<const NBITS: usize, Repr, Ptr, T, Perm = Dense>{ /* private fields */ }Expand description
A wrapper for BitSliceBase that provides the addition of arbitrary metadata.
§Examples
The VectorBase has several named variants that are commonly used:
Vector: An owning, independently allocatedVectorBase.VectorMut: A mutable, reference-like type to aVectorBase.VectorRef: A const, reference-like type to aVectorBase.
use diskann_quantization::{
meta::{Vector, VectorMut, VectorRef},
bits::Unsigned,
};
use diskann_utils::{Reborrow, ReborrowMut};
#[derive(Debug, Default, Clone, Copy, PartialEq)]
struct Metadata {
value: f32,
}
// Create a new heap-allocated Vector for 4-bit compressions capable of
// holding 3 elements.
//
// In this case, the associated m
let mut v = Vector::<4, Unsigned, Metadata>::new_boxed(3);
// We can inspect the underlying bitslice.
let bitslice = v.vector();
assert_eq!(bitslice.get(0).unwrap(), 0);
assert_eq!(bitslice.get(1).unwrap(), 0);
assert_eq!(v.meta(), Metadata::default(), "expected default metadata value");
// If we want, we can mutably borrow the bitslice and mutate its components.
let mut bitslice = v.vector_mut();
bitslice.set(0, 1).unwrap();
bitslice.set(1, 2).unwrap();
bitslice.set(2, 3).unwrap();
assert!(bitslice.set(3, 4).is_err(), "out-of-bounds access");
// Get the underlying pointer for comparison.
let ptr = bitslice.as_ptr();
// Vectors can be converted to a generalized reference.
let mut v_ref = v.reborrow_mut();
// The generalized reference preserves the underlying pointer.
assert_eq!(v_ref.vector().as_ptr(), ptr);
let mut bitslice = v_ref.vector_mut();
bitslice.set(0, 10).unwrap();
// Setting the underlying compensation will be visible in the original allocation.
v_ref.set_meta(Metadata { value: 10.5 });
// Check that the changes are visible.
assert_eq!(v.meta().value, 10.5);
assert_eq!(v.vector().get(0).unwrap(), 10);
// Finally, the immutable ref also maintains pointer compatibility.
let v_ref = v.reborrow();
assert_eq!(v_ref.vector().as_ptr(), ptr);§Constructing a VectorMut From Components
The following example shows how to assemble a VectorMut from raw memory.
use diskann_quantization::{bits::{Unsigned, MutBitSlice}, meta::VectorMut};
// Start with 2 bytes of memory. We will impose a 4-bit scalar quantization on top of
// these 2 bytes.
let mut data = vec![0u8; 2];
let mut metadata: f32 = 0.0;
{
// First, we need to construct a bit-slice over the data.
// This will check that it is sized properly for 4, 4-bit values.
let mut slice = MutBitSlice::<4, Unsigned>::new(data.as_mut_slice(), 4).unwrap();
// Next, we construct the `VectorMut`.
let mut v = VectorMut::new(slice, &mut metadata);
// Through `v`, we can set all the components in `slice` and the compensation.
v.set_meta(123.4);
let mut from_v = v.vector_mut();
from_v.set(0, 1).unwrap();
from_v.set(1, 2).unwrap();
from_v.set(2, 3).unwrap();
from_v.set(3, 4).unwrap();
}
// Now we can check that the changes made internally are visible.
assert_eq!(&data, &[0x21, 0x43]);
assert_eq!(metadata, 123.4);§Canonical Layout
When the metadata type T is
bytemuck::Pod, VectorRef
and VectorMut support layout canonicalization, where a raw slice can be used as the
backing store for such vectors, enabling inline storage.
There are two supported schems for the canonical layout, depending on whether the metadata is located at the beginning of the slice or at the end of the slice.
If the metadata is at the front, then the layout consists of a slice &[u8] where the
first std::mem::size_of::<T>() bytes are the metadata and the remainder compose the
BitSlice codes.
If the metadata is at the back, , then the layout consists of a slice &[u8] where the
last std::mem::size_of::<T>() bytes are the metadata and the prefix is the
BitSlice codes.
The canonical layout needs the following properties:
T: bytemuck::Pod: For safely storing and retrieving.- The length for a vector with
Ndimensions must be equal to the value returne fromVector::canonical_bytes.
The following functions can be used to construct VectorBases from raw slices:
VectorRef::from_canonical_frontVectorRef::from_canonical_backVectorMut::from_canonical_front_mutVectorMut::from_canonical_back_mut
An example is shown below.
use diskann_quantization::{bits, meta::{Vector, VectorRef, VectorMut}};
type CVRef<'a, const NBITS: usize> = VectorRef<'a, NBITS, bits::Unsigned, f32>;
type MutCV<'a, const NBITS: usize> = VectorMut<'a, NBITS, bits::Unsigned, f32>;
let dim = 3;
// Since we don't control the alignment of the returned pointer, we need to oversize it.
let bytes = CVRef::<4>::canonical_bytes(dim);
let mut data: Box<[u8]> = (0..bytes).map(|_| u8::default()).collect();
// Construct a mutable compensated vector over the slice.
let mut mut_cv = MutCV::<4>::from_canonical_front_mut(&mut data, dim).unwrap();
mut_cv.set_meta(1.0);
let mut v = mut_cv.vector_mut();
v.set(0, 1).unwrap();
v.set(1, 2).unwrap();
v.set(2, 3).unwrap();
// Reconstruct a constant CompensatedVector.
let cv = CVRef::<4>::from_canonical_front(&data, dim).unwrap();
assert_eq!(cv.meta(), 1.0);
let v = cv.vector();
assert_eq!(v.get(0).unwrap(), 1);
assert_eq!(v.get(1).unwrap(), 2);
assert_eq!(v.get(2).unwrap(), 3);Implementations§
Source§impl<const NBITS: usize, Repr, Ptr, T, Perm> VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> VectorBase<NBITS, Repr, Ptr, T, Perm>
Sourcepub fn slice_bytes(count: usize) -> usize
pub fn slice_bytes(count: usize) -> usize
Return the number of bytes required for the underlying BitSlice.
Sourcepub fn canonical_bytes(count: usize) -> usizewhere
T: CopyRef,
T::Target: Pod,
pub fn canonical_bytes(count: usize) -> usizewhere
T: CopyRef,
T::Target: Pod,
Return the number of bytes required for the canonical representation of a
Vector.
See: VectorRef::from_canonical_back, VectorMut::from_canonical_back_mut.
Sourcepub fn new<M>(bits: BitSliceBase<NBITS, Repr, Ptr, Perm>, meta: M) -> Selfwhere
M: Into<T>,
pub fn new<M>(bits: BitSliceBase<NBITS, Repr, Ptr, Perm>, meta: M) -> Selfwhere
M: Into<T>,
Construct a new VectorBase over the bit-slice.
Sourcepub fn vector_mut(&mut self) -> MutBitSlice<'_, NBITS, Repr, Perm>where
Ptr: AsMutPtr,
pub fn vector_mut(&mut self) -> MutBitSlice<'_, NBITS, Repr, Perm>where
Ptr: AsMutPtr,
Mutably borrow the integer compressed vector.
Source§impl<const NBITS: usize, Repr, Perm, T> VectorBase<NBITS, Repr, Poly<[u8], GlobalAllocator>, Owned<T>, Perm>
impl<const NBITS: usize, Repr, Perm, T> VectorBase<NBITS, Repr, Poly<[u8], GlobalAllocator>, Owned<T>, Perm>
Source§impl<const NBITS: usize, Repr, Perm, T, A> VectorBase<NBITS, Repr, Poly<[u8], A>, Owned<T>, Perm>
impl<const NBITS: usize, Repr, Perm, T, A> VectorBase<NBITS, Repr, Poly<[u8], A>, Owned<T>, Perm>
Sourcepub fn new_in(len: usize, allocator: A) -> Result<Self, AllocatorError>
pub fn new_in(len: usize, allocator: A) -> Result<Self, AllocatorError>
Create a new owned VectorBase with its metadata default initialized.
Source§impl<'a, const NBITS: usize, Repr, T, Perm> VectorBase<NBITS, Repr, SlicePtr<'a, u8>, Ref<'a, T>, Perm>
impl<'a, const NBITS: usize, Repr, T, Perm> VectorBase<NBITS, Repr, SlicePtr<'a, u8>, Ref<'a, T>, Perm>
Sourcepub fn from_canonical_front(
data: &'a [u8],
dim: usize,
) -> Result<Self, NotCanonical>
pub fn from_canonical_front( data: &'a [u8], dim: usize, ) -> Result<Self, NotCanonical>
Construct an instance of Self viewing data as the canonical layout for a vector.
The canonical layout is as follows:
std::mem::size_of::<T>()for the metadata coefficient.Self::slice_bytes(dim)for the underlying bit-slice.
Returns an error if data.len() != Self::canonical_bytes`.
Sourcepub fn from_canonical_back(
data: &'a [u8],
dim: usize,
) -> Result<Self, NotCanonical>
pub fn from_canonical_back( data: &'a [u8], dim: usize, ) -> Result<Self, NotCanonical>
Construct an instance of Self viewing data as the canonical layout for a vector.
The back canonical layout is as follows:
Self::slice_bytes(dim)for the underlying bit-slice.std::mem::size_of::<T>()for the metadata coefficient.
Returns an error if data.len() != Self::canonical_bytes`.
Sourcepub unsafe fn from_canonical_unchecked(data: &'a [u8], dim: usize) -> Self
pub unsafe fn from_canonical_unchecked(data: &'a [u8], dim: usize) -> Self
Construct a VectorRef from the raw data.
§Safety
data.len()must be equal toSelf::canonical_bytes(dim).
This invariant is checked in debug builds and will panic if not satisfied.
Sourcepub unsafe fn from_canonical_back_unchecked(data: &'a [u8], dim: usize) -> Self
pub unsafe fn from_canonical_back_unchecked(data: &'a [u8], dim: usize) -> Self
Construct a VectorRef from the raw data.
§Safety
data.len()must be equal toSelf::canonical_bytes(dim).
This invariant is checked in debug builds and will panic if not satisfied.
Source§impl<'a, const NBITS: usize, Repr, T, Perm> VectorBase<NBITS, Repr, MutSlicePtr<'a, u8>, Mut<'a, T>, Perm>
impl<'a, const NBITS: usize, Repr, T, Perm> VectorBase<NBITS, Repr, MutSlicePtr<'a, u8>, Mut<'a, T>, Perm>
Sourcepub fn from_canonical_front_mut(
data: &'a mut [u8],
dim: usize,
) -> Result<Self, NotCanonical>
pub fn from_canonical_front_mut( data: &'a mut [u8], dim: usize, ) -> Result<Self, NotCanonical>
Construct an instance of Self viewing data as the canonical layout for a vector.
The canonical layout is as follows:
std::mem::size_of::<T>()for the metadata coefficient.Self::slice_bytes(dim)for the underlying bit-slice.
Returns an error if data.len() != Self::canonical_bytes`.
Sourcepub unsafe fn from_canonical_front_mut_unchecked(
data: &'a mut [u8],
dim: usize,
) -> Self
pub unsafe fn from_canonical_front_mut_unchecked( data: &'a mut [u8], dim: usize, ) -> Self
Construct a VectorMut from the raw data.
§Safety
data.len()must be equal toSelf::canonical_bytes(dim).
This invariant is checked in debug builds and will panic if not satisfied.
Sourcepub fn from_canonical_back_mut(
data: &'a mut [u8],
dim: usize,
) -> Result<Self, NotCanonical>
pub fn from_canonical_back_mut( data: &'a mut [u8], dim: usize, ) -> Result<Self, NotCanonical>
Construct an instance of Self viewing data as the canonical layout for a vector.
The back canonical layout is as follows:
Self::slice_bytes(dim)for the underlying bit-slice.std::mem::size_of::<T>()for the metadata coefficient.
Returns an error if data.len() != Self::canonical_bytes`.
Source§impl<const NBITS: usize> VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>where
Unsigned: Representation<NBITS>,
impl<const NBITS: usize> VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>where
Unsigned: Representation<NBITS>,
Sourcepub fn decompress_into(&self, dst: &mut [f32]) -> Result<(), DecompressError>
pub fn decompress_into(&self, dst: &mut [f32]) -> Result<(), DecompressError>
Decompresses a MinMax quantized vector back into its original floating-point representation.
This method reconstructs the original vector values using the stored quantization parameters
and the MinMax dequantization formula: x = x' * a + b and stores the result in dst
§Arguments
dst- A mutable slice off32values where the decompressed data will be written. Must have the same length as the compressed vector.
§Returns
Ok(())- On successful decompressionErr(DecompressError::LengthMismatch(src_len, dst_len))- If the destination slice length doesn’t match the compressed vector length
Trait Implementations§
Source§impl<const NBITS: usize, Repr, Ptr, T: Clone, Perm> Clone for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8> + Clone,
Repr: Representation<NBITS> + Clone,
Perm: PermutationStrategy<NBITS> + Clone,
impl<const NBITS: usize, Repr, Ptr, T: Clone, Perm> Clone for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8> + Clone,
Repr: Representation<NBITS> + Clone,
Perm: PermutationStrategy<NBITS> + Clone,
Source§fn clone(&self) -> VectorBase<NBITS, Repr, Ptr, T, Perm>
fn clone(&self) -> VectorBase<NBITS, Repr, Ptr, T, Perm>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const NBITS: usize, T, Perm> CompressInto<&[T], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, Compensation>, Perm>> for ScalarQuantizer
impl<const NBITS: usize, T, Perm> CompressInto<&[T], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, Compensation>, Perm>> for ScalarQuantizer
Source§fn compress_into(
&self,
from: &[T],
into: MutCompensatedVectorRef<'_, NBITS, Perm>,
) -> Result<(), Self::Error>
fn compress_into( &self, from: &[T], into: MutCompensatedVectorRef<'_, NBITS, Perm>, ) -> Result<(), Self::Error>
Compress the input vector from into the bitslice into.
This method computes and stores the compensation coefficient required for fast inner product computations.
§Error
Returns an error if the input contains NaN.
§Panics
Panics if:
from.len() != self.dim(): Vector to be compressed must have the same dimensionality as the quantizer.into.len() != self.dim(): Compressed vector must have the same dimensionality as the quantizer.
Source§type Error = InputContainsNaN
type Error = InputContainsNaN
Source§impl<const NBITS: usize, T> CompressInto<&[T], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, MinMaxCompensation>>> for MinMaxQuantizer
impl<const NBITS: usize, T> CompressInto<&[T], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, MinMaxCompensation>>> for MinMaxQuantizer
Source§fn compress_into(
&self,
from: &[T],
to: DataMutRef<'_, NBITS>,
) -> Result<L2Loss, Self::Error>
fn compress_into( &self, from: &[T], to: DataMutRef<'_, NBITS>, ) -> Result<L2Loss, Self::Error>
Compress the input vector from into a mut ref of Data to.
This method computes and stores the compensation coefficients required for computing distances correctly.
§Error
Returns an error if the input contains NaN.
§Panics
Panics if:
from.len() != self.dim(): Vector to be compressed must have the same dimensionality as the quantizer.to.vector().len() != self.output_dim(): Compressed vector must have the same dimensionality as the quantizer.
Source§type Error = InputContainsNaN
type Error = InputContainsNaN
Source§impl<'a, 'b> CompressInto<VectorBase<4, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<2, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
impl<'a, 'b> CompressInto<VectorBase<4, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<2, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
Source§impl<'a, 'b> CompressInto<VectorBase<8, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<2, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
impl<'a, 'b> CompressInto<VectorBase<8, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<2, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
Source§impl<'a, 'b> CompressInto<VectorBase<8, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<4, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
impl<'a, 'b> CompressInto<VectorBase<8, Unsigned, SlicePtr<'a, u8>, Ref<'a, MinMaxCompensation>>, VectorBase<4, Unsigned, MutSlicePtr<'b, u8>, Mut<'b, MinMaxCompensation>>> for Recompressor
Source§impl<const NBITS: usize, A> CompressIntoWith<&[f32], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, DataMeta>>, ScopedAllocator<'_>> for SphericalQuantizer<A>
impl<const NBITS: usize, A> CompressIntoWith<&[f32], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, DataMeta>>, ScopedAllocator<'_>> for SphericalQuantizer<A>
Source§fn compress_into_with(
&self,
from: &[f32],
into: DataMut<'_, NBITS>,
allocator: ScopedAllocator<'_>,
) -> Result<(), Self::Error>
fn compress_into_with( &self, from: &[f32], into: DataMut<'_, NBITS>, allocator: ScopedAllocator<'_>, ) -> Result<(), Self::Error>
Compress the input vector from into the bitslice into.
§Error
Returns an error if
- The input contains
NaN. from.len() != self.dim(): Vector to be compressed must have the same dimensionality as the quantizer.into.len() != self.output_dim(): Compressed vector must have the same dimensionality as the output of the distance-preserving transform. Importantely, this may be different thanself.dim()and should be retrieved fromself.output_dim().
Source§type Error = CompressionError
type Error = CompressionError
Source§impl<const NBITS: usize, Perm, A> CompressIntoWith<&[f32], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, QueryMeta>, Perm>, ScopedAllocator<'_>> for SphericalQuantizer<A>
impl<const NBITS: usize, Perm, A> CompressIntoWith<&[f32], VectorBase<NBITS, Unsigned, MutSlicePtr<'_, u8>, Mut<'_, QueryMeta>, Perm>, ScopedAllocator<'_>> for SphericalQuantizer<A>
Source§fn compress_into_with(
&self,
from: &[f32],
into: QueryMut<'_, NBITS, Perm>,
allocator: ScopedAllocator<'_>,
) -> Result<(), Self::Error>
fn compress_into_with( &self, from: &[f32], into: QueryMut<'_, NBITS, Perm>, allocator: ScopedAllocator<'_>, ) -> Result<(), Self::Error>
Compress the input vector from into the bitslice into.
§Error
Returns an error if
- The input contains
NaN. from.len() != self.dim(): Vector to be compressed must have the same dimensionality as the quantizer.into.len() != self.output_dim(): Compressed vector must have the same dimensionality as the output of the distance-preserving transform. Importantely, this may be different thanself.dim()and should be retrieved fromself.output_dim().
Source§type Error = CompressionError
type Error = CompressionError
Source§impl<const NBITS: usize, Repr, Ptr, T: Debug, Perm> Debug for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8> + Debug,
Repr: Representation<NBITS> + Debug,
Perm: PermutationStrategy<NBITS> + Debug,
impl<const NBITS: usize, Repr, Ptr, T: Debug, Perm> Debug for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8> + Debug,
Repr: Representation<NBITS> + Debug,
Perm: PermutationStrategy<NBITS> + Debug,
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedCosineNormalizedwhere
Unsigned: Representation<NBITS>,
SquaredL2: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
CosineNormalized
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedCosineNormalizedwhere
Unsigned: Representation<NBITS>,
SquaredL2: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
CosineNormalized
This implementation calculates the <x, y> = 1 - L2 / 2 value, which will be further used to compute the CosineNormalised distance function
§Notes
s = 1 - cosine(X, Y) = 1- <X, Y> / (||X|| * ||Y||)
We can make simply assumption that ||X|| = 1 and ||Y|| = 1. Then s = 1 - <X, Y>
The squared L2 distance can be computed as follows: p = ||x||^2 + ||y||^2 - 2<x, y> When vectors are normalized, this becomes p = 2 - 2<x, y> = 2 * (1 - <x, y>)
In other words, the similarity score for the squared L2 distance in an ideal world is 2 times that for cosine similarity. Therefore, squared L2 may serves as a stand-in for cosine normalized as ordering is preserved.
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> MathematicalResult<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> MathematicalResult<f32>
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Compute the inner product between the two compensated vectors.
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Compute the inner product between the two compensated vectors.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision computations.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
§Panics
Panics if x.len() != y.len().
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> MathematicalResult<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> MathematicalResult<f32>
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedSquaredL2where
Unsigned: Representation<NBITS>,
SquaredL2: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Compute the squared euclidean distance between the two compensated vectors.
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for CompensatedSquaredL2where
Unsigned: Representation<NBITS>,
SquaredL2: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Compute the squared euclidean distance between the two compensated vectors.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision distances.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
§Panics
Panics if x.len() != y.len().
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> MathematicalResult<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> MathematicalResult<f32>
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedCosineNormalizedwhere
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedCosineNormalizedwhere
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> Result<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> Result<f32>
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedIPwhere
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
Compute the inner product between the two compensated vectors.
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedIPwhere
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
Compute the inner product between the two compensated vectors.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision computations.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
§Panics
Panics if x.len() != y.len().
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> Result<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> Result<f32>
Source§impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedSquaredL2where
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
Compute the squared euclidean distance between the two compensated vectors.
impl<const NBITS: usize> DistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, Compensation>>, Result<f32, UnequalLengths>> for CompensatedSquaredL2where
Unsigned: Representation<NBITS>,
Self: for<'a, 'b> DistanceFunction<CompensatedVectorRef<'a, NBITS>, CompensatedVectorRef<'b, NBITS>, MathematicalResult<f32>>,
Compute the squared euclidean distance between the two compensated vectors.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision distances.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
§Panics
Panics if x.len() != y.len().
Source§fn evaluate_similarity(
&self,
x: CompensatedVectorRef<'_, NBITS>,
y: CompensatedVectorRef<'_, NBITS>,
) -> Result<f32>
fn evaluate_similarity( &self, x: CompensatedVectorRef<'_, NBITS>, y: CompensatedVectorRef<'_, NBITS>, ) -> Result<f32>
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosinewhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<&'a FullQuery, DataRef<'b, NBITS>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosinewhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<&'a FullQuery, DataRef<'b, NBITS>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosineNormalizedwhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<&'a FullQuery, DataRef<'b, NBITS>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosineNormalizedwhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<&'a FullQuery, DataRef<'b, NBITS>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<&FullQuery, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<&'a [f32], BitSlice<'b, NBITS, Unsigned>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<MathematicalValue<f32>, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosinewhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<DataRef<'a, NBITS>, DataRef<'b, NBITS>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosinewhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<DataRef<'a, NBITS>, DataRef<'b, NBITS>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosineNormalizedwhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<DataRef<'a, NBITS>, DataRef<'b, NBITS>, MathematicalResult<f32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxCosineNormalizedwhere
Unsigned: Representation<NBITS>,
MinMaxIP: for<'a, 'b> PureDistanceFunction<DataRef<'a, NBITS>, DataRef<'b, NBITS>, MathematicalResult<f32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxIPwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Source§impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> PureDistanceFunction<VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, MinMaxCompensation>>, Result<f32, UnequalLengths>> for MinMaxL2Squaredwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
Source§impl<'this, const NBITS: usize, Repr, Ptr, T, Perm> Reborrow<'this> for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8>,
Repr: Representation<NBITS>,
Perm: PermutationStrategy<NBITS>,
T: CopyRef + Reborrow<'this, Target = Ref<'this, <T as CopyRef>::Target>>,
impl<'this, const NBITS: usize, Repr, Ptr, T, Perm> Reborrow<'this> for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8>,
Repr: Representation<NBITS>,
Perm: PermutationStrategy<NBITS>,
T: CopyRef + Reborrow<'this, Target = Ref<'this, <T as CopyRef>::Target>>,
Source§impl<'this, const NBITS: usize, Repr, Ptr, T, Perm> ReborrowMut<'this> for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsMutPtr<Type = u8>,
Repr: Representation<NBITS>,
Perm: PermutationStrategy<NBITS>,
T: CopyMut + ReborrowMut<'this, Target = Mut<'this, <T as CopyRef>::Target>>,
impl<'this, const NBITS: usize, Repr, Ptr, T, Perm> ReborrowMut<'this> for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsMutPtr<Type = u8>,
Repr: Representation<NBITS>,
Perm: PermutationStrategy<NBITS>,
T: CopyMut + ReborrowMut<'this, Target = Mut<'this, <T as CopyRef>::Target>>,
type Target = VectorBase<NBITS, Repr, MutSlicePtr<'this, u8>, Mut<'this, <T as CopyRef>::Target>, Perm>
Source§fn reborrow_mut(&'this mut self) -> Self::Target
fn reborrow_mut(&'this mut self) -> Self::Target
self into a generalized reference type and reborrow.Source§impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, Slice<&[f32], Ref<'_, FullQueryMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<f32>, &'a [f32], BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between a full-precision query and a spherically quantized
data vector.
impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, Slice<&[f32], Ref<'_, FullQueryMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<f32>, &'a [f32], BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between a full-precision query and a spherically quantized data vector.
Returns an error if the arguments have different lengths.
Source§fn run(
self,
arch: A,
x: FullQueryRef<'_>,
y: DataRef<'_, NBITS>,
) -> MathematicalResult<f32>
fn run( self, arch: A, x: FullQueryRef<'_>, y: DataRef<'_, NBITS>, ) -> MathematicalResult<f32>
Architecture.Source§impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, Slice<&[f32], Ref<'_, FullQueryMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<f32>, &'a [f32], BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between a full-precision query and a spherically quantized
data vector.
impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, Slice<&[f32], Ref<'_, FullQueryMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<f32>, &'a [f32], BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between a full-precision query and a spherically quantized data vector.
Returns an error if the arguments have different lengths.
Source§fn run(
self,
arch: A,
x: FullQueryRef<'_>,
y: DataRef<'_, NBITS>,
) -> MathematicalResult<f32>
fn run( self, arch: A, x: FullQueryRef<'_>, y: DataRef<'_, NBITS>, ) -> MathematicalResult<f32>
Architecture.Source§impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<u32>, BitSlice<'a, NBITS, Unsigned>, BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between the two compensated vectors.
impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<u32>, BitSlice<'a, NBITS, Unsigned>, BitSlice<'a, NBITS, Unsigned>>,
Compute the inner product between the two compensated vectors.
Returns an error if the arguments have different lengths.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision computations.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
Source§impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<u32>, BitSlice<'a, NBITS, Unsigned>, BitSlice<'a, NBITS, Unsigned>>,
Compute the squared euclidean distance between the two compensated vectors.
impl<A, const NBITS: usize> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>, VectorBase<NBITS, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<NBITS>,
InnerProduct: for<'a> Target2<A, MathematicalResult<u32>, BitSlice<'a, NBITS, Unsigned>, BitSlice<'a, NBITS, Unsigned>>,
Compute the squared euclidean distance between the two compensated vectors.
The value returned by this function is scaled properly, meaning that distances returned by this method are compatible with full-precision distances.
§Validity
The results of this function are only meaningful if both x, y, and Self belong to
the same quantizer.
Source§impl<A, const Q: usize, const D: usize, Perm> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<Q, Unsigned, SlicePtr<'_, u8>, Ref<'_, QueryMeta>, Perm>, VectorBase<D, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<Q> + Representation<D>,
Perm: PermutationStrategy<Q>,
for<'a> InnerProduct: Target2<A, MathematicalResult<u32>, BitSlice<'a, Q, Unsigned, Perm>, BitSlice<'a, D, Unsigned>>,
impl<A, const Q: usize, const D: usize, Perm> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<Q, Unsigned, SlicePtr<'_, u8>, Ref<'_, QueryMeta>, Perm>, VectorBase<D, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedIPwhere
A: Architecture,
Unsigned: Representation<Q> + Representation<D>,
Perm: PermutationStrategy<Q>,
for<'a> InnerProduct: Target2<A, MathematicalResult<u32>, BitSlice<'a, Q, Unsigned, Perm>, BitSlice<'a, D, Unsigned>>,
Source§impl<A, const Q: usize, const D: usize, Perm> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<Q, Unsigned, SlicePtr<'_, u8>, Ref<'_, QueryMeta>, Perm>, VectorBase<D, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<Q> + Representation<D>,
Perm: PermutationStrategy<Q>,
for<'a> InnerProduct: Target2<A, MathematicalResult<u32>, BitSlice<'a, Q, Unsigned, Perm>, BitSlice<'a, D, Unsigned>>,
impl<A, const Q: usize, const D: usize, Perm> Target2<A, Result<MathematicalValue<f32>, UnequalLengths>, VectorBase<Q, Unsigned, SlicePtr<'_, u8>, Ref<'_, QueryMeta>, Perm>, VectorBase<D, Unsigned, SlicePtr<'_, u8>, Ref<'_, DataMeta>>> for CompensatedSquaredL2where
A: Architecture,
Unsigned: Representation<Q> + Representation<D>,
Perm: PermutationStrategy<Q>,
for<'a> InnerProduct: Target2<A, MathematicalResult<u32>, BitSlice<'a, Q, Unsigned, Perm>, BitSlice<'a, D, Unsigned>>,
impl<const NBITS: usize, Repr, Ptr, T: Copy, Perm> Copy for VectorBase<NBITS, Repr, Ptr, T, Perm>where
Ptr: AsPtr<Type = u8> + Copy,
Repr: Representation<NBITS> + Copy,
Perm: PermutationStrategy<NBITS> + Copy,
Auto Trait Implementations§
impl<const NBITS: usize, Repr, Ptr, T, Perm> Freeze for VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> RefUnwindSafe for VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> Send for VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> Sync for VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> Unpin for VectorBase<NBITS, Repr, Ptr, T, Perm>
impl<const NBITS: usize, Repr, Ptr, T, Perm> UnwindSafe for VectorBase<NBITS, Repr, Ptr, T, Perm>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more