Skip to content

Commit 41a88fc

Browse files
committed
Update on "Put TORCH_LIBRARY in torch/library.h; add custom class API"
Now, you can define a custom class inside a TORCH_LIBRARY block. It looks very similar to what you did before. Instead of ``` static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo); ``` you write ``` TORCH_LIBRARY(Namespace, m) { m.class_<Class>("Class") .def("foo", foo); } ``` All the old usages still work, but at some point we should start updating the tutorials when we're ready to go 100% live with the new pybind11 style API. custom class API previously lived in torch/ folder and in torch namespace, so for consistency, the new TORCH_LIBRARY also got moved to torch/library.h The definition of Library::class_ is in the bottom of that header because I need all of the class_ constructors available, but there is a circular dependency between the two headers. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648) [ghstack-poisoned]
2 parents 18f68ef + 4397524 commit 41a88fc

104 files changed

Lines changed: 2779 additions & 801 deletions

File tree

Some content is hidden

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

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6643,9 +6643,6 @@ workflows:
66436643
- docker_build_job:
66446644
name: "pytorch-linux-bionic-py3.6-clang9"
66456645
image_name: "pytorch-linux-bionic-py3.6-clang9"
6646-
- docker_build_job:
6647-
name: "pytorch-linux-bionic-clang9-thrift-llvmdev"
6648-
image_name: "pytorch-linux-bionic-clang9-thrift-llvmdev"
66496646
- docker_build_job:
66506647
name: "pytorch-linux-xenial-cuda10-cudnn7-py3-gcc7"
66516648
image_name: "pytorch-linux-xenial-cuda10-cudnn7-py3-gcc7"

.circleci/docker/build.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ TRAVIS_DL_URL_PREFIX="https://s3.amazonaws.com/travis-python-archives/binaries/u
3535
# configuration, so we hardcode everything here rather than do it
3636
# from scratch
3737
case "$image" in
38-
pytorch-linux-bionic-clang9-thrift-llvmdev)
39-
CLANG_VERSION=9
40-
THRIFT=yes
41-
LLVMDEV=yes
42-
PROTOBUF=yes
43-
;;
4438
pytorch-linux-xenial-py3.8)
4539
# TODO: This is a hack, get rid of this as soon as you get rid of the travis downloads
4640
TRAVIS_DL_URL_PREFIX="https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/16.04/x86_64"
@@ -181,6 +175,8 @@ fi
181175
tmp_tag="tmp-$(cat /dev/urandom | tr -dc 'a-z' | fold -w 32 | head -n 1)"
182176

183177
# Build image
178+
# TODO: build-arg THRIFT is not turned on for any image, remove it once we confirm
179+
# it's no longer needed.
184180
docker build \
185181
--no-cache \
186182
--build-arg "TRAVIS_DL_URL_PREFIX=${TRAVIS_DL_URL_PREFIX}" \

.circleci/verbatim-sources/workflows-docker-builder.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
- docker_build_job:
1212
name: "pytorch-linux-bionic-py3.6-clang9"
1313
image_name: "pytorch-linux-bionic-py3.6-clang9"
14-
- docker_build_job:
15-
name: "pytorch-linux-bionic-clang9-thrift-llvmdev"
16-
image_name: "pytorch-linux-bionic-clang9-thrift-llvmdev"
1714
- docker_build_job:
1815
name: "pytorch-linux-xenial-cuda10-cudnn7-py3-gcc7"
1916
image_name: "pytorch-linux-xenial-cuda10-cudnn7-py3-gcc7"

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
(! git grep -I -l $'\t' -- . ':(exclude)*.svg' ':(exclude)**Makefile' ':(exclude)**/contrib/**' ':(exclude)third_party' ':(exclude).gitattributes' ':(exclude).gitmodules' || (echo "The above files have tabs; please convert them to spaces"; false))
3535
- name: Ensure canonical include
3636
run: |
37-
(! git grep -I -l $'#include "' -- ./c10 || (echo "The above files have include with quotes; please convert them to #include <xxxx>"; false))
37+
(! git grep -I -l $'#include "' -- ./c10 ./aten ':(exclude)aten/src/ATen/native/quantized/cpu/qnnpack/**' || (echo "The above files have include with quotes; please convert them to #include <xxxx>"; false))
3838
- name: Ensure C++ source files are not executable
3939
run: |
4040
(! find . \( -path ./third_party -o -path ./.git -o -path ./torch/bin -o -path ./build \) -prune -o -type f -executable -regextype posix-egrep -not -regex '.+(\.(bash|sh|py|so)|git-pre-commit)$' -print | grep . || (echo 'The above files have executable permission; please remove their executable permission by using `chmod -x`'; false))

aten/src/ATen/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <TH/TH.h> // for USE_LAPACK
1717

1818
#ifdef USE_FBGEMM
19-
#include "fbgemm/Fbgemm.h"
19+
#include <fbgemm/Fbgemm.h>
2020
#endif // USE_FBGEMM
2121

2222
namespace at {

aten/src/ATen/ParallelNativeTBB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include <atomic>
66
#include <mutex>
77

8-
#include "tbb/tbb.h"
8+
#include <tbb/tbb.h>
99
#define TBB_PREVIEW_GLOBAL_CONTROL 1
10-
#include "tbb/global_control.h"
10+
#include <tbb/global_control.h>
1111

1212
#ifdef _OPENMP
1313
#include <omp.h>

aten/src/ATen/ParallelNativeTBB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define WIN32_LEAN_AND_MEAN
1010
#endif
1111
#endif
12-
#include "tbb/tbb.h"
12+
#include <tbb/tbb.h>
1313

1414
#define INTRA_OP_PARALLEL
1515

aten/src/ATen/ThreadLocalDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "ATen/ThreadLocalDebugInfo.h"
1+
#include <ATen/ThreadLocalDebugInfo.h>
22

33
namespace at {
44

aten/src/ATen/core/aten_interned_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ _(aten, hamming_window) \
362362
_(aten, hann_window) \
363363
_(aten, hardshrink) \
364364
_(aten, hardshrink_backward) \
365+
_(aten, hardsigmoid) \
366+
_(aten, hardsigmoid_backward) \
365367
_(aten, hardtanh) \
366368
_(aten, hardtanh_backward) \
367369
_(aten, hardtanh_forward) \

aten/src/ATen/core/boxing/KernelFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,4 @@ class CAFFE2_API KernelFunction final {
213213

214214
}
215215

216-
#include "KernelFunction_impl.h"
216+
#include <ATen/core/boxing/KernelFunction_impl.h>

0 commit comments

Comments
 (0)