| 38 | |
| 39 | template<typename T> |
| 40 | void transform(Param out, const Param in, const Param tf, bool isInverse, |
| 41 | bool isPerspective, af_interp_type method, int order) { |
| 42 | using cl::EnqueueArgs; |
| 43 | using cl::NDRange; |
| 44 | using std::string; |
| 45 | using std::vector; |
| 46 | using BT = typename dtype_traits<T>::base_type; |
| 47 | |
| 48 | constexpr int TX = 16; |
| 49 | constexpr int TY = 16; |
| 50 | // Used for batching images |
| 51 | constexpr int TI = 4; |
| 52 | constexpr bool isComplex = |
| 53 | static_cast<af_dtype>(dtype_traits<T>::af_type) == c32 || |
| 54 | static_cast<af_dtype>(dtype_traits<T>::af_type) == c64; |
| 55 | |
| 56 | vector<TemplateArg> tmpltArgs = { |
| 57 | TemplateTypename<T>(), |
| 58 | TemplateArg(isInverse), |
| 59 | TemplateArg(isPerspective), |
| 60 | TemplateArg(order), |
| 61 | }; |
| 62 | ToNumStr<T> toNumStr; |
| 63 | vector<string> compileOpts = { |
| 64 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 65 | DefineKeyValue(INVERSE, (isInverse ? 1 : 0)), |
| 66 | DefineKeyValue(PERSPECTIVE, (isPerspective ? 1 : 0)), |
| 67 | DefineKeyValue(ZERO, toNumStr(scalar<T>(0))), |
| 68 | DefineKeyValue(InterpInTy, dtype_traits<T>::getName()), |
| 69 | DefineKeyValue(InterpValTy, dtype_traits<vtype_t<T>>::getName()), |
| 70 | DefineKeyValue(InterpPosTy, dtype_traits<wtype_t<BT>>::getName()), |
| 71 | DefineKeyValue(XDIM, 0), |
| 72 | DefineKeyValue(YDIM, 1), |
| 73 | DefineKeyValue(INTERP_ORDER, order), |
| 74 | DefineKeyValue(IS_CPLX, (isComplex ? 1 : 0)), |
| 75 | }; |
| 76 | if (isComplex) { |
| 77 | compileOpts.emplace_back( |
| 78 | DefineKeyValue(TB, dtype_traits<BT>::getName())); |
| 79 | } |
| 80 | compileOpts.emplace_back(getTypeBuildDefinition<T>()); |
| 81 | addInterpEnumOptions(compileOpts); |
| 82 | |
| 83 | auto transform = common::getKernel("transformKernel", |
| 84 | {{interp_cl_src, transform_cl_src}}, |
| 85 | tmpltArgs, compileOpts); |
| 86 | |
| 87 | const int nImg2 = in.info.dims[2]; |
| 88 | const int nImg3 = in.info.dims[3]; |
| 89 | const int nTfs2 = tf.info.dims[2]; |
| 90 | const int nTfs3 = tf.info.dims[3]; |
| 91 | |
| 92 | NDRange local(TX, TY, 1); |
| 93 | |
| 94 | int batchImg2 = 1; |
| 95 | if (nImg2 != nTfs2) batchImg2 = min(nImg2, TI); |
| 96 | |
| 97 | const int blocksXPerImage = divup(out.info.dims[0], local[0]); |
no test coverage detected