@@ -25,13 +25,13 @@ kf::vec<float, 4> c = kf::fast_rcp(x);
2525kf::vec<float, 4> d = kf::fast_div(a, b);
2626```
2727
28- These functions are only functional for 32-bit and 16-bit floats.
28+ These functions are only functional for 32-bit and 16-bit floats.
2929For other input types, the operation falls back to the regular version.
3030
3131## Approximate Math
3232
33- For 16-bit floats, several approximate functions are provided.
34- These use approximations (typically low-degree polynomials) to calculate rough estimates of the functions.
33+ For 16-bit floats, several approximate functions are provided.
34+ These use approximations (typically low-degree polynomials) to calculate rough estimates of the functions.
3535This can be very fast but also less accurate.
3636
3737
@@ -69,14 +69,15 @@ kf::vec<half, 4> a = kf::approx_sin<3>(x);
6969
7070## Tuning Accuracy Level
7171
72- Many functions in Kernel Float accept an additional Accuracy option as a template parameter.
72+ Many functions in Kernel Float accept an additional ` Accuracy` option as a template parameter.
7373This allows you to tune the accuracy level without changing the function name.
7474
75- There are four possible values for this parameter:
75+ There are five possible values for this parameter:
7676
7777- `kf::accurate_policy`: Use the most accurate version of the function available.
7878- `kf::fast_policy`: Use the "fast math" version.
79- - `kf::approx_policy<N>`: Use the approximate version with degree `N`.
79+ - `kf::approx_level_policy<N>`: Use the approximate version with accuracy level `N` (higher is more accurate).
80+ - `kf::approx_policy`: Use the approximate version with a default accuracy level.
8081- `kf::default_policy`: Use a global default policy (see the next section).
8182
8283For example, consider this code:
@@ -97,15 +98,19 @@ kf::vec<float, 2> c = kf::cos<kf::accurate_policy>(input);
9798kf::vec<float, 2> d = kf::cos<kf::fast_policy>(input);
9899
99100// Use the approximate policy
100- kf::vec<float, 2> e = kf::cos<kf::approx_policy<3>>(input);
101+ kf::vec<float, 2> e = kf::cos<kf::approx_policy>(input);
102+
103+ // Use the approximate policy with degree 3 polynomial.
104+ kf::vec<float, 2> f = kf::cos<kf::approx_level_policy<3>>(input);
101105
102106// You can use aliases to define your own policy
103107using my_own_policy = kf::fast_policy;
104- kf::vec<float, 2> f = kf::cos<my_own_policy>(input);
108+ kf::vec<float, 2> g = kf::cos<my_own_policy>(input);
105109```
106110
107111## Setting `default_policy`
108112
113+ If no policy is explicitly set, any function use the `kf::default_policy`.
109114By default, `kf::default_policy` is set to `kf::accurate_policy`.
110115
111116Set the preprocessor option `KERNEL_FLOAT_FAST_MATH=1` to change the default policy to `kf::fast_policy`.
0 commit comments