Skip to content

Commit 9d9118a

Browse files
authored
Merge pull request #164 from iotamudelta/ifu
Merge from upstream
2 parents b40c0bb + c69f5da commit 9d9118a

File tree

151 files changed

+4266
-966
lines changed

Some content is hidden

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

151 files changed

+4266
-966
lines changed

.jenkins/pytorch/build.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
#!/bin/bash
22

3+
# For distributed, four environmental configs:
4+
# (1) build with only NCCL
5+
# (2) build with NCCL and MPI
6+
# (3) build with only MPI
7+
# (4) build with neither
8+
if [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda9-* ]]; then
9+
# TODO: move this to Docker
10+
sudo apt-get update
11+
sudo apt-get install libnccl-dev=2.2.13-1+cuda9.0 libnccl2=2.2.13-1+cuda9.0
12+
fi
13+
14+
if [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda8-* ]] || [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda9-cudnn7-py2* ]]; then
15+
# TODO: move this to Docker
16+
sudo apt-get update
17+
sudo apt-get install openmpi-bin libopenmpi-dev
18+
sudo apt-get install -y --no-install-recommends openssh-client openssh-server
19+
sudo mkdir -p /var/run/sshd
20+
fi
21+
322
if [[ "$BUILD_ENVIRONMENT" == "pytorch-linux-xenial-py3-clang5-asan" ]]; then
423
exec "$(dirname "${BASH_SOURCE[0]}")/build-asan.sh" $*
524
fi
625

7-
# TODO: move this to Docker
8-
# TODO: add both NCCL and MPI in CI test by fixing these test first
9-
sudo apt-get update
10-
sudo apt-get install libnccl-dev libnccl2
11-
# sudo apt-get install openmpi-bin libopenmpi-dev
12-
1326
# Required environment variable: $BUILD_ENVIRONMENT
1427
# (This is set by default in the Docker images we build, so you don't
1528
# need to set it yourself.

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ if(BUILD_DOCS)
306306

307307
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/docs)
308308
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/docs)
309-
endif (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/docs)
309+
endif()
310310

311311
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs)
312312
configure_file(${DOXYGEN_C_IN} ${DOXYGEN_C_OUT} @ONLY)
@@ -323,10 +323,10 @@ if(BUILD_DOCS)
323323
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
324324
COMMENT "Generating Python API documentation with Doxygen"
325325
VERBATIM)
326-
else (DOXYGEN_FOUND)
326+
else()
327327
message(FATAL_ERROR "Doxygen needs to be installed to generate the documentation")
328-
endif (DOXYGEN_FOUND)
329-
endif (BUILD_DOCS)
328+
endif()
329+
endif()
330330

331331
# ---[ CMake related files
332332
# Uninistall option.

aten/src/ATen/Context.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <stdexcept>
1010

1111
#include "ATen/CPUGenerator.h"
12+
#include "ATen/RegisterCPU.h"
13+
14+
#include "TH/TH.h" // for USE_LAPACK
1215

1316
#ifdef USE_SSE3
1417
#include <pmmintrin.h>
@@ -34,7 +37,7 @@ Context::Context()
3437

3538
generator_registry[static_cast<int>(DeviceType::CPU)]
3639
.reset(new CPUGenerator(this));
37-
Type::registerCPU(this);
40+
register_cpu_types(this);
3841
}
3942

4043
// TODO: This could be bad juju if someone calls globalContext() in the
@@ -79,6 +82,14 @@ bool Context::hasMKL() const {
7982
#endif
8083
}
8184

