Concatenates self with other tensors in `args` along a new dimension specified by `dim`. ```python exec="true" source="above" session="tensor" result="python" t0, t1, t2 = Tensor([1, 2]), Tensor([3, 4]), Tensor([5, 6]) print(t0.stack(t1, t2, dim=0).numpy()) ``` ```python ex
(self, *args:Self, dim:int=0)
| 641 | return padded[0].usum(*padded[1:]) |
| 642 | |
| 643 | def stack(self, *args:Self, dim:int=0) -> Self: |
| 644 | """ |
| 645 | Concatenates self with other tensors in `args` along a new dimension specified by `dim`. |
| 646 | |
| 647 | ```python exec="true" source="above" session="tensor" result="python" |
| 648 | t0, t1, t2 = Tensor([1, 2]), Tensor([3, 4]), Tensor([5, 6]) |
| 649 | print(t0.stack(t1, t2, dim=0).numpy()) |
| 650 | ``` |
| 651 | ```python exec="true" source="above" session="tensor" result="python" |
| 652 | print(t0.stack(t1, t2, dim=1).numpy()) |
| 653 | ``` |
| 654 | """ |
| 655 | # checks for shapes and number of dimensions delegated to cat |
| 656 | unsqueezed = [t.unsqueeze(dim) for t in argfix(self, *args)] |
| 657 | return unsqueezed[0].cat(*unsqueezed[1:], dim=dim) |
| 658 | |
| 659 | def _cumalu(self, axis:int, op:Ops) -> Self: |
| 660 | assert self.shape[axis] != 0 and op in (Ops.ADD, Ops.MAX, Ops.MUL) |