use super::{BUNDLE_NAME, MODEL, RECOMMENDED_COMPUTE, STAGED_PATH};
use crate::{
ComputeUnits,
embeddings::face::{ChannelOrder, Preprocessing, TensorLayout},
};
#[test]
fn the_manifest_is_the_contract_the_recipe_converted() {
assert_eq!(MODEL.input(), "data");
assert_eq!(MODEL.output(), "embedding");
assert_eq!(MODEL.dim(), 512);
assert_eq!(MODEL.preprocessing(), Preprocessing::ARCFACE);
}
#[test]
fn the_preprocessing_is_rgb_nchw_and_maps_bytes_onto_minus_one_to_one() {
let p = MODEL.preprocessing();
assert_eq!(p.order(), ChannelOrder::Rgb);
assert_eq!(p.layout(), TensorLayout::Nchw);
assert_eq!(p.scale(), 1.0 / 127.5);
assert_eq!(p.bias(), [-1.0, -1.0, -1.0]);
assert_eq!(0.0f32.mul_add(p.scale(), p.bias()[0]), -1.0);
let top = 255.0f32.mul_add(p.scale(), p.bias()[0]);
assert!(
(f64::from(top) - 1.0).abs() < 1e-6,
"byte 255 must land on the top of the [-1, 1] range, got {top}"
);
}
#[test]
fn the_recommended_placement_is_the_measured_arm_and_not_the_doors_default() {
assert_eq!(RECOMMENDED_COMPUTE, ComputeUnits::CpuAndNeuralEngine);
assert_ne!(
RECOMMENDED_COMPUTE,
crate::embeddings::face::DEFAULT_FACE_COMPUTE,
"the door's default is the planner's choice for ANY artifact; this is a measurement of one"
);
}
#[test]
fn the_staged_path_ends_in_the_bundle_name() {
assert_eq!(BUNDLE_NAME, "w600k_r50.mlmodelc");
assert_eq!(STAGED_PATH, format!("Models/facekit/{BUNDLE_NAME}"));
}