| 69 | } |
| 70 | |
| 71 | af::dim4 seqToDims(af_index_t *indices, af::dim4 parentDims, |
| 72 | bool reorder = true) { |
| 73 | try { |
| 74 | af::dim4 odims(1); |
| 75 | for (int i = 0; i < AF_MAX_DIMS; i++) { |
| 76 | if (indices[i].isSeq) { |
| 77 | odims[i] = calcDim(indices[i].idx.seq, parentDims[i]); |
| 78 | } else { |
| 79 | dim_t elems = 0; |
| 80 | AF_THROW(af_get_elements(&elems, indices[i].idx.arr)); |
| 81 | odims[i] = elems; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // Change the dimensions if inside GFOR |
| 86 | if (reorder) { |
| 87 | for (int i = 0; i < AF_MAX_DIMS; i++) { |
| 88 | if (indices[i].isBatch) { |
| 89 | int tmp = odims[i]; |
| 90 | odims[i] = odims[3]; |
| 91 | odims[3] = tmp; |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | return odims; |
| 97 | } catch (const logic_error &err) { AF_THROW_ERR(err.what(), AF_ERR_SIZE); } |
| 98 | } |
| 99 | |
| 100 | unsigned numDims(const af_array arr) { |
| 101 | unsigned nd; |
no test coverage detected