11 #ifndef HIPIPE_CORE_STREAM_PAD_HPP
12 #define HIPIPE_CORE_STREAM_PAD_HPP
14 #include <hipipe/core/stream/transform.hpp>
15 #include <hipipe/core/utility/ndim.hpp>
17 namespace hipipe::stream {
21 template<
typename FromColumn,
typename MaskColumn,
typename ValT>
22 struct wrap_pad_fun_for_transform {
25 std::tuple<typename FromColumn::data_type, typename MaskColumn::data_type>
26 operator()(
typename FromColumn::data_type& source)
28 using SourceVector =
typename FromColumn::data_type;
29 using MaskVector =
typename MaskColumn::data_type;
30 constexpr
long SourceDims = utility::ndims<SourceVector>::value;
31 constexpr
long MaskDims = utility::ndims<MaskVector>::value;
32 static_assert(MaskDims <= SourceDims,
"stream::pad requires"
33 " the number of padded dimensions (i.e., the number of dimensions"
34 " of the mask) to be at most the number of dimensions of the source column.");
36 std::vector<std::vector<long>> source_size = utility::ndim_size<MaskDims>(source);
38 utility::ndim_resize<MaskDims>(mask, source_size,
true);
40 utility::ndim_pad<MaskDims>(source, value);
42 source_size = utility::ndim_size<MaskDims>(source);
43 utility::ndim_resize<MaskDims>(mask, source_size,
false);
44 return {std::move(source), std::move(mask)};
83 typename FromColumn,
typename MaskColumn,
87 typename utility::ndim_type_t<
88 typename FromColumn::data_type,
89 utility::ndims<typename MaskColumn::data_type>::value>>
90 auto pad(from_t<FromColumn> f, mask_t<MaskColumn> m, ValT value = ValT{})
92 detail::wrap_pad_fun_for_transform<FromColumn, MaskColumn, ValT>
93 trans_fun{std::move(value)};
95 std::move(trans_fun), dim<0>);