Repeats the tensor along the specified dimensions. Parameters: input : Tensor The tensor to be repeated. sizes : Sequence[int] The number of times to repeat the tensor along each dimension. Returns: A tensor except for repeated input ten
(input: Tensor, sizes: Sequence[int])
| 6290 | |
| 6291 | |
| 6292 | def repeat(input: Tensor, sizes: Sequence[int]) -> Tensor: |
| 6293 | ''' |
| 6294 | Repeats the tensor along the specified dimensions. |
| 6295 | |
| 6296 | Parameters: |
| 6297 | input : Tensor |
| 6298 | The tensor to be repeated. |
| 6299 | sizes : Sequence[int] |
| 6300 | The number of times to repeat the tensor along each dimension. |
| 6301 | |
| 6302 | Returns: |
| 6303 | A tensor except for repeated input tensors along specified dim. |
| 6304 | |
| 6305 | ''' |
| 6306 | assert input.ndim() <= len(sizes), \ |
| 6307 | "Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor" |
| 6308 | repeated_tensor = input |
| 6309 | for k in range(-1, -len(sizes) - 1, -1): |
| 6310 | repeated_tensor = concat([repeated_tensor] * sizes[k], dim=k) |
| 6311 | return repeated_tensor |
| 6312 | |
| 6313 | |
| 6314 | def repeat_interleave(tensor: Tensor, repeats: int, dim: int) -> Tensor: |