r"""Concat some tensors Args: inps: input tensors to concat. axis: over which dimension the tensors are concatenated. Default: 0 device: which device output will be. Default: None Returns: output tensor. Examples: >>> import numpy as np
(inps: Iterable[Tensor], axis: int = 0, device=None)
| 562 | |
| 563 | |
| 564 | def concat(inps: Iterable[Tensor], axis: int = 0, device=None) -> Tensor: |
| 565 | r"""Concat some tensors |
| 566 | |
| 567 | Args: |
| 568 | inps: input tensors to concat. |
| 569 | axis: over which dimension the tensors are concatenated. Default: 0 |
| 570 | device: which device output will be. Default: None |
| 571 | |
| 572 | Returns: |
| 573 | output tensor. |
| 574 | |
| 575 | Examples: |
| 576 | >>> import numpy as np |
| 577 | >>> data1 = Tensor(np.arange(0, 6, dtype=np.float32).reshape((2, 3))) |
| 578 | >>> data2 = Tensor(np.arange(6, 12, dtype=np.float32).reshape((2, 3))) |
| 579 | >>> out = F.concat([data1, data2]) |
| 580 | >>> out.numpy() |
| 581 | array([[ 0., 1., 2.], |
| 582 | [ 3., 4., 5.], |
| 583 | [ 6., 7., 8.], |
| 584 | [ 9., 10., 11.]], dtype=float32) |
| 585 | """ |
| 586 | if len(inps) == 1: |
| 587 | # if we return inps[0] directly, then the grad manager capture nothing |
| 588 | return copy(inps[0], device) |
| 589 | |
| 590 | if device is None: |
| 591 | device = get_device(inps) |
| 592 | device = as_device(device) |
| 593 | (result,) = apply(builtin.Concat(axis=axis, comp_node=device.to_c()), *inps) |
| 594 | return result |
| 595 | |
| 596 | |
| 597 | def stack(inps, axis=0, device=None): |
no test coverage detected