MCPcopy Create free account
hub / github.com/apache/singa / traverse_next

Function traverse_next

src/core/tensor/tensor_math_cpp.h:116–124  ·  view source on GitHub ↗

function to traverse a const strided tensor object it requires an additional vector, traversal_info {0,0,0,0 ...}, comprising (x.shape().size()+2) elements of 0 for e.g. 2d matrix: index 0 and 1 store the base row and column index respectively index 2 stores the current index of the traversal index 3 stores the order of the traversal for e.g. if the order is 0, it means the next element can be nav

Source from the content-addressed store, hash-verified

114// index 3 stores the order of the traversal for e.g. if the order is 0,
115// it means the next element can be navigated to using the innermost stride
116void traverse_next(const Tensor &x, vector<int> &shape_multipliers,
117 vector<int> &traversal_info, int counter) {
118 update_base_index(x, traversal_info);
119 traversal_info[x.shape().size() + 1] =
120 determine_order(shape_multipliers, counter);
121 traversal_info[x.shape().size()] =
122 traversal_info[traversal_info[x.shape().size() + 1]] +
123 x.stride()[x.stride().size() - traversal_info[x.shape().size() + 1] - 1];
124};
125
126inline int next_offset(int offset, const vector<size_t> &shape,
127 const vector<int> &stride, vector<int> *index) {

Callers 1

Cpp>Method · 0.85

Calls 4

update_base_indexFunction · 0.85
determine_orderFunction · 0.85
shapeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected