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