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

Function combineColumns

src/backend/common/dispatch.hpp:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136// RETURN: ndims
137template<typename T>
138T combineColumns(T dims1[AF_MAX_DIMS], T strides1[AF_MAX_DIMS], T& ndims,
139 T dims2[AF_MAX_DIMS], T strides2[AF_MAX_DIMS]) {
140 for (T c{0}; c < ndims - 1; ++c) {
141 if (dims1[c] == dims2[c] && dims1[c] * strides1[c] == strides1[c + 1] &&
142 dims1[c] * strides2[c] == strides2[c + 1]) {
143 // Combine columns, since they are linear
144 // This will increase the dimension of the resulting column,
145 // given more opportunities for kernel optimization
146 dims1[c] *= dims1[c + 1];
147 dims2[c] *= dims2[c + 1];
148 --ndims;
149 for (T i{c + 1}; i < ndims; ++i) {
150 dims1[i] = dims1[i + 1];
151 dims2[i] = dims2[i + 1];
152 strides1[i] = strides1[i + 1];
153 strides2[i] = strides2[i + 1];
154 }
155 dims1[ndims] = 1;
156 dims2[ndims] = 1;
157 --c; // Redo this colum, since it is removed now
158 }
159 }
160 return ndims;
161}
162// Columns with the same stride in both arrays are combined. Both arrays will
163// remain in sync and will return the same ndims.
164// ASSUMPTION: both arrays have the same dims

Callers 4

memcopyFunction · 0.85
copyFunction · 0.85
memcopyFunction · 0.85
copyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected