summaryrefslogtreecommitdiff
path: root/candle-core/examples/conv1d_benchmark.rs
blob: 52fae5e811b10712ff8639bb52b2f2c89c689a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;

#[cfg(feature = "accelerate")]
extern crate accelerate_src;

use anyhow::Result;
use candle_core::{Device, Tensor};

pub const N_ITERS: usize = 5;

fn main() -> Result<()> {
    let inp = Tensor::randn(0f32, 1., (1, 384, 3000), &Device::Cpu)?;
    let w = Tensor::randn(0f32, 1., (384, 384, 3), &Device::Cpu)?;
    let res = inp.conv1d(&w, 0, 1);
    println!("{res:?}");
    let start = std::time::Instant::now();
    for i in 0..N_ITERS {
        let res = inp.conv1d(&w, 0, 1);
        println!("{i} {res:?}");
    }
    println!("{:?}", start.elapsed() / N_ITERS as u32);
    Ok(())
}