Return the offset of the given index on the given strides
| 162 | |
| 163 | /// Return the offset of the given index on the given strides |
| 164 | static int64_t CalculateValueOffset(const std::vector<int64_t>& strides, |
| 165 | const std::vector<int64_t>& index) { |
| 166 | const int64_t n = static_cast<int64_t>(index.size()); |
| 167 | int64_t offset = 0; |
| 168 | for (int64_t i = 0; i < n; ++i) { |
| 169 | offset += index[i] * strides[i]; |
| 170 | } |
| 171 | return offset; |
| 172 | } |
| 173 | |
| 174 | int64_t CalculateValueOffset(const std::vector<int64_t>& index) const { |
| 175 | return Tensor::CalculateValueOffset(strides_, index); |