generate strides automatically if stride field is not passed
| 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 |