| 94 | |
| 95 | template<typename Ti, typename Tw, typename To> |
| 96 | void meanDimLauncher(Param out, Param owt, Param in, Param inWeight, |
| 97 | const int dim, const int threads_y, |
| 98 | const uint groups_all[4]) { |
| 99 | using cl::EnqueueArgs; |
| 100 | using cl::NDRange; |
| 101 | |
| 102 | bool input_weight = ((inWeight.info.dims[0] * inWeight.info.dims[1] * |
| 103 | inWeight.info.dims[2] * inWeight.info.dims[3]) != 0); |
| 104 | |
| 105 | bool output_weight = ((owt.info.dims[0] * owt.info.dims[1] * |
| 106 | owt.info.dims[2] * owt.info.dims[3]) != 0); |
| 107 | |
| 108 | ToNumStr<To> toNumStr; |
| 109 | ToNumStr<Tw> twNumStr; |
| 110 | common::Transform<uint, Tw, af_add_t> transform_weight; |
| 111 | |
| 112 | std::array<TemplateArg, 7> targs = { |
| 113 | TemplateTypename<Ti>(), TemplateTypename<To>(), |
| 114 | TemplateTypename<Tw>(), TemplateArg(dim), |
| 115 | TemplateArg(threads_y), TemplateArg(input_weight), |
| 116 | TemplateArg(output_weight), |
| 117 | }; |
| 118 | std::vector<std::string> options = { |
| 119 | DefineKeyValue(Ti, dtype_traits<Ti>::getName()), |
| 120 | DefineKeyValue(To, dtype_traits<To>::getName()), |
| 121 | DefineKeyValue(Tw, dtype_traits<Tw>::getName()), |
| 122 | DefineKeyValue(kDim, dim), |
| 123 | DefineKeyValue(DIMY, threads_y), |
| 124 | DefineValue(THREADS_X), |
| 125 | DefineKeyValue(init_To, toNumStr(common::Binary<To, af_add_t>::init())), |
| 126 | DefineKeyValue(init_Tw, twNumStr(transform_weight(0))), |
| 127 | DefineKeyValue(one_Tw, twNumStr(transform_weight(1))), |
| 128 | getTypeBuildDefinition<Ti, To>()}; |
| 129 | if (input_weight) { options.emplace_back(DefineKey(INPUT_WEIGHT)); } |
| 130 | if (output_weight) { options.emplace_back(DefineKey(OUTPUT_WEIGHT)); } |
| 131 | |
| 132 | auto meanOp = common::getKernel( |
| 133 | "meanDim", {{mean_ops_cl_src, mean_dim_cl_src}}, targs, options); |
| 134 | |
| 135 | NDRange local(THREADS_X, threads_y); |
| 136 | NDRange global(groups_all[0] * groups_all[2] * local[0], |
| 137 | groups_all[1] * groups_all[3] * local[1]); |
| 138 | |
| 139 | if (input_weight && output_weight) { |
| 140 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 141 | *owt.data, owt.info, *in.data, in.info, *inWeight.data, |
| 142 | inWeight.info, groups_all[0], groups_all[1], groups_all[dim]); |
| 143 | } else if (!input_weight && !output_weight) { |
| 144 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 145 | *in.data, in.info, groups_all[0], groups_all[1], |
| 146 | groups_all[dim]); |
| 147 | } else if (input_weight && !output_weight) { |
| 148 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 149 | *in.data, in.info, *inWeight.data, inWeight.info, groups_all[0], |
| 150 | groups_all[1], groups_all[dim]); |
| 151 | } else if (!input_weight && output_weight) { |
| 152 | meanOp(EnqueueArgs(getQueue(), global, local), *out.data, out.info, |
| 153 | *owt.data, owt.info, *in.data, in.info, groups_all[0], |
nothing calls this directly
no test coverage detected