Skip to content

Commit eb85125

Browse files
authored
Merge pull request #197 from iotamudelta/ifu
Merge from upstream
2 parents 1bfa331 + 70af48f commit eb85125

File tree

968 files changed

+26787
-15959
lines changed

Some content is hidden

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

968 files changed

+26787
-15959
lines changed

.circleci/config.yml

Lines changed: 139 additions & 94 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ aten/src/ATen/cuda/CUDAConfig.h
2525
build/
2626
dist/
2727
docs/src/**/*
28-
docs/cpp/xml/
29-
docs/cpp/html/
30-
docs/cpp/api/
28+
docs/cpp/build
29+
docs/cpp/source/api
3130
test/.coverage
3231
test/cpp/api/mnist
32+
test/custom_operator/model.pt
3333
test/data/gpu_tensors.pt
3434
test/data/legacy_modules.t7
3535
test/data/legacy_serialized.pt
3636
test/data/linear.pt
3737
test/htmlcov
38+
test/cpp_extensions/install/
3839
third_party/build/
3940
tools/shared/_utils_internal.py
4041
torch.egg-info/
@@ -43,6 +44,7 @@ torch/csrc/cudnn/cuDNN.cpp
4344
torch/csrc/generated
4445
torch/csrc/generic/TensorMethods.cpp
4546
torch/csrc/jit/generated/*
47+
torch/csrc/jit/fusers/Config.h
4648
torch/csrc/nn/THCUNN.cpp
4749
torch/csrc/nn/THCUNN.cwrap
4850
torch/csrc/nn/THNN_generic.cpp
@@ -65,6 +67,7 @@ torch/lib/protoc
6567
torch/lib/tmp_install
6668
torch/lib/torch_shm_manager
6769
torch/lib/python*
70+
torch/share/
6871
torch/version.py
6972

7073
# IPython notebook checkpoints

.jenkins/caffe2/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ else
226226
export MAX_JOBS=`expr $(nproc) - 1`
227227
fi
228228
229-
USE_OPENCV=1 BUILD_BINARY=1 python setup.py install --user
229+
USE_LEVELDB=1 USE_LMDB=1 USE_OPENCV=1 BUILD_BINARY=1 python setup.py install --user
230230
231231
# This is to save test binaries for testing
232232
cp -r torch/lib/tmp_install $INSTALL_PREFIX

.jenkins/caffe2/test.sh

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ fi
4949
5050
mkdir -p $TEST_DIR/{cpp,python}
5151
52+
if [[ $BUILD_ENVIRONMENT == *-rocm* ]]; then
53+
export LANG=C.UTF-8
54+
export LC_ALL=C.UTF-8
55+
56+
# Pin individual runs to specific gpu so that we can schedule
57+
# multiple jobs on machines that have multi-gpu.
58+
NUM_AMD_GPUS=$(/opt/rocm/bin/rocminfo | grep 'Device Type.*GPU' | wc -l)
59+
if (( $NUM_AMD_GPUS == 0 )); then
60+
echo >&2 "No AMD GPU detected!"
61+
exit 1
62+
fi
63+
export HIP_VISIBLE_DEVICES=$(($BUILD_NUMBER % $NUM_AMD_GPUS))
64+
fi
65+
5266
cd "${WORKSPACE}"
5367
5468
# C++ tests
@@ -62,19 +76,27 @@ for test in $(find "${INSTALL_PREFIX}/test" -executable -type f); do
6276
*/mkl_utils_test|*/aten/integer_divider_test)
6377
continue
6478
;;
65-
*/aten/*)
66-
# ATen uses test framework Catch2
67-
# NB: We do NOT use the xml test reporter, because
68-
# Catch doesn't support multiple reporters
79+
*/scalar_tensor_test|*/basic|*/native_test)
80+
if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
81+
continue
82+
else
83+
"$test"
84+
fi
85+
;;
86+
*)
87+
# Currently, we use a mixture of gtest (caffe2) and Catch2 (ATen). While
88+
# planning to migrate to gtest as the common PyTorch c++ test suite, we
89+
# currently do NOT use the xml test reporter, because Catch doesn't
90+
# support multiple reporters
6991
# c.f. https://github.com/catchorg/Catch2/blob/master/docs/release-notes.md#223
7092
# which means that enabling XML output means you lose useful stdout
7193
# output for Jenkins. It's more important to have useful console
7294
# output than it is to have XML output for Jenkins.
95+
# Note: in the future, if we want to use xml test reporter once we switch
96+
# to all gtest, one can simply do:
97+
# "$test" --gtest_output=xml:"$gtest_reports_dir/$(basename $test).xml"
7398
"$test"
7499
;;
75-
*)
76-
"$test" --gtest_output=xml:"$gtest_reports_dir/$(basename $test).xml"
77-
;;
78100
esac
79101
done
80102
@@ -98,9 +120,6 @@ fi
98120
99121
rocm_ignore_test=()
100122
if [[ $BUILD_ENVIRONMENT == *-rocm* ]]; then
101-
export LANG=C.UTF-8
102-
export LC_ALL=C.UTF-8
103-
104123
# Currently these tests are failing on ROCM platform:
105124
106125
# Unknown reasons, need to debug
@@ -115,10 +134,6 @@ if [[ $BUILD_ENVIRONMENT == *-rocm* ]]; then
115134
# Our cuda top_k op has some asm code, the hipified version doesn't
116135
# compile yet, so we don't have top_k operator for now
117136
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))
122137
fi
123138
124139
# Python tests

