211 Commits

Author SHA1 Message Date
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
91e922a338 [AI Bench] Add support for nlu model
Summary: add support for nlu specific input

Test Plan:
tested

```
buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/fbnet/assistant_mobile_inference.json --platform android/full_jit --framework pytorch --remote --devices  SM-G950U-7.0-24
```
make sure it compatible with previous test
```
buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/fbnet/fbnet_mobile_inference.json --platform android/full_jit --framework pytorch --remote --devices  SM-G950U-7.0-24
```

```
{
  "model": {
    "category": "CNN",
    "description": "Assistant Mobile Inference",
    "files": {
      "model": {
        "filename": "model.pt1",
        "location": "//everstore/GICWmAB2Znbi_mAAAB0P51IPW8UrbllgAAAP/model.pt1",
        "md5": "c0f4b29c442bbaeb0007fb0ce513ccb3"
      },
      "data": {
        "filename": "input.txt",
        "location": "/home/pengxia/test/input.txt",
        "md5": "c0f4b29c442bbaeb0007fb0ce513ccb3"
      }
    },
    "format": "pytorch",
    "framework": "pytorch",
    "kind": "deployment",
    "name": "Assistant Mobile Inference"
  },
  "tests": [
    {
      "command": "{program} --model {files.model}  --input_dims \"1\" --input_type NLUType --warmup {warmup} --iter {iter} --input_file {files.data} --report_pep true",
      "identifier": "{ID}",
      "metric": "delay",
      "iter": 5,
      "warmup": 2,
      "log_output": true
    }
  ]
}

```
input.txt
```
what is weather today
what time it is
set a reminder for tomorrow
```

result
https://our.intern.facebook.com/intern/aibench/details/137241352201417

Reviewed By: kimishpatel

Differential Revision: D20300947

