How can i concatenate or ensemble two features separately?

I got the below runtime error while I tried to ensemble resnet50 with another model using ensemble class

return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 5.80 GiB total capacity; 191.43 MiB already allocated; 16.56 MiB free; 202.00 MiB reserved in total by PyTorch)

how can I concatenate between them if I have their features separately? does this should work

class MyEnsemble(nn.Module):
    def __init__(self, modelA, modelB):
        x1 = self.modelA(x.clone())  
        x1 = x1.view(x1.size(0), -1)
        x2 = self.modelB(x)
        x2 = x2.view(x2.size(0), -1)
        x = torch.cat((x1, x2), dim=1)
        dump(x, open('result.pkl', 'wb'))      
        return x
with open(r"v1.pkl", "rb") as input_file:
    modelA=cPickle.load(input_file)
with open(r"v2.pkl", "rb") as input1_file1:
    modelB=cPickle.load(input1_file1)
model = MyEnsemble(modelA, modelB)