Skip to content

Merge from upstream #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9a9a732
Remove the generation of storage files
cpuhrsch Jul 30, 2018
b4f8c60
Don't use the XML reporter for Catch2. (#10012)
ezyang Jul 30, 2018
73a60ef
Fix Caffe2CTScan error (#9962)
jerryzh168 Jul 30, 2018
ce5f0d4
Enable n-dimensional empty tensors. (#9947)
gchanan Jul 30, 2018
faa96c1
Deal with spaces in einsum equation string (#9994)
t-vi Jul 30, 2018
40a8239
Fix a bug in argument spec (#9958)
zdevito Jul 30, 2018
04939a4
Match parameter names and = default (#9737)
goldsborough Jul 30, 2018
c9eab34
Fix Caffe2 with ATen conda build failure (#10020)
mingzhe09088 Jul 30, 2018
ea3c36b
NumPy Scalar to PyTorch Scalar (#9225)
vishwakftw Jul 30, 2018
6c7fb15
Introduce __array_priority__ on torch.Tensor (#9651)
t-vi Jul 30, 2018
57750bd
Enable ATen in C2 in integration builds to test ONNX ATen conversions…
bddppq Jul 30, 2018
7214754
Check and return when numel() == 0 in Loops.cuh.
gchanan Jul 30, 2018
9987282
Use Retainable as base class for StorageImpl
cpuhrsch Jul 30, 2018
db96a09
Add SIMD version to GFTRL optimizer (#9698)
xiuyanni Jul 30, 2018
e57cb4a
Add a Constant Propagation Pass to the JIT (#8808)
Jul 30, 2018
3e3f40a
Update onnx to latest master (#10024)
onnxbot Jul 30, 2018
e0a0234
Remove C++14 feature (#10022)
Jul 30, 2018
788b2e9
nomnigraph - minor cleanup of Graph.h (#9890)
duc0 Jul 30, 2018
8f0a229
Fix HPTT path for 0-sized inputs.
Jul 31, 2018
51539fa
Add pyyaml into caffe2 requirements.txt for USE_ATEN
bddppq Jul 31, 2018
aa36a5d
Add typing into caffe2 requirements.txt for USE_ATEN (#10047)
bddppq Jul 31, 2018
37a226d
When BUILD_ATEN=OFF, use ATen/core directly (#10019)
ezyang Jul 31, 2018
78b806c
Fix the onnx symbolic for upsample (#10001)
houseroad Jul 31, 2018
6fb9acf
Revert empty n-dim and ATen in C2 integration builds
gchanan Jul 31, 2018
5e5c15d
Add (constant size) TensorLists to JIT, use them in cat and stack nod…
apaszke Jul 31, 2018
bdebdd1
Merge remote-tracking branch 'upstream/master'
iotamudelta Jul 31, 2018
68cbe37
fix the reference link path
103yiran Jul 31, 2018
c2d9d28
Fix typo in tensors.rst (#10073)
mohammad7t Jul 31, 2018
0c11101
Prepare THNN/THCUNN for first class scalars. (#10023)
gchanan Jul 31, 2018
cba03e2
Handle dynamic repeats in onnx symbolic (#10052)
bddppq Jul 31, 2018
f779202
Correctly set CAFFE2_DISABLE_NUMA when USE_NUMA=OFF in cmake (#10061)
bddppq Jul 31, 2018
430e444
Delete some obsolete steps in the ROCm build. (#10005)
ezyang Jul 31, 2018
685224a
Add CTC loss (#9628)
t-vi Jul 31, 2018
1ae520c
Add AT_CHECK for null storage. (#9823)
ezyang Jul 31, 2018
371a786
Errors out when Openmpi < 2.x.x with distributed. (#10015)
Jul 31, 2018
81f78a8
Merge remote-tracking branch 'upstream/master'
iotamudelta Jul 31, 2018
11df981
Missed one removal.
iotamudelta Jul 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# NOTE: there must be no spaces before the '-', so put the comma first.
Checks: '
*
,clang-analyzer-*
,modernize-*
,-cert-err58-cpp
,-cert-err60-cpp
,-clang-diagnostic-*
,-cppcoreguidelines-owning-memory
,-cppcoreguidelines-pro-bounds-array-to-pointer-decay
,-cppcoreguidelines-pro-bounds-constant-array-index
,-cppcoreguidelines-pro-type-member-init
,-cppcoreguidelines-pro-type-static-cast-downcast
,-cppcoreguidelines-pro-type-vararg
,-cppcoreguidelines-special-member-functions
Expand All @@ -23,9 +25,11 @@ Checks: '
,-hicpp-braces-around-statements
,-hicpp-explicit-conversions
,-hicpp-no-array-decay
,-hicpp-signed-bitwise
,-hicpp-special-member-functions
,-hicpp-vararg
,-llvm-header-guard
,-llvm-include-order
,-llvm-namespace-comment
,-misc-unused-parameters
,-modernize-make-unique
Expand All @@ -34,7 +38,6 @@ Checks: '
,-readability-braces-around-statements
,-readability-else-after-return
,-readability-named-parameter
,clang-analyzer-*
'
WarningsAsErrors: ''
HeaderFilterRegex: 'torch/csrc/'
Expand Down
8 changes: 7 additions & 1 deletion .jenkins/caffe2/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ for test in $(find "${INSTALL_PREFIX}/test" -executable -type f); do
;;
*/aten/*)
# ATen uses test framework Catch2
"$test" -r=xml -o "${junit_reports_dir}/$(basename $test).xml"
# NB: We do NOT use the xml test reporter, because
# Catch doesn't support multiple reporters
# c.f. https://github.com/catchorg/Catch2/blob/master/docs/release-notes.md#223
# which means that enabling XML output means you lose useful stdout
# output for Jenkins. It's more important to have useful console
# output than it is to have XML output for Jenkins.
"$test"
;;
*)
"$test" --gtest_output=xml:"$gtest_reports_dir/$(basename $test).xml"
Expand Down
9 changes: 3 additions & 6 deletions .jenkins/pytorch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
# https://github.com/RadeonOpenCompute/hcc#hcc-with-thinlto-linking
export KMTHINLTO=1

sudo chown -R jenkins:jenkins /usr/local
rm -rf "$(dirname "${BASH_SOURCE[0]}")/../../../pytorch_amd/" || true
python "$(dirname "${BASH_SOURCE[0]}")/../../tools/amd_build/build_pytorch_amd.py"

USE_ROCM=1 python setup.py install
exit
python tools/amd_build/build_pytorch_amd.py
USE_ROCM=1 python setup.py install --user
exit 0
fi

# TODO: Don't install this here
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ include_directories(BEFORE ${PROJECT_SOURCE_DIR})
# in PROJECT_SOURCE_DIR.
include_directories(BEFORE ${PROJECT_BINARY_DIR})

include_directories(BEFORE ${PROJECT_SOURCE_DIR}/aten/src/)

# ---[ Old caffe protobuf
if(BUILD_CAFFE2)
add_subdirectory(caffe/proto)
Expand Down
5 changes: 3 additions & 2 deletions aten/src/ATen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ CONFIGURE_FILE(cuda/CUDAConfig.h.in "${CMAKE_CURRENT_SOURCE_DIR}/cuda/CUDAConfig
# NB: If you edit these globs, you'll have to update setup.py package_data as well
FILE(GLOB base_h "*.h" "detail/*.h")
FILE(GLOB base_cpp "*.cpp" "detail/*.cpp")
add_subdirectory(core)
FILE(GLOB cuda_h "cuda/*.h" "cuda/detail/*.h" "cuda/*.cuh" "cuda/detail/*.cuh")
FILE(GLOB cuda_cpp "cuda/*.cpp" "cuda/detail/*.cpp")
FILE(GLOB cuda_cu "cuda/*.cu" "cuda/detail/*.cu")
Expand All @@ -62,7 +63,7 @@ FILE(GLOB native_cuda_cpp "native/cuda/*.cpp")
FILE(GLOB native_mkl_cpp "native/mkl/*.cpp")
FILE(GLOB native_mkldnn_cpp "native/mkldnn/*.cpp")

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})
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})
if(AT_MKL_ENABLED)
set(all_cpu_cpp ${all_cpu_cpp} ${mkl_cpp})
endif()
Expand Down Expand Up @@ -393,7 +394,7 @@ INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake-exports/ATenConfig.cmake"
DESTINATION "${AT_INSTALL_SHARE_DIR}/cmake/ATen")

# https://stackoverflow.com/questions/11096471/how-can-i-install-a-hierarchy-of-files-using-cmake
FOREACH(HEADER ${base_h} ${cuda_h} ${cudnn_h})
FOREACH(HEADER ${base_h} ${ATen_CORE_HEADERS} ${cuda_h} ${cudnn_h})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" HEADER_SUB ${HEADER})
GET_FILENAME_COMPONENT(DIR ${HEADER_SUB} DIRECTORY)
INSTALL(FILES ${HEADER} DESTINATION ${AT_INSTALL_INCLUDE_DIR}/ATen/${DIR})
Expand Down
3 changes: 3 additions & 0 deletions aten/src/ATen/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "ATen/detail/CUDAHooksInterface.h"
#include "ATen/CUDAStream.h"

// This is temporary
#include "ATen/core/ATenCoreTest.h"

#include <memory>
#include <mutex>
#include <cstdint>
Expand Down
30 changes: 20 additions & 10 deletions aten/src/ATen/Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@

namespace at {

Storage::Storage(at::ScalarType scalar_type, size_t size, Allocator* allocator)
: storage_impl_(new StorageImpl(
scalar_type,
size,
allocator,
/* resizable */ false)) {}

Storage::Storage(
at::ScalarType scalar_type,
at::DataPtr data_ptr,
size_t size,
const std::function<void(void*)>& deleter)
: storage_impl_(new StorageImpl(
scalar_type,
size,
std::move(data_ptr),
/* allocator */ nullptr,
/* resizable */ false)) {}

Storage::~Storage() {
if (!storage_impl_) {
return;
}
if (--storage_impl_->refcount == 0) {
if (storage_impl_->finalizer) {
(*storage_impl_->finalizer)();
}
storage_impl_->finalizer = nullptr;
storage_impl_->data_ptr.clear();
if (storage_impl_ && --storage_impl_->weakcount == 0) {
delete storage_impl_;
}
}
storage_impl_->release();
}

} // namespace at
6 changes: 6 additions & 0 deletions aten/src/ATen/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ struct AT_API Storage {
public:
Storage() = delete;
Storage(StorageImpl* storage_impl) : storage_impl_(storage_impl) {}
Storage(at::ScalarType, size_t size, Allocator* allocator);
Storage(
at::ScalarType,
at::DataPtr,
size_t size,
const std::function<void(void*)>& deleter);
~Storage();
// There are reasonable interpretations of these constructors, but they're to
// be implemented on demand.
Expand Down
2 changes: 0 additions & 2 deletions aten/src/ATen/StorageImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ StorageImpl::StorageImpl(
: scalar_type(scalar_type),
data_ptr(std::move(data_ptr)),
size(size),
refcount(1),
weakcount(1), // from the strong reference
resizable(resizable),
allocator(allocator),
finalizer(nullptr) {}
Expand Down
16 changes: 10 additions & 6 deletions aten/src/ATen/StorageImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <ATen/Allocator.h>
#include <ATen/ScalarType.h>
#include <ATen/ScalarTypeUtils.h>
#include <ATen/Retainable.h>
#include <TH/THTypeConversion.hpp>
#include <atomic>

Expand Down Expand Up @@ -39,7 +40,7 @@ namespace at {

struct Type;

struct TH_CPP_API StorageImpl {
struct TH_CPP_API StorageImpl : public Retainable {

StorageImpl() = delete;
virtual ~StorageImpl() {};
Expand All @@ -48,8 +49,6 @@ struct TH_CPP_API StorageImpl {
at::ScalarType scalar_type;
at::DataPtr data_ptr;
ptrdiff_t size;
std::atomic<int> refcount;
std::atomic<int> weakcount;
bool resizable;
at::Allocator* allocator;
std::unique_ptr<THFinalizer> finalizer;
Expand All @@ -76,6 +75,14 @@ struct TH_CPP_API StorageImpl {
return static_cast<T*>(this->data_ptr.get());
}

void release_resources() {
if (finalizer) {
(*finalizer)();
}
finalizer = nullptr;
data_ptr.clear();
}

void operator=(const StorageImpl&) = delete;

virtual size_t elementSize() const {
Expand All @@ -94,9 +101,6 @@ struct TH_CPP_API StorageImpl {
const void* data() const {
return data_ptr.get();
};
void retain() {
++refcount;
}

int getDevice() const {
return data_ptr.device().index();
Expand Down
1 change: 0 additions & 1 deletion aten/src/ATen/THLongStorageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class THLongStorageView {
storage.size = ref.size();
}
storage.scalar_type = at::CTypeToScalarType<th::from_type<int64_t>>::to();
storage.refcount = 0;
storage.set_resizable(false);
}
private:
Expand Down
10 changes: 10 additions & 0 deletions aten/src/ATen/core/ATenCoreTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <ATen/core/ATenCoreTest.h>

namespace at {

static int CoreTestGlobal = 0;
int CoreTest() {
return CoreTestGlobal++;
}

}
18 changes: 18 additions & 0 deletions aten/src/ATen/core/ATenCoreTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

// TODO: Move this to something like ATenCoreGeneral.h
#ifdef _WIN32
# if defined(ATen_cpu_EXPORTS) || defined(caffe2_EXPORTS)
# define AT_CORE_API __declspec(dllexport)
# else
# define AT_CORE_API __declspec(dllimport)
# endif
#else
# define AT_CORE_API
#endif

namespace at {

AT_CORE_API int CoreTest();

}
13 changes: 13 additions & 0 deletions aten/src/ATen/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file solely exists to let Caffe2 Android build get at the list
# of core files without having to trundle through all of ATen's CMakeLists.txt

FILE(GLOB ATen_CORE_HEADERS "*.h")
FILE(GLOB ATen_CORE_SRCS "*.cpp")

# Pass to parent
set(ATen_CORE_HEADERS ${ATen_CORE_HEADERS} PARENT_SCOPE)
set(ATen_CORE_SRCS ${ATen_CORE_SRCS} PARENT_SCOPE)
# This is a little dodgy, because it means ALL ATen headers are made
# visible. Fortunately, you should just get a lot of undefined symbol
# errors if you go outside core
set(ATen_CORE_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/../.. PARENT_SCOPE)
5 changes: 5 additions & 0 deletions aten/src/ATen/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ATen Core
---------

ATen Core is a minimal subset of ATen which is suitable for deployment
on mobile. Binary size of files in this folder is an important constraint.
14 changes: 14 additions & 0 deletions aten/src/ATen/cudnn/Descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@ struct AT_CUDA_API RNNDescriptor
}
};

#if CUDNN_VERSION >= 7000

struct AT_CUDA_API CTCLossDescriptor
: public Descriptor<cudnnCTCLossStruct,
&cudnnCreateCTCLossDescriptor,
&cudnnDestroyCTCLossDescriptor>
{
void set(cudnnDataType_t datatype) {
AT_CUDNN_CHECK(cudnnSetCTCLossDescriptor(mut_desc(), datatype));
}
};

#endif

union Constant
{
float f;
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/function_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def __init__(self, reason):
'Backend::${DenseBackend}, ScalarType::Long)'),
'THStorage*':
CodeTemplate(
'checked_cast_storage<${Storage}>('
'checked_cast_storage<Storage>('
'&${arg_name},"${arg_name}",${arg_pos}, '
'Backend::${Backend}, ScalarType::${ScalarName})'),
'THGenerator*':
Expand Down
10 changes: 1 addition & 9 deletions aten/src/ATen/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ def check_all_files_written(self):
TEMPLATE_PATH = options.source_path + "/templates"
GENERATOR_DERIVED = CodeTemplate.from_file(
TEMPLATE_PATH + "/GeneratorDerived.h")
STORAGE_DERIVED_CPP = CodeTemplate.from_file(
TEMPLATE_PATH + "/StorageDerived.cpp")
STORAGE_DERIVED_H = CodeTemplate.from_file(TEMPLATE_PATH + "/StorageDerived.h")

TYPE_DERIVED_CPP = CodeTemplate.from_file(TEMPLATE_PATH + "/TypeDerived.cpp")
SPARSE_TYPE_DERIVED_CPP = CodeTemplate.from_file(TEMPLATE_PATH + "/SparseTypeDerived.cpp")
TYPE_DERIVED_H = CodeTemplate.from_file(TEMPLATE_PATH + "/TypeDerived.h")
Expand Down Expand Up @@ -237,7 +233,6 @@ def generate_storage_type_and_tensor(backend, density, scalar_type, declarations
env['isFloatingType'] = is_floating_type
env['isIntegralType'] = not is_floating_type
if density == 'Dense':
env['Storage'] = "{}{}Storage".format(backend, scalar_name)
env['Tensor'] = "{}{}{}Tensor".format(density_tag, backend, scalar_name)
env['Type'] = "{}{}{}Type".format(density_tag, backend, scalar_name)
env['DenseTensor'] = "{}{}Tensor".format(backend, scalar_name)
Expand All @@ -246,7 +241,6 @@ def generate_storage_type_and_tensor(backend, density, scalar_type, declarations
env['storage_tensor_headers'] = []
if density != 'Sparse':
env['storage_tensor_headers'] = [
'#include "ATen/{}.h"'.format(env['Storage']),
'#include "ATen/{}.h"'.format(env['Tensor']),
'#include "ATen/{}ByteTensor.h"'.format(env['Backend']),
'#include "ATen/{}IntTensor.h"'.format(env['Backend']),
Expand Down Expand Up @@ -322,8 +316,6 @@ def generate_storage_type_and_tensor(backend, density, scalar_type, declarations

if density != 'Sparse':
# there are no storage or tensor types for sparse; it's all uniform
fm.write(env['Storage'] + ".cpp", STORAGE_DERIVED_CPP, env)
fm.write(env['Storage'] + ".h", STORAGE_DERIVED_H, env)
env['TensorDenseOrSparse'] = TENSOR_DENSE_CPP.substitute(env)
fm.write(env['Tensor'] + ".cpp", TENSOR_DERIVED_CPP, env)
fm.write(env['Tensor'] + ".h", TENSOR_DERIVED_H, env)
Expand Down Expand Up @@ -379,7 +371,7 @@ def declare_outputs():
for backend, density, scalar_types in iterate_types():
scalar_name = scalar_types[0]
full_backend = "Sparse" + backend if density == "Sparse" else backend
for kind in ["Storage", "Type", "Tensor"]:
for kind in ["Type", "Tensor"]:
if kind != 'Type' and density == "Sparse":
# No Storage or Tensor for sparse
continue
Expand Down
5 changes: 4 additions & 1 deletion aten/src/ATen/native/Linear.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ATen/ATen.h"
#include "ATen/NativeFunctions.h"
#include "ATen/WrapDimUtilsMulti.h"
#include <cctype>

namespace at { namespace native {

Expand Down Expand Up @@ -136,6 +137,8 @@ Tensor einsum(std::string eqn, TensorList tensors) {
} else {
in_eqn = eqn;
}
// remove spaces for einsum compatibility (#9929)
in_eqn.erase(std::remove_if(in_eqn.begin(), in_eqn.end(), isspace), in_eqn.end());

// next we parse in_eq (the left hand side) by iterating. It is a string of comma separated terms per index
int64_t operand = 0;
Expand Down Expand Up @@ -212,7 +215,7 @@ Tensor einsum(std::string eqn, TensorList tensors) {
num_output_dims++;
}
}
} else { // letter (hopefully)
} else if (! isspace(c)) { // letter (hopefully)
AT_CHECK((ell_char_count == 0) || (ell_char_count == 3), "'.' must only occur in ellipsis in the right hand side");
AT_CHECK(('a' <= c) && (c <= 'z'), "only lowercase letters a-z allowed as indices");
int64_t letter_num = c-'a';
Expand Down
Loading