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

Function assign

src/backend/cuda/assign.cpp:26–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25template<typename T>
26void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs) {
27 AssignKernelParam p;
28 std::vector<af_seq> seqs(4, af_span);
29 // create seq vector to retrieve output
30 // dimensions, offsets & offsets
31 for (dim_t x = 0; x < 4; ++x) {
32 if (idxrs[x].isSeq) { seqs[x] = idxrs[x].idx.seq; }
33 }
34
35 // retrieve dimensions, strides and offsets
36 dim4 dDims = out.dims();
37 // retrieve dimensions & strides for array
38 // to which rhs is being copied to
39 dim4 dstOffs = toOffset(seqs, dDims);
40 dim4 dstStrds = toStride(seqs, dDims);
41
42 for (dim_t i = 0; i < 4; ++i) {
43 p.isSeq[i] = idxrs[i].isSeq;
44 p.offs[i] = dstOffs[i];
45 p.strds[i] = dstStrds[i];
46 }
47
48 std::vector<Array<uint>> idxArrs(4, createEmptyArray<uint>(dim4()));
49 // look through indexs to read af_array indexs
50 for (dim_t x = 0; x < 4; ++x) {
51 // set idxPtrs to null
52 p.ptr[x] = 0;
53 // set index pointers were applicable
54 if (!p.isSeq[x]) {
55 idxArrs[x] = castArray<uint>(idxrs[x].idx.arr);
56 p.ptr[x] = idxArrs[x].get();
57 }
58 }
59
60 kernel::assign<T>(out, rhs, p);
61}
62
63#define INSTANTIATE(T) \
64 template void assign<T>(Array<T> & out, const af_index_t idxrs[], \

Callers

nothing calls this directly

Calls 5

toOffsetFunction · 0.85
toStrideFunction · 0.85
dim4Class · 0.50
dimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected