Addressing Deprecations of ATen with PyTorch 1.0

After updating to PyTorch 1.0, I have noticed many deprecated functions in the ATen library. I cannot find any resources on the correct way to create a new tensor.

Here is how I would create a new tensor on the CPU using an input’s type:

at::Tensor grad_input = at::zeros({batch_size, n_points, 3}, torch::CPU(input.dtype()));

This line throws an error when compiling:

cpp/chamfer_distance.cpp:95:90: error: cannot convert ‘caffe2::TypeMeta’ to ‘c10::ScalarType’ for argument ‘1’ to ‘at::TypeExtendedInterface& torch::CPU(c10::ScalarType)’
 at::Tensor grad_input = at::zeros({batch_size, n_points, 3}, torch::CPU(input.dtype()));

How should I create tensors with ATen in PyTorch 1.0?

I was able to compile this by removing the call to torch::CPU. The tensor is now created using:

at::Tensor grad_input = at::zeros({batch_size, n_points, 3}, input.dtype());

The recommended way is to use TensorOptions.

Sorry, I am a newbie.
What is TensorOptions and how to use it?

I found a great write up about it in the documentation: https://pytorch.org/cppdocs/notes/tensor_creation.html