I’m getting a segmentation fault when running loss backward.
int n_a = 31;
int n_b = 100;

torch::Tensor dynamic_parameters = torch::full({1}, /*value=*/0.0002, torch::dtype(torch::kFloat64).requires_grad(true));
torch::optim::SGD optimizer({dynamic_parameters}, /*lr=*/0.01);

torch::Tensor target = torch::zeros({n_a}, torch::dtype(torch::kFloat64).requires_grad(false));

torch::Tensor dots = torch::zeros({n_a, n_b}, torch::dtype(torch::kFloat64).requires_grad(false));
// I fill this with some data
torch::Tensor magnitudes = torch::zeros({n_b}, torch::dtype(torch::kFloat64).requires_grad(false));
// I fill out this with some data

torch::Tensor prediction = torch::matmul(dots, magnitudes);

torch::Tensor loss = torch::nn::functional::mse_loss(prediction, target);
loss.backward();

I’m getting
Abnormal program termination: received signal 11 (Segmentation fault)

I printed loss, in case that helps.:
1.31119e+07
[ CPUDoubleType{} ]

I’m only setting requires_grad on the parameter I’m using SGD on - should I be setting it on all of these tensors?
Thanks,
Ian