31 #ifndef REMORA_KERNELS_CONV2D_HPP 32 #define REMORA_KERNELS_CONV2D_HPP 37 namespace remora{
namespace kernels{
55 template<
class E1,
class E2,
class M>
57 vector_expression<E1, cpu_tag>
const& image,
58 vector_expression<E2, cpu_tag>
const& filter,
59 vector_expression<M, cpu_tag>& output,
60 std::size_t num_channels,
61 std::size_t num_filters,
62 std::size_t image_height,
63 std::size_t image_width,
64 std::size_t filter_height,
65 std::size_t filter_width,
66 std::size_t padding_height = 0,
67 std::size_t padding_width = 0
69 std::size_t output_rows_per_filter = (image_height - filter_height +1 + padding_height) * (image_width - filter_width +1 + padding_width);
70 std::size_t filter_size = filter_width * filter_height * num_channels;
72 REMORA_SIZE_CHECK(output().size() == num_filters * output_rows_per_filter);
73 REMORA_SIZE_CHECK(image().size() == num_channels * image_width * image_height);
74 REMORA_SIZE_CHECK(filter().size() == num_filters * filter_size);
77 image, filter, output, num_channels, num_filters,
78 image_height, image_width, filter_height, filter_width,
79 padding_height, padding_width