12 #include "etl/impl/max_pooling_derivative.hpp" 13 #include "etl/impl/avg_pooling_derivative.hpp" 17 #include "etl/impl/std/max_pooling.hpp" 18 #include "etl/impl/std/avg_pooling.hpp" 19 #include "etl/impl/cudnn/max_pooling.hpp" 33 template <etl_dma X, etl_dma Y>
42 #ifdef ETL_MANUAL_SELECT 50 template <
typename X,
typename Y>
59 std::cerr <<
"Forced selection to CUDNN pool implementation, but not possible for this expression" << std::endl;
84 template <
typename X,
typename Y>
86 return select_default_pool_impl<X, Y>(
false);
117 template <
size_t C1,
size_t C2,
size_t S1,
size_t S2,
size_t P1,
size_t P2,
typename X,
typename Y>
118 static void apply(
const X& x, Y&& y) {
119 constexpr_select
const auto impl = select_pool_impl<X, Y>();
124 etl::impl::standard::max_pool_2d::apply<C1, C2, S1, S2, P1, P2>(
smart_forward(x), y);
132 cpp_unreachable(
"Invalid selection for pooling");
151 template <
typename X,
typename Y>
152 static void apply(
const X& x, Y&& y,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1,
size_t p2) {
153 constexpr_select
const auto impl = select_pool_impl<X, Y>();
166 cpp_unreachable(
"Invalid selection for pooling");
179 template <
typename A>
197 template <
size_t C1,
size_t C2,
size_t S1,
size_t S2,
size_t P1,
size_t P2,
typename X,
typename Y>
198 static void apply(
const X& x, Y&& y) {
199 constexpr_select
const auto impl = select_pool_impl<X, Y>();
204 etl::impl::standard::avg_pool_2d::apply<C1, C2, S1, S2, P1, P2>(
smart_forward(x), y);
212 cpp_unreachable(
"Invalid selection for pooling");
231 template <
typename X,
typename Y>
232 static void apply(
const X& x, Y&& y,
size_t c1,
size_t c2,
size_t s1,
size_t s2,
size_t p1,
size_t p2) {
233 constexpr_select
const auto impl = select_pool_impl<X, Y>();
246 cpp_unreachable(
"Invalid selection for pooling");
259 template <
typename A>
277 template <
size_t C1,
size_t C2,
size_t C3,
size_t S1,
size_t S2,
size_t S3,
size_t P1,
size_t P2,
size_t P3,
typename X,
typename Y>
278 static void apply(
const X& x, Y&& y) {
279 constexpr_select
const auto impl = select_pool_impl<X, Y>();
284 etl::impl::standard::max_pool_3d::apply<C1, C2, C3, S1, S2, S3, P1, P2, P3>(
smart_forward(x), y);
289 etl::impl::cudnn::max_pool_3d::apply(
smart_forward_gpu(x), y, C1, C2, C3, S1, S2, S3, P1, P2, P3);
292 cpp_unreachable(
"Invalid selection for pooling");
311 template <
typename X,
typename Y>
312 static void apply(
const X& x, Y&& y,
size_t c1,
size_t c2,
size_t c3,
size_t s1,
size_t s2,
size_t s3,
size_t p1,
size_t p2,
size_t p3) {
313 constexpr_select
const auto impl = select_pool_impl<X, Y>();
318 etl::impl::standard::max_pool_3d::apply(
smart_forward(x), y, c1, c2, c3, s1, s2, s3, p1, p2, p3);
323 etl::impl::cudnn::max_pool_3d::apply(
smart_forward_gpu(x), y, c1, c2, c3, s1, s2, s3, p1, p2, p3);
326 cpp_unreachable(
"Invalid selection for pooling");
339 template <
typename A>
357 template <
size_t C1,
size_t C2,
size_t C3,
size_t S1,
size_t S2,
size_t S3,
size_t P1,
size_t P2,
size_t P3,
typename X,
typename Y>
358 static void apply(
const X& x, Y&& y) {
359 constexpr_select
const auto impl = select_pool_impl<X, Y>();
364 etl::impl::standard::avg_pool_3d::apply<C1, C2, C3, S1, S2, S3, P1, P2, P3>(
smart_forward(x), y);
369 etl::impl::cudnn::avg_pool_3d::apply(
smart_forward_gpu(x), y, C1, C2, C3, S1, S2, S3, P1, P2, P3);
372 cpp_unreachable(
"Invalid selection for pooling");
391 template <
typename X,
typename Y>
392 static void apply(
const X& x, Y&& y,
size_t c1,
size_t c2,
size_t c3,
size_t s1,
size_t s2,
size_t s3,
size_t p1,
size_t p2,
size_t p3) {
393 const auto impl = select_pool_impl<X, Y>();
398 etl::impl::standard::avg_pool_3d::apply(
smart_forward(x), y, c1, c2, c3, s1, s2, s3, p1, p2, p3);
403 etl::impl::cudnn::avg_pool_3d::apply(
smart_forward_gpu(x), y, c1, c2, c3, s1, s2, s3, p1, p2, p3);
406 cpp_unreachable(
"Invalid selection for pooling");
static void apply(const A &sub, M &&m)
Apply the functor on sub and store the result in m.
Definition: avg_pooling.hpp:587
pool_impl
Enumeration describing the different implementations of pooling.
Definition: pool_impl.hpp:21
static void apply(const X &x, Y &&y, size_t c1, size_t c2, size_t s1, size_t s2, size_t p1, size_t p2)
Pool x into y.
Definition: pooling.hpp:232
Functor for 2D Average Pooling.
Definition: pooling.hpp:174
static void apply(const X &x, Y &&y)
Pool x into y.
Definition: pooling.hpp:198
static void apply(const X &x, Y &&y)
Pool x into y.
Definition: pooling.hpp:118
static void apply(const A &sub, M &&m)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:855
context & local_context()
Return the configuration context of the current thread.
Definition: context.hpp:50
Functor for 2D Max Pooling.
Definition: pooling.hpp:94
static void apply(const X &x, Y &&y, size_t c1, size_t c2, size_t c3, size_t s1, size_t s2, size_t s3, size_t p1, size_t p2, size_t p3)
Pool x into y.
Definition: pooling.hpp:392
constexpr bool cudnn_enabled
Indicates if the NVIDIA CUDNN library is available for ETL.
Definition: config.hpp:114
static void apply([[maybe_unused]] const X &x, [[maybe_unused]] Y &&y, [[maybe_unused]] size_t c1, [[maybe_unused]] size_t c2, [[maybe_unused]] size_t c3, [[maybe_unused]] size_t s1, [[maybe_unused]] size_t s2, [[maybe_unused]] size_t s3, [[maybe_unused]] size_t p1, [[maybe_unused]] size_t p2, [[maybe_unused]] size_t p3)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:249
bool cpu
Force CPU evaluation.
Definition: context.hpp:29
static constexpr bool gpu_computable
Indicates if the temporary expression can be directly evaluated using only GPU.
Definition: pooling.hpp:100
static void apply([[maybe_unused]] const X &x, [[maybe_unused]] Y &&y, [[maybe_unused]] size_t c1, [[maybe_unused]] size_t c2, [[maybe_unused]] size_t c3, [[maybe_unused]] size_t s1, [[maybe_unused]] size_t s2, [[maybe_unused]] size_t s3, [[maybe_unused]] size_t p1, [[maybe_unused]] size_t p2, [[maybe_unused]] size_t p3)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:276
static void apply(const X &x, Y &&y)
Pool x into y.
Definition: pooling.hpp:358
decltype(auto) smart_forward_gpu(E &expr)
Smart forwarding for a temporary expression that will be computed in GPU.
Definition: helpers.hpp:343
static void apply(const A &sub, M &&m)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:134
static void apply(const X &x, Y &&y, size_t c1, size_t c2, size_t s1, size_t s2, size_t p1, size_t p2)
Pool x into y.
Definition: pooling.hpp:152
Functor for 3D Average Pooling.
Definition: pooling.hpp:334
static void apply(const A &sub, M &&m)
Apply the functor on sub and store the result in m.
Definition: avg_pooling.hpp:127
decltype(auto) smart_forward(E &expr)
Smart forwarding for a temporary expression.
Definition: helpers.hpp:323
static void apply(const X &x, Y &&y)
Pool x into y.
Definition: pooling.hpp:278
static void apply([[maybe_unused]] const X &x, [[maybe_unused]] Y &&y, [[maybe_unused]] size_t c1, [[maybe_unused]] size_t c2, [[maybe_unused]] size_t s1, [[maybe_unused]] size_t s2, [[maybe_unused]] size_t p1, [[maybe_unused]] size_t p2)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:201
Definition: avg_pooling_derivative.hpp:10
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25
static void apply(const X &x, Y &&y, size_t c1, size_t c2, size_t c3, size_t s1, size_t s2, size_t s3, size_t p1, size_t p2, size_t p3)
Pool x into y.
Definition: pooling.hpp:312
Functor for 3D Max Pooling.
Definition: pooling.hpp:254
static void apply([[maybe_unused]] const X &x, [[maybe_unused]] Y &&y, [[maybe_unused]] size_t c1, [[maybe_unused]] size_t c2, [[maybe_unused]] size_t s1, [[maybe_unused]] size_t s2, [[maybe_unused]] size_t p1, [[maybe_unused]] size_t p2)
Apply the functor on sub and store the result in m.
Definition: max_pooling.hpp:225