Commit Graph

47 Commits

Author SHA1 Message Date
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
Tao Xu
6de6041585 [iOS] Disable NNPACK on iOS builds (#39868)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39868

### Summary

why disable NNPACK on iOS

- To stay consistency with our internal version
- It's currently blocking some external users due to its lack support of x86 architecture
    - https://github.com/pytorch/pytorch/issues/32040
    - https://discuss.pytorch.org/t/undefined-symbols-for-architecture-x86-64-for-libtorch-in-swift-unit-test/84552/6
- NNPACK uses fast convolution algorithms (FFT, winograd) to reduce the computational complexity of convolutions with large kernel size. The algorithmic speedup is limited to specific conv params which are unlikely to appear in mobile networks.
- Since XNNPACK has been enabled, it performs much better than NNPACK on depthwise-separable convolutions which is the algorithm being used by most of mobile computer vision networks.

### Test Plan

- CI Checks

Test Plan: Imported from OSS

Differential Revision: D22087365

Pulled By: xta0

fbshipit-source-id: 89a959b0736c1f8703eff10723a8fbd02357fd4a
2020-06-17 01:39:56 -07:00
Tao Xu
307920731d [iOS] Add nonVarTypeModeGuard to fix the unit test (#39743)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39743

### Summary

Still need this RAII guard for full JIT

### Test Plan

- CI checks

Test Plan: Imported from OSS

Differential Revision: D21968256

Pulled By: xta0

fbshipit-source-id: 8ea63c699fed4e2a01390232a58f039110391844
2020-06-09 20:05:32 -07:00
Tao Xu
9b0e7ebab0 [iOS] 1.5.0 Cocoapods Release (#37039)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37039

### Summary

Cocoapods 1.5.0 release. Binary has been pushed to AWS - https://ossci-ios.s3.amazonaws.com/libtorch_ios_1.5.0.zip

### Test Plan

- ` pod spec lint --verbose --allow-warnings --no-clean --use-libraries --skip-import-validation`
- TestApp

Test Plan: Imported from OSS

Differential Revision: D21169113

Pulled By: xta0

fbshipit-source-id: d015c218ed20b168a1ef21025db8880da4e3b074
2020-04-22 10:36:18 -07:00
Eli Uriegas
ff71a4192d Bump base version to 1.6.0a0 (#35495)
Summary:
Since we've done the branch cut for 1.5.0 we should bump nightlies to 1.6.0

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35495

Differential Revision: D20697043

Pulled By: seemethere

fbshipit-source-id: 3646187a5e729994138bf2c68625f25f11430b3a
2020-03-27 12:14:49 -07:00
Michael Suo
c235be42dd [jit] kill script namespace (#34515)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34515

Once upon a time we thought this was necessary. In reality it is not, so
removing it.

For backcompat, our public interface (defined in `api/`) still has
typedefs to the old `script::` names.

There was only one collision: `Pass` as a `Stmt` and `Pass` as a graph
transform. I renamed one of them.

Test Plan: Imported from OSS

Differential Revision: D20353503

Pulled By: suo

fbshipit-source-id: 48bb911ce75120a8c9e0c6fb65262ef775dfba93
2020-03-11 23:32:48 -07:00
Jiakai Liu
7aca9afdfb [pytorch] remove boilerplate setQEngine() from PyTorch mobile predictors (#34556)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34556

According to
https://github.com/pytorch/pytorch/pull/34012#discussion_r388581548,
this `at::globalContext().setQEngine(at::QEngine::QNNPACK);` call isn't
really necessary for mobile.

In Context.cpp it selects the last available QEngine if the engine isn't
set explicitly. For OSS mobile prebuild it should only include QNNPACK
engine so the default behavior should already be desired behavior.

It makes difference only when USE_FBGEMM is set - but it should be off
for both OSS mobile build and internal mobile build.

Test Plan: Imported from OSS

Differential Revision: D20374522

Pulled By: ljk53

fbshipit-source-id: d4e437a03c6d4f939edccb5c84f02609633a0698
2020-03-11 00:55:14 -07:00
Jiakai Liu
9a5e9d8cec [pytorch][mobile] change mobile build scripts to build PyTorch by default (#34203)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34203

Currently cmake and mobile build scripts still build libcaffe2 by
default. To build pytorch mobile users have to set environment variable
BUILD_PYTORCH_MOBILE=1 or set cmake option BUILD_CAFFE2_MOBILE=OFF.

PyTorch mobile has been released for a while. It's about time to change
CMake and build scripts to build libtorch by default.

Changed caffe2 CI job to build libcaffe2 by setting BUILD_CAFFE2_MOBILE=1
environment variable. Only found android CI for libcaffe2 - do we ever
have iOS CI for libcaffe2?

Test Plan: Imported from OSS

Differential Revision: D20267274

Pulled By: ljk53

fbshipit-source-id: 9d997032a599c874d62fbcfc4f5d4fbf8323a12e
2020-03-05 23:40:47 -08:00
Michael Suo
dbe850af5b [jit] do the code reorg (#33851)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33851

Rationale and context described in #33828.

Script to reproduce the move:
https://gist.github.com/suo/16cbefaaeb67ca5a7c6caffd49b7f6e9
ghstack-source-id: 99079645

Test Plan: Make sure CI passes

Reviewed By: jamesr66a

Differential Revision: D20133869

fbshipit-source-id: 390e9241a9c85366d9005c492ac31f10aa96488e
2020-02-27 13:02:51 -08:00
Ashkan Aliabadi
6aecfd1e80 Mobile Backend: NHWC memory layout + XNNPACK integration. (#33722)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33722

In order to improve CPU performance on floating-point models on mobile, this PR introduces a new CPU backend for mobile that implements the most common mobile operators with NHWC memory layout support through integration with XNNPACK.

XNNPACK itself, and this codepath, are currently only included in the build, but the actual integration is gated with USE_XNNPACK preprocessor guards.  This preprocessor symbol is intentionally not passed on to the compiler, so as to enable this rollout in multiple stages in follow up PRs.  This changeset will build XNNPACK as part of the build if the identically named USE_XNNPACK CMAKE variable, defaulted to ON, is enabled, but will not actually expose or enable this code path in any other way.

Furthermore, it is worth pointing out that in order to efficiently map models to these operators, some front-end method of exposing this backend to the user is needed.  The less efficient implementation would be to hook these operators into their corresponding native implementations, granted that a series of XNNPACK-specific conditions are met, much like how NNPACK is integrated with PyTorch today for instance.

Having said that, while the above implementation is still expected to outperform NNPACK based on the benchmarks I ran, the above integration would be leave a considerable gap between the performance achieved and the maximum performance potential XNNPACK enables, as it does not provide a way to compute and factor out one-time operations out of the inner most forward() loop.

The more optimal solution, and one we will  decide on soon, would involve either providing a JIT pass that maps nn operators onto these newly introduced operators, while allowing one-time calculations to be factored out, much like quantized mobile models.  Alternatively, new eager-mode modules can also be introduced that would directly call into these implementations either through c10 or some other mechanism, also allowing for decoupling of op creation from op execution.

This PR does not include any of the front end changes  mentioned above.  Neither does it include the mobile threadpool unification present in the original https://github.com/pytorch/pytorch/issues/30644.  Furthermore, this codepath seems to be faster than NNPACK in a good number of use cases, which can potentially allow us to remove NNPACK from aten to make the codebase a little simpler, granted that there is widespread support for such a move.

Regardless, these changes will be introduced gradually and in a more controlled way in subsequent PRs.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/32509

Test Plan:
Build: CI
Functionality: Not exposed

Reviewed By: dreiss

Differential Revision: D20069796

Pulled By: AshkanAliabadi

fbshipit-source-id: d46c1c91d4bea91979ea5bd46971ced5417d309c
2020-02-24 21:58:56 -08:00
Brian Wignall
f326045b37 Fix typos, via a Levenshtein-type corrector (#31523)
Summary:
Should be non-semantic.

Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos, with https://github.com/bwignall/typochecker to help automate the checking.

Uses an updated version of the tool used in https://github.com/pytorch/pytorch/pull/30606 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31523

Differential Revision: D19216749

Pulled By: mrshenli

fbshipit-source-id: 7fd489cb9a77cd7e4950c1046f925d57524960ea
2020-01-17 16:03:19 -08:00
Tao Xu
aa61d1ee85 Add a new job to support custom build (#32323)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32323

### Summary

Since we have released the custom build in 1.4.0, it's time to setup a CI for that. This PR adds a new iOS job to the iOS builds. To save time, It only runs the arm64 build.

### Test Plan

- Don't break any iOS jobs
- Custom Build works.

Test Plan: Imported from OSS

Differential Revision: D19451342

Pulled By: xta0

fbshipit-source-id: 9de305c004fc795710ecf01d436ef4792c07760c
2020-01-17 11:39:08 -08:00
Tao Xu
8c8bd79f32 Add CI scripts for Custom Build (#32316)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32316

### Summary

Since the Custom Build has been released in 1.4.0, it's time setup CI. To do that, we need

1.  Add a python script to generate the yaml file
2. Add new build scripts to circle CI (arm64 only).

### Test Plan

- Don't break the current iOS CIs

Test Plan: Imported from OSS

Differential Revision: D19437362

Pulled By: xta0

fbshipit-source-id: 395e27a582c43663af88d11b1ef974a4687e672c
2020-01-16 14:46:16 -08:00
Tao Xu
ecc3497172 Update Gemfile (#32147)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32147

### Summary

Got some security warnings regarding the ruby dependencies. This diff updates the packages in Gemfile.

```
GitHub has detected that a package defined in the ios/TestApp/Gemfile.lock file of the pytorch/pytorch repository contains a security vulnerability.

Package name: excon
Affected versions: < 0.71.0
Fixed in version: 0.71.0
Severity: LOW

Identifier(s):
GHSA-q58g-455p-8vw9
CVE-2019-16779
```

### Test Plan

- Won't affect the existing iOS CI jobs

Test Plan: Imported from OSS

Differential Revision: D19400087

Pulled By: xta0

fbshipit-source-id: 34b548d136cfd6b68fcc53bf0b243461bd7afd64
2020-01-14 14:52:50 -08:00
Eli Uriegas
346a349111 Update all instances of 1.4.0 -> 1.5.0 (#31785)
Summary:
Done with:

```
❯ sed -i 's/1\.4\.0/1.5.0/g' $(find -type f -not -path "./third_party/*")
```

This was previously done in separate commits, but it would be beneficial to bump all included projects within this repository at the same time.

Old bumps for reference:
* [iOS]Update Cocoapods to 1.4.0: https://github.com/pytorch/pytorch/pull/30326
* [android] Change nightly builds version to 1.4.0-SNAPSHOT: https://github.com/pytorch/pytorch/pull/27381
* Roll master to 1.4.0: https://github.com/pytorch/pytorch/pull/27374

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31785

Differential Revision: D19277925

Pulled By: seemethere

fbshipit-source-id: f72ad082f0566004858c9374879f4b1bee169f9c
2020-01-07 08:00:17 -08:00
Tao Xu
47033b49f3 Suppress XCode build warnings (#31000)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31000

## Summary

Add Fastlane configurations to suppress the build warnings from XCode.

Test Plan: Imported from OSS

Differential Revision: D18912489

Pulled By: xta0

fbshipit-source-id: f2c54d54a12ad2415695d1fcb1800684c7a9e560
2019-12-10 11:37:52 -08:00
Edward Yang
38986e1dea Split libtorch.so back into libtorch_{cpu,cuda,hip} (#30315)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30315

The new structure is that libtorch_cpu contains the bulk of our
code, and libtorch depends on libtorch_cpu and libtorch_cuda.
This is a reland of https://github.com/pytorch/pytorch/pull/29731 but
I've extracted all of the prep work into separate PRs which can be
landed before this one.

Some things of note:

* torch/csrc/cuda/nccl.cpp was added to the wrong list of SRCS, now fixed (this didn't matter before because previously they were all in the same library)
* The dummy file for libtorch was brought back from the dead; it was previously deleted in #20774
In an initial version of the patch, I forgot to make torch_cuda explicitly depend on torch_cpu. This lead to some very odd errors, most notably "bin/blob_test: hidden symbol `_ZNK6google8protobuf5Arena17OnArenaAllocationEPKSt9type_infom' in lib/libprotobuf.a(arena.cc.o) is referenced by DSO"
* A number of places in Android/iOS builds have to add torch_cuda explicitly as a library, as they do not have transitive dependency calculation working correctly
* I had to torch_cpu/torch_cuda caffe2_interface_library so that they get whole-archived linked into torch when you statically link. And I had to do this in an *exported* fashion because torch needs to depend on torch_cpu_library. In the end I exported everything and removed the redefinition in the Caffe2Config.cmake. However, I am not too sure why the old code did it in this way in the first place; however, it doesn't seem to have broken anything to switch it this way.
* There's some uses of `__HIP_PLATFORM_HCC__` still in `torch_cpu` code, so I had to apply it to that library too (UGH). This manifests as a failer when trying to run the CUDA fuser. This doesn't really matter substantively right now because we still in-place HIPify, but it would be good to fix eventually. This was a bit difficult to debug because of an unrelated HIP bug, see https://github.com/ROCm-Developer-Tools/HIP/issues/1706

Fixes #27215 (as our libraries are smaller), and executes on
part of the plan in #29235.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D18790941

Pulled By: ezyang

fbshipit-source-id: 01296f6089d3de5e8365251b490c51e694f2d6c7
2019-12-04 08:04:57 -08:00
Sebastian Messmer
bc2e6d10fa Back out "Revert D17908478: Switch PyTorch/Caffe2 to C++14"
Summary: Original commit changeset: 775d2e29be0b

Test Plan: CI

Reviewed By: mruberry

Differential Revision: D18775520

fbshipit-source-id: a350b3f86b66d97241f208786ee67e9a51172eac
2019-12-03 14:33:43 -08:00
Tao Xu
f114c33e69 Fix iOS CI (#30327)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30327

### Summary

Seems like starting from macOS 10.15, we can no longer get access to the `Downloads` folder in our macOS machines.

```
permissionError: [Errno 1] Operation not permitted: '/Users/distiller/Downloads'
```

The fix is to change the conda download directory to ${HOME}

### Test Plan

- iOS jobs are back to normal
- Don't break other jobs

Test Plan: Imported from OSS

Differential Revision: D18717380

Pulled By: xta0

fbshipit-source-id: cad754076bf4ae5035741aa57a310ad87c76726e
2019-12-03 11:24:21 -08:00
Sebastian Messmer
a2ed50c920 Revert D17908478: Switch PyTorch/Caffe2 to C++14
Test Plan: revert-hammer

Differential Revision:
D17908478

Original commit changeset: 6e340024591e

fbshipit-source-id: 775d2e29be0bc3a0db64f164c8960c44d4877d5d
2019-11-27 14:57:05 -08:00
Sebastian Messmer
d0acc9c085 Switch PyTorch/Caffe2 to C++14 (#30406)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30406

ghstack-source-id: 94642238

Test Plan: waitforsandcastle

Differential Revision: D17908478

fbshipit-source-id: 6e340024591ec2c69521668022999df4a33b4ddb
2019-11-27 10:47:31 -08:00
Hao Lu
9fb879934e Revert D18641413: add unit tests to iOS CI jobs
Test Plan: revert-hammer

Differential Revision:
D18641413

Original commit changeset: 12942206f1de

fbshipit-source-id: 4fa76d50fb897db4342d10a4e46a9887e37ef233
2019-11-22 15:24:27 -08:00
Tao Xu
638f4c1fb3 Update Cocoapods to 1.4.0 (#30326)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30326

Note that this PR won't trigger the cocoapods build. We'll push the binary and release the cocoapods after the branch cut.

Test Plan: Imported from OSS

Differential Revision: D18660308

Pulled By: xta0

fbshipit-source-id: 95dd97b7b67e70ecee3a65d8bbc125791872b7ca
2019-11-22 11:31:21 -08:00
Tao Xu
fa242246ee add unit tests to iOS CI jobs (#30133)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30133

### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors.

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Test Plan: Imported from OSS

Differential Revision: D18641413

Pulled By: xta0

fbshipit-source-id: 12942206f1dee045b2addba3ae618760e992752c
2019-11-22 10:52:11 -08:00
Junjie Bai
352731bd6e Revert D18632773: Split libtorch.so back into libtorch_{cpu,cuda,hip}
Test Plan: revert-hammer

Differential Revision:
D18632773

Original commit changeset: ea717c81e0d7

fbshipit-source-id: 18601439f9f81c9f389020e5a0e4e04adb21772d
2019-11-21 15:01:09 -08:00
Edward Yang
ec30d9028a Split libtorch.so back into libtorch_{cpu,cuda,hip} (#29731)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29731

The new structure is that libtorch_cpu contains the bulk of our
code, and libtorch depends on libtorch_cpu and libtorch_cuda.

Some subtleties about the patch:
- There were a few functions that crossed CPU-CUDA boundary without API macros. I just added them, easy enough. An inverse situation was aten/src/THC/THCTensorRandom.cu where we weren't supposed to put API macros directly in a cpp file.
- DispatchStub wasn't getting all of its symbols related to static members on DispatchStub exported properly. I tried a few fixes but in the end I just moved everyone off using DispatchStub to dispatch CUDA/HIP (so they just use normal dispatch for those cases.) Additionally, there were some mistakes where people incorrectly were failing to actually import the declaration of the dispatch stub, so added includes for those cases.
- torch/csrc/cuda/nccl.cpp was added to the wrong list of SRCS, now fixed (this didn't matter before because previously they were all in the same library)
- The dummy file for libtorch was brought back from the dead; it was previously deleted in #20774
- In an initial version of the patch, I forgot to make torch_cuda explicitly depend on torch_cpu. This lead to some very odd errors, most notably "bin/blob_test: hidden symbol `_ZNK6google8protobuf5Arena17OnArenaAllocationEPKSt9type_infom' in lib/l
ibprotobuf.a(arena.cc.o) is referenced by DSO"
- A number of places in Android/iOS builds have to add torch_cuda explicitly as a library, as they do not have transitive dependency calculation working correctly. This situation also happens with custom C++ extensions.
- There's a ROCm compiler bug where extern "C" on functions is not respected. There's a little workaround to handle this.
- Because I was too lazy to check if HIPify was converting TORCH_CUDA_API into TORCH_HIP_API, I just made it so HIP build also triggers the TORCH_CUDA_API macro. Eventually, we should translate and keep the nature of TORCH_CUDA_API constant in all cases.

Fixes #27215 (as our libraries are smaller), and executes on
part of the plan in #29235.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D18632773

Pulled By: ezyang

fbshipit-source-id: ea717c81e0d7554ede1dc404108603455a81da82
2019-11-21 11:27:33 -08:00
Tao Xu
5fa941d4e2 update fastlane to use Scanfile (#29963)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29963

### Summary

To run unit tests via Fastlane, simply run `fastlane scan`. Under the hood, it uses `xcodebuild` to run the unit tests. The Scanfile serves as a config file for Fastlane where you can specify parameters you want to pass to `xcodebuild`. More about Scan - https://docs.fastlane.tools/actions/scan/

### Test Plan

- `fastlane scan` is able to run on CI machines.

Test Plan: Imported from OSS

Differential Revision: D18606098

Pulled By: xta0

fbshipit-source-id: b4727d964fa56076b2ff383b40d1b13607721394
2019-11-19 16:32:26 -08:00
Tao Xu
57acc2ff3a add an unit test target to TestApp (#29962)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29962

### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. Starting from this PR, we'll add some unit tests to the iOS Simulator build. As follows:

1. Add an unit test target to XCode (this PR)
2. Use Fastlane to run the tests on CI
3. Modify the CI scripts to trigger tests

### Test Plan

- Don't break the existing CI jobs unless they are flaky.

Test Plan: Imported from OSS

Differential Revision: D18582908

Pulled By: xta0

fbshipit-source-id: f960c47d3bbda79e754a0513e8711867fd3588d2
2019-11-19 11:03:45 -08:00
Tao Xu
30f88bb05a Fix the TestApp (#29247)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29247

### Summary

If you run the TestApp using Cocoapods, you'll likely run into an error due to the lack of `config.json` in the main bundle. This PR fixes this crash and updates the README as well.

### Test Plan

- Don't break CIs

Test Plan: Imported from OSS

Differential Revision: D18339047

Pulled By: xta0

fbshipit-source-id: 244cf1ca8729c7ac918258d4eff14d34363e8389
2019-11-05 16:28:51 -08:00
Tao Xu
ebf5dd447e Cocoapods 1.3.1 release (#29240)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29240

### Summary

The 1.3.1 binary has been uploaded to AWS - https://ossci-ios.s3.amazonaws.com/libtorch_ios_1.3.1.zip. This PR updates the cocoapods version to 1.3.1

### Test Plan

- The 1.3.1 binary works well

Test Plan: Imported from OSS

Differential Revision: D18333750

Pulled By: xta0

fbshipit-source-id: fe6e42c51f3902ad42cab33f473dffb0f6f33333
2019-11-05 14:50:46 -08:00
Tao Xu
73d77626b8 Check device connection before running xcodebuild (#28996)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28996

### Summary

It'd be frustrated to realize the device is not connected after waiting for the build finishes. This PR checks the device connection status before xcodebuild.

### Test Plan

- Don't break `bootstrap.sh`

Test Plan: Imported from OSS

Differential Revision: D18258348

Pulled By: xta0

fbshipit-source-id: dda90e7194114e99b2774a3b64ed41f78221f827
2019-11-02 14:38:08 -07:00
Tao Xu
a0339c8d8f bootstrap.sh refactor (#28809)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28809

### Summary

This PR adds the interactive mode to `bootstrap.sh`. Instead of passing the credential information from command parameters(`-t`,`-p`), we're going to ask the user enter that information and save it to a config file, such that next time you don't have to enter again. So all you need now, is one line command

```shell
./bootstrap
```

### Test Plan

- TestApp.ipa can be installed on any devices
- Don't break CI jobs

Test Plan: Imported from OSS

Differential Revision: D18194032

Pulled By: xta0

fbshipit-source-id: a416ef7f13fa565e2c10bb55f94a8ce994b4e869
2019-10-28 22:20:29 -07:00
Tao Xu
e96ea288a8 Automation scripts for perf testing (#28622)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28622

### Summary

As discussed in #28405 , this is the third PR.  The`bootstrap.sh` script is mainly for those who want to do perf on iOS but don't want to touch XCode or any iOS code.  But it does require you have valid iOS dev credentials installed on your machine. (You can easily acquire those stuff from any experienced iOS developers. Takes only 5 mins to setup )

 All you need to do is run

```shell
./bootstrap -t ${TEAM_ID} -p ${PROFILE}
```

The testing app will be automatically installed on your device. The log of the benchmark function will be displayed on the screen.

### Test plan

Don't break any CI jobs unless they're flaky.

Test Plan: Imported from OSS

Differential Revision: D18156178

Pulled By: xta0

fbshipit-source-id: cd7ba8d87bf26db885262888b9d6a5fd072309d1
2019-10-25 19:50:24 -07:00
Tao Xu
896b5d9113 Scripts for setting up benchmark projects (#28469)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28469

### Summary

As described [here](https://github.com/pytorch/pytorch/pull/28405), This PR is the second one that contains scripts for setting up the benchmark projects.

### Test Plan

Don't break CI jobs unless they are flaky.

Test Plan: Imported from OSS

Differential Revision: D18097248

Pulled By: xta0

fbshipit-source-id: 6f9d1275a07aecae21afd81d5e90a89a75d0270f
2019-10-23 16:16:57 -07:00
Tao Xu
636fbcdd0a add benchmark code to iOS TestApp (#28405)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28405

### Summary

As discussed with AshkanAliabadi  and ljk53, the iOS TestApp will share the same benchmark code with Android's speed_benchmark_torch.cpp. This PR is the first part which contains the Objective-C++ code.

The second PR will include the scripts to setup and run the benchmark project. The third PR will include scripts that can automate the whole "build - test - install" process.

There are many ways to run the benchmark project. The easiest way is to use cocoapods. Simply run `pod install`. However, that will pull the 1.3 binary which is not what we want, but we can still use this approach to test the benchmark code. The second PR will contain scripts to run custom builds that we can tweak.

### Test Plan
- Don't break any existing CI jobs  (except for those flaky ones)

Test Plan: Imported from OSS

Differential Revision: D18064187

Pulled By: xta0

fbshipit-source-id: 4cfbb83c045803d8b24bf6d2c110a55871d22962
2019-10-22 12:52:30 -07:00
Tao Xu
d403410e0d Fastlane update (#28356)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28356

### Summary

I'm working on setting up a benchmark test project for iOS, which will reuse this Fastlane file. This PR removes the "cert install" code from "before_all" to a standalone lane target.

### Test Plan

- don't break any existing CI jobs

Test Plan: Imported from OSS

Differential Revision: D18053675

Pulled By: xta0

fbshipit-source-id: e4760a8494916c410af19ca43f040fc463551d11
2019-10-21 19:31:55 -07:00
Tao Xu
6385a39eec add testing code to PR jobs (#27594)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27594

## Summary

Since the nightly jobs are lack of  testing phases, we don't really have a way to test the binary before uploading it to AWS. To make the work more solid, we need to figure out a way to verify the binary.

Fortunately, the XCode tool chain offers a way to build your app without XCode app, which is the [xcodebuild](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) command. Now we can link our binary to a testing app and run `xcodebuild` to to see if there is any linking error. The PRs below have already done some of the preparation jobs

- [#26261](https://github.com/pytorch/pytorch/pull/26261)
- [#26632](https://github.com/pytorch/pytorch/pull/26632)

The challenge comes when testing the arm64 build as we don't have a way to code-sign our TestApp. Circle CI has a  [tutorial](https://circleci.com/docs/2.0/ios-codesigning/)  but is too complicated to implement. Anyway, I figured out an easier way to do it

1. Disable automatically code sign in XCode
2. Export the encoded developer certificate and provisioning profile to org-context in Circle CI (done)
3. Install the developer certificate to the key chain store on CI machines via Fastlane.
4. Add the testing code to PR jobs and verify the result.
5. Add the testing code to nightly jobs and verify the result.

## Test Plan

- Both PR jobs and nightly jobs can finish successfully.
- `xcodebuild` can finish successfully

Test Plan: Imported from OSS

Differential Revision: D17850703

Pulled By: xta0

fbshipit-source-id: ab220061c6e2ec75cae23684ad999c4f9c276820
2019-10-10 17:36:12 -07:00
Tao Xu
52985a3501 Install developer certificate for code signing (#27593)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27593

## Summary

Since the nightly jobs are lack of  testing phases, we don't really have a way to test the binary before uploading it to AWS. To make the work more solid, we need to figure out a way to verify the binary.

Fortunately, the XCode tool chain offers a way to build your app without XCode app, which is the [xcodebuild](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) command. Now we can link our binary to a testing app and run `xcodebuild` to to see if there is any linking error. The PRs below have already done some of the preparation jobs

- [#26261](https://github.com/pytorch/pytorch/pull/26261)
- [#26632](https://github.com/pytorch/pytorch/pull/26632)

The challenge comes when testing the arm64 build as we don't have a way to code-sign our TestApp. Circle CI has a  [tutorial](https://circleci.com/docs/2.0/ios-codesigning/)  but is too complicated to implement. Anyway, I figured out an easier way to do it

1. Disable automatically code sign in XCode
2. Export the encoded developer certificate and provisioning profile to org-context in Circle CI (done)
3. Install the developer certificate to the key chain store on CI machines via Fastlane.
4. Add the testing code to PR jobs and verify the result.
5. Add the testing code to nightly jobs and verify the result.

## Test Plan

- Both PR jobs and nightly jobs can finish successfully.
- `xcodebuild` can finish successfully

Test Plan: Imported from OSS

Differential Revision: D17848814

Pulled By: xta0

fbshipit-source-id: 48353f001c38e61eed13a43943253cae30d8831a
2019-10-09 20:07:30 -07:00
Tao Xu
7591010077 Disable automatically code signing for TestApp (#27591)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27591

## Summary

Since the nightly jobs are lack of  testing phases, we don't really have a way to test the binary before uploading it to AWS. To make the work more solid, we need to figure out a way to verify the binary.

Fortunately, the XCode tool chain offers a way to build your app without XCode app, which is the [xcodebuild](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) command. Now we can link our binary to a testing app and run `xcodebuild` to to see if there is any linking error. The PRs below have already done some of the preparation jobs

- [#26261](https://github.com/pytorch/pytorch/pull/26261)
- [#26632](https://github.com/pytorch/pytorch/pull/26632)

The challenge comes when testing the arm64 build as we don't have a way to code-sign our TestApp. Circle CI has a  [tutorial](https://circleci.com/docs/2.0/ios-codesigning/)  but is too complicated to implement. Anyway, I figured out an easier way to do it

1. Disable automatically code sign in XCode
2. Export the encoded developer certificate and provisioning profile to org-context in Circle CI (done)
3. Install the developer certificate to the key chain store on CI machines via Fastlane.
4. Add the testing code to PR jobs and verify the result.
5. Add the testing code to nightly jobs and verify the result.

## Test Plan

- Both PR jobs and nightly jobs can finish successfully.
- `xcodebuild` can finish successfully

Test Plan: Imported from OSS

Differential Revision: D17844036

Pulled By: xta0

fbshipit-source-id: 741f0442a718c9bda706107a2c4c3baed4c37137
2019-10-09 16:23:15 -07:00
Tao Xu
75d8dab9be Update the link for iOS demo app in README.md (#27145)
Summary:
Update the link for iOS demo app in README.md
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27145

Differential Revision: D17746591

Pulled By: xta0

fbshipit-source-id: 6f49a0daddc8b79804e1b8487ba1db3807a3f481
2019-10-03 13:43:58 -07:00
Tao Xu
f7742d2b21 Prepare for Cocoapods 1.3 Release (#26751)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26751

### Summary

We're going to use the AWS s3 bucket - `s3://ossci-ios` to store the release binary. To release the cocoapods, we can follow the steps below:

1.  Open a fake PR to trigger the CI job that pulls the code from the 1.3.0 tag branch and does the building and uploading.
2. Verify the binary locally  - Run tests on both arm64 and simulator
3. Publish the cocoapods officially

### Test plan

- podspec lint command succeeds
    - `pod spec lint --verbose --allow-warnings --no-clean --use-libraries --skip-import-validation`

Test Plan: Imported from OSS

Differential Revision: D17577131

Pulled By: xta0

fbshipit-source-id: 55fee918ecc5c4e0b6d714488a12351b4370afac
2019-09-25 12:16:06 -07:00
Tao Xu
781f861847 Add testing script for iOS x86 build (#26632)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26632

### Summary

This script builds the TestApp (located in ios folder) to generate an iOS x86 executable via the `xcodebuild` toolchain on macOS. The goal is to provide a quick way to test the generated static libraries to see if there are any linking errors. The script can also be used by the iOS CI jobs. To run the script, simply see description below:

```shell
$ruby scripts/xcode_ios_x86_build.rb --help

-i, --install                    path to the cmake install folder
-x, --xcodeproj                  path to the XCode project file
```

### Note

The script mainly deals with the iOS simulator build. For the arm64 build, I haven't found a way to disable the Code Sign using the `xcodebuiild` tool chain (XCode 10). If anyone knows how to do that, please feel free to leave a comment below.

### Test Plan

- The script can build the TestApp and link the generated static libraries successfully
- Don't break any CI job

Test Plan: Imported from OSS

Differential Revision: D17530990

Pulled By: xta0

fbshipit-source-id: f50bef7127ff8c11e884c99889cecff82617212b
2019-09-23 11:21:21 -07:00
Lu Fang
72aeafd3d0 Fix no tab check (#26399)
Summary:
ignore the folder and its children ios/TestApp
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26399

Differential Revision: D17451239

Pulled By: houseroad

fbshipit-source-id: d6ba666bf955454eca4a10c00784ee5947a70f59
2019-09-18 09:11:32 -07:00
Tao Xu
cc61af3c3d Add iOS test app skeleton (#26261)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26261

### Summary

Previously we have enabled the CI jobs for Pull Requests and nightly build

-  **#25840 [iOS][Circle CI] Add PR jobs for iOS builds**
-  **#26074 [IOS][CIRCLE CI] Nightly jobs for iOS builds**

The testing phase is missing in the nightly build process.  Although we are able to generate the build and upload it to the AWS,  there is no way to know whether the binary is valid or not (there could be a linking error). To add the test phase to the process, we need

1. Put a dummy test App in the repo.
2. After the build jobs finishes, manually link the static libs to the dummy app to produce an executable using the xcode tool chain.
3. If there is no linking error, then upload the binaris to AWS. If there is an error, then stops the following process and reports an error in CI.

The second and third steps depends on the first step which needs to be landed first.

### Test Plan
- Don't break any existing CI jobs

Test Plan: Imported from OSS

Differential Revision: D17408929

Pulled By: xta0

fbshipit-source-id: e391da242639943005453d1318795f981034cc72
2019-09-17 11:06:57 -07:00
Tao Xu
3051e36e05 Remove armv7s build from iOS (#26222)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26222

### Summary

The last generation of armv7s device is Phone 5C. As discussed with David offline, we decided not to support iOS armv7s devices.

### Test plan

- CI finishes successfully
- Builds can be run only on X86_64 and arm64 devices

Test Plan: Imported from OSS

Differential Revision: D17385308

Pulled By: xta0

fbshipit-source-id: f883999aed18224ea3386b1f016964a33270fa34
2019-09-14 11:07:37 -07:00
Tao Xu
b5a3a8b427 Change the source link in podspec (#26089)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26089

### Summary

A couple of changes

1. Replace the source link with the newly nightly build address
2. Remove module support for Swift and Objective-C
3. Expose all static libraries instead of archiving them into one single library. This is because those static libraries might contain object files that have the same name, e.g. `init.c.o` in both `libcupinfo.a` and `libqnnpack.a`. If we archive them into one using this `libtool -static` command, by default, it only picks one object file and discards the others, which could result in undefined symbols when linking the executable. The change here is to expose all the static libraries and let the linker decide which one to use.

### Test Plan

- pod spec lint succeed
 - `pod spec lint --verbose --allow-warnings --no-clean --use-libraries --skip-import-validation`

Test Plan: Imported from OSS

Differential Revision: D17363037

Pulled By: xta0

fbshipit-source-id: ba77b0001b58e6e2353d8379d932db598166d37d
2019-09-13 15:00:31 -07:00
Tao Xu
115494b00b Cocoapods for iOS OSS release (#25847)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25847

### Summary

The Podspec file for iOS OSS release. This podspec contains the C++ header files and a static library that supports three architectures.

Please ignore the link for `s.source` for now, as I'm still working on the CI nightly build. This is a temporary link for testing purpose.

### Note

Previously I have a cocoapods release proposal  -  https://github.com/pytorch/pytorch/pull/25543 which contains two podspec files. However, for the time being, we haven't decided whether we want to release the Objective-C API wrapper or not. Please review and refer to this one if you have questions.

Test Plan: Imported from OSS

Differential Revision: D17262459

Pulled By: xta0

fbshipit-source-id: 4cc60787a41beab14cf9b1c0e9ab62b8b14603c5
2019-09-09 14:50:03 -07:00