| 224 | } |
| 225 | |
| 226 | void TensorSlice::ComputeRelative(const TensorSlice& sub, |
| 227 | TensorSlice* relative) const { |
| 228 | DCHECK_EQ(dims(), sub.dims()); |
| 229 | relative->SetFullSlice(dims()); |
| 230 | for (int d = 0; d < dims(); ++d) { |
| 231 | if (IsFullAt(d)) { |
| 232 | relative->set_start(d, sub.start(d)); |
| 233 | relative->set_length(d, sub.length(d)); |
| 234 | } else { |
| 235 | // Otherwise the relative start is the difference between the start of |
| 236 | // sub and the start of base |
| 237 | relative->set_start(d, sub.start(d) - start(d)); |
| 238 | relative->set_length(d, sub.length(d)); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | void TensorSlice::UpdateToCover(const TensorSlice& other) { |
| 244 | DCHECK_EQ(dims(), other.dims()); |