Files
rustytorch/crates/models/rtx-vision/tests/architecture_imports_test.rs
T
2026-03-04 00:08:42 +00:00

135 lines
4.5 KiB
Rust

//! TDD tests for architecture module imports
//! These tests define expected behavior for importing vision architecture types
use rtx_vision::architectures::{
mobilenet::{DepthwiseSeparableConv, InvertedResidual, MobileNetConfig, MobileNetVariant},
mobilevit::{
EfficientAttention, EfficientAttentionConfig, MobileViTBlock, MobileViTBlockConfig,
MobileViTConfig, MobileViTVariant, TransformerBlock,
},
nfnet::{
AGCConfig, AdaptiveGradientClipping, NFBlock, NFBlockConfig, NFNetConfig, NFNetHead,
NFNetStem, NFNetTransition, NFNetVariant, ScaledWSConfig, ScaledWeightStandardization,
},
regnet::{
RegNetBlock, RegNetBlockConfig, RegNetConfig, RegNetHead, RegNetStage, RegNetStageConfig,
RegNetStem, SEModule, SEModuleConfig,
},
};
#[test]
fn test_mobilenet_types_exist() {
// Test that MobileNet types are properly exported and instantiable
let config = MobileNetConfig::default();
assert!(matches!(
config.variant,
MobileNetVariant::V1
| MobileNetVariant::V2
| MobileNetVariant::V3Small
| MobileNetVariant::V3Large
));
// Test that key components can be created
let _conv = DepthwiseSeparableConv::new(32, 64, 3, 1, 1);
let _residual = InvertedResidual::new(32, 64, 3, 1, 6);
}
#[test]
fn test_mobilevit_types_exist() {
// Test that MobileViT types are properly exported and instantiable
let config = MobileViTConfig::default();
assert!(matches!(
config.variant,
MobileViTVariant::XS | MobileViTVariant::S | MobileViTVariant::XXS
));
// Test that key components can be created
let block_config = MobileViTBlockConfig::new(128, 256, 4);
let _block = MobileViTBlock::new(block_config);
let attn_config = EfficientAttentionConfig::new(256, 8);
let _attention = EfficientAttention::new(attn_config);
let _transformer = TransformerBlock::new(256, 8, 1024);
}
#[test]
fn test_nfnet_types_exist() {
// Test that NFNet types are properly exported and instantiable
let config = NFNetConfig::default();
assert!(matches!(
config.variant,
NFNetVariant::F0 | NFNetVariant::F1 | NFNetVariant::F2
));
// Test that key components can be created
let block_config = NFBlockConfig::new(256, 1024, 1, 1);
let _block = NFBlock::new(block_config);
let _stem = NFNetStem::new(64);
let _transition = NFNetTransition::new(256, 512);
let _head = NFNetHead::new(2048, 1000);
let agc_config = AGCConfig::new(0.01);
let _agc = AdaptiveGradientClipping::new(agc_config);
let ws_config = ScaledWSConfig::new(1.0);
let _sws = ScaledWeightStandardization::new(ws_config);
}
#[test]
fn test_regnet_types_exist() {
// Test that RegNet types are properly exported and instantiable
let config = RegNetConfig::default();
assert!(config.depth > 0);
assert!(config.width > 0);
// Test that key components can be created
let block_config = RegNetBlockConfig::new(256, 256, 1, 1);
let _block = RegNetBlock::new(block_config);
let stage_config = RegNetStageConfig::new(256, 512, 2, 1);
let _stage = RegNetStage::new(stage_config);
let _stem = RegNetStem::new(64);
let _head = RegNetHead::new(2048, 1000);
let se_config = SEModuleConfig::new(256, 16);
let _se = SEModule::new(se_config);
}
#[test]
fn test_architecture_integration() {
// Test that architectures can be used together and have consistent interfaces
let mobilenet_config = MobileNetConfig::default();
let mobilevit_config = MobileViTConfig::default();
let nfnet_config = NFNetConfig::default();
let regnet_config = RegNetConfig::default();
// All configs should have basic properties
assert!(mobilenet_config.num_classes > 0);
assert!(mobilevit_config.num_classes > 0);
assert!(nfnet_config.num_classes > 0);
assert!(regnet_config.num_classes > 0);
}
#[test]
fn test_default_configurations() {
// Test that default configurations are reasonable
let mobilenet = MobileNetConfig::default();
assert_eq!(mobilenet.num_classes, 1000);
assert_eq!(mobilenet.width_multiplier, 1.0);
let mobilevit = MobileViTConfig::default();
assert_eq!(mobilevit.num_classes, 1000);
assert_eq!(mobilevit.image_size, 256);
let nfnet = NFNetConfig::default();
assert_eq!(nfnet.num_classes, 1000);
assert!(nfnet.alpha > 0.0);
let regnet = RegNetConfig::default();
assert_eq!(regnet.num_classes, 1000);
assert!(regnet.stem_width > 0);
}