#![allow(dead_code)]
use rlx_flow::CompileProfile;
use rlx_ir::Graph;
use rlx_runtime::{CompileOptions, CompiledGraph, Device, Session};
use std::collections::HashMap;
pub fn attach_params(compiled: &mut CompiledGraph, params: &HashMap<String, Vec<f32>>) {
for (name, data) in params {
compiled.set_param(name, data.as_slice());
}
}
pub fn compile_legacy(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
let mut compiled = Session::new(device).compile_with(graph, &CompileOptions::new());
attach_params(&mut compiled, ¶ms);
compiled
}
pub fn compile_with_options(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
opts: &CompileOptions,
) -> CompiledGraph {
let mut compiled = Session::new(device).compile_with(graph, opts);
attach_params(&mut compiled, ¶ms);
compiled
}
pub fn compile_with_profile(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
profile: &CompileProfile,
) -> CompiledGraph {
let mut compiled = rlx_models::flow_bridge::compile_graph_with_profile(device, graph, profile)
.expect("compile_graph_with_profile");
attach_params(&mut compiled, ¶ms);
compiled
}
pub fn compile_sam(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::sam_encoder())
}
pub fn compile_encoder(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::encoder())
}
pub fn compile_qwen35_prefill(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::qwen35_prefill())
}
pub fn compile_qwen35_decode(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::qwen35_decode())
}
pub fn compile_qwen3_prefill(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::qwen3_prefill())
}
pub fn compile_llama32_prefill(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::llama32_prefill())
}
pub fn compile_llama32_decode(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::llama32_decode())
}
pub fn compile_llada2(
device: Device,
graph: Graph,
params: HashMap<String, Vec<f32>>,
) -> CompiledGraph {
compile_with_profile(device, graph, params, &CompileProfile::llada2_diffusion())
}