Skip to content

Commit 5f26c03

Browse files
committed
it was just the inlining
1 parent 03e2227 commit 5f26c03

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

include/fdeep/layers/relu_layer.hpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include "fdeep/layers/activation_layer.hpp"
1010

11-
#include <algorithm>
12-
#include <limits>
1311
#include <string>
1412

1513
namespace fdeep {
@@ -31,28 +29,13 @@ namespace internal {
3129
protected:
3230
tensor transform_input(const tensor& in_vol) const override
3331
{
34-
// Fast path for the common standard ReLU (max(0, x)):
35-
// std::transform with a simple lambda allows GCC/Clang to emit
36-
// SIMD vmaxps, unlike fplus::transform_convert which uses push_back.
37-
if (negative_slope_ == static_cast<float_type>(0) &&
38-
threshold_ == static_cast<float_type>(0) &&
39-
max_value_ == std::numeric_limits<float_type>::max()) {
40-
const auto& src = *in_vol.as_vector();
41-
float_vec result(src.size());
42-
std::transform(src.begin(), src.end(), result.begin(),
43-
[](float_type x) -> float_type {
44-
return std::max(static_cast<float_type>(0), x);
45-
});
46-
return tensor(in_vol.shape(), std::move(result));
47-
}
48-
auto activation_function = [&](float_type x) -> float_type {
32+
return transform_tensor([&](float_type x) -> float_type {
4933
if (x >= max_value_)
5034
return max_value_;
5135
if (threshold_ <= x && x < max_value_)
5236
return x;
5337
return negative_slope_ * (x - threshold_);
54-
};
55-
return transform_tensor(activation_function, in_vol);
38+
}, in_vol);
5639
}
5740
float_type max_value_;
5841
float_type negative_slope_;

0 commit comments

Comments
 (0)