1use std::path::Path;
19
20use rlx_flow::CompileProfile;
21
22use rlx_core::flow_bridge::profile_near_weights as load_profile_near_weights;
23
24pub const SAM_PROFILE_FILE: &str = "sam.rlx.toml";
26
27pub fn sam_profile_near_weights(weights: &Path) -> CompileProfile {
29 load_profile_near_weights(weights, SAM_PROFILE_FILE, CompileProfile::sam_encoder())
30}
31
32pub fn sam3_profile_near_weights(weights: &Path) -> CompileProfile {
34 load_profile_near_weights(weights, SAM_PROFILE_FILE, CompileProfile::sam3())
35}
36
37pub fn sam2_profile_near_weights(weights: &Path) -> CompileProfile {
39 load_profile_near_weights(weights, SAM_PROFILE_FILE, CompileProfile::sam2())
40}
41
42pub fn sam2_profile_default() -> CompileProfile {
43 CompileProfile::sam2()
44}
45
46pub fn sam_profile_default() -> CompileProfile {
48 CompileProfile::sam_encoder()
49}
50
51pub fn sam3_profile_default() -> CompileProfile {
53 CompileProfile::sam3()
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59 use rlx_flow::FusionPolicyKind;
60
61 #[test]
62 fn sam_rlx_toml_loads_for_sam3() {
63 let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/sam.rlx.toml");
64 let p = CompileProfile::from_toml_path(&path).unwrap();
65 assert_eq!(p.fusion.policy, FusionPolicyKind::Direct);
66 assert!(p.passes.dce);
67 assert!(p.backend.cpu.unfuse_regions);
68 }
69}