What's the best practice to change the values of a tensor?

I am looking into a project that has to re-initialize weights at some point. A problem suddenly occurs to me.

I used to change values of tensors in the following way, which I believe outdated/not recommended now:

m = nn.Linear(100, 100)
m.weight.data.fill_(1)

I am wondering what is the correct/encouraged way to manage it in the current version. My current idea is like this:

m.weight.detach().fill_(1)

Are there any more recommendations?