| 188 | |
| 189 | template<typename Ti, typename Tw, typename To> |
| 190 | void meanFirstLauncher(Param out, Param owt, Param in, Param inWeight, |
| 191 | const int threads_x, const uint groups_x, |
| 192 | const uint groups_y) { |
| 193 | using cl::EnqueueArgs; |
| 194 | using cl::NDRange; |
| 195 | |
| 196 | bool input_weight = ((inWeight.info.dims[0] * inWeight.info.dims[1] * |
| 197 | inWeight.info.dims[2] * inWeight.info.dims[3]) != 0); |
| 198 | |
| 199 | bool output_weight = ((owt.info.dims[0] * owt.info.dims[1] * |
| 200 | owt.info.dims[2] * owt.info.dims[3]) != 0); |
| 201 | ToNumStr<To> toNumStr; |
| 202 | ToNumStr<Tw> twNumStr; |
| 203 | common::Transform<uint, Tw, af_add_t> transform_weight; |
| 204 | |
| 205 | std::array<TemplateArg, 6> targs = { |
| 206 | TemplateTypename<Ti>(), TemplateTypename<To>(), |
| 207 | TemplateTypename<Tw>(), TemplateArg(threads_x), |
| 208 | TemplateArg(input_weight), TemplateArg(output_weight), |
| 209 | }; |
| 210 | std::vector<std::string> options = { |
| 211 | DefineKeyValue(Ti, dtype_traits<Ti>::getName()), |
| 212 | DefineKeyValue(To, dtype_traits<To>::getName()), |
| 213 | DefineKeyValue(Tw, dtype_traits<Tw>::getName()), |
| 214 | DefineKeyValue(DIMX, threads_x), |
| 215 | DefineValue(THREADS_PER_GROUP), |
| 216 | DefineKeyValue(init_To, toNumStr(common::Binary<To, af_add_t>::init())), |
| 217 | DefineKeyValue(init_Tw, twNumStr(transform_weight(0))), |
| 218 | DefineKeyValue(one_Tw, twNumStr(transform_weight(1))), |
| 219 | }; |
| 220 | options.emplace_back(getTypeBuildDefinition<Ti, To>()); |
| 221 | if (input_weight) { options.emplace_back(DefineKey(INPUT_WEIGHT)); } |
| 222 | if (output_weight) { options.emplace_back(DefineKey(OUTPUT_WEIGHT)); } |
| 223 | |
| 224 | auto meanOp = common::getKernel( |
| 225 | "meanFirst", {{mean_ops_cl_src, mean_first_cl_src}}, targs, options); |
| 226 | |
| 227 | NDRange local(threads_x, THREADS_PER_GROUP / threads_x); |
| 228 | NDRange global(groups_x * in.info.dims[2] * local[0], |
| 229 | groups_y * in.info.dims[3] * local[1]); |
| 230 | |
| 231 | uint repeat = divup(in.info.dims[0], (local[0] * groups_x)); |
| 232 | |
| 233 | if (input_weight && output_weight) { |
| 234 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 235 | *owt.data, owt.info, *in.data, in.info, *inWeight.data, |
| 236 | inWeight.info, groups_x, groups_y, repeat); |
| 237 | } else if (!input_weight && !output_weight) { |
| 238 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 239 | *in.data, in.info, groups_x, groups_y, repeat); |
| 240 | } else if (input_weight && !output_weight) { |
| 241 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 242 | *in.data, in.info, *inWeight.data, inWeight.info, groups_x, |
| 243 | groups_y, repeat); |
| 244 | } else if (!input_weight && output_weight) { |
| 245 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 246 | *owt.data, owt.info, *in.data, in.info, groups_x, groups_y, |
| 247 | repeat); |
nothing calls this directly
no test coverage detected