MCPcopy Create free account
hub / github.com/carsonpo/haystackdb / gemm

Function gemm

src/math/gemm.rs:3–17  ·  view source on GitHub ↗
(
    a: &Vec<[f32; VECTOR_SIZE]>,
    b: &Vec<[f32; VECTOR_SIZE]>,
    result: &mut Vec<[f32; VECTOR_SIZE]>,
)

Source from the content-addressed store, hash-verified

1use crate::constants::VECTOR_SIZE;
2
3pub fn gemm(
4 a: &Vec<[f32; VECTOR_SIZE]>,
5 b: &Vec<[f32; VECTOR_SIZE]>,
6 result: &mut Vec<[f32; VECTOR_SIZE]>,
7) {
8 for i in 0..a.len() {
9 for j in 0..VECTOR_SIZE {
10 let mut sum = 0.0_f32;
11 for k in 0..VECTOR_SIZE {
12 sum += a[i][k] * b[k][j];
13 }
14 result[i][j] = sum;
15 }
16 }
17}

Callers 4

criterion_benchmarkFunction · 0.85
test_gemm_identityFunction · 0.85
test_gemm_zeroFunction · 0.85
test_gemm_onesFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by 3

test_gemm_identityFunction · 0.68
test_gemm_zeroFunction · 0.68
test_gemm_onesFunction · 0.68