`np.repeat` with equivalent implementation for torch (`repeat_interleave`). Args: a: input data to repeat. repeats: number of repetitions for each element, repeats is broadcast to fit the shape of the given axis. axis: axis along which to repeat values. kwar
(a: NdarrayOrTensor, repeats: int, axis: int | None = None, **kwargs)
| 362 | |
| 363 | |
| 364 | def repeat(a: NdarrayOrTensor, repeats: int, axis: int | None = None, **kwargs) -> NdarrayOrTensor: |
| 365 | """ |
| 366 | `np.repeat` with equivalent implementation for torch (`repeat_interleave`). |
| 367 | |
| 368 | Args: |
| 369 | a: input data to repeat. |
| 370 | repeats: number of repetitions for each element, repeats is broadcast to fit the shape of the given axis. |
| 371 | axis: axis along which to repeat values. |
| 372 | kwargs: if `a` is PyTorch Tensor, additional args for `torch.repeat_interleave`, more details: |
| 373 | https://pytorch.org/docs/stable/generated/torch.repeat_interleave.html. |
| 374 | |
| 375 | """ |
| 376 | if isinstance(a, np.ndarray): |
| 377 | return np.repeat(a, repeats, axis) |
| 378 | return torch.repeat_interleave(a, repeats, dim=axis, **kwargs) |
| 379 | |
| 380 | |
| 381 | def isnan(x: NdarrayOrTensor) -> NdarrayOrTensor: |
no outgoing calls
no test coverage detected
searching dependent graphs…