In my initial program it makes no difference if I detach the output variable or not…  Loss remains constant either way.
The code is as follows:
torch::Tensor output = torch::zeros(127, torch::requires_grad(true));
for(unsigned int epoch=0; epoch<epochs; epoch++) {
	optimizer.zero_grad();			
	output = classifier->forward(data_x);
	loss = torch::mse_loss(output, data_x.detach_());
	loss.backward();
	optimizer.step();
}

Is it possible that the forward() method creates an output Tensor without gradient information?