I’m trying to do the equivalent of layer.weights.data = tensor using the PyTorch C++ frontend.
I’ve tried a few things:
*module.named_parameters()["layer"].data<float>() = *vector.data();

This segmentation faults.
module.named_parameters()["layer"].set_data(torch::from_blob(vector.data(), tensor_size));

This gives !is_variable() ASSERT FAILED.
module.named_parameters()["layer"] = torch::from_blob(vector.data(), tensor_size);

This apparently doesn’t do anything. The weights afterwards don’t change.
Is there a way to do this in C++?