Generates a large, random array, and extracts a subarray for the af_ function to use. testWriteToOutputArray expects that the large array that it receives is equal to the same large array with the gold array injected on the same subarray location
| 587 | // it receives is equal to the same large array with the gold array injected |
| 588 | // on the same subarray location |
| 589 | void genSubArray(TestOutputArrayInfo *metadata, const unsigned ndims, |
| 590 | const dim_t *const dims, const af_dtype ty) { |
| 591 | const dim_t pad_size = 2; |
| 592 | |
| 593 | // The large array is padded on both sides of each dimension |
| 594 | // Padding is only applied if the dimension is used, i.e. if dims[i] > 1 |
| 595 | dim_t full_arr_dims[4] = {dims[0], dims[1], dims[2], dims[3]}; |
| 596 | for (uint i = 0; i < ndims; ++i) { |
| 597 | full_arr_dims[i] = dims[i] + 2 * pad_size; |
| 598 | } |
| 599 | |
| 600 | // Calculate index of sub-array. These will be used also by |
| 601 | // testWriteToOutputArray so that the gold sub array will be placed in |
| 602 | // the same location. Currently, this location is the center of the |
| 603 | // large array |
| 604 | af_seq subarr_idxs[4] = {af_span, af_span, af_span, af_span}; |
| 605 | for (uint i = 0; i < ndims; ++i) { |
| 606 | af_seq idx = {pad_size, pad_size + dims[i] - 1.0, 1.0}; |
| 607 | subarr_idxs[i] = idx; |
| 608 | } |
| 609 | |
| 610 | metadata->init(ndims, full_arr_dims, ty, &subarr_idxs[0]); |
| 611 | } |
| 612 | |
| 613 | void genSubArray(TestOutputArrayInfo *metadata, double val, |
| 614 | const unsigned ndims, const dim_t *const dims, |
no test coverage detected