summaryrefslogtreecommitdiff
path: root/.gitmodules
diff options
context:
space:
mode:
authorcpuhrsch <cpuhrsch@googlemail.com>2018-03-12 15:19:12 -0400
committerSam Gross <colesbury@gmail.com>2018-03-12 15:19:12 -0400
commit310c3735b9eb97f30cee743b773e5bb054989edc (patch)
treeffd639fcf864b479bdc69945f9bfbd9b53ab3a75 /.gitmodules
parent4a96f5616cd70e3b850c9444be0a3f0493042510 (diff)
downloadpytorch-310c3735b9eb97f30cee743b773e5bb054989edc.tar.gz
pytorch-310c3735b9eb97f30cee743b773e5bb054989edc.tar.bz2
pytorch-310c3735b9eb97f30cee743b773e5bb054989edc.zip
ATen ReduceOps (#5481)
This diff adds vectorization to ATen. It uses intel intrinsics to build a general vec256 class, that represents types of 256bit width. These can then be treated like regular variables. Using those it implements torch.sum() for the contiguous case. It uses Intel TBB for multithreading, which allows workstealing and chunks the reduction operations based on a experimentally chosen value (_THRESHOLD). It uses cpuinfo to pick the right code depending on the host's capabilities. The kernels are implemented under native/cpu. Each .cpp file is compiled with -avx, -avx2 and no additional flags. A macro is used to append AVX, AVX2 or NONE to the function name. The header then needs to define the functions three times, one for each capability. This could be improved by either changing the cmake file a bit or possibly generating source code using a Python script etc. For the non-contiguous case this defaults to the current implementation within TH. For CUDA is entirely defaults to the implementation within THC. There probably needs to be a bit of a debate around the design decisions here, the additional dependencies, parallelization strategy, clarity, etc. The numerical results also diverge from numpy with larger tensors, which is expected since we're summing, for example, 8 numbers and then adding the result to the running sum, instead of each number one by one. But there might be something to be said about accumulating into a double for floats or the degree of divergence, the behavior with respect to CUDA, etc. I wrote a [small Python script]( https://github.com/cpuhrsch/benchmark/blob/sumall/benchmarks/sum_bench.py) to compare the results with numpy numerically as well as on timing. I ran this script to create timings both on master and this branch. Here is the command for 1 core `OMP_NUM_THREAD=1 taskset -c 0 python sum_bench.py --enable_numpy 200` Here is the command for all cores `python sum_bench.py --enable_numpy 200` Here are the results of each: [Master, 1 core](https://paste.fedoraproject.org/paste/Nho9JzHpPVK9av8a6mByjQ) [This branch, 1 core](https://paste.fedoraproject.org/paste/6xLHkYvcVJx9z~5MoHxN4w) [Master, all cores](https://paste.fedoraproject.org/paste/5l3V1d5zGqvJcMXIUteMRw) [This branch, all cores](https://paste.fedoraproject.org/paste/J4RuDU-0Drz0aZwtphQwEA) To test the command is `python sum_bench.py --test 200` [This branch, test results](https://paste.fedoraproject.org/paste/kTEoUC~oWgXA6XWMAfNfNw) For this test we look at the average absolute value of the differences. This does not take into account the relative magnitude of the numbers. The numbers are sampled from a standard normal distribution. In terms of performance this diff should bring PyTorch on par with Numpy and usually exceed it by 1.5 to 2x.
Diffstat (limited to '.gitmodules')
-rw-r--r--.gitmodules7
1 files changed, 7 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index 50f06fdae9..9a7ac8a6a4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,3 +7,10 @@
[submodule "torch/lib/nanopb"]
path = torch/lib/nanopb
url = https://github.com/nanopb/nanopb.git
+[submodule "aten/src/ATen/cpu/cpuinfo"]
+ path = aten/src/ATen/cpu/cpuinfo
+ url = https://github.com/Maratyszcza/cpuinfo
+[submodule "aten/src/ATen/cpu/tbb/tbb_remote"]
+ path = aten/src/ATen/cpu/tbb/tbb_remote
+ url = https://github.com/01org/tbb
+ branch = tbb_2018