Skip to content

Commit 4fca9cb

Browse files
committed
Add approximation functions
1 parent de62ad0 commit 4fca9cb

File tree

9 files changed

+875
-36
lines changed

9 files changed

+875
-36
lines changed

include/kernel_float.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef KERNEL_FLOAT_H
22
#define KERNEL_FLOAT_H
33

4+
#include "kernel_float/approx.h"
45
#include "kernel_float/base.h"
56
#include "kernel_float/bf16.h"
67
#include "kernel_float/binops.h"

include/kernel_float/apply.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ struct apply_impl {
130130

131131
template<typename F, size_t N, typename Output, typename... Args>
132132
struct apply_fastmath_impl: apply_impl<F, N, Output, Args...> {};
133+
134+
template<int Deg, typename F, size_t N, typename Output, typename... Args>
135+
struct apply_approx_impl: apply_fastmath_impl<F, N, Output, Args...> {};
133136
} // namespace detail
134137

135138
struct accurate_policy {
@@ -142,6 +145,14 @@ struct fast_policy {
142145
using type = detail::apply_fastmath_impl<F, N, Output, Args...>;
143146
};
144147

148+
template<int Degree = -1>
149+
struct approximate_policy {
150+
template<typename F, size_t N, typename Output, typename... Args>
151+
using type = detail::apply_approx_impl<Degree, F, N, Output, Args...>;
152+
};
153+
154+
using default_approximate_policy = approximate_policy<>;
155+
145156
#ifdef KERNEL_FLOAT_POLICY
146157
using default_policy = KERNEL_FLOAT_POLICY;
147158
#else

0 commit comments

Comments
 (0)