From ba5d33bedeec57bb35cf27a9d6023c8b3676dda5 Mon Sep 17 00:00:00 2001 From: Junjie Bai Date: Tue, 31 Jul 2018 15:23:51 -0700 Subject: [PATCH] Re-Enable ATen in C2 in integration builds to test ONNX ATen conversions Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/10060 Differential Revision: D9081387 Pulled By: bddppq fbshipit-source-id: 13cbff63df5241e013d4ebacfcd6da082e7196f6 --- .jenkins/caffe2/build.sh | 2 +- CMakeLists.txt | 3 ++- cmake/MiscCheck.cmake | 9 +++++++++ setup_caffe2.py | 1 + test/onnx/test_pytorch_onnx_caffe2.py | 12 ++++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.jenkins/caffe2/build.sh b/.jenkins/caffe2/build.sh index 6b8aa6fc62b..3bc5157d9ca 100755 --- a/.jenkins/caffe2/build.sh +++ b/.jenkins/caffe2/build.sh @@ -124,7 +124,7 @@ CMAKE_ARGS+=("-DUSE_OBSERVERS=ON") CMAKE_ARGS+=("-DUSE_ZSTD=ON") CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}") -if [[ $BUILD_ENVIRONMENT == *-aten-* ]]; then +if [[ $BUILD_ENVIRONMENT == *-aten-* || -n "$INTEGRATED" ]]; then if [[ CMAKE_ARGS != *USE_ATEN* ]] && [[ CMAKE_ARGS != *BUILD_ATEN* ]]; then CMAKE_ARGS+=("-DBUILD_ATEN=ON") fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 51984e0b79c..b8e2f2dbda0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") # These flags are not available in GCC-4.8.5. Set only when using clang. # Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-typedef-redefinition") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option") @@ -226,6 +226,7 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++14-extensions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") endif() if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0"))) OR (CMAKE_COMPILER_IS_GNUCXX diff --git a/cmake/MiscCheck.cmake b/cmake/MiscCheck.cmake index b05acdf1c90..2f2628bb149 100644 --- a/cmake/MiscCheck.cmake +++ b/cmake/MiscCheck.cmake @@ -161,6 +161,15 @@ if (${COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_VISIBILITY_FLAG}") endif() +# ---[ Checks if linker supports -rdynamic. `-rdynamic` tells linker +# -to add all (including unused) symbols into the dynamic symbol +# -table. We need this to get symbols when generating backtrace at +# -runtime. +check_cxx_compiler_flag("-rdynamic" COMPILER_SUPPORTS_RDYNAMIC) +if (${COMPILER_SUPPORTS_RDYNAMIC}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") +endif() + # ---[ If we are using msvc, set no warning flags # Note(jiayq): if you are going to add a warning flag, check if this is # totally necessary, and only add when you see fit. If it is needed due to diff --git a/setup_caffe2.py b/setup_caffe2.py index 0fd620549b3..d8ebf4fc7ed 100644 --- a/setup_caffe2.py +++ b/setup_caffe2.py @@ -131,6 +131,7 @@ class cmake_build(Caffe2Command): # configure cmake_args = [ find_executable('cmake'), + '-DUSE_ATEN=ON', '-DBUILD_SHARED_LIBS=OFF', '-DPYTHON_EXECUTABLE:FILEPATH={}'.format(sys.executable), '-DPYTHON_INCLUDE_DIR={}'.format(sysconfig.get_python_inc()), diff --git a/test/onnx/test_pytorch_onnx_caffe2.py b/test/onnx/test_pytorch_onnx_caffe2.py index 0284828e400..7130a7695cc 100644 --- a/test/onnx/test_pytorch_onnx_caffe2.py +++ b/test/onnx/test_pytorch_onnx_caffe2.py @@ -676,6 +676,18 @@ class TestCaffe2Backend(unittest.TestCase): x = Variable(torch.randn(*shape)) self.run_model_test(MyModel(), train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False) + def test_cumsum(self): + shape = (3, 4, 5) + for params in [{'dim': i} for i in range(len(shape))]: + class MyModel(torch.nn.Module): + def __init__(self): + super(MyModel, self).__init__() + + def forward(self, x): + return torch.cumsum(x, **params) + x = Variable(torch.randn(*shape)) + self.run_model_test(MyModel(), train=False, input=(x), batch_size=BATCH_SIZE, use_gpu=False) + def test_repeat(self): class MyModel(torch.nn.Module): def __init__(self):