Skip to content

Commit

Permalink
gemm datagen with linspace option
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbarton committed Jan 15, 2024
1 parent 5c01510 commit 7de1bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sw/blas/gemm/data/datagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ def emit_header(**kwargs):
b = sign_b << 7 | exponent_b << FP8_FORMATS['fp8']['mant'] | mantissa_b
c = sign_c << 7 | exponent_c << FP8_FORMATS['fp8']['mant'] | mantissa_c
else:
a = np.random.rand(kwargs['M'], kwargs['K']).astype(dtype)
b = np.random.rand(kwargs['K'], kwargs['N']).astype(dtype)
c = np.random.rand(kwargs['M'], kwargs['N']).astype(dtype)
if kwargs['linspace']:
a = np.linspace(0.1, kwargs['M'] * kwargs['K'] + 0.1 -1, num=kwargs['M'] * kwargs['K']).reshape((kwargs['M'], kwargs['K'])).astype(dtype)
b = np.linspace(0.2, kwargs['K'] * kwargs['N'] + 0.2 -1, num=kwargs['K'] * kwargs['N']).reshape((kwargs['K'], kwargs['N'])).astype(dtype)
c = np.linspace(0.3, kwargs['M'] * kwargs['N'] + 0.3 -1, num=kwargs['M'] * kwargs['N']).reshape((kwargs['M'], kwargs['N'])).astype(dtype)
else:
a = np.random.rand(kwargs['M'], kwargs['K']).astype(dtype)
b = np.random.rand(kwargs['K'], kwargs['N']).astype(dtype)
c = np.random.rand(kwargs['M'], kwargs['N']).astype(dtype)
result = golden_model(a, b, kwargs['alpha'], c)

# Store matrices in transposed form if requested
Expand Down
1 change: 1 addition & 0 deletions sw/blas/gemm/data/params.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
tb: true, // must be true for SIMD
prec: 64,
expand: 0
linspace: true
}

0 comments on commit 7de1bb0

Please sign in to comment.