Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make backend names in JSON reports match burnbench CLI #1375

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions backend-comparison/benches/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,25 @@ impl<B: Backend, const D: usize> Benchmark for BinaryBenchmark<B, D> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
let benchmark = BinaryBenchmark::<B, 3> {
shape: [32, 512, 1024].into(),
device: device.clone(),
};

save::<B>(vec![run_benchmark(benchmark)], device, url, token).unwrap();
save::<B>(
vec![run_benchmark(benchmark)],
device,
feature_name,
url,
token,
)
.unwrap();
}

fn main() {
Expand Down
16 changes: 14 additions & 2 deletions backend-comparison/benches/conv_transpose2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ impl<B: Backend> Benchmark for ConvTranspose2dBenchmark<B> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
// Shapes
let batch_size = 16;
let channels_in = 16;
Expand Down Expand Up @@ -85,7 +90,14 @@ fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>)
device: device.clone(),
};

save::<B>(vec![run_benchmark(benchmark)], device, url, token).unwrap();
save::<B>(
vec![run_benchmark(benchmark)],
device,
feature_name,
url,
token,
)
.unwrap();
}

fn main() {
Expand Down
8 changes: 7 additions & 1 deletion backend-comparison/benches/custom_gelu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ fn erf_positive<B: Backend, const D: usize>(x: Tensor<B, D>) -> Tensor<B, D> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
const D: usize = 3;
let shape: Shape<D> = [32, 512, 2048].into();

Expand Down Expand Up @@ -144,6 +149,7 @@ fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>)
run_benchmark(custom_erf_gelu),
],
device,
feature_name,
url,
token,
)
Expand Down
8 changes: 7 additions & 1 deletion backend-comparison/benches/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ impl<B: Backend, const D: usize> Benchmark for FromDataBenchmark<B, D> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
const D: usize = 3;
let shape: Shape<D> = [32, 512, 1024].into();

Expand All @@ -81,6 +86,7 @@ fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>)
save::<B>(
vec![run_benchmark(to_benchmark), run_benchmark(from_benchmark)],
device,
feature_name,
url,
token,
)
Expand Down
16 changes: 14 additions & 2 deletions backend-comparison/benches/matmul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ impl<B: Backend, const D: usize> Benchmark for MatmulBenchmark<B, D> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
const D: usize = 3;
let batch_size = 3;
let m = 1024;
Expand All @@ -53,7 +58,14 @@ fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>)

let benchmark = MatmulBenchmark::<B, D>::new(shape_lhs, shape_rhs, device.clone());

save::<B>(vec![run_benchmark(benchmark)], device, url, token).unwrap();
save::<B>(
vec![run_benchmark(benchmark)],
device,
feature_name,
url,
token,
)
.unwrap();
}

fn main() {
Expand Down
16 changes: 14 additions & 2 deletions backend-comparison/benches/max_pool2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ impl<B: Backend> Benchmark for MaxPool2dBenchmark<B> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
let benchmark = MaxPool2dBenchmark::<B> {
shape: [32, 32, 512, 512].into(),
kernel_size: [5, 5],
Expand All @@ -52,7 +57,14 @@ fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>)
device: device.clone(),
};

save::<B>(vec![run_benchmark(benchmark)], device, url, token).unwrap();
save::<B>(
vec![run_benchmark(benchmark)],
device,
feature_name,
url,
token,
)
.unwrap();
}