.jenkins/pytorch/build.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda9-* ]]; then
1111
sudo apt-get install -y --allow-downgrades --allow-change-held-packages libnccl-dev=2.2.13-1+cuda9.0 libnccl2=2.2.13-1+cuda9.0
1212
fi
1313

14-
if [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda8-* ]] || [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda9-cudnn7-py2* ]]; then
14+
if [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda8-* ]] || [[ "$BUILD_ENVIRONMENT" == *-xenial-cuda9-cudnn7-py2* ]] || [[ "$BUILD_ENVIRONMENT" == *-trusty-py2.7.9* ]]; then
1515
# TODO: move this to Docker
1616
sudo apt-get update
1717
sudo apt-get install -y --allow-downgrades --allow-change-held-packages openmpi-bin libopenmpi-dev
@@ -102,12 +102,6 @@ fi
102102
# Add the test binaries so that they won't be git clean'ed away
103103
git add -f build/bin
104104

105-
# Testing ATen install
106-
if [[ "$BUILD_ENVIRONMENT" != *cuda* ]]; then
107-
echo "Testing ATen install"
108-
time tools/test_aten_install.sh
109-
fi
110-
111105
# Test C FFI plugins
112106
# cffi install doesn't work for Python 3.7
113107
if [[ "$BUILD_ENVIRONMENT" != *pynightly* ]]; then
@@ -124,7 +118,7 @@ if [[ "$BUILD_ENVIRONMENT" == *xenial-cuda8-cudnn6-py3* ]]; then
124118
pushd docs
125119
# TODO: Don't run this here
126120
pip install -r requirements.txt || true
127-
make html
121+
LC_ALL=C make html
128122
popd
129123
fi
130124

@@ -138,4 +132,14 @@ if [[ "$BUILD_TEST_LIBTORCH" == "1" ]]; then
138132
pushd ../cpp-build/caffe2
139133
WERROR=1 VERBOSE=1 DEBUG=1 python $BUILD_LIBTORCH_PY
140134
popd
135+
136+
# Build custom operator tests.
137+
CUSTOM_OP_BUILD="$PWD/../custom-op-build"
138+
CUSTOM_OP_TEST="$PWD/test/custom_operator"
139+
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
140+
mkdir "$CUSTOM_OP_BUILD"
141+
pushd "$CUSTOM_OP_BUILD"
142+
CMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" cmake "$CUSTOM_OP_TEST"
143+
make VERBOSE=1
144+
popd
141145
fi

.jenkins/pytorch/common.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ else
112112
exit 1
113113
fi
114114

115-
if [[ "$BUILD_ENVIRONMENT" == *pytorch-linux-trusty-py3.6-gcc7* ]]; then
115+
if [[ "$BUILD_ENVIRONMENT" == *pytorch-linux-xenial-cuda9-cudnn7-py3 ]] || \
116+
[[ "$BUILD_ENVIRONMENT" == *pytorch-linux-trusty-py3.6-gcc7* ]]; then
116117
BUILD_TEST_LIBTORCH=1
117118
else
118119
BUILD_TEST_LIBTORCH=0

