Helper for Split() that returns the slice index.
| 335 | |
| 336 | // Helper for Split() that returns the slice index. |
| 337 | static inline int GetSliceIndex(const int dim, const int split_size, |
| 338 | const int residual) { |
| 339 | DCHECK_GT(split_size, 0); |
| 340 | DCHECK_GE(dim, 0); |
| 341 | if (residual == 0) return dim / split_size; |
| 342 | const int offset = residual * (split_size + 1); |
| 343 | if (dim < offset) { |
| 344 | return dim / (split_size + 1); |
| 345 | } else { |
| 346 | return residual + ((dim - offset) / split_size); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | // Helper for Split() that returns the dimension in the slice. |
| 351 | static inline int GetDimensionInSlice(const int dim, const int split_size, |