Skip to content

Deprecated function messages give incorrect suggestions #36773

@gchanan

Description

@gchanan

🐛 Bug

Consider the following:

>>> torch.ones(2,3, dtype=torch.int64).add(2,3.)
../torch/csrc/utils/python_arg_parser.cpp:755: UserWarning: This overload of add is deprecated:
	add(Number alpha, Tensor other)
Consider using one of the following signatures instead:
	add(Tensor other, Number alpha)
Out[2]:
tensor([[7., 7., 7.],
        [7., 7., 7.]])

A reasonable reading of this message is that the order of the parameters should be reversed, but this isn't equivalent:

>>> torch.ones(2,3, dtype=torch.int64).add(3.,2)
RuntimeError: For integral input tensors, argument alpha must not be a floating point number.

The problem is that the second signature has a keyword-only argument but it's printed. It also doesn't include defaults and such, but that's probably secondary. In this case the problem is at least flagged, but it's not clear to me whether there are other deprecated signatures that silently suggest the wrong thing.

Environment

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

Collecting environment information...
PyTorch version: 1.5.0a0+060794a
Is debug build: Yes
CUDA used to build PyTorch: Could not collect

OS: CentOS Linux 7 (Core)
GCC version: (GCC) 7.4.0
CMake version: version 3.14.0

Python version: 3.7
Is CUDA available: No
CUDA runtime version: 9.2.88
GPU models and configuration:
GPU 0: Tesla M40
GPU 1: Tesla M40

Nvidia driver version: 396.69
cuDNN version: /usr/local/cuda-9.2/targets/x86_64-linux/lib/libcudnn.so.7.4.2

Versions of relevant libraries:
[pip] numpy==1.17.2
[pip] torch==1.5.0a0+060794a
[conda] blas 1.0 mkl
[conda] mkl 2019.4 243
[conda] mkl-include 2019.4 243
[conda] mkl-service 2.3.0 py37he904b0f_0
[conda] mkl_fft 1.0.14 py37ha843d7b_0
[conda] mkl_random 1.1.0 py37hd6b4f25_0
[conda] torch 1.5.0a0+060794a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions