do not use constexpr with CUDA >= 9.2 compiler on Windows. (#18986)
authorShuichi KITAGUCHI <kit@ysnb.net>
Tue, 9 Apr 2019 15:00:18 +0000 (08:00 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 9 Apr 2019 15:03:13 +0000 (08:03 -0700)
commit17adce1b6945b647673bf2913b3a08c367bb0097
tree18ccab31d6b166c64c0537e9766321a78c383b9b
parent5f24f9a29b678603b0cd783cdd2a03b6b2085bd2
do not use constexpr with CUDA >= 9.2 compiler on Windows. (#18986)

Summary:
Define `AT_CPP14_CONSTEXPR` from `constexpr` to empty on Windows with CUDA >= 9.2 as workaround.

Discussed in #18425.

When using CUDA 10.1 on Windows, I faced following errors:
~~~
D:/data/source/pytorch\c10/util/ArrayRef.h(144): error: variable in constexpr function does not have automatic storage duration
          detected during instantiation of "const T &c10::ArrayRef<T>::front() const [with T=at::Tensor]"
D:/data/source/pytorch/aten/src\ATen/DeviceGuard.h(30): here
~~~

From documentation of CUDA Toolkit v10.1.105, compiler supports `constexpr` and relaxing requirements (in C++14), but compilation failed.

I suppose this could be compiler bug and require this workaround.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18986

Differential Revision: D14821836

Pulled By: ezyang

fbshipit-source-id: 9800da2fe7291e7c09e8e5e882adebab08d83ae3
c10/util/C++17.h