42 for (uint32_t out_ch = 0; out_ch < out_shape.
depth(); ++out_ch)
44 for (uint32_t out_row = 0; out_row < out_shape.
height(); ++out_row)
46 for (uint32_t out_col = 0; out_col < out_shape.
width(); ++out_col)
48 OutputDType out_value = 0;
50 for (uint32_t ker_ch = 0; ker_ch < ker_shape.
depth(); ++ker_ch)
52 for (uint32_t ker_row = 0; ker_row < ker_shape.
height(); ++ker_row)
54 for (uint32_t ker_col = 0; ker_col < ker_shape.
width(); ++ker_col)
56 const int64_t vertical_stride =
static_cast<int64_t
>(stride_info.
vertical());
57 const int64_t horizontal_stride =
static_cast<int64_t
>(stride_info.
horizontal());
58 const int64_t top_padding =
static_cast<int64_t
>(pad_info.
top());
59 const int64_t left_padding =
static_cast<int64_t
>(pad_info.
left());
61 const uint32_t in_ch = ker_ch;
62 const int64_t in_row = vertical_stride * out_row - top_padding + ker_row;
63 const int64_t in_col = horizontal_stride * out_col - left_padding + ker_col;
65 const bool is_padding = (in_row < 0) || (in_row >= in_shape.
height()) ||
66 (in_col < 0) || (in_col >= in_shape.
width());
68 const auto in_value = (is_padding) ? 0
69 : in_data.
at(in_ch,
static_cast<uint32_t
>(in_row),
70 static_cast<uint32_t
>(in_col));
72 const auto ker_value = ker_data.
at(out_ch, in_ch, ker_row, ker_col);
74 out_value += in_value * ker_value;
79 out_data.
at(out_ch, out_row, out_col) = out_value;