Skip to content

Commit

Permalink
Add approximation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnh committed Nov 18, 2024
1 parent de62ad0 commit 4fca9cb
Show file tree
Hide file tree
Showing 9 changed files with 875 additions and 36 deletions.
1 change: 1 addition & 0 deletions include/kernel_float.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef KERNEL_FLOAT_H
#define KERNEL_FLOAT_H

#include "kernel_float/approx.h"
#include "kernel_float/base.h"
#include "kernel_float/bf16.h"
#include "kernel_float/binops.h"
Expand Down
11 changes: 11 additions & 0 deletions include/kernel_float/apply.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ struct apply_impl {

template<typename F, size_t N, typename Output, typename... Args>
struct apply_fastmath_impl: apply_impl<F, N, Output, Args...> {};

template<int Deg, typename F, size_t N, typename Output, typename... Args>
struct apply_approx_impl: apply_fastmath_impl<F, N, Output, Args...> {};
} // namespace detail

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

template<int Degree = -1>
struct approximate_policy {
template<typename F, size_t N, typename Output, typename... Args>
using type = detail::apply_approx_impl<Degree, F, N, Output, Args...>;
};

using default_approximate_policy = approximate_policy<>;

#ifdef KERNEL_FLOAT_POLICY
using default_policy = KERNEL_FLOAT_POLICY;
#else
Expand Down
Loading

0 comments on commit 4fca9cb

Please sign in to comment.