Hi everybody,
I am working on an nn.Module.
The forward method of the module takes two tensors as input. It first apply a CNN to both of theses inputs. It need then to concatenate the first output with all the lines inside the second output.
What I did for now is the following:
class Model(nn.class):

def __init__(self):
        super().__init__()
        self.layer1 = SomeModule1()
        self.layer2 = SomeModule2()

def forward(self,x : torch.Tensor(n), y : torch.Tensor(m,n)):
       x = self.layer1(x)
       y = self.layer1(y)

       cat = torch.zeros(2*n,m)

       for i in range(y.size(0)):
             cat[i] = torch.cat(x,y[i])

      return self.layer2(cat)

the code work. However I feel that there is a better way to achieve it. I have got some grad_fn= in the tensor grad. I am note sure what it is exactly but I have the feeling that it is not efficient.
What would be the best efficient solution for the concatenation ?
thanks in advance