pytorch/examples

Build failing on C++ 20 - M2 MacOS

sjoptra opened this issue · 0 comments

I tried the regression example in cpp using C++ 20 instead of 14.
(https://github.com/pytorch/examples/tree/main/cpp/regression )

I just changed set(CMAKE_CXX_STANDARD 14) to set(CMAKE_CXX_STANDARD 20) in CMakeLists.txt

The following errors occur:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.1.sdk/usr/include/c++/v1/vector:549:52: error: arithmetic on a pointer to an incomplete type 'c10::IValue'
{return static_cast<size_type>(__end_cap() - this->_begin);}
~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.1.sdk/usr/include/c++/v1/vector:763:56: note: in instantiation of member function 'std::vectorc10::IValue::capacity' requested here
__annotate_contiguous_container(data(), data() + capacity(),
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.1.sdk/usr/include/c++/v1/vector:442:18: note: in instantiation of member function 'std::vectorc10::IValue::__annotate_delete' requested here
_vec.__annotate_delete();
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/vector:456:67: note: in instantiation of member function 'std::vectorc10::IValue::__destroy_vector::operator()' requested here
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { destroy_vector(*this)(); }
^
/opt/homebrew/lib/python3.11/site-packages/torch/include/ATen/core/List.h:27:12: note: in instantiation of member function 'std::vectorc10::IValue::~vector' requested here
explicit ListImpl(list_type list
, TypePtr elementType
)
^
/opt/homebrew/lib/python3.11/site-packages/torch/include/c10/core/impl/PyInterpreter.h:17:8: note: forward declaration of 'c10::IValue'
struct IValue;

/opt/homebrew/lib/python3.11/site-packages/torch/include/ATen/core/ivalue_inl.h:522:14: error: binding reference of type 'IValue' to value of type 'const value_type' (aka 'const c10::IValue') drops 'const' qualifier
return elementsVector_[idx];
^~~~~~~~~~~~~~~~~~~~
/opt/homebrew/lib/python3.11/site-packages/torch/include/ATen/core/ivalue_inl.h:1503:18: error: no viable overloaded '='
slots_[slot] = std::move(v);

Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: macOS 14.1 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.0.28.1.1)
CMake version: version 3.27.3
Libc version: N/A

Python version: 3.9.6 (default, Aug 12 2023, 13:13:19) [Clang 15.0.0 (clang-1500.0.37.1) ] (64-bit runtime)
Python platform: macOS-14.1-arm64-arm-64bit
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Apple M2 Pro

Versions of relevant libraries:
[pip3] numpy==1.19.0