Deprecation warnings for dispatch macros that don't appear to be deprecated

I extended PyTorch with a few custom C++/CUDA layers using PyTorch 1.0. I am now upgrading those layers to support PyTorch 1.2, and I can’t seem to figure out this deprecation warning:

ext_modules/include/nn/cuda/my_file.cuh: In lambda function:
ext_modules/include/nn/cuda/my_file.cuh:169:101: warning: ‘c10::ScalarType detail::scalar_type(const at::DeprecatedTypeProperties&)’ is deprecated [-Wdeprecated-declarations]
/data/anaconda3/envs/my_lib/lib/python3.7/site-packages/torch/include/ATen/Dispatch.h:78:1: note: declared here
 inline at::ScalarType scalar_type(const at::DeprecatedTypeProperties &t) {

It seems to be related to my usage of AT_DISPATCH_FLOATING_TYPES. For example, I get this warning from my reimplementation of im2col:

void Im2Col2DLauncher(at::Tensor data_im, const int64_t channels,
                      const int64_t height_im, const int64_t width_im,
                      const int64_t width_out, const int64_t width_col,
                      const int64_t kernel_h, const int64_t kernel_w,
                      const int64_t pad_h, const int64_t pad_w,
                      const int64_t stride_h, const int64_t stride_w,
                      const int64_t dilation_h, const int64_t dilation_w,
                      at::Tensor data_col) {
  const int64_t num_kernels = channels * width_col;
  const dim3 blocks((num_kernels + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS);

  // Launch channels * width_col kernels, with each kernel responsible for
  // copying a the convolutions over a single channel.
      data_col.type(), "Im2Col2DKernel", ([&] {
        Im2Col2DKernel<<<blocks, CUDA_NUM_THREADS>>>(
            num_kernels,<scalar_t>(), height_im, width_im,
            width_out, width_col, kernel_h, kernel_w, pad_h, pad_w, stride_h,
            stride_w, dilation_h, dilation_w,<scalar_t>());

The only related include I am using is #include <torch/extension.h>.

I looked at the Dispatch.h file but I don’t see AT_DISPATCH_FLOATING_TYPES listed as deprecated.

What’s going on? And is there a deprecation guide somewhere?

1 Like

It appears the issue lies in:

      data_col.type(), ...

The correct way to do this now is to use .scalar_type(), so it should read:

      data_col.scalar_type(), ...

Thanks. it solved my problem.