use anyhow::Result;
use clankers_ml::ModelValidator;
pub fn execute(
pytorch: Option<&str>,
checkpoint: Option<&str>,
onnx: &str,
samples: &str,
tolerance: f32,
) -> Result<()> {
if pytorch.is_some() || checkpoint.is_some() {
anyhow::bail!(
"--pytorch/--checkpoint are not supported yet: live PyTorch comparison \
is planned but not implemented, and silently ignoring these flags could \
produce a misleading pass.\n\
Instead: export reference outputs next to your sample inputs as \
`expected_output.json` (see `clankers import-pytorch` and \
docs/pytorch_to_onnx.md), then run:\n \
clankers validate-model --onnx {onnx} --samples {samples}"
);
}
let report = ModelValidator::new()
.onnx_model(onnx)
.sample_inputs(samples)
.tolerance(tolerance)
.validate()
.map_err(|e| anyhow::anyhow!("{e}"))?;
report.print();
if !report.passed {
anyhow::bail!("model validation failed");
}
Ok(())
}