Pytorch C++ API, Conv2d crash

when running the following code :

            torch::Tensor kernel = torch::full({ 1, 32, 1, 2 }, 0, torch::kInt32);
	// Define the bias
	torch::Tensor bias = torch::tensor({ 0 }, torch::kInt32);
	// Define the input image
	torch::Tensor image = torch::full({ 32, 6, 7 }, 0, torch::kInt);

	/// Define the convolution operation
	//torch::nn::Conv2d conv(torch::nn::Conv2dOptions(32, 1, {1,2}).bias(false));
	//depth_conv = Conv2d(in_channels = 10, out_channels = 10, kernel_size = 3, groups = 10)
	torch::nn::Conv2d depth_conv = torch::nn::Conv2d(
		torch::nn::Conv2dOptions(32, 1, {1,2}).groups(1).bias(false)
	);
	 
	

	// Set the filter for the convolution operation
	depth_conv->weight = kernel;

	// Set the bias for the convolution operation
	depth_conv->bias = bias;
	std::cout << "Original Data Tensor:\n" << image << std::endl;
	std::cout << "Original Wght Tensor:\n" << depth_conv->weight << std::endl;
	

	// Apply the convolution operation
	torch::Tensor output = depth_conv->forward(image);
	std::cout << "Output:\n" << output.dtype() << std::endl;

	// Print the output shape and values
	std::cout << "Output Shape: " << output.sizes() << std::endl;
	std::cout << "Output:\n" << output.dtype() << std::endl;

the convolution is done and every thing is ok, when out of scope the code crash, any idea why is that ?