Skip to content

Commit

Permalink
Small bits, coverage improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Nov 2, 2023
1 parent c2b0e94 commit 9c04d4e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/heyoka/math/sin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef HEYOKA_MATH_SIN_HPP
#define HEYOKA_MATH_SIN_HPP

#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
10 changes: 9 additions & 1 deletion src/math/cos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <boost/numeric/conversion/cast.hpp>

#include <fmt/format.h>
#include <fmt/core.h>

#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/DerivedTypes.h>
Expand Down Expand Up @@ -223,6 +223,8 @@ llvm::Value *taylor_diff_cos_impl(llvm_state &s, llvm::Type *fp_t, const cos_imp
return llvm_fdiv(s, ret_acc, div);
}

// LCOV_EXCL_START

// All the other cases.
template <typename U, std::enable_if_t<!is_num_param_v<U>, int> = 0>
llvm::Value *taylor_diff_cos_impl(llvm_state &, llvm::Type *, const cos_impl &, const std::vector<std::uint32_t> &,
Expand All @@ -233,6 +235,8 @@ llvm::Value *taylor_diff_cos_impl(llvm_state &, llvm::Type *, const cos_impl &,
"An invalid argument type was encountered while trying to build the Taylor derivative of a cosine");
}

// LCOV_EXCL_STOP

llvm::Value *taylor_diff_cos(llvm_state &s, llvm::Type *fp_t, const cos_impl &f, const std::vector<std::uint32_t> &deps,
const std::vector<llvm::Value *> &arr, llvm::Value *par_ptr, std::uint32_t n_uvars,
std::uint32_t order, std::uint32_t idx, std::uint32_t batch_size)
Expand Down Expand Up @@ -370,6 +374,8 @@ llvm::Function *taylor_c_diff_func_cos_impl(llvm_state &s, llvm::Type *fp_t, con
return f;
}

// LCOV_EXCL_START

// All the other cases.
template <typename U, std::enable_if_t<!is_num_param_v<U>, int> = 0>
llvm::Function *taylor_c_diff_func_cos_impl(llvm_state &, llvm::Type *, const cos_impl &, const U &, std::uint32_t,
Expand All @@ -379,6 +385,8 @@ llvm::Function *taylor_c_diff_func_cos_impl(llvm_state &, llvm::Type *, const co
"of a cosine in compact mode");
}

// LCOV_EXCL_STOP

llvm::Function *taylor_c_diff_func_cos(llvm_state &s, llvm::Type *fp_t, const cos_impl &fn, std::uint32_t n_uvars,
std::uint32_t batch_size)
{
Expand Down
1 change: 1 addition & 0 deletions src/math/relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <heyoka/llvm_state.hpp>
#include <heyoka/math/relu.hpp>
#include <heyoka/s11n.hpp>
#include <heyoka/taylor.hpp>
#include <heyoka/variable.hpp>

HEYOKA_BEGIN_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion src/math/sin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <boost/numeric/conversion/cast.hpp>

#include <fmt/format.h>
#include <fmt/core.h>

#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/DerivedTypes.h>
Expand Down
2 changes: 2 additions & 0 deletions test/taylor_relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ TEST_CASE("taylor relu relup")
{
llvm_state s{kw::opt_level = opt_level};

taylor_add_jet<fp_t>(s, "jet2", {relu(par[0]) + relup(par[1]), x + y}, 3, 2, high_accuracy, compact_mode);
taylor_add_jet<fp_t>(s, "jet", {relu(par[0]) + relup(par[1]), x + y}, 3, 2, high_accuracy, compact_mode);

s.compile();
Expand Down Expand Up @@ -109,6 +110,7 @@ TEST_CASE("taylor relu relup")
{
llvm_state s{kw::opt_level = opt_level};

taylor_add_jet<fp_t>(s, "jet2", {relu(x) + relup(y), x + y}, 3, 2, high_accuracy, compact_mode);
taylor_add_jet<fp_t>(s, "jet", {relu(x) + relup(y), x + y}, 3, 2, high_accuracy, compact_mode);

s.compile();
Expand Down

0 comments on commit 9c04d4e

Please sign in to comment.