42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
//! Integration test to verify that rtx-science can use core RTX types
|
|
|
|
use crate::*;
|
|
|
|
#[test]
|
|
fn test_import_core_types() {
|
|
// Test that we can use the imported types without compilation errors
|
|
|
|
// Test Tensor and Device (from rtx-tensor)
|
|
let device = Device::cpu();
|
|
let _tensor = Tensor::zeros(&[2, 3], &device).unwrap();
|
|
|
|
// Test Variable (from rtx-autograd)
|
|
let tensor = Tensor::ones(&[2, 2], &device).unwrap();
|
|
let var = Variable::new(tensor, true);
|
|
assert!(var.requires_grad());
|
|
|
|
// Test error types
|
|
let _error: AutogradError = AutogradError::BackwardError("test".to_string());
|
|
let _tensor_error: TensorError = TensorError::Shape {
|
|
message: "test".to_string(),
|
|
};
|
|
|
|
// Note: DistributedContext is temporarily disabled due to NCCL compilation issues
|
|
// When rtx-distributed is re-enabled, add the following tests:
|
|
// let ctx = DistributedContext::uninitialized();
|
|
// assert!(ctx.is_master());
|
|
// assert_eq!(ctx.world_size(), 1);
|
|
// assert_eq!(ctx.rank(), 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_scientific_tensor() {
|
|
// Test our ScientificTensor still works
|
|
let tensor = ScientificTensor::zeros(&[3, 3]);
|
|
assert_eq!(tensor.shape(), &[3, 3]);
|
|
|
|
let tensor2 = ScientificTensor::ones(&[3, 3]);
|
|
let result = tensor.add(&tensor2).unwrap();
|
|
assert_eq!(result.data().sum(), 9.0);
|
|
}
|