Skip to content

Commit 8035a4b

Browse files
authored
Merge pull request #90 from iotamudelta/master
Merge from upstream
2 parents 59a4ef4 + e220141 commit 8035a4b

File tree

269 files changed

+9224
-8002
lines changed

Some content is hidden

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

269 files changed

+9224
-8002
lines changed

.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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ if [[ $BUILD_ENVIRONMENT == *-rocm* ]]; then
115115
# Our cuda top_k op has some asm code, the hipified version doesn't
116116
# compile yet, so we don't have top_k operator for now
117117
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))
118122
fi
119123
120124
# Python tests

CMakeLists.txt

Lines changed: 3 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

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
445445
endif()
446446

447447
# Pass source, includes, and libs to parent
448+
set(ATen_CORE_SRCS ${ATen_CORE_SRCS} PARENT_SCOPE)
448449
set(ATen_CPU_SRCS ${ATen_CPU_SRCS} PARENT_SCOPE)
449450
set(ATen_CUDA_SRCS ${ATen_CUDA_SRCS} PARENT_SCOPE)
450451
set(ATen_CPU_TEST_SRCS ${ATen_CPU_TEST_SRCS} PARENT_SCOPE)

aten/src/ATen/CPUApplyUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ struct strided_tensor_iter {
109109
: data_(tensor.data<T>()),
110110
dim_(tensor.ndimension()),
111111
counter_(dim_, 0),
112-
sizes_(tensor.sizes()),
113-
strides_(tensor.strides()) {
112+
sizes_(tensor.sizes().vec()),
113+
strides_(tensor.strides().vec()) {
114114
_setup_arrays(tensor, this);
115115
}
116116
};

aten/src/ATen/Context.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ Context::Context()
3737
Type::registerCPU(this);
3838
}
3939

40+
// NB: Ensure that globalContext is initialized before we load
41+
// variable hooks, otherwise we will deadlock. Regardless, the
42+
// deadlock is bad, and being tracked at https://github.com/pytorch/pytorch/issues/9784
43+
static Context globalContext_;
4044
Context & globalContext() {
41-
static Context globalContext_;
4245
return globalContext_;
4346
}
4447

0 commit comments

Comments
 (0)