| 41 | |
| 42 | template<typename T> |
| 43 | static af_array transform_coordinates(const af_array &tf_, const float d0_, |
| 44 | const float d1_) { |
| 45 | af::dim4 h_dims(4, 3); |
| 46 | T zero = 0; |
| 47 | T one = 1; |
| 48 | T d0 = static_cast<T>(d0_); |
| 49 | T d1 = static_cast<T>(d1_); |
| 50 | // clang-format off |
| 51 | T h_in[4 * 3] = {zero, zero, d1, d1, |
| 52 | zero, d0, d0, zero, |
| 53 | one, one, one, one}; |
| 54 | // clang-format on |
| 55 | |
| 56 | const Array<T> tf = getArray<T>(tf_); |
| 57 | Array<T> in = createHostDataArray<T>(h_dims, h_in); |
| 58 | |
| 59 | std::vector<af_seq> idx(2); |
| 60 | idx[0] = af_make_seq(0, 2, 1); |
| 61 | |
| 62 | // w = 1.0 / matmul(tf, in(span, 2)); |
| 63 | // iw = matmul(tf, in(span, 2)); |
| 64 | idx[1] = af_make_seq(2, 2, 1); |
| 65 | Array<T> iw = multiplyIndexed(in, tf, idx); |
| 66 | |
| 67 | // xt = w * matmul(tf, in(span, 0)); |
| 68 | // xt = matmul(tf, in(span, 0)) / iw; |
| 69 | idx[1] = af_make_seq(0, 0, 1); |
| 70 | Array<T> xt = |
| 71 | arithOp<T, af_div_t>(multiplyIndexed(in, tf, idx), iw, iw.dims()); |
| 72 | |
| 73 | // yt = w * matmul(tf, in(span, 1)); |
| 74 | // yt = matmul(tf, in(span, 1)) / iw; |
| 75 | idx[1] = af_make_seq(1, 1, 1); |
| 76 | Array<T> yw = |
| 77 | arithOp<T, af_div_t>(multiplyIndexed(in, tf, idx), iw, iw.dims()); |
| 78 | |
| 79 | // return join(1, xt, yt) |
| 80 | Array<T> r = join(1, xt, yw); |
| 81 | return getHandle(r); |
| 82 | } |
| 83 | |
| 84 | af_err af_transform_coordinates(af_array *out, const af_array tf, |
| 85 | const float d0_, const float d1_) { |
nothing calls this directly
no test coverage detected