MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / genReorderedArray

Function genReorderedArray

test/arrayfire_test.cpp:641–667  ·  view source on GitHub ↗

Generates a reordered array. testWriteToOutputArray expects that this array will still have the correct output values from the af_* function, even though the array was initially reordered.

Source from the content-addressed store, hash-verified

639// array will still have the correct output values from the af_* function,
640// even though the array was initially reordered.
641void genReorderedArray(TestOutputArrayInfo *metadata, const unsigned ndims,
642 const dim_t *const dims, const af_dtype ty) {
643 // The rest of this function assumes that dims has 4 elements. Just in
644 // case dims has < 4 elements, use another dims array that is filled
645 // with 1s
646 dim_t all_dims[4] = {1, 1, 1, 1};
647 for (uint i = 0; i < ndims; ++i) { all_dims[i] = dims[i]; }
648
649 // This reorder combination will not move data around, but will simply
650 // call modDims and modStrides (see src/api/c/reorder.cpp).
651 // The output will be checked if it is still correct even with the
652 // modified dims and strides "hack" with no data movement
653 uint reorder_idxs[4] = {0, 2, 1, 3};
654
655 // Shape the output array such that the reordered output array will have
656 // the correct dimensions that the test asks for (i.e. must match dims
657 // arg)
658 dim_t init_dims[4] = {all_dims[0], all_dims[1], all_dims[2], all_dims[3]};
659 for (uint i = 0; i < 4; ++i) { init_dims[i] = all_dims[reorder_idxs[i]]; }
660 metadata->init(4, init_dims, ty);
661
662 af_array reordered = 0;
663 ASSERT_SUCCESS(af_reorder(&reordered, metadata->getOutput(),
664 reorder_idxs[0], reorder_idxs[1], reorder_idxs[2],
665 reorder_idxs[3]));
666 metadata->setOutput(reordered);
667}
668
669void genReorderedArray(TestOutputArrayInfo *metadata, double val,
670 const unsigned ndims, const dim_t *const dims,

Callers 1

genTestOutputArrayFunction · 0.85

Calls 4

getOutputMethod · 0.80
setOutputMethod · 0.80
af_reorderFunction · 0.50
initMethod · 0.45

Tested by

no test coverage detected