Skip to content

Commit adcdb6e

Browse files
author
Andrea Belano
committed
Fix sw tests
1 parent 675e965 commit adcdb6e

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

golden-model/FP16/scripts/pace.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77

88
import numpy as np
9-
import os
9+
import os
1010

1111
def float16_to_hex(f16_val):
1212
arr = np.array(f16_val, dtype=np.float16).reshape(())
@@ -184,18 +184,18 @@ def write_x_file(coeffs, xmin=-6, xmax=6, partitions=8, stimuli_file="x_input.h"
184184
f_x.write('};\n')
185185
print(f"✅ x_input header written to: {stimuli_file}")
186186

187-
187+
188188

189189
def write_inp_inc_file(results, stimuli_file="w_input.h"):
190-
size = len(results["x_vals"])
190+
size = len(results["x_vals"])
191191
with open(stimuli_file, "w") as f:
192192
f.write(f' uint16_t w_inp [{size}] =' +'{')
193193
for i, x in enumerate(results["x_vals"]):
194194
if i%8==0:
195195
f.write('\n')
196-
if i == size - 1:
196+
if i == size - 1:
197197
f.write(f" {float16_to_hex(x)}\n")
198-
else:
198+
else:
199199
f.write(f" {float16_to_hex(x)},")
200200
f.write('};\n')
201201
print(f"✅ Stimuli header written to: {stimuli_file}")
@@ -207,8 +207,8 @@ def write_golden_oup_inc_file(results, stimuli_file="golden.h"):
207207
with open(stimuli_file, "w") as f:
208208
f.write(f'uint32_t golden[{size}] = {{\n')
209209
for i in range(0, len(y_approx), 2):
210-
low_16 = float16_to_hex(y_approx[i]).removeprefix("0x")
211-
high_16 = float16_to_hex(y_approx[i + 1]).removeprefix("0x")
210+
low_16 = float16_to_hex(y_approx[i]).replace("0x", "")
211+
high_16 = float16_to_hex(y_approx[i + 1]).replace("0x", "")
212212
combined = f"0x{high_16}{low_16}"
213213
end_char = ',\n' if i < len(y_approx) - 2 else '\n'
214214
f.write(f"{combined}{end_char}")
@@ -217,7 +217,7 @@ def write_golden_oup_inc_file(results, stimuli_file="golden.h"):
217217

218218
def write_golden_inc_debug_file(results, stimuli_file="golden_debug.h"):
219219
y_approx = results["y_approx"]
220-
size = len(y_approx)
220+
size = len(y_approx)
221221

222222
with open(stimuli_file, "w") as f:
223223
f.write(f'uint32_t golden[{size}] = {{')
@@ -259,6 +259,7 @@ def write_tensor_dim_inc_file(stimuli_file = "tensor_dim.h", n_tests=1000):
259259
f_d.write('#define DST_FMT FP16\n' )
260260
f_d.write('#define FPFORMAT 16\n' )
261261
f_d.write('uint8_t gemm_ops = PACE; \n' )
262+
f_d.write('uint8_t quant_fmt = 0; \n' )
262263
f_d.write('\n#endif\n' )
263264
f_d.close()
264265

@@ -287,7 +288,7 @@ def write_tensor_dim_inc_file(stimuli_file = "tensor_dim.h", n_tests=1000):
287288
write_actual_oup_inc_file(results, stimuli_file=os.path.join(args.inc_dir, "z_output.h"))
288289
write_golden_inc_debug_file(results, stimuli_file=os.path.join(args.txt_dir, "golden_debug.h"))
289290
write_y_inp_inc_file(stimuli_file=os.path.join(args.inc_dir, "y_input.h"))
290-
write_x_file(coeffs=results["coeffs"], xmin=args.x_min, xmax=args.x_max, partitions=8, stimuli_file=os.path.join(args.inc_dir, "x_input.h"))
291+
write_x_file(coeffs=results["coeffs"], xmin=args.x_min, xmax=args.x_max, partitions=8, stimuli_file=os.path.join(args.inc_dir, "x_input.h"))
291292
write_tensor_dim_inc_file(stimuli_file=os.path.join(args.inc_dir, "tensor_dim.h"), n_tests=args.n_tests)
292293

293294

sw/redmule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int main() {
7474

7575

7676
redmule_cfg((unsigned int)x, (unsigned int)w, (unsigned int)y, (unsigned int)g, (unsigned int)s, (unsigned int)b, m_size, n_size, k_size,
77-
(uint8_t)gemm_ops, float_fmt, d_en, float_fmt);
77+
(uint8_t)gemm_ops, float_fmt, d_en, quant_fmt);
7878

7979
// Start RedMulE operation and sleeping until the end of computation
8080
printf("Triggering accelerator and going to sleep...\n");

0 commit comments

Comments
 (0)