64 lines
1.8 KiB
Rust
64 lines
1.8 KiB
Rust
use rtx_multimodal::error::Result;
|
|
use rtx_tensor::{Device, Tensor};
|
|
|
|
#[test]
|
|
fn test_basic_tensor_operations() -> Result<()> {
|
|
let device = Device::default();
|
|
|
|
// Test basic tensor creation
|
|
let tensor = Tensor::zeros([2, 3], &device)?;
|
|
assert_eq!(tensor.shape().dims(), &[2, 3]);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_simple_vision_operations() -> Result<()> {
|
|
let device = Device::default();
|
|
|
|
// Test patch embedding concept with basic tensors
|
|
let input = Tensor::randn(&[1, 3, 32, 32], &device)?; // Small image
|
|
assert_eq!(input.shape().dims(), &[1, 3, 32, 32]);
|
|
|
|
// Test transpose operation
|
|
let matrix = Tensor::randn(&[4, 4], &device)?;
|
|
let transposed = matrix.transpose(0, 1)?;
|
|
assert_eq!(transposed.shape().dims(), &[4, 4]);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_basic_audio_operations() -> Result<()> {
|
|
let device = Device::default();
|
|
|
|
// Test basic audio tensor operations
|
|
let audio = Tensor::randn(&[1, 1000], &device)?; // 1 second at 1kHz
|
|
assert_eq!(audio.shape().dims(), &[1, 1000]);
|
|
|
|
// Test activation functions
|
|
let activated = audio.gelu()?;
|
|
assert_eq!(activated.shape().dims(), &[1, 1000]);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_basic_multimodal_fusion() -> Result<()> {
|
|
let device = Device::default();
|
|
|
|
// Test basic fusion concept with simple concatenation
|
|
let vision_features = Tensor::randn(&[1, 512], &device)?;
|
|
let audio_features = Tensor::randn(&[1, 256], &device)?;
|
|
|
|
assert_eq!(vision_features.shape().dims(), &[1, 512]);
|
|
assert_eq!(audio_features.shape().dims(), &[1, 256]);
|
|
|
|
// Test that we can at least create the tensors for fusion
|
|
let combined_size = 512 + 256;
|
|
let fused = Tensor::randn(&[1, combined_size], &device)?;
|
|
assert_eq!(fused.shape().dims(), &[1, 768]);
|
|
|
|
Ok(())
|
|
}
|