shenkev:

def forward(self, input):
repeated_weight = None
for i in range(0, self.in_features):
row = self.repeat(self.weight[i], self.in_features)
repeated_weight = repeated_weight.cat(repeated_weight, row, 0)


Autograd will also work with your original code. The cat and repeat functions both have a backward() implemented somewhere and autograd will call those when computing gradients.  Most functions that you can apply to a Variable have a backward somewhere.