| 27 | |
| 28 | template<typename T> |
| 29 | void gradient(Param grad0, Param grad1, const Param in) { |
| 30 | constexpr int TX = 32; |
| 31 | constexpr int TY = 8; |
| 32 | |
| 33 | std::array<TemplateArg, 1> targs = { |
| 34 | TemplateTypename<T>(), |
| 35 | }; |
| 36 | std::array<std::string, 6> options = { |
| 37 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 38 | DefineValue(TX), |
| 39 | DefineValue(TY), |
| 40 | DefineKeyValue(ZERO, scalar_to_option(scalar<T>(0))), |
| 41 | DefineKeyValue(CPLX, static_cast<int>(iscplx<T>())), |
| 42 | getTypeBuildDefinition<T>()}; |
| 43 | |
| 44 | auto gradOp = |
| 45 | common::getKernel("gradient", {{gradient_cl_src}}, targs, options); |
| 46 | |
| 47 | cl::NDRange local(TX, TY, 1); |
| 48 | |
| 49 | int blocksPerMatX = divup(in.info.dims[0], TX); |
| 50 | int blocksPerMatY = divup(in.info.dims[1], TY); |
| 51 | cl::NDRange global(local[0] * blocksPerMatX * in.info.dims[2], |
| 52 | local[1] * blocksPerMatY * in.info.dims[3], 1); |
| 53 | |
| 54 | gradOp(cl::EnqueueArgs(getQueue(), global, local), *grad0.data, grad0.info, |
| 55 | *grad1.data, grad1.info, *in.data, in.info, blocksPerMatX, |
| 56 | blocksPerMatY); |
| 57 | CL_DEBUG_FINISH(getQueue()); |
| 58 | } |
| 59 | } // namespace kernel |
| 60 | } // namespace opencl |
| 61 | } // namespace arrayfire |
nothing calls this directly
no test coverage detected