Sample:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wformat -fPIC -I/remote/wheel/vision/test -I/remote/wheel/vision/torchvision/csrc/models -I/opt/python/cp37-cp37m/lib/python3.7/site-packages/torch/include -I/opt/python/cp37-cp37m/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/opt/python/cp37-cp37m/lib/python3.7/site-packages/torch/include/TH -I/opt/python/cp37-cp37m/lib/python3.7/site-packages/torch/include/THC -I/opt/python/cp37-cp37m/include/python3.7m -c /remote/wheel/vision/torchvision/csrc/models/shufflenetv2.cpp -o build/temp.linux-x86_64-3.7/remote/wheel/vision/torchvision/csrc/models/shufflenetv2.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C_tests -D_GLIBCXX_USE_CXX11_ABI
=0 -std=c++11 #warning DEPRECATE_MESSAGE [-Wcpp] :
# warning DEPRECATE_MESSAGEthon3.7/site-packages/torch/include/torch/csrc/api/include/torch/ ^
cc @ShahriarSS as this seems to be in the C++ models codepath
I think that I have seen the messages. I'll look into this @fmassa
Warnings:
/usr/lib/python3.7/site-packages/torch/include/c10/util/ArrayRef.h: In instantiation of ‘constexpr c10::ArrayRef<T>::ArrayRef(const std::initializer_list<_Tp>&) [with T = unsigned char]’:
/usr/lib/python3.7/site-packages/torch/include/ATen/NativeFunctions.h:47:1: required from here
/usr/lib/python3.7/site-packages/torch/include/c10/util/ArrayRef.h:103:39: warning: initializing ‘c10::ArrayRef<unsigned char>::Data’ from ‘std::initializer_list<unsigned char>::begin’ does not extend the lifetime of the underlying array [-Winit-list-lifetime]
This goes for most of the basic types here: with T = unsigned char.
/usr/lib/python3.7/site-packages/torch/include/ATen/Dispatch.h:163:56: warning: ‘c10::ScalarType detail::scalar_type(const at::DeprecatedTypeProperties&)’ is deprecated [-Wdeprecated-declarations]
163 | at::ScalarType _st = ::detail::scalar_type(the_type); \
| ^
/home/shahriar/Music/vision/torchvision/csrc/cpu/ROIPool_cpu.cpp:152:3: note: in expansion of macro ‘AT_DISPATCH_FLOATING_TYPES_AND_HALF’
152 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.type(), "ROIPool_forward", [&] {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/python3.7/site-packages/torch/include/ATen/Dispatch.h:78:23: note: declared here
78 | inline at::ScalarType scalar_type(const at::DeprecatedTypeProperties &t) {
|
/usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:14:4: warning: #warning DEPRECATE_MESSAGE [-Wcpp]
14 | # warning DEPRECATE_MESSAGE
| ^~~~~~~
In file included from /usr/lib/python3.7/site-packages/torch/include/c10/core/MemoryFormat.h:5,
from /usr/lib/python3.7/site-packages/torch/include/ATen/core/Tensor.h:5,
from /usr/lib/python3.7/site-packages/torch/include/ATen/Tensor.h:2,
from /usr/lib/python3.7/site-packages/torch/include/ATen/Context.h:4,
from /usr/lib/python3.7/site-packages/torch/include/ATen/ATen.h:5,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:4,
from /usr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,
from /home/shahriar/Music/vision/torchvision/csrc/models/vgg.h:4,
from /home/shahriar/Music/vision/torchvision/csrc/models/vgg.cpp:1:
The first one is every where but the second one is in /home/shahriar/Music/vision/torchvision/csrc/cpu/ROIAlign_cpu.cpp and /home/shahriar/Music/vision/torchvision/csrc/cpu/nms_cpu.cpp.
I think you literally just have to change what header you import. The warning is bad because someone is trying to interpolate a string but that doesn't work in pragmas. The real error is:
#ifdef _MSC_VER
# pragma message ( "Including torch/torch.h for C++ extensions is deprecated. Please include torch/extension.h" )
#else
# warning "Including torch/torch.h for C++ extensions is deprecated. Please include torch/extension.h"
#endif
@ezyang Apparenty including extension.h where you bind the functions is not enough. It needs to be included in all of the headers (I may be wrong here. I'll need to test this out). But apparently the other messages are not because of the code. I wrote a simple code here but when I build this simple PR I get a lot of similar messages.
Yes, I could believe that we need to avoid including torch/torch.h in all cases, to fix this.
@ezyang I'll send a PR fixing this but the naming doesn't seem right. The models or datasets are not an extension to the Python API.
Hmm, maybe hold off.
Are you saying that these includes occur from C++ only headers? In that case, it definitely is wrong to switch them to extension.h. So perhaps the chain of problem is that these headers are transitively included from a Python extension, and then we trigger the warning. Hmm... I'm not so sure what to do; maybe the warning is wrong in the first place.
@ezyang The problem is that these headers (models headers) are both the public C++ API and included in test/test_models.cpp (to be able to compare them to python API). So they are directly included in extension code. I just think that public C++ API headers should include torch/torch.h and not torch/extension.h.
Yes, I'd agree with you.
So @ezyang what should we do here?
I'm thinking we should remove the deprecation warning from PyTorch itself. I'm halfway about whether or not we should force c++ extension writers to include torch/extension.h to get pybind bits. Do you want to submit this patch?
The patch only removes the deprecated warning message? If so then I'll open a PR for it in PyTorch.
sure
Most helpful comment
I think that I have seen the messages. I'll look into this @fmassa