Skip to main content

rlx_fft/
study_html.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! Unified HTML study report — delegates to [`crate::study_full_html`].
17
18use crate::ablation::AblationReport;
19use crate::study_full_html::{FullStudyInputs, write_full_study_html};
20use crate::study_telemetry::StudyTelemetryBundle;
21use crate::train_multi::MultiTrainReport;
22use anyhow::Result;
23use std::path::Path;
24
25#[derive(Debug, Clone, Default)]
26pub struct StudyInputs {
27    pub ablation: Option<AblationReport>,
28    pub multi_train: Option<MultiTrainReport>,
29    pub telemetry: Option<StudyTelemetryBundle>,
30}
31
32pub fn write_study_html(path: &Path, inputs: &StudyInputs) -> Result<()> {
33    write_full_study_html(
34        path,
35        &FullStudyInputs {
36            ablation: inputs.ablation.clone(),
37            multi_train: inputs.multi_train.clone(),
38            telemetry: inputs.telemetry.clone(),
39        },
40    )
41}
42
43pub fn render_study_html(inputs: &StudyInputs) -> String {
44    crate::study_full_html::render_full_study_html(&FullStudyInputs {
45        ablation: inputs.ablation.clone(),
46        multi_train: inputs.multi_train.clone(),
47        telemetry: inputs.telemetry.clone(),
48    })
49}
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54    use crate::ablation::AblationRow;
55
56    #[test]
57    fn render_study_html_smoke() {
58        let inputs = StudyInputs {
59            ablation: Some(crate::ablation::AblationReport {
60                iters: 10,
61                train_steps: 0,
62                both_dirs: true,
63                with_welch: true,
64                limit_sweep: false,
65                n_ffts: vec![256],
66                elapsed_ms: 1.0,
67                rows: vec![AblationRow {
68                    tier: "baseline".into(),
69                    variant: "rustfft".into(),
70                    direction: "Forward".into(),
71                    n_fft: 256,
72                    batch: 8,
73                    device: "cpu".into(),
74                    iters: 10,
75                    ms: 0.01,
76                    max_err: 0.0,
77                    train_steps: 0,
78                    param_count: 0,
79                    memory_bytes: 0,
80                    status: "ok".into(),
81                    note: None,
82                }],
83            }),
84            multi_train: None,
85            telemetry: None,
86        };
87        let html = render_study_html(&inputs);
88        assert!(html.contains("RLX-FFT Full Study Report"));
89        assert!(html.contains("rustfft"));
90    }
91}