Return the offset of the given index on the given strides
| 178 | |
| 179 | /// Return the offset of the given index on the given strides |
| 180 | static int64_t CalculateValueOffset(const std::vector<int64_t>& strides, |
| 181 | const std::vector<int64_t>& index) { |
| 182 | const int64_t n = static_cast<int64_t>(index.size()); |
| 183 | int64_t offset = 0; |
| 184 | for (int64_t i = 0; i < n; ++i) { |
| 185 | offset += index[i] * strides[i]; |
| 186 | } |
| 187 | return offset; |
| 188 | } |
| 189 | |
| 190 | int64_t CalculateValueOffset(const std::vector<int64_t>& index) const { |
| 191 | return Tensor::CalculateValueOffset(strides_, index); |