21 std::vector<ck_tile::long_index_t> conv_strides,
22 std::vector<ck_tile::long_index_t> conv_dilations,
23 std::vector<ck_tile::long_index_t> in_left_pads,
24 std::vector<ck_tile::long_index_t>)
30 throw std::runtime_error(
"wrong! inconsistent dimension");
33 if constexpr(NDimSpatial == 1)
35 auto func = [&](
auto g,
auto n,
auto k,
auto wo) {
38 for(std::size_t c = 0; c < weight.
get_lengths()[2]; ++c)
40 for(std::size_t x = 0; x < weight.
get_lengths()[3]; ++x)
46 if(wi >= 0 && ck_tile::type_convert<std::size_t>(wi) < input.
get_lengths()[3])
48 InDataType v_in = input(g, n, c, wi);
49 WeiDataType v_wei = weight(g, k, c, x);
50 v_acc += ck_tile::type_convert<float>(v_in) *
51 ck_tile::type_convert<float>(v_wei);
55 OutDataType v_acc_converted = ck_tile::type_convert<OutDataType>(v_acc);
56 output(g, n, k, wo) = v_acc_converted;
63 output.
get_lengths()[3])(std::thread::hardware_concurrency());
65 else if constexpr(NDimSpatial == 2)
67 auto func = [&](
auto g,
auto n,
auto k,
auto ho,
auto wo) {
70 for(std::size_t c = 0; c < weight.
get_lengths()[2]; ++c)
72 for(std::size_t y = 0; y < weight.
get_lengths()[3]; ++y)
78 for(std::size_t x = 0; x < weight.
get_lengths()[4]; ++x)
85 ck_tile::type_convert<std::size_t>(hi) < input.
get_lengths()[3] &&
87 ck_tile::type_convert<std::size_t>(wi) < input.
get_lengths()[4])
89 InDataType v_in = input(g, n, c, hi, wi);
90 WeiDataType v_wei = weight(g, k, c, y, x);
92 v_acc += ck_tile::type_convert<float>(v_in) *
93 ck_tile::type_convert<float>(v_wei);
98 OutDataType v_acc_converted = ck_tile::type_convert<OutDataType>(v_acc);
99 output(g, n, k, ho, wo) = v_acc_converted;
107 output.
get_lengths()[4])(std::thread::hardware_concurrency());
109 else if constexpr(NDimSpatial == 3)
111 auto func = [&](
auto g,
auto n,
auto k,
auto d_o,
auto ho,
auto wo) {
114 for(std::size_t c = 0; c < weight.
get_lengths()[2]; ++c)
116 for(std::size_t z = 0; z < weight.
get_lengths()[3]; ++z)
121 for(std::size_t y = 0; y < weight.
get_lengths()[4]; ++y)
126 for(std::size_t x = 0; x < weight.
get_lengths()[5]; ++x)
132 ck_tile::type_convert<std::size_t>(di) < input.
get_lengths()[3] &&
134 ck_tile::type_convert<std::size_t>(hi) < input.
get_lengths()[4] &&
136 ck_tile::type_convert<std::size_t>(wi) < input.
get_lengths()[5])
138 InDataType v_in = input(g, n, c, di, hi, wi);
139 WeiDataType v_wei = weight(g, k, c, z, y, x);
141 v_acc += ck_tile::type_convert<float>(v_in) *
142 ck_tile::type_convert<float>(v_wei);
148 OutDataType v_acc_converted = ck_tile::type_convert<OutDataType>(v_acc);
149 output(g, n, k, d_o, ho, wo) = v_acc_converted;
158 output.
get_lengths()[5])(std::thread::hardware_concurrency());
162 throw std::runtime_error(
"Ref_Conv_fwd: number of dimensions must be between 1 and 3.");
#define CK_TILE_HOST
Definition: config.hpp:40
Definition: cluster_descriptor.hpp:13
CK_TILE_HOST auto make_ParallelTensorFunctor(F f, Xs... xs)
Definition: host_tensor.hpp:329
int32_t index_t
Definition: integer.hpp:9
int64_t long_index_t
Definition: integer.hpp:11
CK_TILE_HOST void reference_grouped_conv_fwd(const HostTensor< InDataType > &input, const HostTensor< WeiDataType > &weight, HostTensor< OutDataType > &output, std::vector< ck_tile::long_index_t > conv_strides, std::vector< ck_tile::long_index_t > conv_dilations, std::vector< ck_tile::long_index_t > in_left_pads, std::vector< ck_tile::long_index_t >)
Definition: reference_grouped_conv_fwd.hpp:18
Definition: host_tensor.hpp:336
decltype(auto) get_lengths() const
Definition: host_tensor.hpp:390
std::size_t get_num_of_dimension() const
Definition: host_tensor.hpp:396