| 66 | } |
| 67 | |
| 68 | inline int32_t ClampedIndex(int32_t index, int dim, bool pos_stride) { |
| 69 | return pos_stride |
| 70 | ? (index >= dim ? dim |
| 71 | : PositiveRemainder( |
| 72 | std::min(std::max(index, -dim), dim), dim)) |
| 73 | : (index < -dim |
| 74 | ? -1 |
| 75 | : PositiveRemainder( |
| 76 | std::min(std::max(index, -dim), dim - 1), dim)); |
| 77 | } |
| 78 | |
| 79 | // TODO(b/77971377) this logic should be removed, as it's a duplication of |
| 80 | // StartForAxis() & StopForAxis() in kernels/internal/reference/reference_ops.h |
no test coverage detected