Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vortex-tensor/src/encodings/turboquant/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ use crate::scalar_fns::l2_denorm::normalize_as_l2_denorm;
use crate::scalar_fns::sorf_transform::SorfMatrix;
use crate::scalar_fns::sorf_transform::SorfOptions;
use crate::scalar_fns::sorf_transform::SorfTransform;
use crate::types::vector::AnyVector;
use crate::types::vector::Vector;
use crate::utils::cast_to_f32;
use crate::vector::AnyVector;
use crate::vector::Vector;

/// Configuration for TurboQuant encoding.
#[derive(Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions vortex-tensor/src/encodings/turboquant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ use vortex_error::VortexResult;
use vortex_error::vortex_ensure;
use vortex_error::vortex_err;

use crate::vector::AnyVector;
use crate::vector::VectorMatcherMetadata;
use crate::types::vector::AnyVector;
use crate::types::vector::VectorMatcherMetadata;

/// Validates that `dtype` is a [`Vector`](crate::vector::Vector) extension type with
/// dimension >= [`MIN_DIMENSION`].
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/encodings/turboquant/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use vortex_error::VortexResult;
use crate::encodings::turboquant::TurboQuantConfig;
use crate::encodings::turboquant::turboquant_encode;
use crate::tests::SESSION;
use crate::vector::Vector;
use crate::types::vector::Vector;

