| 246 | } |
| 247 | |
| 248 | int64 StridedBound(int64 bound, int64 window_size, int64 stride) { |
| 249 | CHECK_GE(window_size, 0); |
| 250 | CHECK_GE(bound, 0); |
| 251 | CHECK_GE(stride, 1); |
| 252 | |
| 253 | if (bound == 0 || window_size > bound) { |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | // Without considering stride, the maximum valid offset is bound - |
| 258 | // window_size. Taking stride into account, the valid offsets then have the |
| 259 | // form q * stride for q = 0, ..., Q such that q * stride <= bound - |
| 260 | // window_size. This implies that Q equals floor(bound - window_size / |
| 261 | // stride). There are Q + 1 valid values of q, yielding the formula below. |
| 262 | return (bound - window_size) / stride + 1; |
| 263 | } |
| 264 | |
| 265 | } // namespace window_util |
| 266 | } // namespace xla |
no outgoing calls
no test coverage detected