fn main() {
Expand Down
16 changes: 14 additions & 2 deletions backend-comparison/benches/unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,25 @@ impl<B: Backend, const D: usize> Benchmark for UnaryBenchmark<B, D> {
}

#[allow(dead_code)]
fn bench<B: Backend>(device: &B::Device, url: Option<&str>, token: Option<&str>) {
fn bench<B: Backend>(
device: &B::Device,
feature_name: &str,
url: Option<&str>,
token: Option<&str>,
) {
const D: usize = 3;
let shape: Shape<D> = [32, 512, 1024].into();

let benchmark = UnaryBenchmark::<B, D>::new(shape, device.clone());

save::<B>(vec![run_benchmark(benchmark)], device, url, token).unwrap();
save::<B>(
vec![run_benchmark(benchmark)],
device,
feature_name,
url,
token,
)
.unwrap();
}

fn main() {
Expand Down
43 changes: 36 additions & 7 deletions backend-comparison/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,41 @@ macro_rules! bench_on_backend {
let args: Vec<String> = env::args().collect();
let url = backend_comparison::get_sharing_url(&args);
let token = backend_comparison::get_sharing_token(&args);
#[cfg(feature = "candle-accelerate")]
let feature_name = "candle-accelerate";
#[cfg(feature = "candle-cpu")]
let feature_name = "candle-cpu";
#[cfg(feature = "candle-cuda")]
let feature_name = "candle-cuda";
#[cfg(feature = "candle-metal")]
let feature_name = "candle-metal";
#[cfg(feature = "ndarray")]
let feature_name = "ndarray";
#[cfg(feature = "ndarray-blas-accelerate")]
let feature_name = "ndarray-blas-accelerate";
#[cfg(feature = "ndarray-blas-netlib")]
let feature_name = "ndarray-blas-netlib";
#[cfg(feature = "ndarray-blas-openblas")]
let feature_name = "ndarray-blas-openblas";
#[cfg(feature = "tch-cpu")]
let feature_name = "tch-cpu";
#[cfg(feature = "tch-gpu")]
let feature_name = "tch-gpu";
#[cfg(feature = "wgpu")]
let feature_name = "wgpu";
#[cfg(feature = "wgpu-fusion")]
let feature_name = "wgpu-fusion";

#[cfg(feature = "wgpu")]
{
use burn::backend::wgpu::{AutoGraphicsApi, Wgpu, WgpuDevice};

bench::<Wgpu<AutoGraphicsApi, f32, i32>>(&WgpuDevice::default(), url, token);
bench::<Wgpu<AutoGraphicsApi, f32, i32>>(
&WgpuDevice::default(),
feature_name,
url,
token,
);
}

#[cfg(feature = "tch-gpu")]
Expand All @@ -49,15 +78,15 @@ macro_rules! bench_on_backend {
let device = LibTorchDevice::Cuda(0);
#[cfg(target_os = "macos")]
let device = LibTorchDevice::Mps;
bench::<LibTorch>(&device, url, token);
bench::<LibTorch>(&device, feature_name, url, token);
}

#[cfg(feature = "tch-cpu")]
{
use burn::backend::{libtorch::LibTorchDevice, LibTorch};

let device = LibTorchDevice::Cpu;
bench::<LibTorch>(&device, url, token);
bench::<LibTorch>(&device, feature_name, url, token);
}

#[cfg(any(
Expand All @@ -71,7 +100,7 @@ macro_rules! bench_on_backend {
use burn::backend::NdArray;

let device = NdArrayDevice::Cpu;
bench::<NdArray>(&device, url, token);
bench::<NdArray>(&device, feature_name, url, token);
}

#[cfg(feature = "candle-cpu")]
Expand All @@ -80,7 +109,7 @@ macro_rules! bench_on_backend {
use burn::backend::Candle;

let device = CandleDevice::Cpu;
bench::<Candle>(&device, url, token);
bench::<Candle>(&device, feature_name, url, token);
}

#[cfg(feature = "candle-cuda")]
Expand All @@ -89,7 +118,7 @@ macro_rules! bench_on_backend {
use burn::backend::Candle;

let device = CandleDevice::Cuda(0);
bench::<Candle>(&device, url, token);
bench::<Candle>(&device, feature_name, url, token);
}

#[cfg(feature = "candle-metal")]
Expand All @@ -98,7 +127,7 @@ macro_rules! bench_on_backend {
use burn::backend::Candle;

let device = CandleDevice::Metal(0);
bench::<Candle>(&device, url, token);
bench::<Candle>(&device, feature_name, url, token);
}
};
}
Expand Down
Loading
Loading