mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 19:18:50 +00:00
Add a matvec cpu benchmark. (#1076)
This commit is contained in:
@ -180,8 +180,25 @@ impl Benchmark for Conv2dIm2Col {
|
|||||||
const ITERS: usize = 5;
|
const ITERS: usize = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Matmul;
|
struct MatMul;
|
||||||
impl Benchmark for Matmul {
|
impl Benchmark for MatMul {
|
||||||
|
type PreProcessData = (Tensor, Tensor);
|
||||||
|
type RunResult = Tensor;
|
||||||
|
fn preprocess() -> Result<Self::PreProcessData> {
|
||||||
|
let lhs = Tensor::randn(0f32, 1., (1024, 1024), &Device::Cpu)?;
|
||||||
|
let rhs = Tensor::randn(0f32, 1., (1024, 1024), &Device::Cpu)?;
|
||||||
|
Ok((lhs, rhs))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_one(d: &Self::PreProcessData) -> Result<Self::RunResult> {
|
||||||
|
d.0.matmul(&d.1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const ITERS: usize = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MatVec;
|
||||||
|
impl Benchmark for MatVec {
|
||||||
type PreProcessData = (Tensor, Tensor);
|
type PreProcessData = (Tensor, Tensor);
|
||||||
type RunResult = Tensor;
|
type RunResult = Tensor;
|
||||||
fn preprocess() -> Result<Self::PreProcessData> {
|
fn preprocess() -> Result<Self::PreProcessData> {
|
||||||
@ -271,6 +288,7 @@ enum Task {
|
|||||||
Conv2d,
|
Conv2d,
|
||||||
Conv2dIm2Col,
|
Conv2dIm2Col,
|
||||||
Matmul,
|
Matmul,
|
||||||
|
Matvec,
|
||||||
Qmatmul,
|
Qmatmul,
|
||||||
Softmax,
|
Softmax,
|
||||||
SoftmaxLastDim,
|
SoftmaxLastDim,
|
||||||
@ -293,7 +311,8 @@ fn main() -> Result<()> {
|
|||||||
Task::Conv1d => run::<Conv1d>(args.iters)?,
|
Task::Conv1d => run::<Conv1d>(args.iters)?,
|
||||||
Task::Conv2d => run::<Conv2d>(args.iters)?,
|
Task::Conv2d => run::<Conv2d>(args.iters)?,
|
||||||
Task::Conv2dIm2Col => run::<Conv2dIm2Col>(args.iters)?,
|
Task::Conv2dIm2Col => run::<Conv2dIm2Col>(args.iters)?,
|
||||||
Task::Matmul => run::<Matmul>(args.iters)?,
|
Task::Matmul => run::<MatMul>(args.iters)?,
|
||||||
|
Task::Matvec => run::<MatVec>(args.iters)?,
|
||||||
Task::Softmax => run::<Softmax>(args.iters)?,
|
Task::Softmax => run::<Softmax>(args.iters)?,
|
||||||
Task::SoftmaxLastDim => run::<SoftmaxLastDim>(args.iters)?,
|
Task::SoftmaxLastDim => run::<SoftmaxLastDim>(args.iters)?,
|
||||||
Task::Qmatmul => run::<QMatMul>(args.iters)?,
|
Task::Qmatmul => run::<QMatMul>(args.iters)?,
|
||||||
|
Reference in New Issue
Block a user