pytorch/scripts
Ashkan Aliabadi 9184c9832e
Re-apply PyTorch pthreadpool changes (#40951)
* Re-apply PyTorch pthreadpool changes

Summary:
This re-applies D21232894 (b9d3869df3) and D22162524, plus updates jni_deps in a few places
to avoid breaking host JNI tests.

Test Plan: `buck test @//fbandroid/mode/server //fbandroid/instrumentation_tests/com/facebook/caffe2:host-test`

Reviewed By: xcheng16

Differential Revision: D22199952

fbshipit-source-id: df13eef39c01738637ae8cf7f581d6ccc88d37d5

* Enable XNNPACK ops on iOS and macOS.

Test Plan: buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/pytext/pytext_mobile_inference.json --platform ios --framework pytorch --remote --devices D221 (9788a74da8)AP-12.0.1

Reviewed By: xta0

Differential Revision: D21886736

fbshipit-source-id: ac482619dc1b41a110a3c4c79cc0339e5555edeb

* Respect user set thread count. (#40707)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/40707

Test Plan: Imported from OSS

Differential Revision: D22318197

Pulled By: AshkanAliabadi

fbshipit-source-id: f11b7302a6e91d11d750df100d2a3d8d96b5d1db

* Fix and reenable threaded QNNPACK linear (#40587)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40587

Previously, this was causing divide-by-zero only in the multithreaded
empty-batch case, while calculating tiling parameters for the threads.
In my opinion, the bug here is using a value that is allowed to be zero
(batch size) for an argument that should not be zero (tile size), so I
fixed the bug by bailing out right before the call to
pthreadpool_compute_4d_tiled.

Test Plan: TestQuantizedOps.test_empty_batch

Differential Revision: D22264414

Pulled By: dreiss

fbshipit-source-id: 9446d5231ff65ef19003686f3989e62f04cf18c9

* Fix batch size zero for QNNPACK linear_dynamic (#40588)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40588

Two bugs were preventing this from working.  One was a divide by zero
when multithreading was enabled, fixed similarly to the fix for static
quantized linear in the previous commit.  The other was computation of
min and max to determine qparams.  FBGEMM uses [0,0] for [min,max] of
empty input, do the same.

Test Plan: Added a unit test.

Differential Revision: D22264415

Pulled By: dreiss

fbshipit-source-id: 6ca9cf48107dd998ef4834e5540279a8826bc754

Co-authored-by: David Reiss <dreiss@fb.com>
2020-07-06 06:58:25 -07:00
..
appveyor move flags to c10 (#12144) 2018-10-04 02:09:56 -07:00
fbcode-dev-setup Fix typos (#30606) 2019-12-02 20:17:42 -08:00
model_zoo Bump up opset version to 7 in Caffe2 ONNX exporter (#8854) 2018-06-28 07:39:02 -07:00
onnx [ONNX] Enable models tests (#38791) 2020-05-27 09:09:59 -07:00
release .circleci: Add simple backup and restore solution for RCs (#38690) 2020-05-21 13:09:12 -07:00
add_apache_header.sh Re-license to Apache 2017-09-28 16:22:00 -07:00
apache_header.txt Re-license to Apache 2017-09-28 16:22:00 -07:00
apache_python.txt Add script for removing Apache header. 2018-03-27 13:10:18 -07:00
build_android.sh [android] ANDROID_STL=c++_shared (#39588) 2020-06-18 13:50:05 -07:00
build_host_protoc.sh Port all PyTorch and Caffe2 jobs to CircleCI (#11264) 2018-09-05 16:28:11 -07:00
build_ios.sh [iOS] Disable NNPACK on iOS builds (#39868) 2020-06-17 01:39:56 -07:00
build_local.sh Only set CCACHE_WRAPPER_PATH in the build scripts if it is not already passed in. 2019-11-01 18:39:12 -07:00
build_mobile.sh Fix SELECTED_OP_LIST file path issue (#33942) 2020-03-11 13:19:31 -07:00
build_pytorch_android.sh [android][test_app][reland] test_app example linking to pytorch_android aar content (#40313) 2020-06-20 07:34:42 -07:00
build_raspbian.sh Fix target name. 2019-02-22 17:27:16 -08:00
build_tegra_x1.sh Allow specifying cmake build directory in the build scripts 2017-11-20 20:32:30 -08:00
build_tizen.sh Allow specifying cmake build directory in the build scripts 2017-11-20 20:32:30 -08:00
build_windows.bat Turn off warnings on Windows CI. (#24331) 2019-08-30 07:11:07 -07:00
diagnose_protobuf.py Fix several DeprecationWarning: invalid escape sequence (#15733) 2019-01-05 08:53:35 -08:00
get_python_cmake_flags.py [caffe2][build] Update python cmake flag print script (#7306) 2018-05-08 00:34:42 -07:00
proto.ps1 Sync fbcode/caffe2 and xplat/caffe2 (1) (#19218) 2019-04-13 21:45:52 -07:00
read_conda_versions.sh Adding gcc4 conda builds (#2283) 2018-03-17 17:26:37 -07:00
README.md Enhance build_ios.sh to be consistent with build_android.sh (#18564) 2019-03-28 21:37:55 -07:00
remove_apache_header.sh Add script for removing Apache header. 2018-03-27 13:10:18 -07:00
temp.sh Add script for removing Apache header. 2018-03-27 13:10:18 -07:00
xcode_build.rb Re-apply PyTorch pthreadpool changes (#40951) 2020-07-06 06:58:25 -07:00

This directory contains the useful tools.

build_android.sh

This script is to build PyTorch/Caffe2 library for Android. Take the following steps to start the build:

  • set ANDROID_NDK to the location of ndk
export ANDROID_NDK=YOUR_NDK_PATH
  • run build_android.sh
#in your PyTorch root directory
bash scripts/build_android.sh

If succeeded, the libraries and headers would be generated to build_android/install directory. You can then copy these files from build_android/install to your Android project for further usage.

You can also override the cmake flags via command line, e.g., following command will also compile the executable binary files:

bash scripts/build_android.sh -DBUILD_BINARY=ON

build_ios.sh

This script is to build PyTorch/Caffe2 library for iOS, and can only be performed on macOS. Take the following steps to start the build:

  • Install Xcode from App Store, and configure "Command Line Tools" properly on Xcode.
  • Install the dependencies:
brew install cmake automake libtool
  • run build_ios.sh
#in your PyTorch root directory
bash scripts/build_ios.sh

If succeeded, the libraries and headers would be generated to build_ios/install directory. You can then copy these files to your Xcode project for further usage.