/// Basic compilation test - TDD RED phase /// Tests that our fundamental structures compile and work use rtx_tensor::{Device, Tensor}; #[test] fn test_basic_tensor_operations_compile() { // RED: Test basic tensor operations we need let device = Device::default(); // Test tensor creation let a = Tensor::ones(&[2, 3], &device); assert!(a.is_ok(), "Should create tensor"); let a = a.unwrap(); assert_eq!(a.shape(), &[2, 3]); // Test tensor addition let b = Tensor::ones(&[2, 3], &device).unwrap(); let c = (&a + &b); assert!(c.is_ok(), "Addition should work"); // Test tensor concatenation let t1 = Tensor::randn(&[2, 3, 4], &device).unwrap(); let t2 = Tensor::randn(&[2, 5, 4], &device).unwrap(); // Clone to pass ownership let concat_result = Tensor::cat(&[t1.clone(), t2.clone()], 1); assert!(concat_result.is_ok(), "Concatenation should work"); let concatenated = concat_result.unwrap(); assert_eq!(concatenated.shape(), &[2, 8, 4]); } #[test] fn test_fusion_config_creation() { // RED: Test that FusionConfig can be created use rtx_multimodal::fusion::FusionConfig; let config = FusionConfig::new(256, 256, 256, 256, 8); assert_eq!(config.vision_dim, 256); assert_eq!(config.audio_dim, 256); assert_eq!(config.text_dim, 256); assert_eq!(config.output_dim, 256); assert_eq!(config.num_heads, 8); } #[test] fn test_cross_modal_config_creation() { // RED: Test CrossModalConfig creation use rtx_multimodal::cross_modal_attention::CrossModalConfig; let config = CrossModalConfig::new(512, 8); assert_eq!(config.hidden_dim, 512); assert_eq!(config.num_heads, 8); assert_eq!(config.head_dim, 64); // 512 / 8 } #[test] fn test_multimodal_config_creation() { // RED: Test main MultimodalConfig use rtx_multimodal::MultimodalConfig; let config = MultimodalConfig::new(768, 12); assert_eq!(config.hidden_dim, 768); assert_eq!(config.num_heads, 12); } #[test] fn test_tensor_mean_operation() { // RED: Test mean operation that caused errors let device = Device::default(); let tensor = Tensor::randn(&[2, 3, 4], &device).unwrap(); // Test mean with dimensions let mean_result = tensor.mean(&[1], false); assert!(mean_result.is_ok(), "Mean should work"); let mean = mean_result.unwrap(); assert_eq!(mean.shape(), &[2, 4]); // Test mean over all dimensions let full_mean = tensor.mean(&[], false); assert!(full_mean.is_ok(), "Full mean should work"); } #[test] fn test_tensor_narrow_operation() { // RED: Test narrow operation for splitting tensors let device = Device::default(); let tensor = Tensor::randn(&[2, 6, 4], &device).unwrap(); // Test narrow to split tensor let first_half = tensor.narrow(1, 0, 3); assert!(first_half.is_ok(), "First narrow should work"); assert_eq!(first_half.unwrap().shape(), &[2, 3, 4]); let second_half = tensor.narrow(1, 3, 3); assert!(second_half.is_ok(), "Second narrow should work"); assert_eq!(second_half.unwrap().shape(), &[2, 3, 4]); } #[test] fn test_tensor_pow_and_sqrt() { // RED: Test power and sqrt operations for normalization let device = Device::default(); let tensor = Tensor::randn(&[2, 3], &device).unwrap(); // Test power let squared = tensor.pow_scalar(2.0); assert!(squared.is_ok(), "Power should work"); // Test sqrt let sqrt_result = squared.unwrap().sqrt(); assert!(sqrt_result.is_ok(), "Sqrt should work"); } #[test] fn test_tensor_sum_operation() { // RED: Test sum operation for normalization let device = Device::default(); let tensor = Tensor::randn(&[2, 3, 4], &device).unwrap(); // Test sum along dimensions let sum_result = tensor.sum(Some(2)); assert!(sum_result.is_ok(), "Sum should work"); let summed = sum_result.unwrap(); assert_eq!(summed.shape(), &[2, 3]); } #[test] fn test_tensor_unsqueeze_operation() { // RED: Test unsqueeze for broadcasting let device = Device::default(); let tensor = Tensor::randn(&[2, 3], &device).unwrap(); // Test unsqueeze let unsqueezed = tensor.unsqueeze(-1); assert!(unsqueezed.is_ok(), "Unsqueeze should work"); let result = unsqueezed.unwrap(); assert_eq!(result.shape(), &[2, 3, 1]); } #[test] fn test_tensor_full_creation() { // RED: Test creating tensor with specific value let device = Device::default(); let full_tensor = Tensor::full(&[2, 3], 1e-8, &device); assert!(full_tensor.is_ok(), "Full tensor creation should work"); let tensor = full_tensor.unwrap(); assert_eq!(tensor.shape(), &[2, 3]); }