Skip to content

Commit

Permalink
Merge pull request #60 from robertknight/gemv-bench
Browse files Browse the repository at this point in the history
Add benchmark for vector-matrix product
  • Loading branch information
robertknight authored Mar 18, 2024
2 parents ff8d22d + fb5db6a commit c4ca855
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup rust
- name: Install Rust wasm toolchain
run: rustup target add wasm32-unknown-unknown
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install wasm-bindgen
Expand Down
10 changes: 10 additions & 0 deletions src/gemm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ mod tests {
n: 128,
k: 512,
},
// Vector-matrix. This is common in transformer decoders for example.
Case {
m: 1,
n: 4096,
k: 512,
},
];

println!("Testing kernel {}", GemmExecutor::new().kernel_name());
Expand All @@ -1473,6 +1479,10 @@ mod tests {
let target_ops: u64 = 512 * 512 * 512 * 1000;
let iters = target_ops / (m * n * k) as u64;

// Cap the number of iterations, for cases where the equal-efficiency
// assumption is untrue.
let iters = iters.min(1000);

let mut rng = XorShiftRng::new(1234);
let mut result = Tensor::zeros(&[m, n]);
let a = Tensor::rand(&[m, k], &mut rng);
Expand Down

0 comments on commit c4ca855

Please sign in to comment.