This would work:
conv = nn.Conv2d(3, 6, 3, 1, 1)
my_weight = torch.ones(6, 3, 3, 3)
with torch.no_grad():
    conv.weight.copy_(my_weight)
print(conv.weight)

x = torch.randn(2, 3, 24, 24)
out = conv(x)