.jenkins/pytorch/macos-test.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,35 @@ test_cpp_api() {
7878
"$CPP_BUILD"/caffe2/bin/test_api
7979
}
8080

81+
test_custom_script_ops() {
82+
echo "Testing custom script operators"
83+
pushd test/custom_operator
84+
# Build the custom operator library.
85+
rm -rf build && mkdir build
86+
pushd build
87+
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
88+
CMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" cmake ..
89+
make VERBOSE=1
90+
popd
91+
92+
# Run tests Python-side and export a script module.
93+
python test_custom_ops.py -v
94+
python model.py --export-script-module=model.pt
95+
# Run tests C++-side and load the exported script module.
96+
build/test_custom_ops ./model.pt
97+
popd
98+
}
99+
100+
81101
if [ -z "${JOB_BASE_NAME}" ] || [[ "${JOB_BASE_NAME}" == *-test ]]; then
82102
test_python_all
83103
test_cpp_api
104+
test_custom_script_ops
84105
else
85106
if [[ "${JOB_BASE_NAME}" == *-test1 ]]; then
86107
test_python_all
87108
elif [[ "${JOB_BASE_NAME}" == *-test2 ]]; then
88109
test_cpp_api
110+
test_custom_script_ops
89111
fi
90112
fi

.jenkins/pytorch/test.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ test_python_all_except_nn() {
9090

9191
test_aten() {
9292
# Test ATen
93+
# The following test(s) of ATen have already been skipped by caffe2 in rocm environment:
94+
# scalar_tensor_test, basic, native_test
9395
if ([[ "$BUILD_ENVIRONMENT" != *asan* ]] && [[ "$BUILD_ENVIRONMENT" != *rocm* ]]); then
9496
echo "Running ATen tests with pytorch lib"
9597
TORCH_LIB_PATH=$(python -c "import site; print(site.getsitepackages()[0])")/torch/lib
9698
# NB: the ATen test binaries don't have RPATH set, so it's necessary to
9799
# put the dynamic libraries somewhere were the dynamic linker can find them.
98100
# This is a bit of a hack.
99101
if [[ "$BUILD_ENVIRONMENT" == *ppc64le* ]]; then
100-
SUDO=sudo
102+
SUDO=sudo
101103
fi
102104

103105
${SUDO} ln -s "$TORCH_LIB_PATH"/libcaffe2* build/bin
@@ -140,12 +142,28 @@ test_libtorch() {
140142
fi
141143
}
142144

145+
test_custom_script_ops() {
146+
if [[ "$BUILD_TEST_LIBTORCH" == "1" ]]; then
147+
echo "Testing custom script operators"
148+
CUSTOM_OP_BUILD="$PWD/../custom-op-build"
149+
pushd test/custom_operator
150+
cp -r "$CUSTOM_OP_BUILD" build
151+
# Run tests Python-side and export a script module.
152+
python test_custom_ops.py -v
153+
python model.py --export-script-module=model.pt
154+
# Run tests C++-side and load the exported script module.
155+
build/test_custom_ops ./model.pt
156+
popd
157+
fi
158+
}
159+
143160
if [ -z "${JOB_BASE_NAME}" ] || [[ "${JOB_BASE_NAME}" == *-test ]]; then
144161
test_python_nn
145162
test_python_all_except_nn
146163
test_aten
147164
test_torchvision
148165
test_libtorch
166+
test_custom_script_ops
149167
else
150168
if [[ "${JOB_BASE_NAME}" == *-test1 ]]; then
151169
test_python_nn
@@ -154,5 +172,6 @@ else
154172
test_aten
155173
test_torchvision
156174
test_libtorch
175+
test_custom_script_ops
157176
fi
158177
fi

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ matrix:
2828
script: mypy @mypy-files.txt
2929
- env: CPP_DOC_CHECK
3030
install: sudo apt-get install -y doxygen
31-
script: cd docs/cpp && ./check-doxygen.sh
31+
script: cd docs/cpp/source && ./check-doxygen.sh

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ option(BUILD_BINARY "Build C++ binaries" OFF)
6060
option(BUILD_DOCS "Build Caffe2 documentation" OFF)
6161
option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON)
6262
option(BUILD_PYTHON "Build Python binaries" ON)
63+
option(BUILD_CAFFE2_OPS "Build Caffe2 operators" ON)
6364
option(BUILD_SHARED_LIBS "Build libcaffe2.so" ON)
6465
cmake_dependent_option(
6566
CAFFE2_LINK_LOCAL_PROTOBUF "If set, build protobuf inside libcaffe2.so." ON
@@ -115,14 +116,15 @@ option(USE_IDEEP "Use IDEEP interface in MKL BLAS" ON)
115116
option(USE_MKLML "Use MKLML interface in MKL BLAS" ON)
116117
option(USE_DISTRIBUTED "Use distributed" ON)
117118
cmake_dependent_option(
118-
USE_MPI "Use MPI for Caffe2. Only available if USE_DISTRIBUTED is on." OFF
119+
USE_MPI "Use MPI for Caffe2. Only available if USE_DISTRIBUTED is on." ON
119120
"USE_DISTRIBUTED" OFF)
120121
cmake_dependent_option(
121122
USE_GLOO "Use Gloo. Only available if USE_DISTRIBUTED is on." ON
122123
"USE_DISTRIBUTED" OFF)
123124
cmake_dependent_option(
124125
USE_GLOO_IBVERBS "Use Gloo IB verbs for distributed. Only available if USE_GLOO is on." OFF
125126
"USE_GLOO" OFF)
127+
option(TORCH_USE_CEREAL "Build the C++ API with Cereal for serialization support" OFF)
126128

127129
# Used when building Caffe2 through setup.py
128130
option(BUILDING_WITH_TORCH_LIBS "Tell cmake if Caffe2 is being built alongside torch libs" OFF)

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Each line is a file pattern followed by one or more owners.
33

44
/aten/ @apaszke @soumith @colesbury @gchanan @zdevito @ezyang
5+
/aten/src/ATen/core/
56
/torch/ @apaszke @soumith @colesbury @gchanan @zdevito @ezyang
67
/docs/source @apaszke @soumith @colesbury @gchanan @zdevito @ezyang @ssnl @zou3519
78
/docs/cpp @goldsborough @ebetica @apaszke @soumith @colesbury @gchanan @zdevito @ezyang

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ We are in an early-release beta. Expect some adventures and rough edges.
1515
- [Binaries](#binaries)
1616
- [From Source](#from-source)
1717
- [Docker Image](#docker-image)
18+
- [Building the Documentation](#building-the-documentation)
1819
- [Previous Versions](#previous-versions)
1920
- [Getting Started](#getting-started)
2021
- [Communication](#communication)
@@ -200,9 +201,8 @@ set DISTUTILS_USE_SDK=1
200201
REM The following two lines are needed for Python 2.7, but the support for it is very experimental.
201202
set MSSdk=1
202203
set FORCE_PY27_BUILD=1
203-
REM As for CUDA 8, VS2015 Update 3 is also required to build PyTorch. Use the following two lines.
204-
set "PREBUILD_COMMAND=%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
205-
set PREBUILD_COMMAND_ARGS=x64
204+
REM As for CUDA 8, VS2015 Update 3 is also required to build PyTorch. Use the following line.
205+
set "CUDA_HOST_COMPILER=%VS140COMNTOOLS%\..\..\VC\bin\amd64\cl.exe"
206206
207207
call "%VS150COMNTOOLS%\vcvarsall.bat" x64 -vcvars_ver=14.11
208208
python setup.py install
@@ -224,6 +224,18 @@ Please note that PyTorch uses shared memory to share data between processes, so
224224
for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you
225225
should increase shared memory size either with `--ipc=host` or `--shm-size` command line options to `nvidia-docker run`.
226226

227+
### Building the Documentation
228+
229+
To build documentation in various formats, you will need Sphinx and the
230+
readthedocs theme.
231+
232+
```
233+
cd docs/
234+
pip install -r requirements.txt
235+
```
236+
You can then build the documentation by running ``make <format>`` from the
237+
``docs/`` folder. Run ``make`` to get a list of all available output formats.
238+
227239
### Previous Versions
228240

229241
Installation instructions and binaries for previous PyTorch versions may be found

0 commit comments

Comments
 (0)