Skip to content

Commit

Permalink
Back out "Revert D17908478: Switch PyTorch/Caffe2 to C++14"
Browse files Browse the repository at this point in the history
Summary: Original commit changeset: 775d2e29be0b

Test Plan: CI

Reviewed By: mruberry

Differential Revision: D18775520

fbshipit-source-id: a350b3f86b66d97241f208786ee67e9a51172eac
  • Loading branch information
smessmer authored and facebook-github-bot committed Dec 3, 2019
1 parent aff693a commit bc2e6d1
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 86 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()

set(CMAKE_INSTALL_MESSAGE NEVER)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
if (NOT MSVC)
set(CMAKE_C_STANDARD 11)
endif()
Expand Down Expand Up @@ -417,8 +417,8 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0
endif()

# ---[ Build flags
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ two dynamic libraries, one linking with the other:

```CMake
project(myproject CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
add_library(foo SHARED foo.cpp)
add_library(bar SHARED bar.cpp)
# NB: don't forget to __declspec(dllexport) at least one symbol from foo,
Expand Down
2 changes: 1 addition & 1 deletion android/pytorch_android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.4.1)
project(pytorch_jni CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE ON)

set(TRACE_ENABLED OFF)
Expand Down
6 changes: 3 additions & 3 deletions aten/src/ATen/cpu/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ endif()
if (UNIX)
add_definitions (-DUSE_PTHREAD)

check_cxx_compiler_flag ("-std=c++11" SUPPORTS_STDCXX11)
if (SUPPORTS_STDCXX11)
set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
check_cxx_compiler_flag ("-std=c++14" SUPPORTS_STDCXX14)
if (SUPPORTS_STDCXX14)
set (CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
endif ()

check_cxx_compiler_flag ("-mrtm -Werror" SUPPORTS_MRTM)
Expand Down
78 changes: 39 additions & 39 deletions aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ ELSE()
MESSAGE(FATAL_ERROR "Unsupported QNNPACK library type \"${PYTORCH_QNNPACK_LIBRARY_TYPE}\". Must be \"static\", \"shared\", or \"default\"")
ENDIF()
SET_TARGET_PROPERTIES(pytorch_qnnpack PROPERTIES
CXX_STANDARD 11
C_STANDARD 99
CXX_STANDARD 14
C_STANDARD 11
C_EXTENSIONS YES)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[5-8]" OR IOS_ARCH MATCHES "^armv7")
SET_PROPERTY(SOURCE ${PYTORCH_QNNPACK_ARM_NEON_UKERNELS} APPEND_STRING PROPERTY COMPILE_FLAGS " -O2 -marm -mfpu=neon ")
Expand Down Expand Up @@ -367,7 +367,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)
# ---[ Build unit tests for high-level functionality
ADD_EXECUTABLE(convolution-test test/convolution.cc)
SET_TARGET_PROPERTIES(convolution-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(convolution-test PRIVATE src test)
Expand All @@ -376,7 +376,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(deconvolution-test test/deconvolution.cc)
SET_TARGET_PROPERTIES(deconvolution-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(deconvolution-test PRIVATE src test)
Expand All @@ -385,7 +385,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(fully-connected-test test/fully-connected.cc)
SET_TARGET_PROPERTIES(fully-connected-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(fully-connected-test PRIVATE src test)
Expand All @@ -394,7 +394,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(channel-shuffle-test test/channel-shuffle.cc)
SET_TARGET_PROPERTIES(channel-shuffle-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(channel-shuffle-test PRIVATE src test)
Expand All @@ -403,7 +403,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(add-test test/add.cc)
SET_TARGET_PROPERTIES(add-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(add-test PRIVATE src test)
Expand All @@ -412,7 +412,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(leaky-relu-test test/leaky-relu.cc)
SET_TARGET_PROPERTIES(leaky-relu-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(leaky-relu-test PRIVATE src test)
Expand All @@ -421,7 +421,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(sigmoid-test test/sigmoid.cc)
SET_TARGET_PROPERTIES(sigmoid-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(sigmoid-test PRIVATE src test)
Expand All @@ -430,7 +430,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(clamp-test test/clamp.cc)
SET_TARGET_PROPERTIES(clamp-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(clamp-test PRIVATE src test)
Expand All @@ -439,7 +439,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(softargmax-test test/softargmax.cc)
SET_TARGET_PROPERTIES(softargmax-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(softargmax-test PRIVATE src test)
Expand All @@ -448,7 +448,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(max-pooling-test test/max-pooling.cc)
SET_TARGET_PROPERTIES(max-pooling-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(max-pooling-test PRIVATE src test)
Expand All @@ -457,7 +457,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(average-pooling-test test/average-pooling.cc)
SET_TARGET_PROPERTIES(average-pooling-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(average-pooling-test PRIVATE src test)
Expand All @@ -466,7 +466,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(global-average-pooling-test test/global-average-pooling.cc)
SET_TARGET_PROPERTIES(global-average-pooling-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(global-average-pooling-test PRIVATE src test)
Expand All @@ -476,7 +476,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)
# ---[ Build unit tests for micro-kernels
ADD_EXECUTABLE(q8gemm-test test/q8gemm.cc)
SET_TARGET_PROPERTIES(q8gemm-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8gemm-test PRIVATE src test)
Expand All @@ -485,7 +485,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(q8conv-test test/q8conv.cc)
SET_TARGET_PROPERTIES(q8conv-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8conv-test PRIVATE src test)
Expand All @@ -494,7 +494,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(q8dwconv-test test/q8dwconv.cc)
SET_TARGET_PROPERTIES(q8dwconv-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8dwconv-test PRIVATE src test)
Expand All @@ -503,7 +503,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(q8vadd-test test/q8vadd.cc)
SET_TARGET_PROPERTIES(q8vadd-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8vadd-test PRIVATE src test)
Expand All @@ -512,7 +512,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(q8avgpool-test test/q8avgpool.cc)
SET_TARGET_PROPERTIES(q8avgpool-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8avgpool-test PRIVATE src test)
Expand All @@ -521,7 +521,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(q8gavgpool-test test/q8gavgpool.cc)
SET_TARGET_PROPERTIES(q8gavgpool-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8gavgpool-test PRIVATE src test)
Expand All @@ -530,7 +530,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(u8maxpool-test test/u8maxpool.cc)
SET_TARGET_PROPERTIES(u8maxpool-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(u8maxpool-test PRIVATE src test)
Expand All @@ -539,7 +539,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(u8clamp-test test/u8clamp.cc)
SET_TARGET_PROPERTIES(u8clamp-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(u8clamp-test PRIVATE src test)
Expand All @@ -548,7 +548,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(u8rmax-test test/u8rmax.cc)
SET_TARGET_PROPERTIES(u8rmax-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(u8rmax-test PRIVATE src test)
Expand All @@ -557,7 +557,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(u8lut32norm-test test/u8lut32norm.cc)
SET_TARGET_PROPERTIES(u8lut32norm-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(u8lut32norm-test PRIVATE src test)
Expand All @@ -566,7 +566,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(x8lut-test test/x8lut.cc)
SET_TARGET_PROPERTIES(x8lut-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(x8lut-test PRIVATE src test)
Expand All @@ -575,7 +575,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(x8zip-test test/x8zip.cc)
SET_TARGET_PROPERTIES(x8zip-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(x8zip-test PRIVATE src test)
Expand All @@ -584,7 +584,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(hgemm-test test/hgemm.cc)
SET_TARGET_PROPERTIES(hgemm-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(hgemm-test PRIVATE src test)
Expand All @@ -593,7 +593,7 @@ IF(PYTORCH_QNNPACK_BUILD_TESTS)

ADD_EXECUTABLE(sgemm-test test/sgemm.cc)
SET_TARGET_PROPERTIES(sgemm-test PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(sgemm-test PRIVATE src test)
Expand All @@ -613,63 +613,63 @@ IF(PYTORCH_QNNPACK_BUILD_BENCHMARKS)

ADD_EXECUTABLE(add-bench bench/add.cc)
SET_TARGET_PROPERTIES(add-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(add-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(average-pooling-bench bench/average-pooling.cc)
SET_TARGET_PROPERTIES(average-pooling-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(average-pooling-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(channel-shuffle-bench bench/channel-shuffle.cc)
SET_TARGET_PROPERTIES(channel-shuffle-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(channel-shuffle-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(convolution-bench bench/convolution.cc)
SET_TARGET_PROPERTIES(convolution-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(convolution-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(global-average-pooling-bench bench/global-average-pooling.cc)
SET_TARGET_PROPERTIES(global-average-pooling-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(global-average-pooling-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(max-pooling-bench bench/max-pooling.cc)
SET_TARGET_PROPERTIES(max-pooling-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(max-pooling-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(sigmoid-bench bench/sigmoid.cc)
SET_TARGET_PROPERTIES(sigmoid-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(sigmoid-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(softargmax-bench bench/softargmax.cc)
SET_TARGET_PROPERTIES(softargmax-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_LINK_LIBRARIES(softargmax-bench PRIVATE pytorch_qnnpack benchmark)

ADD_EXECUTABLE(q8gemm-bench bench/q8gemm.cc)
SET_TARGET_PROPERTIES(q8gemm-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(q8gemm-bench PRIVATE src)
Expand All @@ -678,15 +678,15 @@ IF(PYTORCH_QNNPACK_BUILD_BENCHMARKS)

ADD_EXECUTABLE(hgemm-bench bench/hgemm.cc)
SET_TARGET_PROPERTIES(hgemm-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(hgemm-bench PRIVATE src)
TARGET_LINK_LIBRARIES(hgemm-bench PRIVATE pytorch_qnnpack cpuinfo fp16 benchmark)

ADD_EXECUTABLE(sgemm-bench bench/sgemm.cc)
SET_TARGET_PROPERTIES(sgemm-bench PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
TARGET_INCLUDE_DIRECTORIES(sgemm-bench PRIVATE src)
Expand Down
6 changes: 3 additions & 3 deletions aten/src/ATen/test/test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0)
find_package(ATen REQUIRED)
include_directories(${ATEN_INCLUDE_DIR})

# C++11
if (not MSVC)
set(CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
# C++14
if (not MSVC)
set(CMAKE_CXX_FLAGS "--std=c++14 ${CMAKE_CXX_FLAGS}")
endif()
add_executable(main main.cpp)
target_link_libraries(main ${ATEN_LIBRARIES})
Loading

0 comments on commit bc2e6d1

Please sign in to comment.