Tweak/add kind to gelu benchmark name (#1533)

* Add kind to gelu benchmark name

* [backend-comparison] Compute column size in benchmarks report
This commit is contained in:
Sylvain Benner 2024-03-28 12:35:15 -04:00 committed by GitHub
parent 279be0496a
commit 32a8d8041c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 9 deletions

View File

@ -27,10 +27,9 @@ impl<B: Backend, const D: usize> Benchmark for CustomGeluBenchmark<B, D> {
fn name(&self) -> String { fn name(&self) -> String {
match self.autodiff { match self.autodiff {
true => "gelu_autodiff", true => format!("gelu_autodiff_{:?}", self.kind),
false => "gelu", false => format!("gelu_{:?}", self.kind),
} }
.into()
} }
fn options(&self) -> Option<String> { fn options(&self) -> Option<String> {

View File

@ -242,20 +242,33 @@ pub(crate) struct BenchmarkCollection {
impl Display for BenchmarkCollection { impl Display for BenchmarkCollection {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// Compute the max length for each column
let mut max_name_len = 0;
let mut max_backend_len = 0;
for record in self.records.iter() {
let backend_name = [record.backend.clone(), record.device.clone()].join("-");
max_name_len = max_name_len.max(record.results.name.len());
max_backend_len = max_backend_len.max(backend_name.len());
}
// Header
writeln!( writeln!(
f, f,
"| {0:<15}| {1:<35}| {2:<15}|\n|{3:-<16}|{4:-<36}|{5:-<16}|", "| {:<width_name$} | {:<width_backend$} | Median |\n|{:->width_name$}--|{:->width_backend$}--|----------------|",
"Benchmark", "Backend", "Median", "", "", "" "Benchmark", "Backend", "", "", width_name = max_name_len, width_backend = max_backend_len
)?; )?;
// Table entries
for record in self.records.iter() { for record in self.records.iter() {
let backend = [record.backend.clone(), record.device.clone()].join("-"); let backend_name = [record.backend.clone(), record.device.clone()].join("-");
writeln!( writeln!(
f, f,
"| {0:<15}| {1:<35}| {2:<15.3?}|", "| {:<width_name$} | {:<width_backend$} | {:<15.3?}|",
record.results.name, backend, record.results.computed.median record.results.name,
backend_name,
record.results.computed.median,
width_name = max_name_len,
width_backend = max_backend_len
)?; )?;
} }
Ok(()) Ok(())
} }
} }