fbshipit-source-id: 7c1619541a2e9514a560a9acb9029cfc4669f37a
2020-03-09 10:39:49 -07:00
02478984d6 Add support to dump unsupported ops. Add lite_interpter_load test. (#34278)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34278

This diff helps check all the ops not supported by lite_interpreter.
Helpful mainly to find all the ops that need to be added instead of adding them
one by one.

Test Plan:
buck run caffe2/binaries:lite_interpreter_model_load --
--model=<bytecode-model-path>

Reviewed By: iseeyuan

Differential Revision: D20266341

fbshipit-source-id: 5a6c7a5bc52f910cea82a72045870da8105ccb87
2020-03-05 18:31:31 -08:00
d59e036f4d Revert D20194092: Add support to dump unsupported ops. Add lite_interpter_load test.
Test Plan: revert-hammer

Differential Revision:
D20194092

Original commit changeset: 0d596cd02043

fbshipit-source-id: 17b4bae27543f231bd6c12d90368d399ca55ebdf
2020-03-04 13:53:58 -08:00
17a5c67796 Add support to dump unsupported ops. Add lite_interpter_load test. (#34072)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34072

This diff helps check all the ops not supported by lite_interpreter.
Helpful mainly to find all the ops that need to be added instead of adding them
one by one.

Test Plan:
buck run caffe2/binaries:lite_interpreter_model_load --
--model=<bytecode-model-path>

Reviewed By: iseeyuan

Differential Revision: D20194092

fbshipit-source-id: 0d596cd0204308027194af7ed738551d0c32a374
2020-03-04 13:18:12 -08:00
358450e02b improved TorchScript traceback (#33834)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33834

This changes how we report Tracebacks to make them more clear when
there are both serialized and non-serialized ranges. It now looks like:

```
Traceback (most recent call last):
  File "foo.py", line 25, in <module>
    s2(a, b)
  File "/scratch/zdevito/pytorch/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript, serialized code (most recent call last):
  File "code/__torch__.py", line 7, in forward
    x: Tensor,
    y: Tensor) -> Tensor:
    return (self).bar(x, y, )
            ~~~~~~~~~ <--- HERE
  def bar(self: __torch__.Moo,
    x: Tensor,
  File "code/__torch__.py", line 11, in bar
    x: Tensor,
    y: Tensor) -> Tensor:
    _0 = (self).baz(x, y, )
          ~~~~~~~~~ <--- HERE
    _1 = torch.ones([3], dtype=None, layout=None, device=None, pin_memory=None)
    return torch.add(_0, _1, alpha=1)
  File "code/__torch__.py", line 17, in baz
    x: Tensor,
    y: Tensor) -> Tensor:
    return torch.add(x, y, alpha=1)
           ~~~~~~~~~ <--- HERE

Traceback of TorchScript, original code (most recent call last):
  File "foo.py", line 11, in forward
    def forward(self, x, y):
        return self.bar(x, y)
               ~~~~~~~~ <--- HERE
  File "foo.py", line 9, in bar
    def bar(self, x, y):
        return self.baz(x, y) + torch.ones(3)
               ~~~~~~~~ <--- HERE
  File "foo.py", line 7, in baz
    def baz(self, x, y):
        return x + y
               ~~~~~ <--- HERE
RuntimeError: The size of tensor a (4) must match the size of tensor b (5) at non-singleton dimension 1
```

It follows Python convension of having the most important information last
and reading from the bottom up.

Changes:
* Moved the error message to the end, to copy Python
* Report original traceback separate from serialized traceback
* Make sure root functions have names in the interpreter trace.

Test Plan: Imported from OSS

Differential Revision: D20126136

Pulled By: zdevito

fbshipit-source-id: fd01f9985e5d74e04c4d064c02e8bc320f4fac13
2020-03-03 12:27:38 -08:00
4b3ae7e0af Enable -Werror=format compile errors on torch exception types (#34019)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/33899

In the issue, we have
```
TypeError("expected %s (got %s)", dispatch_key, toString(other.key_set()).c_str());
```
which results in `dispatch_key` being interpreted as a c-string by `sprintf`. Adding `__attrbute__((format))` to the `TypeError` constructor allows gcc or clang to detect this at compile time. Then `-Werror=format` makes it a hard error at compile time.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34019

Differential Revision: D20194842

Pulled By: ezyang

fbshipit-source-id: fa4448916c309d91e3d949fa65bb3aa7cca5c6a8
2020-03-02 13:25:39 -08:00
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
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
643ca5def2 Replace c10::guts::stuff with std::stuff (#30915)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30915

Since we now have C++14, we don't need these c10::guts helpers anymore
ghstack-source-id: 95777609

Test Plan: waitforsandcastle

Differential Revision: D18869639

fbshipit-source-id: 97716f932297c64c6e814410ac47b444c33d4e2e
2019-12-16 13:57:19 -08:00
e7fe64f6a6 Fix typos (#30606)
Summary:
Should be non-semantic.

Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30606

Differential Revision: D18763028

Pulled By: mrshenli

fbshipit-source-id: 896515a2156d062653408852e6c04b429fc5955c
2019-12-02 20:17:42 -08:00
f5ef3a6fb6 disable JIT optimizer in Android wrapper for mobile custom build (#30285)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30285

PR #30144 introduced custom build script to tailor build to specific
models. It requires a list of all potentially used ops at build time.

Some JIT optimization passes can transform the IR by replacing
operators, e.g. decompose pass can replace aten::addmm with aten::mm if
coefficients are 1s.

Disabling optimization pass can ensure that the list of ops we dump from
the model is the list of ops that are needed.

Test Plan: - rerun the test on PR #30144 to verify the raw list without aten::mm works.

Differential Revision: D18652777

Pulled By: ljk53

fbshipit-source-id: 084751cb9a9ee16d8df7e743e9e5782ffd8bc4e3
2019-11-22 00:25:04 -08:00
f2f285c240 Add arguments to benchmark to run pytext models. Output results in ms. (#30273)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30273

Pytext models expect input of the form `1xlength` and another input specifying the length.
Add the `pytext_len` argument to specify this.
ghstack-source-id: 94383501

Test Plan: ./speed_benchmark_torch --model model.pt --input_dims "1,4" --input_type int64 --warmup 10 --iter 10 --report_pep=true --pytext_len=4

Reviewed By: iseeyuan

Differential Revision: D18646028

fbshipit-source-id: 7d5fe0c36da6e5f7b0261619ce4784a46b70f3d8
2019-11-21 16:03:00 -08:00
18bdf97dbb Factor Module into Object and Module
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/29500

Test Plan: Imported from OSS

Differential Revision: D18463064

Pulled By: jamesr66a

fbshipit-source-id: d37bef242a8626593d4b8754042152cfc0f0acb2
2019-11-17 22:58:50 -08:00
d75222f3f5 Dump operator names of a module and its submodules.
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/29374

Test Plan: Imported from OSS

Reviewed By: ljk53

Differential Revision: D18372073

Pulled By: ljk53

fbshipit-source-id: cf2df0d44ffe74dd24dc63f1f07f395e36b5393d
2019-11-08 08:22:05 -08:00
78a34d3205 Revert D18350353: dump operator names of a module and its sub-modules.
Test Plan: revert-hammer

Differential Revision:
D18350353

Original commit changeset: 2026c8ab7650

fbshipit-source-id: 401f34cb276c3ea34a5439de4c3415969a04ab2a
2019-11-07 05:28:33 -08:00
dc7552f9ca dump operator names of a module and its sub-modules. (#29208)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29208

A binary to dump operator names from a script model and its sub models.
Usage:
dump_operator_names path/to/script_model.pt path/to/output.yaml

Test Plan: Imported from OSS

Differential Revision: D18350353

fbshipit-source-id: 2026c8ab765069ad059ab2ca44fc27b79315b973
2019-11-06 20:57:28 -08:00
d0204ea92a Remove dead includes in caffe2/binaries
Reviewed By: ezyang

Differential Revision: D18136357

fbshipit-source-id: df357c9d4b344b5621b838c2a2657658e10f7000
2019-11-01 10:58:42 -07:00
2cc0f1bbc6 Run pytorch mobile benchmark in PEP (#28437)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28437

Add target to build speed_benchmark_torch for PEP.
Added a new argument `--report_pep` to print total runtime information for PEP. Can add per-op stats under this later.

Test Plan: https://our.intern.facebook.com/intern/aibench/details/664440309179004

Reviewed By: hl475

Differential Revision: D18062059

fbshipit-source-id: ca80e980ce8e48604782a15ac44dd8d403832817
2019-10-22 14:21:49 -07:00
04bfc213ab remove AutoNonVariableTypeMode guard around forward() call (#28399)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28399

This is also to address issue #26764

Turns out it's incorrect to wrap the entire forward() call with
NonVariableTypeMode guard as some JIT passes has is_variable() check and
can be triggered within forward() call, e.g.:
jit/passes/constant_propagation.cpp

Since now we are toggling NonVariableTypeMode per method/op call, we can
remove the guard around forward() now.

Test Plan: - With stacked PRs, verified it can load and run previously failed models.

Differential Revision: D18055850

Pulled By: ljk53

fbshipit-source-id: 3074d0ed3c6e05dbfceef6959874e5916aea316c
2019-10-22 14:08:49 -07:00
987e37b9c2 Enable EXE001 flake8 check. (#27560)
Summary:
According to https://github.com/pytorch/pytorch/issues/27285 , seems we do not intend to use shebang as an indication of Python version, thus
we enable EXE001 flake8 check.
For violations, we either remove shebang from non-executable Python scripts or grant them executable permission.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27560

Differential Revision: D17831782

Pulled By: ezyang

fbshipit-source-id: 6282fd3617b25676a6d959af0d318faf05c09b26
2019-10-09 09:15:29 -07:00
8d5c2aa71c Set quantized engine backend for mobile in speed_benchmark_torch (#26911)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26911

Check if QNNPACK is present as a backend (should always be present on mobile).
If it is present then set the backend to QNNPACK

Test Plan:
Test on mobile
./speed_benchmark_torch --model mobilenet_quantized_scripted.pt  --input_dims="1,3,224,224" --input_type=float --warmup=5 --iter 20 --print_output True

Imported from OSS

Differential Revision: D17613908

fbshipit-source-id: af96722570a0111f13d69c38ccca52416ea5e460
2019-09-26 16:28:23 -07:00
3363ec9283 clean up binaries/cmake for mobile (#25651)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25651

Most of the bianries are not useful/compilable for mobile. Consolidate the gating
logic and move to the beginning of the file.

Test Plan: - make sure BUILD_BINARY=ON works for both mobile and non-mobile builds;

Differential Revision: D17183550

Pulled By: ljk53

fbshipit-source-id: a8179f4e80999271bf43b5d97798abc713c59843
2019-09-04 22:32:45 -07:00
890d0f88ae update speed benchmark binary to work in USE_STATIC_DISPATCH mode (#25449)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25449

Currently Variable and Tensor are still not 100% merged. There are
various places in ATen/TH codebase where it asserts input type to be
Variable/Tensor.

Usually when input type is Variable it will dispatch function calls to
corresponding generated VariableType methods, where it converts input
Variable type to Tensor type with "unpack()" before calling into LegacyTHFunctions
and then converts result from Tensor type back to Variable type with "as_variable()".

However, when USE_STATIC_DISPATCH mode is enabled, it no longer dispatches function
calls to VariableType methods. This way, Variable inputs will remain as
Variable instances when they reach LegacyTHFunctions and fail the "checked_tensor_unwrap"
asserts. And there are a couple other failed asserts because of similar reason.

There are several options to address this problem with USE_STATIC_DISPATCH:
1. Wait until Variable and Tensor are fully merged as planned in https://github.com/pytorch/pytorch/issues/23032;
2. Create Tensors instead of Variables upfront on caller side (JIT);
3. Fix downstream asserts in ATen/TH to tolerant Variable inputs when AutoGrad is disabled;

Option 1 will still take some time; Option 2 was tried before and caused
a lot problems; Option 3 needs to be conducted case by case as it can be
dangerous to remove asserts before 100% merge happens.

After digging into it a bit more, turns out NonVariableTypeMode not only controls how
it dispatches, but also controls TensorImpl.is_variable() result. So the
problem can be addressed by:
1. Set AutoNonVariableTypeMode mode right before calling forward();
2. Make sure all inputs/params are created as Variable, e.g.:
 A. should use torch::ones() to create test input tensor instead of at::ones();
 B. should not set AutoNonVariableTypeMode before torch::jit::load() call;

This diff applied these changes to speed benchmark to proof how it works.

Test Plan:
- Build speed benchmark binary for Android:
```
./scripts/build_android.sh \
-DBUILD_BINARY=ON \
-DBUILD_CAFFE2_MOBILE=OFF \
-DUSE_STATIC_DISPATCH=ON \
-DCMAKE_PREFIX_PATH=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') \
-DPYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')
```

- Push binaries and model to Android device:
```
adb push build_android/bin/speed_benchmark_torch /data/local/tmp
adb push resnet.pb /data/local/tmp
```

- Run inference on device:
```
/data/local/tmp # ./speed_benchmark_torch --model=resnet.pb \
--input_dims="1,3,224,224" --input_type=float --print_output=true
```

Differential Revision: D17128567

Pulled By: ljk53

fbshipit-source-id: 58cc49ff35d21fefc906172cc3271f984eeb29f0
2019-08-30 15:16:45 -07:00
a779263501 add speed benchmark binary for torch jit (#25486)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25486

Reland PR #25230.

Test Plan: Imported from OSS

Differential Revision: D17137095

Pulled By: ljk53

fbshipit-source-id: 3b258e29e16d03ef24b5b49d9b67b72257f0f3a8
2019-08-30 15:16:41 -07:00
c2b710c3bd Revert D17067216: [pytorch][perf] add speed benchmark binary for torch jit
Test Plan: revert-hammer

Differential Revision:
D17067216

Original commit changeset: 0cf4c46f1c90

fbshipit-source-id: a8fa2a72042da817d199d325c30624a451b24582
2019-08-30 06:22:21 -07:00
86b1d5f271 add speed benchmark binary for torch jit (#25230)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25230

Add similar benchmark binary as caffe2 speed benchmark for torch JIT.

Test Plan:
- Test with ResNet-18 torch script model:
```
./speed_benchmark_torch --model=res18.pb --input_dims="1,3,224,224" --input_type=float --print_output=true
./speed_benchmark_torch --model=res18.pb --input_dims="1,3,224,224" --input_type=float --warmup=5 --iter=20
```

- Verified building as desktop/server binary works:
```
BUILD_BINARY=ON python setup.py develop
```

- Verified building as android binary works:
```
./scripts/build_android.sh \
-DBUILD_BINARY=ON \
-DBUILD_CAFFE2_MOBILE=OFF \
-DCMAKE_PREFIX_PATH=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') \
-DPYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')
```

Differential Revision: D17067216

Pulled By: ljk53

fbshipit-source-id: 0cf4c46f1c90b89bd8dca2a14bb0e5fb70b233a1
2019-08-29 19:34:44 -07:00
e370486d80 fix binaries build for BUILD_CAFFE2_MOBILE=OFF (#25229)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25229

The binaries don't build when BUILD_CAFFE2_MOBILE=OFF (libtorch mode)
in which case we don't include caffe2/predictor which is needed by
predictor_verifier.cc.

Add BUILD_BINARY=ON to libtorch android CI script to make sure binaries
can be compiled for libtorch android as we will add speed benchmark
binary for it.

Test Plan:
- Verified BUILD_BINARY=ON works with BUILD_CAFFE2_MOBILE=OFF and ON.
- Will check CI builds.

Differential Revision: D17067217

Pulled By: ljk53

fbshipit-source-id: 2a28139d9d25ff738be7b49b24849c9d300ef9a9
2019-08-29 19:34:40 -07:00
cef0443464 Ensure proper file executable permissions in CI. (#24214)
Summary:
Some files have inproper executable permissions (which git tracks). This
commit adds a test in CI to ensure that executable permissions are off
for files that shouldn't have such a permission. This also ensures fixes
such as https://github.com/pytorch/pytorch/issues/21305 are complied in the future.

 ---

Disclaimer: I'm the author of flake8-executable, and I've been using it
on my end for over a month and thus I think it should be stable enough.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/24214

Differential Revision: D16783437

Pulled By: ezyang

fbshipit-source-id: 018e55798f1411983c65444e6304a25c5763cd19
2019-08-16 06:11:09 -07:00
ceb9a573d9 Implement virtual memory computation in caffe2_benchmark binary (#24144)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/24144

Implement virtual memory computation in caffe2_benchmark binary in windows.

Reviewed By: hl475

Differential Revision: D16752250

fbshipit-source-id: aceb13ddd507aa2e6bad07de28d79776e6ee517c
2019-08-12 13:08:47 -07:00
e23e4cc356 Back out "Revert D16469619: Add Virtual Memory and CPU percentage computation to AIBench"
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/23821

Reviewed By: hl475

Differential Revision: D16654854

fbshipit-source-id: f057023e890cbcbd9145ef2ecb449df2fbba592b
2019-08-07 15:44:22 -07:00
1b1bddaab3 Revert D16469619: Add Virtual Memory and CPU percentage computation to AIBench
Differential Revision:
D16469619

Original commit changeset: 670f3549c830

fbshipit-source-id: f55d4cda36f5e29df2df306d33a70158e5a7908b
2019-08-04 16:06:51 -07:00
445440a6a9 Add Virtual Memory and CPU percentage computation to AIBench (#23590)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23590

This diff adds CPU% and Virtual Memory computation by default to AIBench when doing mobile remote run

Reviewed By: llyfacebook

Differential Revision: D16469619

fbshipit-source-id: 670f3549c830a36bc456a57f2ea668f9f82dd15a
2019-08-04 09:29:44 -07:00
7b1d6c8912 Update intra_inter_benchmark (#22051)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22051
ghimport-source-id: 70710b3866b1a5e21656b77d2695ada74d00254e

Test Plan:
PARALLEL_BACKEND=NATIVE_TBB USE_OPENMP=0 USE_TBB=1 MKL_SEQ=1
MKLDNN_THREADING=SEQ USE_CUDA=0 BLAS=MKL USE_MKLDNN=1 BUILD_BINARY=1
python setup.py develop --cmake

./build/bin/intra_inter_benchmark

Imported from OSS

Differential Revision: D15933951

Pulled By: ilia-cher

fbshipit-source-id: 88ad8f7a1634c1612ffaa68f22721ffc73d9b2ba
2019-06-21 23:06:27 -07:00
fc3f702ba8 at::launch benchmark (#21581)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/21581
ghimport-source-id: 6a65d73694b17611d6ad45db0b39b86c318a68c7

Differential Revision: D15736495

Pulled By: ilia-cher

fbshipit-source-id: 6b9109ad3611ff3c8b1a37796e9149bef0c2ad36
2019-06-13 10:46:35 -07:00
5485f09f18 Native TBB parallel backend (#20480)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20480
ghimport-source-id: c710f897c4c9b9616fc3dd76d80b4845aea43a1f

Differential Revision: D15333692

Pulled By: ilia-cher

fbshipit-source-id: 61e476dd5c737fe144e3aec000d8ebb11fbc0547
2019-06-13 10:11:16 -07:00
c25e33789e Lightweight at-most-once logging for API usage (#20745)
Summary:
Resubmit #20698 which got messed up.

Idea is that when PyTorch is used in a custom build environment (e.g. Facebook), it's useful to track usage of various APIs centrally. This PR introduces a simple very lightweight mechanism to do so - only first invocation of a trigger point would be logged. This is significantly more lightweight than #18235 and thus we can allow to put logging in e.g. TensorImpl.

Also adds an initial list of trigger points. Trigger points are added in such a way that no static initialization triggers them, i.e. just linking with libtorch.so will not cause any logging. Further suggestions of what to log are welcomed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20745

Differential Revision: D15429196

Pulled By: dzhulgakov

fbshipit-source-id: a5e41a709a65b7ebccc6b95f93854e583cf20aca
2019-05-23 23:17:59 -07:00
481b6d0268 Allow a non-OpenMP based build (#19749)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19749
ghimport-source-id: a6636c0acddbdc5fd5b0dcb20b9f80cbdb9159b9

Differential Revision: D15141993

Pulled By: ilia-cher

fbshipit-source-id: 96085608398b2a4c97c68b2948f5184d07f9ad3d
2019-05-06 19:34:48 -07:00
5903522ad6 refactor: a bit intricate so I refactor it (#16995)
Summary:
this code is a bit intricate so i refactor it
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16995

Differential Revision: D14050667

Pulled By: ifedan

fbshipit-source-id: 55452339c6518166f3d4bc9898b1fe2f28601dc4
2019-02-26 10:21:22 -08:00
6a46738986 Fix android crash when model detects nothing
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17119

Reviewed By: sf-wind

Differential Revision: D14087835

Pulled By: ZhizhenQin

fbshipit-source-id: 32e61d46679bae645fd0bbec724513cfa5c553ab
2019-02-14 17:29:14 -08:00
632df48207 Merge binaries "convert_image_to_tensor" and "caffe2_benchmark" (#16875)
Summary:
Merge binaries "convert_image_to_tensor" and "caffe2_benchmark" to remove the overhead of writing to/reading from Tensor file.

*TODO next: TensorProtos is another overhead. No need for de-serialization.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16875

Reviewed By: sf-wind

Differential Revision: D13997726

Pulled By: ZhizhenQin

fbshipit-source-id: 4dec17f0ebb59cf1438b9aba5421db2b41c47a9f
2019-02-11 13:07:26 -08:00
2fb2d080d3 caffe2_benchmark msvc build fix (#15619)
Summary:
Fixing error in caffe2_benchmark binary

```
2018-12-29T14:09:59.7867995Z   d:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.h(90): error C2678: binary '|=': no operator found which takes a left-hand operand of type 'std::_Iosb<int>::_Openmode' (or there is no acceptable conversion) (compiling source file D:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.cc) [D:\a\1\s\caffe2_builders\v141\pytorch\build\Release\binaries\caffe2_benchmark.vcxproj]
2018-12-29T14:09:59.7868252Z   d:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.h(92): error C2678: binary '|=': no operator found which takes a left-hand operand of type 'std::_Iosb<int>::_Openmode' (or there is no acceptable conversion) (compiling source file D:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.cc) [D:\a\1\s\caffe2_builders\v141\pytorch\build\Release\binaries\caffe2_benchmark.vcxproj]
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15619

Differential Revision: D13580195

Pulled By: soumith

fbshipit-source-id: b0a4479cd5f7555801b1977aeee96b6433293da7
2019-01-05 08:29:31 -08:00
c1643ec551 add the int support (#15581)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15581

as title

Reviewed By: protonu

Differential Revision: D13556274

fbshipit-source-id: ba21f0970257d526e2fe7574eea4f89465b9c618
2018-12-27 17:16:32 -08:00
2b23ba8ef0 The benchmark binary support multiple batches in one run (#15443)
Summary:
It is sometimes beneficial to run multiple batches in one benchmark and check the aggregated results.

This PR enables this functionality.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15443

Reviewed By: llyfacebook

Differential Revision: D13531129

Pulled By: sf-wind

fbshipit-source-id: 553a762a5cbadf5a3d9fd6af767ae34899bc1aa2
2018-12-21 08:45:41 -08:00
2a64a78e7b Extract arguments to its own file and pass arguments to ios apps (#15413)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15413

In order to pass arguments to the ios app, need to extarct the arguments
to its own file. Also, in the ios app, do not use the benchmark.json, which
parses the arguments.

This is an incompatible change, needs to add hot fix to the tests.

Reviewed By: llyfacebook

Differential Revision: D13523240

fbshipit-source-id: b559cc7f52d8f50ee206a7ff8d7b59292d855197
2018-12-20 13:31:48 -08:00
60badccd10 Fix a typo in the assert
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15265

Reviewed By: llyfacebook

Differential Revision: D13477029

Pulled By: sf-wind

fbshipit-source-id: 9c5571a583c01f9701625541ebec0c836cb923f2
2018-12-15 09:09:09 -08:00
e1808be37d Add several features to converting images to blobs (#15204)
Summary:
Several enhancements are implemented:

* Resize the images to be within a boundary between min-size and max-size (can be height and weight). It tries to resize the minimum size to match the min-size and keep the aspect ratio. However, if in that case the maximum size is more than the max-size, then resize the maximum size to be equal to the max-size (and the minimum size is less than min-size). The min/max sizes are specified in argument scale, in a comma separated form. If one of the size is -1, then that size is not a restriction.

* Change the OpenCV resize function arguments from using cv::Size() to the x, y scale. Theoretically they should be the same. But in reality, the two ways of specifying them may result to different resized outputs.

* Once the image is read in, change the data to floats. That means, after resize and other preprocessing steps, the float values are preserved (not truncated to int).

* It is possible to convert data in text format to the blob format.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15204

Reviewed By: llyfacebook

Differential Revision: D13467225

Pulled By: sf-wind

fbshipit-source-id: 7da34a72d43a9603cd7ab953f5821c1222d0178f
2018-12-14 17:37:21 -08:00
107c9ef518 Add back c2 string_utils include header to benchmark_helper
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15143

Differential Revision: D13439694

fbshipit-source-id: 78698b66d52a0178118cbf3e79a7a5ad1763d47b
2018-12-12 16:38:00 -08:00
00a4c8d41c Use c10::to_string that works cross platform (#15117)
Summary:
Fix master breakage introduced in #15108
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15117

Differential Revision: D13430568

Pulled By: bddppq

fbshipit-source-id: ce10bc552f085d1bf0afbc13119991bee014ac95
2018-12-12 02:58:49 -08:00
e20f9bbead Update the output format for benchmark_helper. It outputs the dimensi… (#15108)
Summary:
…on first and all the values in the next line. This way, it can output arbitrary blob
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15108

Reviewed By: llyfacebook

Differential Revision: D13429346

Pulled By: sf-wind

fbshipit-source-id: 5e0bba2a46fbe8d997dfc3d55a698484552e3af8
2018-12-11 22:24:56 -08:00