42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
/// Basic compilation test for rtx-vision-advanced
|
|
/// This ensures our fixes allow the crate to at least parse and type-check
|
|
|
|
#[cfg(test)]
|
|
mod compilation_tests {
|
|
use rtx_tensor::{Device, Tensor};
|
|
use rtx_vision_advanced::VisionResult;
|
|
|
|
#[test]
|
|
fn test_tensor_creation() -> VisionResult<()> {
|
|
// Test that Tensor::randn works without DType parameter
|
|
let _tensor = Tensor::randn(&[1, 3, 224, 224], &Device::default())?;
|
|
|
|
// Test that zeros works
|
|
let _zeros = Tensor::zeros(&[10], &Device::default())?;
|
|
|
|
// Test that zeros_typed works
|
|
let _zeros_typed = Tensor::zeros_typed(&[10], rtx_tensor::DType::F32, &Device::default())?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_conv2d_signature() -> VisionResult<()> {
|
|
let input = Tensor::randn(&[1, 3, 32, 32], &Device::default())?;
|
|
let weight = Tensor::randn(&[16, 3, 3, 3], &Device::default())?;
|
|
|
|
// Test conv2d with 6 parameters: weight, bias, stride, padding, dilation, groups
|
|
let _output = input.conv2d(&weight, None, 1, 1, 1, 1)?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_sigmoid_on_f32() {
|
|
let score = 0.5f32;
|
|
// Manual sigmoid implementation for f32
|
|
let sigmoid_value = 1.0 / (1.0 + (-score).exp());
|
|
assert!(sigmoid_value > 0.0 && sigmoid_value < 1.0);
|
|
}
|
|
}
|