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

Function getOffsets

src/backend/cpu/kernel/morph.hpp:20–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace kernel {
19template<typename T>
20void getOffsets(std::vector<dim_t>& offsets, const af::dim4& strides,
21 const CParam<T>& mask) {
22 const af::dim4 fstrides = mask.strides();
23 const T* filter = mask.get();
24 const dim_t dim0 = mask.dims()[0], dim1 = mask.dims()[1];
25 const dim_t R0 = dim0 / 2;
26 const dim_t R1 = dim1 / 2;
27
28 offsets.reserve(mask.dims().elements());
29 for (dim_t j = 0; j < dim1; ++j) {
30 for (dim_t i = 0; i < dim0; ++i) {
31 if (filter[getIdx(fstrides, i, j)] > (T)0) {
32 dim_t offset = (j - R1) * strides[1] + (i - R0) * strides[0];
33 offsets.push_back(offset);
34 }
35 }
36 }
37}
38
39template<typename T, bool IsDilation>
40struct MorphFilterOp {

Callers 1

morphFunction · 0.85

Calls 5

getIdxFunction · 0.85
stridesMethod · 0.45
getMethod · 0.45
dimsMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected