Skip to content

Commit 13eb934

Browse files
authored
Merge pull request #94 from ashishfarmer/caffe2_specific
Sync with master branch
2 parents 93c0948 + 8602912 commit 13eb934

File tree

375 files changed

+11849
-8809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+11849
-8809
lines changed

.clang-tidy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# NOTE: there must be no spaces before the '-', so put the comma first.
33
Checks: '
44
*
5+
,clang-analyzer-*
56
,modernize-*
67
,-cert-err58-cpp
78
,-cert-err60-cpp
89
,-clang-diagnostic-*
910
,-cppcoreguidelines-owning-memory
1011
,-cppcoreguidelines-pro-bounds-array-to-pointer-decay
1112
,-cppcoreguidelines-pro-bounds-constant-array-index
13+
,-cppcoreguidelines-pro-type-member-init
1214
,-cppcoreguidelines-pro-type-static-cast-downcast
1315
,-cppcoreguidelines-pro-type-vararg
1416
,-cppcoreguidelines-special-member-functions
@@ -23,9 +25,11 @@ Checks: '
2325
,-hicpp-braces-around-statements
2426
,-hicpp-explicit-conversions
2527
,-hicpp-no-array-decay
28+
,-hicpp-signed-bitwise
2629
,-hicpp-special-member-functions
2730
,-hicpp-vararg
2831
,-llvm-header-guard
32+
,-llvm-include-order
2933
,-llvm-namespace-comment
3034
,-misc-unused-parameters
3135
,-modernize-make-unique
@@ -34,7 +38,6 @@ Checks: '
3438
,-readability-braces-around-statements
3539
,-readability-else-after-return
3640
,-readability-named-parameter
37-
,clang-analyzer-*
3841
'
3942
WarningsAsErrors: ''
4043
HeaderFilterRegex: 'torch/csrc/'

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.bat text eol=crlf

.jenkins/caffe2/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ CMAKE_ARGS+=("-DUSE_OBSERVERS=ON")
124124
CMAKE_ARGS+=("-DUSE_ZSTD=ON")
125125
CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}")
126126
127-
if [[ $BUILD_ENVIRONMENT == *-aten-* ]]; then
127+
if [[ $BUILD_ENVIRONMENT == *-aten-* || -n "$INTEGRATED" ]]; then
128128
if [[ CMAKE_ARGS != *USE_ATEN* ]] && [[ CMAKE_ARGS != *BUILD_ATEN* ]]; then
129129
CMAKE_ARGS+=("-DBUILD_ATEN=ON")
130130
fi

.jenkins/caffe2/test.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ for test in $(find "${INSTALL_PREFIX}/test" -executable -type f); do
6464
;;
6565
*/aten/*)
6666
# ATen uses test framework Catch2
67-
"$test" -r=xml -o "${junit_reports_dir}/$(basename $test).xml"
67+
# NB: We do NOT use the xml test reporter, because
68+
# Catch doesn't support multiple reporters
69+
# c.f. https://github.com/catchorg/Catch2/blob/master/docs/release-notes.md#223
70+
# which means that enabling XML output means you lose useful stdout
71+
# output for Jenkins. It's more important to have useful console
72+
# output than it is to have XML output for Jenkins.
73+
"$test"
6874
;;
6975
*)
7076
"$test" --gtest_output=xml:"$gtest_reports_dir/$(basename $test).xml"
@@ -109,6 +115,10 @@ if [[ $BUILD_ENVIRONMENT == *-rocm* ]]; then
109115
# Our cuda top_k op has some asm code, the hipified version doesn't
110116
# compile yet, so we don't have top_k operator for now
111117
rocm_ignore_test+=("--ignore $CAFFE2_PYPATH/python/operator_test/top_k_test.py")
118+
119+
# Our AMD CI boxes have 4 gpus on each
120+
# Remove this once we have added multi-gpu support
121+
export HIP_VISIBLE_DEVICES=$(($BUILD_NUMBER % 4))
112122
fi
113123
114124
# Python tests

.jenkins/pytorch/build.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
4343
# https://github.com/RadeonOpenCompute/hcc#hcc-with-thinlto-linking
4444
export KMTHINLTO=1
4545

46-
sudo chown -R jenkins:jenkins /usr/local
47-
rm -rf "$(dirname "${BASH_SOURCE[0]}")/../../../pytorch_amd/" || true
48-
python "$(dirname "${BASH_SOURCE[0]}")/../../tools/amd_build/build_pytorch_amd.py"
49-
50-
USE_ROCM=1 python setup.py install
51-
exit
46+
python tools/amd_build/build_pytorch_amd.py
47+
USE_ROCM=1 python setup.py install --user
48+
exit 0
5249
fi
5350

5451
# TODO: Don't install this here

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ if(NOT MSVC)
214214
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-overflow")
215215
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
216216
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
217+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow")
217218
# These flags are not available in GCC-4.8.5. Set only when using clang.
218219
# Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html
219-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
220+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
220221
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization")
221222
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-typedef-redefinition")
222223
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
@@ -226,6 +227,7 @@ if(NOT MSVC)
226227
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++14-extensions")
227228
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
228229
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
230+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
229231
endif()
230232
if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
231233
OR (CMAKE_COMPILER_IS_GNUCXX
@@ -284,6 +286,8 @@ include_directories(BEFORE ${PROJECT_SOURCE_DIR})
284286
# in PROJECT_SOURCE_DIR.
285287
include_directories(BEFORE ${PROJECT_BINARY_DIR})
286288

289+
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/aten/src/)
290+
287291
# ---[ Old caffe protobuf
288292
if(BUILD_CAFFE2)
289293
add_subdirectory(caffe/proto)

aten/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,5 @@ if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
146146
set(ATen_THIRD_PARTY_INCLUDE ${ATen_THIRD_PARTY_INCLUDE} PARENT_SCOPE)
147147
set(ATen_CPU_DEPENDENCY_LIBS ${ATen_CPU_DEPENDENCY_LIBS} PARENT_SCOPE)
148148
set(ATen_CUDA_DEPENDENCY_LIBS ${ATen_CUDA_DEPENDENCY_LIBS} PARENT_SCOPE)
149+
set(ATen_CORE_TEST_SRCS ${ATen_CORE_TEST_SRCS} PARENT_SCOPE)
149150
endif()

aten/src/ATen/Allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <ATen/Error.h>
77
#include <ATen/Retainable.h>
88
#include <ATen/Device.h>
9-
#include <ATen/detail/UniqueVoidPtr.h>
9+
#include <ATen/core/UniqueVoidPtr.h>
1010

1111
namespace at {
1212

aten/src/ATen/ArrayRef.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <ATen/ArrayRef.h>

aten/src/ATen/ArrayRef.h

Lines changed: 1 addition & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,2 @@
1-
//===--- ArrayRef.h - Array Reference Wrapper -------------------*- C++ -*-===//
2-
//
3-
// The LLVM Compiler Infrastructure
4-
//
5-
// This file is distributed under the University of Illinois Open Source
6-
// License. See LICENSE.TXT for details.
7-
//
8-
//===----------------------------------------------------------------------===//
9-
10-
// ATen: modified from llvm::ArrayRef.
11-
// removed llvm-specific functionality
12-
// removed some implicit const -> non-const conversions that rely on
13-
// complicated std::enable_if meta-programming
14-
// removed a bunch of slice variants for simplicity...
15-
161
#pragma once
17-
18-
#include <ATen/Error.h>
19-
#include <ATen/SmallVector.h>
20-
21-
#include <array>
22-
#include <iterator>
23-
#include <vector>
24-
25-
namespace at {
26-
/// ArrayRef - Represent a constant reference to an array (0 or more elements
27-
/// consecutively in memory), i.e. a start pointer and a length. It allows
28-
/// various APIs to take consecutive elements easily and conveniently.
29-
///
30-
/// This class does not own the underlying data, it is expected to be used in
31-
/// situations where the data resides in some other buffer, whose lifetime
32-
/// extends past that of the ArrayRef. For this reason, it is not in general
33-
/// safe to store an ArrayRef.
34-
///
35-
/// This is intended to be trivially copyable, so it should be passed by
36-
/// value.
37-
template<typename T>
38-
class ArrayRef {
39-
public:
40-
typedef const T *iterator;
41-
typedef const T *const_iterator;
42-
typedef size_t size_type;
43-
44-
typedef std::reverse_iterator<iterator> reverse_iterator;
45-
46-
private:
47-
/// The start of the array, in an external buffer.
48-
const T *Data;
49-
50-
/// The number of elements.
51-
size_type Length;
52-
53-
public:
54-
/// @name Constructors
55-
/// @{
56-
57-
/// Construct an empty ArrayRef.
58-
/*implicit*/ ArrayRef() : Data(nullptr), Length(0) {}
59-
60-
/// Construct an ArrayRef from a single element.
61-
/*implicit*/ ArrayRef(const T &OneElt)
62-
: Data(&OneElt), Length(1) {}
63-
64-
/// Construct an ArrayRef from a pointer and length.
65-
/*implicit*/ ArrayRef(const T *data, size_t length)
66-
: Data(data), Length(length) {}
67-
68-
/// Construct an ArrayRef from a range.
69-
ArrayRef(const T *begin, const T *end)
70-
: Data(begin), Length(end - begin) {}
71-
72-
/// Construct an ArrayRef from a SmallVector. This is templated in order to
73-
/// avoid instantiating SmallVectorTemplateCommon<T> whenever we
74-
/// copy-construct an ArrayRef.
75-
template<typename U>
76-
/*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
77-
: Data(Vec.data()), Length(Vec.size()) {
78-
}
79-
80-
/// Construct an ArrayRef from a std::vector.
81-
template<typename A>
82-
/*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
83-
: Data(Vec.data()), Length(Vec.size()) {}
84-
85-
/// Construct an ArrayRef from a std::array
86-
template <size_t N>
87-
/*implicit*/ constexpr ArrayRef(const std::array<T, N> &Arr)
88-
: Data(Arr.data()), Length(N) {}
89-
90-
/// Construct an ArrayRef from a C array.
91-
template <size_t N>
92-
/*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
93-
94-
/// Construct an ArrayRef from a std::initializer_list.
95-
/*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
96-
: Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
97-
Length(Vec.size()) {}
98-
99-
/// @}
100-
/// @name Simple Operations
101-
/// @{
102-
103-
const_iterator begin() const { return Data; }
104-
const_iterator end() const { return Data + Length; }
105-
106-
reverse_iterator rbegin() const { return reverse_iterator(end()); }
107-
reverse_iterator rend() const { return reverse_iterator(begin()); }
108-
109-
/// empty - Check if the array is empty.
110-
bool empty() const { return Length == 0; }
111-
112-
const T *data() const { return Data; }
113-
114-
/// size - Get the array size.
115-
size_t size() const { return Length; }
116-
117-
/// front - Get the first element.
118-
const T &front() const {
119-
AT_CHECK(!empty(), "ArrayRef: attempted to access front() of empty list");
120-
return Data[0];
121-
}
122-
123-
/// back - Get the last element.
124-
const T &back() const {
125-
AT_CHECK(!empty(), "ArrayRef: attempted to access back() of empty list");
126-
return Data[Length-1];
127-
}
128-
129-
/// equals - Check for element-wise equality.
130-
bool equals(ArrayRef RHS) const {
131-
if (Length != RHS.Length)
132-
return false;
133-
return std::equal(begin(), end(), RHS.begin());
134-
}
135-
136-
/// slice(n, m) - Chop off the first N elements of the array, and keep M
137-
/// elements in the array.
138-
ArrayRef<T> slice(size_t N, size_t M) const {
139-
AT_CHECK(N+M <= size(), "ArrayRef: invalid slice, ", N, " + ", M, " is not <= ", size());
140-
return ArrayRef<T>(data()+N, M);
141-
}
142-
143-
/// slice(n) - Chop off the first N elements of the array.
144-
ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
145-
146-
/// @}
147-
/// @name Operator Overloads
148-
/// @{
149-
const T &operator[](size_t Index) const {
150-
return Data[Index];
151-
}
152-
153-
/// Vector compatibility
154-
const T &at(size_t Index) const {
155-
AT_CHECK(Index < Length, "ArrayRef: invalid index ", Index, " for length ", Length);
156-
return Data[Index];
157-
}
158-
159-
/// Disallow accidental assignment from a temporary.
160-
///
161-
/// The declaration here is extra complicated so that "arrayRef = {}"
162-
/// continues to select the move assignment operator.
163-
template <typename U>
164-
typename std::enable_if<std::is_same<U, T>::value, ArrayRef<T>>::type &
165-
operator=(U &&Temporary) = delete;
166-
167-
/// Disallow accidental assignment from a temporary.
168-
///
169-
/// The declaration here is extra complicated so that "arrayRef = {}"
170-
/// continues to select the move assignment operator.
171-
template <typename U>
172-
typename std::enable_if<std::is_same<U, T>::value, ArrayRef<T>>::type &
173-
operator=(std::initializer_list<U>) = delete;
174-
175-
/// @}
176-
/// @name Expensive Operations
177-
/// @{
178-
std::vector<T> vec() const {
179-
return std::vector<T>(Data, Data+Length);
180-
}
181-
182-
/// @}
183-
/// @name Conversion operators
184-
/// @{
185-
operator std::vector<T>() const {
186-
return std::vector<T>(Data, Data+Length);
187-
}
188-
189-
/// @}
190-
};
191-
192-
} // end namespace at
2+
#include <ATen/core/ArrayRef.h>

aten/src/ATen/Backtrace.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,2 @@
11
#pragma once
2-
3-
#include <cstddef>
4-
#include <string>
5-
#include <typeinfo>
6-
7-
#include <ATen/ATenGeneral.h>
8-
9-
namespace at {
10-
/// Utility to demangle a C++ symbol name.
11-
AT_API std::string demangle(const char* name);
12-
13-
/// Returns the printable name of the type.
14-
template <typename T>
15-
inline const char* demangle_type() {
16-
#ifdef __GXX_RTTI
17-
static const std::string name = demangle(typeid(T).name());
18-
return name.c_str();
19-
#else // __GXX_RTTI
20-
return "(RTTI disabled, cannot show name)";
21-
#endif // __GXX_RTTI
22-
}
23-
24-
AT_API std::string get_backtrace(
25-
size_t frames_to_skip = 0,
26-
size_t maximum_number_of_frames = 64,
27-
bool skip_python_frames = true);
28-
} // namespace at
2+
#include <ATen/core/Backtrace.h>

aten/src/ATen/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ CONFIGURE_FILE(cuda/CUDAConfig.h.in "${CMAKE_CURRENT_SOURCE_DIR}/cuda/CUDAConfig
4444
# NB: If you edit these globs, you'll have to update setup.py package_data as well
4545
FILE(GLOB base_h "*.h" "detail/*.h")
4646
FILE(GLOB base_cpp "*.cpp" "detail/*.cpp")
47+
add_subdirectory(core)
4748
FILE(GLOB cuda_h "cuda/*.h" "cuda/detail/*.h" "cuda/*.cuh" "cuda/detail/*.cuh")
4849
FILE(GLOB cuda_cpp "cuda/*.cpp" "cuda/detail/*.cpp")
4950
FILE(GLOB cuda_cu "cuda/*.cu" "cuda/detail/*.cu")
@@ -62,7 +63,7 @@ FILE(GLOB native_cuda_cpp "native/cuda/*.cpp")
6263
FILE(GLOB native_mkl_cpp "native/mkl/*.cpp")
6364
FILE(GLOB native_mkldnn_cpp "native/mkldnn/*.cpp")
6465

65-
set(all_cpu_cpp ${base_cpp} ${native_cpp} ${native_sparse_cpp} ${native_mkl_cpp} ${native_mkldnn_cpp} ${generated_cpp} ${ATen_CPU_SRCS} ${cpu_kernel_cpp})
66+
set(all_cpu_cpp ${base_cpp} ${ATen_CORE_SRCS} ${native_cpp} ${native_sparse_cpp} ${native_mkl_cpp} ${native_mkldnn_cpp} ${generated_cpp} ${ATen_CPU_SRCS} ${cpu_kernel_cpp})
6667
if(AT_MKL_ENABLED)
6768
set(all_cpu_cpp ${all_cpu_cpp} ${mkl_cpp})
6869
endif()
@@ -393,7 +394,7 @@ INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake-exports/ATenConfig.cmake"
393394
DESTINATION "${AT_INSTALL_SHARE_DIR}/cmake/ATen")
394395

395396
# https://stackoverflow.com/questions/11096471/how-can-i-install-a-hierarchy-of-files-using-cmake
396-
FOREACH(HEADER ${base_h} ${cuda_h} ${cudnn_h})
397+
FOREACH(HEADER ${base_h} ${ATen_CORE_HEADERS} ${cuda_h} ${cudnn_h})
397398
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" HEADER_SUB ${HEADER})
398399
GET_FILENAME_COMPONENT(DIR ${HEADER_SUB} DIRECTORY)
399400
INSTALL(FILES ${HEADER} DESTINATION ${AT_INSTALL_INCLUDE_DIR}/ATen/${DIR})
@@ -444,6 +445,7 @@ if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
444445
endif()
445446

446447
# Pass source, includes, and libs to parent
448+
set(ATen_CORE_SRCS ${ATen_CORE_SRCS} PARENT_SCOPE)
447449
set(ATen_CPU_SRCS ${ATen_CPU_SRCS} PARENT_SCOPE)
448450
set(ATen_CUDA_SRCS ${ATen_CUDA_SRCS} PARENT_SCOPE)
449451
set(ATen_CPU_TEST_SRCS ${ATen_CPU_TEST_SRCS} PARENT_SCOPE)

0 commit comments

Comments
 (0)