85+
bool Context::hasLAPACK() const {
86+
#ifdef USE_LAPACK
87+
return true;
88+
#else
89+
return false;
90+
#endif
91+
}
92+
8293
bool Context::setFlushDenormal(bool on) {
8394
#ifdef USE_SSE3
8495
// Setting flush-to-zero (FTZ) flag

aten/src/ATen/Context.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class AT_API Context {
5050
return *generator;
5151
}
5252
bool hasMKL() const;
53+
bool hasLAPACK() const;
54+
bool hasMAGMA() const {
55+
return detail::getCUDAHooks().hasMAGMA();
56+
}
5357
bool hasCUDA() const {
5458
return detail::getCUDAHooks().hasCUDA();
5559
}
@@ -114,6 +118,7 @@ class AT_API Context {
114118
std::atomic<size_t> next_id;
115119
std::unique_ptr<THCState, void(*)(THCState*)> thc_state;
116120
friend struct Type;
121+
friend void register_cpu_types(Context * context);
117122
friend void register_cuda_types(Context * context);
118123
};
119124

@@ -157,6 +162,14 @@ static inline bool hasMKL() {
157162
return globalContext().hasMKL();
158163
}
159164

165+
static inline bool hasLAPACK() {
166+
return globalContext().hasLAPACK();
167+
}
168+
169+
static inline bool hasMAGMA() {
170+
return globalContext().hasMAGMA();
171+
}
172+
160173
static inline int64_t current_device() {
161174
return globalContext().current_device();
162175
}

aten/src/ATen/DeviceGuard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#include <ATen/Device.h>
4-
#include <ATen/ScalarType.h>
3+
#include <ATen/core/Device.h>
4+
#include <ATen/core/ScalarType.h>
55
#include <ATen/Tensor.h>
66
#include <ATen/core/Error.h>
77
#include <ATen/detail/CUDAHooksInterface.h>

aten/src/ATen/Formatting.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "ATen/Formatting.h"
22
#include "ATen/Tensor.h"
3-
#include "ATen/Context.h"
43
#include "ATen/TensorMethods.h"
54

65
#include <cmath>

aten/src/ATen/Storage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ struct AT_API Storage {
2626
template <typename T>
2727
T* unsafe_data() const { return storage_impl_->unsafe_data<T>(); }
2828

29-
size_t elementSize() const { return storage_impl_->elementSize(); }
30-
ptrdiff_t size() const { return storage_impl_->size(); }
29+
size_t elementSize() const { return storage_impl_->itemsize(); }
30+
ptrdiff_t size() const { return storage_impl_->numel(); }
3131
bool resizable() const { return storage_impl_->resizable(); }
3232
// get() use here is to get const-correctness
3333
void* data() const { return storage_impl_.get()->data(); }

aten/src/ATen/StorageImpl.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
#include <ATen/Context.h>
21
#include <ATen/StorageImpl.h>
32

43
namespace at {
54

65
StorageImpl::StorageImpl(
76
at::DataType data_type,
8-
ptrdiff_t size,
7+
int64_t numel,
98
at::DataPtr data_ptr,
109
at::Allocator* allocator,
1110
bool resizable)
1211
: data_type_(data_type),
1312
data_ptr_(std::move(data_ptr)),
14-
size_(size),
13+
numel_(numel),
1514
resizable_(resizable),
16-
allocator_(allocator),
17-
finalizer_(nullptr) {}
15+
allocator_(allocator) {}
1816

1917
StorageImpl::StorageImpl(
2018
at::DataType data_type,
21-
ptrdiff_t size,
19+
int64_t numel,
2220
at::Allocator* allocator,
2321
bool resizable)
2422
: StorageImpl(
2523
data_type,
26-
size,
24+
numel,
2725
allocator->allocate(
28-
at::elementSize(dataTypeToScalarType(data_type)) * size),
26+
at::elementSize(dataTypeToScalarType(data_type)) * numel),
2927
allocator,
3028
resizable) {}
3129

aten/src/ATen/StorageImpl.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <ATen/Allocator.h>
44
#include <ATen/ScalarType.h>
55
#include <ATen/ScalarTypeUtils.h>
6-
#include <TH/THTypeConversion.hpp>
76

87
#include <ATen/core/intrusive_ptr.h>
98

@@ -21,16 +20,16 @@ struct Type;
2120
struct AT_API StorageImpl : public c10::intrusive_ptr_target {
2221
public:
2322
StorageImpl() = delete;
24-
virtual ~StorageImpl() {};
23+
~StorageImpl() {};
2524
StorageImpl(
2625
at::DataType data_type,
27-
ptrdiff_t size,
26+
int64_t numel,
2827
at::DataPtr data_ptr,
2928
at::Allocator* allocator,
3029
bool resizable);
3130
StorageImpl(
3231
at::DataType data_type,
33-
ptrdiff_t size,
32+
int64_t numel,
3433
at::Allocator* allocator,
3534
bool resizable);
3635
StorageImpl(StorageImpl&) = delete;
@@ -44,7 +43,7 @@ struct AT_API StorageImpl : public c10::intrusive_ptr_target {
4443
template <typename T>
4544
inline T* data() const {
4645
auto data_type_T =
47-
at::scalarTypeToDataType(at::CTypeToScalarType<th::from_type<T>>::to());
46+
at::scalarTypeToDataType(at::CTypeToScalarType<T>::to());
4847
if (dtype() != data_type_T) {
4948
AT_ERROR(
5049
"Attempt to access StorageImpl having data type ",
@@ -61,27 +60,22 @@ struct AT_API StorageImpl : public c10::intrusive_ptr_target {
6160
}
6261

6362
void release_resources() override {
64-
if (finalizer_) {
65-
(*finalizer_)();
66-
}
67-
finalizer_ = nullptr;
6863
data_ptr_.clear();
6964
}
7065

7166
void operator=(const StorageImpl&) = delete;
7267

73-
size_t elementSize() const {
68+
size_t itemsize() const {
7469
return at::elementSize(dataTypeToScalarType(data_type_));
7570
}
7671

7772
Type& type();
7873

79-
// TODO: Rename to size() and size to size_
80-
ptrdiff_t size() const {
81-
return size_;
74+
int64_t numel() const {
75+
return numel_;
8276
};
83-
void set_size(ptrdiff_t size) {
84-
size_ = size;
77+
void set_numel(int64_t numel) {
78+
numel_ = numel;
8579
};
8680
bool resizable() const {
8781
return resizable_;
@@ -132,9 +126,8 @@ struct AT_API StorageImpl : public c10::intrusive_ptr_target {
132126
private:
133127
at::DataType data_type_;
134128
at::DataPtr data_ptr_;
135-
ptrdiff_t size_;
129+
int64_t numel_;
136130
bool resizable_;
137131
at::Allocator* allocator_;
138-
std::unique_ptr<THFinalizer> finalizer_;
139132
};
140133
} // namespace at

aten/src/ATen/TensorBase.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

aten/src/ATen/TensorImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <atomic>
44
#include <memory>
55

6-
#include "ATen/Retainable.h"
7-
#include "ATen/StorageImpl.h"
86
#include "ATen/Storage.h"
97
#include "ATen/core/optional.h"
108
#include "ATen/core/TensorTypeId.h"

aten/src/ATen/TensorOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include <ATen/core/Backend.h>
44
#include <ATen/Context.h>
5-
#include <ATen/Device.h>
5+
#include <ATen/core/Device.h>
66
#include <ATen/DeviceGuard.h>
77
#include <ATen/core/Layout.h>
8-
#include <ATen/ScalarType.h>
8+
#include <ATen/core/ScalarType.h>
99
#include <ATen/Tensor.h>
1010
#include <ATen/Type.h>
1111

aten/src/ATen/UndefinedTensor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "ATen/UndefinedTensor.h"
2-
#include "ATen/Context.h"
32
#include "ATen/core/Error.h"
43

54
namespace at {

aten/src/ATen/UndefinedType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
namespace at {
55

6-
UndefinedType::UndefinedType(Context* context)
7-
: Type(context, UndefinedTensorId(), /*is_variable=*/false, /*is_undefined=*/true) {}
6+
UndefinedType::UndefinedType()
7+
: Type(UndefinedTensorId(), /*is_variable=*/false, /*is_undefined=*/true) {}
88
ScalarType UndefinedType::scalarType() const {
99
return ScalarType::Undefined;
1010
}

aten/src/ATen/UndefinedType.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "ATen/Type.h"
4-
#include "ATen/Context.h"
54
#include "ATen/CheckGenerator.h"
65

76
#ifdef _MSC_VER
@@ -13,7 +12,7 @@
1312
namespace at {
1413

1514
struct UndefinedType final : public Type {
16-
explicit UndefinedType(Context* context);
15+
explicit UndefinedType();
1716
virtual ScalarType scalarType() const override;
1817
virtual Backend backend() const override;
1918
virtual bool is_cuda() const override;

0 commit comments

Comments
 (0)