Solved by ptrblck in post #2 
              
              
                I’m not sure, if you need the get() operation, but you might want to add the NoGrad guard: 
torch::NoGradGuard no_grad;
linear->weight.copy_(tensor);

should work.