engine/rr: hardware FP8 saturation for the f32 conversions
RADV lowers saturatedConvertEXT to FP8 as a NaN-preserving clamp per element (v_minimummaximum_f32) followed by v_cvt_pk_fp8_f32, because the hardware's FP16_OVFL saturation turns infinities into NaN instead of +-448. Run over all 2^32 f32 inputs on an RX 9070 XT, FP16_OVFL gives the clamp's result for every finite value and NaN; only +-Inf differ. The f32 values the native stages convert are never infinite (sums of FP8 products and binary16 biases, far below 3.4e38). Writing the conversion as "an infinity becomes NaN, then saturate" (FINITE in rr_exact.glsl) makes it the pattern nir_opt_algebraic turns into f2e4m3fn_satfn (vkd3d-proton's, Mesa >= 25.2, the same release that added the FP8 conversions): the hardware conversion with FP16_OVFL and no clamp. RR_SAT_CLAMP=1 builds the old form. 168 - 232 fewer instructions per network stage (enc0 960 -> 128 clamps). Every image byte-identical on the replay inputs (also robustness2). RX 9070 XT, 720p -> 1440p: frame 3.92 -> 3.79 ms, every network stage faster (dec0_1 607 -> 576 us, enc0 752 -> 727, enc1 262 -> 247). Signed-off-by: itchyfeetleech <[email protected]>
This commit is contained in:
1 parent
2fa4561bc1
commit
e46c589c68
4 files changed
+31
-7
No files matched your search
@@ -90,7 +90,7 @@ layout(set = 0, binding = 2, std430) buffer Arena { uint w[]; } arena;
|
||||
#define E4V(w, b) float(uintBitsToFloate4m3EXT(uint8_t(((w) >> (8u * (b))) & 0xffu)))
|
||||
#define RESID(d, a, s, c) const float d = fma(float(a), float(s), float(c));
|
||||
#define Q8R(x) q8s(x)
|
||||
#define ACT8(dst, h) [[unroll]] for (int i_ = 0; i_ < 8; i_ += 2) { const vec2 x_ = vec2(float((h)[i_]), float((h)[i_ + 1])); const vec2 y_ = clamp(x_, vec2(-2.0), vec2(2.0)); const vec2 g_ = fma(y_, fma(-abs(y_), vec2(0.0810546875), vec2(0.412109375)), vec2(0.5)); fe4m3vec2 t_; saturatedConvertEXT(t_, x_ * g_); (dst)[i_] = t_.x; (dst)[i_ + 1] = t_.y; }
|
||||
#define ACT8(dst, h) [[unroll]] for (int i_ = 0; i_ < 8; i_ += 2) { const vec2 x_ = vec2(float((h)[i_]), float((h)[i_ + 1])); const vec2 y_ = clamp(x_, vec2(-2.0), vec2(2.0)); const vec2 g_ = fma(y_, fma(-abs(y_), vec2(0.0810546875), vec2(0.412109375)), vec2(0.5)); fe4m3vec2 t_; saturatedConvertEXT(t_, FINITE2(x_ * g_)); (dst)[i_] = t_.x; (dst)[i_ + 1] = t_.y; }
|
||||
#else
|
||||
#define RVT float16_t
|
||||
#define E4V(w, b) e4((w), (b))
|
||||
|
||||
Reference in new issue
Block a user