/// Create a FixedSizeListArray of random f32 vectors with the given validity.
fn make_fsl_with_validity(
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/encodings/turboquant/tests/structural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn sorf_transform_roundtrip_isolation() -> VortexResult<()> {
use crate::scalar_fns::sorf_transform::SorfMatrix;
use crate::scalar_fns::sorf_transform::SorfOptions;
use crate::scalar_fns::sorf_transform::SorfTransform;
use crate::vector::Vector;
use crate::types::vector::Vector;

let dim = 128usize;
let seed = 99u64;
Expand Down
10 changes: 6 additions & 4 deletions vortex-tensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ use vortex_array::scalar_fn::session::ScalarFnSessionExt;
use vortex_array::session::ArraySessionExt;
use vortex_session::VortexSession;

use crate::fixed_shape::FixedShapeTensor;
use crate::scalar_fns::cosine_similarity::CosineSimilarity;
use crate::scalar_fns::inner_product::InnerProduct;
use crate::scalar_fns::l2_denorm::L2Denorm;
use crate::scalar_fns::l2_norm::L2Norm;
use crate::scalar_fns::sorf_transform::SorfTransform;
use crate::vector::Vector;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::vector::Vector;

pub mod matcher;
pub mod scalar_fns;

pub mod fixed_shape;
pub mod vector;
mod types;

pub use types::fixed_shape;
pub use types::vector;

pub mod encodings;

Expand Down
8 changes: 4 additions & 4 deletions vortex-tensor/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use vortex_array::dtype::PType;
use vortex_array::dtype::extension::ExtDTypeRef;
use vortex_array::dtype::extension::Matcher;

use crate::fixed_shape::AnyFixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMatcherMetadata;
use crate::vector::AnyVector;
use crate::vector::VectorMatcherMetadata;
use crate::types::fixed_shape::AnyFixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMatcherMetadata;
use crate::types::vector::AnyVector;
use crate::types::vector::VectorMatcherMetadata;

/// Matcher for any tensor-like extension type.
///
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/scalar_fns/cosine_similarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ mod tests {
use crate::scalar_fns::cosine_similarity::CosineSimilarity;
use crate::scalar_fns::l2_denorm::L2Denorm;
use crate::tests::SESSION;
use crate::types::vector::Vector;
use crate::utils::test_helpers::assert_close;
use crate::utils::test_helpers::constant_tensor_array;
use crate::utils::test_helpers::l2_denorm_array;
use crate::utils::test_helpers::tensor_array;
use crate::utils::test_helpers::vector_array;
use crate::vector::Vector;

/// Evaluates cosine similarity between two tensor arrays and returns the result as `Vec<f64>`.
fn eval_cosine_similarity(lhs: ArrayRef, rhs: ArrayRef, len: usize) -> VortexResult<Vec<f64>> {
Expand Down
4 changes: 2 additions & 2 deletions vortex-tensor/src/scalar_fns/inner_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ use crate::matcher::AnyTensor;
use crate::scalar_fns::l2_denorm::DenormOrientation;
use crate::scalar_fns::sorf_transform::SorfMatrix;
use crate::scalar_fns::sorf_transform::SorfTransform;
use crate::types::vector::Vector;
use crate::utils::extract_constant_flat_row;
use crate::utils::extract_flat_elements;
use crate::utils::extract_l2_denorm_children;
use crate::utils::validate_binary_tensor_float_inputs;
use crate::vector::Vector;

/// Inner product (dot product) between two columns.
///
Expand Down Expand Up @@ -906,10 +906,10 @@ mod tests {
use crate::scalar_fns::sorf_transform::SorfOptions;
use crate::scalar_fns::sorf_transform::SorfTransform;
use crate::tests::SESSION;
use crate::types::vector::Vector;
use crate::utils::extract_flat_elements;
use crate::utils::test_helpers::literal_vector_array;
use crate::utils::test_helpers::vector_array;
use crate::vector::Vector;

/// Build a `Vector<list_size, f32>` whose storage is `FSL(DictArray(codes: u8, values:
/// f32))`. This mirrors the shape that TurboQuant produces as the SorfTransform child.
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/scalar_fns/l2_denorm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,11 @@ mod tests {
use crate::scalar_fns::l2_denorm::normalize_as_l2_denorm;
use crate::scalar_fns::l2_denorm::validate_l2_normalized_rows_against_norms;
use crate::tests::SESSION;
use crate::types::vector::Vector;
use crate::utils::test_helpers::assert_close;
use crate::utils::test_helpers::constant_tensor_array;
use crate::utils::test_helpers::tensor_array;
use crate::utils::test_helpers::vector_array;
use crate::vector::Vector;

/// Evaluates L2 denorm on a tensor/vector array and returns the executed array.
fn eval_l2_denorm(normalized: ArrayRef, norms: ArrayRef, len: usize) -> VortexResult<ArrayRef> {
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/scalar_fns/l2_norm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ mod tests {

use crate::scalar_fns::l2_norm::L2Norm;
use crate::tests::SESSION;
use crate::types::vector::Vector;
use crate::utils::test_helpers::assert_close;
use crate::utils::test_helpers::literal_vector_array;
use crate::utils::test_helpers::tensor_array;
use crate::utils::test_helpers::vector_array;
use crate::vector::Vector;

/// Evaluates L2 norm on a tensor/vector array and returns the result as `Vec<f64>`.
fn eval_l2_norm(input: ArrayRef, len: usize) -> VortexResult<Vec<f64>> {
Expand Down
7 changes: 5 additions & 2 deletions vortex-tensor/src/scalar_fns/sorf_transform/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::encodings::turboquant::centroids::compute_centroid_boundaries;
use crate::encodings::turboquant::centroids::find_nearest_centroid;
use crate::encodings::turboquant::centroids::get_centroids;
use crate::tests::SESSION;
use crate::vector::Vector;
use crate::types::vector::Vector;

/// Build a unit-normalized input vector array and forward-transform + quantize it, returning
/// `(input_f32, Vector<padded_dim>(FSL(Dict(codes, centroids))), padded_dim)`.
Expand Down Expand Up @@ -300,7 +300,10 @@ fn return_dtype_is_vector_extension() -> VortexResult<()> {
let ext = return_dtype
.as_extension_opt()
.expect("return dtype should be an extension type");
assert!(ext.metadata_opt::<crate::vector::AnyVector>().is_some());
assert!(
ext.metadata_opt::<crate::types::vector::AnyVector>()
.is_some()
);

// Inner FSL should have the original (unpadded) dimension.
let DType::FixedSizeList(_, inner_dim, _) = ext.storage_dtype() else {
Expand Down
4 changes: 2 additions & 2 deletions vortex-tensor/src/scalar_fns/sorf_transform/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use super::SorfOptions;
use super::SorfTransform;
use super::rotation::SorfMatrix;
use super::validate_sorf_options;
use crate::vector::AnyVector;
use crate::vector::Vector;
use crate::types::vector::AnyVector;
use crate::types::vector::Vector;

impl ScalarFnVTable for SorfTransform {
type Options = SorfOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use vortex_array::dtype::extension::Matcher;
use vortex_error::VortexExpect;
use vortex_error::vortex_panic;

use crate::fixed_shape::FixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMetadata;

pub struct AnyFixedShapeTensor;

Expand Down Expand Up @@ -98,7 +98,7 @@ mod tests {
use vortex_error::VortexResult;

use super::*;
use crate::vector::Vector;
use crate::types::vector::Vector;

fn tensor_storage_dtype(element_ptype: PType, list_size: u32) -> DType {
DType::FixedSizeList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_err;

use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::types::fixed_shape::FixedShapeTensorMetadata;

/// Protobuf representation of [`FixedShapeTensorMetadata`].
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
use vortex_error::vortex_ensure_eq;

use crate::fixed_shape::FixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::fixed_shape::proto;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMetadata;
use crate::types::fixed_shape::proto;

impl ExtVTable for FixedShapeTensor {
type Metadata = FixedShapeTensorMetadata;
Expand Down Expand Up @@ -80,8 +80,8 @@ mod tests {
use vortex_array::dtype::extension::ExtVTable;
use vortex_error::VortexResult;

use crate::fixed_shape::FixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMetadata;

/// Serializes and deserializes the given metadata through protobuf, asserting equality.
fn assert_roundtrip(metadata: &FixedShapeTensorMetadata) -> VortexResult<()> {
Expand Down
7 changes: 7 additions & 0 deletions vortex-tensor/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Internal homes for tensor extension types.

pub mod fixed_shape;
pub mod vector;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vortex_error::VortexResult;
use vortex_error::vortex_ensure;
use vortex_error::vortex_panic;

use crate::vector::Vector;
use crate::types::vector::Vector;

pub struct AnyVector;

Expand Down Expand Up @@ -101,8 +101,8 @@ mod tests {
use vortex_error::VortexResult;

use super::*;
use crate::fixed_shape::FixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMetadata;

fn vector_storage_dtype(element_ptype: PType, dimensions: u32) -> DType {
DType::FixedSizeList(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;

use crate::vector::Vector;
use crate::types::vector::Vector;

impl ExtVTable for Vector {
type Metadata = EmptyMetadata;
Expand Down Expand Up @@ -70,7 +70,7 @@ mod tests {
use vortex_array::extension::EmptyMetadata;
use vortex_error::VortexResult;

use crate::vector::Vector;
use crate::types::vector::Vector;

/// Constructs a `FixedSizeList` storage dtype with the given float [`PType`], list size, and
/// [`Nullability`].
Expand Down
6 changes: 3 additions & 3 deletions vortex-tensor/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ pub mod test_helpers {
use vortex_buffer::Buffer;
use vortex_error::VortexResult;

use crate::fixed_shape::FixedShapeTensor;
use crate::fixed_shape::FixedShapeTensorMetadata;
use crate::scalar_fns::l2_denorm::L2Denorm;
use crate::vector::Vector;
use crate::types::fixed_shape::FixedShapeTensor;
use crate::types::fixed_shape::FixedShapeTensorMetadata;
use crate::types::vector::Vector;

/// Builds a `FixedSizeList<T, list_size>` storage array from flat `elements`. The row count is
/// inferred from `elements.len() / list_size`.
Expand Down
2 changes: 1 addition & 1 deletion vortex-tensor/src/vector_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use vortex_array::scalar_fn::fns::operators::Operator;
use vortex_error::VortexResult;

use crate::scalar_fns::cosine_similarity::CosineSimilarity;
use crate::vector::Vector;
use crate::types::vector::Vector;

/// Build the lazy similarity-search expression tree for a prepared database array and a
/// single query vector.
Expand Down
Loading