This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/tests/r4d_emu/ref_host.h
T
baKon 51293b269c tests: lora_test and r4d_emu_lora over one shared case matrix
lora_cases.h holds the matrix (M 1/3/17/64/130, R 16/32/48, S 4, K and N 64/256/1000, a bf16 or
E4M3 with a 128-column scale, y bf16/f32, f16/f32/E5M2/i8 once; a, a_scale and y as column
slices; slots -1, -5, 0..3 and S) and the checks: base rows untouched by bytes (a sentinel NaN in
t, -0 in y), adapter rows against an f64 sum within (K + 2) 2^-24 sum|terms| (shrink) and half an
ulp of y plus 4 (R + 2) 2^-24 (|y| + |scale| sum|terms|) (expand).

lora_test runs libref and libavx at every ISA level through rad_plugin_open (libavx builds its fp8
decode table there). r4d_emu_lora runs libr4d's source on the SIMT emulator beside ref_host.cpp
and libref, expand bit for bit.
2026-10-16 20:52:09 -05:00

24 lines
991 B
C

/* ref_host.h -- host C++ versions of the libr4d units r4d_emu runs.
*
* Each restates a device kernel's arithmetic, RadArgs in and RAD_OK or an error out. Tests hold
* the emulated kernels to these, beside the unfused chain each test builds (the joins,
* expert_scale) or a brute force (pair_argmax). No HIP, no libr4d header. */
#pragma once
#include "rad_abi.h"
#include "rad_plugin.h"
/* bf16 as libr4d converts it: exact widening, round-to-nearest-even narrowing. rb() is a value
* stored to bf16 and read back. */
inline float b2f(uint16_t h) { return rad_bf16_to_f32(h); }
inline uint16_t f2b(float f) { return rad_f32_to_bf16(f); }
inline float rb(float f) { return b2f(f2b(f)); }
int host_pair_argmax(const RadArgs* a);
int host_norm_add_norm(const RadArgs* a);
int host_norm_add_norm_route(const RadArgs* a);
int host_join_add_scale(const RadArgs* a);
int host_expert_scale(const RadArgs* a);
int host_lora_shrink(const RadArgs* a);
int host_lora_expand(const RadArgs* a);