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

Function next_offset

src/core/tensor/tensor_math_cpp.h:126–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124};
125
126inline int next_offset(int offset, const vector<size_t> &shape,
127 const vector<int> &stride, vector<int> *index) {
128 for (int k = shape.size() - 1; k >= 0; k--) {
129 if (index->at(k) + 1 < int(shape.at(k))) {
130 offset += stride.at(k);
131 index->at(k) += 1;
132 break;
133 }
134 index->at(k) = 0;
135 offset -= stride.at(k) * (shape.at(k) - 1);
136 }
137 return offset;
138}
139
140template <typename DType>
141void traverse_unary(const Tensor &in, Tensor *out,

Callers 2

traverse_unaryFunction · 0.85
traverse_binaryFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected