Hello!

How do I add my tensor `recurrent_input`

at the end of my tensor `input`

? `torch::cat`

documentation seems to be missing? https://github.com/pytorch/pytorch/issues/35667

Note that both are 1 dims tensors. 1x10 and 1x40

Hello!

How do I add my tensor `recurrent_input`

at the end of my tensor `input`

? `torch::cat`

documentation seems to be missing? https://github.com/pytorch/pytorch/issues/35667

Note that both are 1 dims tensors. 1x10 and 1x40

`torch::cat({ input, recurrent_input }, 0);`

1 Like

How to replicate this behaviour

```
>>> t = torch.tensor([[1, 2, 3], [4, 4, 4]])
>>> t
tensor([[1, 2, 3],
[4, 4, 4]])
>>> torch.cat(3*[t])
```

I want to know how to cat repeat

Your approach would work, so I’m unsure, if you are facing any issues with it.

Alternatively, you could also try to use `tensor.expand`

or `tensor.repeat`

in case this would better fit your use case.

I am sorry I didn’t make my question clear.

I want to know how to implement this in torch cpp.

What’s the exact syntax for this?

Thank you!

Ah, I didn’t realize the thread topic.

`expand`

and `repeat`

are both available in `libtorch`

e.g. via: `tensor.expand({3, 1})`

.

1 Like