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

Method generate_stride

include/singa/core/tensor.h:287–300  ·  view source on GitHub ↗

generate strides automatically if stride field is not passed

Source from the content-addressed store, hash-verified

285 protected:
286 // generate strides automatically if stride field is not passed
287 void generate_stride() {
288 stride_.clear();
289 if (shape_.size() == 0) {
290 stride_.push_back(1);
291 return;
292 }
293
294 size_t dim = Size();
295 int cumulative_product = 1;
296 for (size_t n = 0; n < shape_.size(); ++n) {
297 cumulative_product = cumulative_product * shape_[n];
298 stride_.push_back(dim / cumulative_product);
299 }
300 }
301
302 void set_strides(const vector<int> new_strides) { stride_ = new_strides; }
303

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected