Commit Graph

33 Commits

Author SHA1 Message Date
Richard Barnes
ed327876f5 [codemod] c10:optional -> std::optional (#126135)
Generated by running the following from PyTorch root:
```
find . -regex ".*\.\(cpp\|h\|cu\|hpp\|cc\|cxx\)$" | grep -v "build/" | xargs -n 50 -P 4 perl -pi -e 's/c10::optional/std::optional/'
```

`c10::optional` is just an alias for `std::optional`. This removes usages of that alias in preparation for eliminating it entirely.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126135
Approved by: https://github.com/Skylion007, https://github.com/malfet, https://github.com/albanD, https://github.com/aaronenyeshi
2024-05-14 19:35:51 +00:00
cyy
5d5990fc49 Remaining replacement of c10::stoi with std::stoi (#109482)
PR #109179 replaced c10::stoi with std::stoi. However, there were some files forgotten to change. This patch fixes them.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/109482
Approved by: https://github.com/vfdev-5, https://github.com/Skylion007
2023-09-18 16:05:09 +00:00
Salil Desai
df1cc0ef47 [Vulkan] Add Vulkan Rewrite to Transfer Inputs and Outputs to Vulkan and CPU Backends Respectively (#87432)
With this change, we don't have to manually invoke transferring input and output backends when we run vulkan models.

Graph rewrite code based off of:
- 32efff45ba (diff-a473bddb458dc24225866a45092d6eca064eddd256245d93020e48e216eee4d5R160-R179)

Differential Revision: [D39519168](https://our.internmc.facebook.com/intern/diff/D39519168/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D39519168/)!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87432
Approved by: https://github.com/mcr229, https://github.com/digantdesai
2022-10-31 14:18:45 +00:00
Sicheng Stephen Jia
52175307e2 [vulkan] Allow benchmark binary to handle non-single tensor inputs/outputs for Vulkan models (#73109)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/73109

This change updates the Vulkan model runner in `speed_benchmark_torch` to be able to generate inputs for models that have input/output types other than just a single tensor. Input elements are processed depending on their type.

Test Plan: Imported from OSS

Reviewed By: mikaylagawarecki

Differential Revision: D34354839

Pulled By: SS-JIA

fbshipit-source-id: 993e55372d2664fa7eddb16146deba264727f399
(cherry picked from commit 4a140202ac)
2022-02-19 01:33:51 +00:00
Scott Wolchok
82f7f8d471 [PyTorch] Adopt IValue::toTupleRef() where obvious (#65505)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65505

Generated with

`fastmod -m 'toTuple\(\)(\s*)->' 'toTupleRef()${1}.'`

, followed by

`fastmod '(std::move\(.*)toTupleRef\(\).' '${1}toTuple()->'`

to unbreak 2 callsites.
ghstack-source-id: 142065835

Test Plan: CI

Reviewed By: gchanan

Differential Revision: D31131025

fbshipit-source-id: 54457ae5bbeb38db9c7f196d469b98521c3d3f34
2021-11-02 10:22:18 -07:00
Stephen Jia
df475aa1dc Update Vulkan runner in benchmark binary to handle non-tensor inputs (#66123)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66123

Some models may take in a list of tensors as inputs, thus the bundled inputs will contain `IValues` that are of the type `c10::List`. For Vulkan models, every tensor in the `IValue` list has to be converted to a vulkan tensor first, and this case is not currently handled by the Vulkan model wrapper in the benchmark binary.

This diff introduces `IValue` type checking to the input processor of the Vulkan model wrapper, and adds support for Tensor and List types.

Test Plan:
```
# Build the binary
cd ~/fbsource
buck build -c ndk.custom_libcxx=false -c pt.enable_qpl=0 //xplat/caffe2:ptmobile_compareAndroid\#android-arm64 --show-output
# Push it to the device
adb push buck-out/gen/xplat/caffe2/ptmobile_compareAndroid\#android-arm64 /data/local/tmp/compare_models

# Run the benchmark binary
BENCH_CMD="/data/local/tmp/compare_models"
BENCH_CMD+=" --model=$PATH_TO_MODEL"
BENCH_CMD+=" --refmodel=$PATH_TO_REFERENCE_MODEL"
BENCH_CMD+=" --input_type=float --input_dims=$MODEL_INPUT_SIZE"
BENCH_CMD+=" --iter=100"
BENCH_CMD+=" --tolerance 1e-5"
```

Reviewed By: beback4u

Differential Revision: D31276862

fbshipit-source-id: 1d9abf958963da6ecad641202f0458402bee5ced
2021-10-05 07:59:56 -07:00
Sam Estep
3a0801f960 [skip ci] Fix "arugment" typos (#61459)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/61455.

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

Reviewed By: soulitzer

Differential Revision: D29636559

Pulled By: samestep

fbshipit-source-id: 9ad65265c0491d9e81bb303abe3a07c6843bfa4a
2021-07-15 15:20:18 -07:00
Ivan Kobzarev
85fcadc059 [lite-interpreter] speed_benchmark_torch support BUILD_LITE_INTERPRETER (#55402)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55402

Test Plan: Imported from OSS

Reviewed By: cccclai

Differential Revision: D27599824

Pulled By: IvanKobzarev

fbshipit-source-id: 3adbb8a16a785d3610404d71ef2d895904b1a8ef
2021-04-07 11:39:32 -07:00
Ailing Zhang
24c904951c Replace AutoNonVariableTypeMode with InferenceMode in fbcode. (#55114)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55114

Test Plan: CI

Reviewed By: ezyang, bhosmer

Differential Revision: D27472768

fbshipit-source-id: 76f17ef7de40f6e04e2968f8958027b5f93e1c0c
2021-04-02 11:45:53 -07:00
Stephen Jia
c2558b4b61 [vulkan] Add nonVarTypeModeGuard to vulkan tests and speed_benchmark_torch (#52535)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52535

Test Plan: Imported from OSS

Reviewed By: ailzhang

Differential Revision: D26580994

Pulled By: SS-JIA

fbshipit-source-id: 94f091432265cf6607b73c34846c07273d47c70b
2021-02-25 14:23:40 -08:00
Ashkan Aliabadi
251398acca Force a sync on non-CPU tensors for the benchmark to reflect the timing accurately. (#48856)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/48856

Test Plan: Imported from OSS

Reviewed By: IvanKobzarev

Differential Revision: D25339803

Pulled By: AshkanAliabadi

fbshipit-source-id: fdfd9a0e0cc37245d7671419f492e445396fbdb8
2020-12-05 10:47:44 -08:00
Kimish Patel
6e55a26e10 Move mobile specific CPUCachingAllocator to c10/mobile folder. (#45364)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45364

Plus add some more comments about the usage, limitations and cons.

Test Plan: Build and run benchmark binary.

Reviewed By: gchanan

Differential Revision: D23944193

fbshipit-source-id: 30d4f4991d2185a0ab768d94c846d73730fc0835
2020-09-29 11:33:26 -07:00
Kimish Patel
2a08566b8f Simple caching allocator for CPU. (#42006)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42006

This PR introduces a simple CPU caching allocator. This is specifically
intended for mobile use cases and for inference. There is nothing
specific to the implementation that can prevent it from other use cases,
however its simplicity may not be suitable everywhere.
It simply tracks allocation by sizes and relies on deterministic
repeatable behavior where allocation of same sizes are made on every
inference.
Thus after the first allocation when the pointer is returned, instead of
returning it to system, allocator caches it for subsequent use.
Memory is freed automatically at the end of the process, or it can be
explicitly freed.
This is enabled at the moment in DefaultMobileCPUAllocator only.

Test Plan:
android test: cpu_caching_allocator_test

Imported from OSS

Reviewed By: dreiss

Differential Revision: D22726976

fbshipit-source-id: 9a38b1ce34059d5653040a1c3d035bfc97609e6c
2020-08-21 19:09:22 -07:00
Wanchao Liang
4b028a8e07 [jit] support pad_sequence/pack_sequence (#39844)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/39844

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D22026720

Pulled By: wanchaol

fbshipit-source-id: cc51ea77eff3689e319ec7e89a54c788646b5940
2020-06-19 19:03:14 -07:00
Ivan Kobzarev
e399e470b6 [vulkan] speed_becnhmark_torch add vulkan arg to use Vulkan backend (#39076)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39076

`--vulkan` argument to use torch benchmark on Vulkan Backend
if it is True - inputs will be converted to Vulkan backend before module.forward

Usage for mobilenetv2 fp32:
```
/build/bin/speed_benchmark_torch --model=mn-fp32.pt --input_type=float --input_dims=1,3,224,224 --warmup=1 --iter=5 --vulkan=true
```

Test Plan: Imported from OSS

Differential Revision: D21962428

Pulled By: IvanKobzarev

fbshipit-source-id: 3136af5386b6bce9ea53ba4a9019af2d312544b3
2020-06-10 22:19:22 -07:00
Kimish Patel
dd64d26d74 Make speed_benchmark_torch report latency in us (#37953)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37953

Earlier it said us but reported ms.

Test Plan: buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/fbnet/fbnet_mobile_inference.json --devices s9u --remote --framework pytorch --logger_level info --job_queue aibench_interactive --platform android/full_jit

Reviewed By: xcheng16

Differential Revision: D21349612

fbshipit-source-id: b97b6216eb0264123ff2c7852a0678b2008b0bf1
2020-05-07 11:08:14 -07:00
Ashkan Aliabadi
c4b9f3bf55 Enable torch_speed_benchmark to accept different memory formats. (#36202)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/36202

Test Plan: Imported from OSS

Differential Revision: D20970216

Pulled By: AshkanAliabadi

fbshipit-source-id: bb5a260e5677716356eec6ad4daa1f3c65420bbd
2020-04-23 13:18:43 -07:00
David Reiss
1c15cb4773 Add bundled input support to speed_benchmark_torch (#36765)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36765

We recently added support for bundling inputs with models.  Now add
support to the benchmarker to use those inputs.  This frees users from
having to look up the proper input format for each model.

Test Plan:
- Ran on a model without bundled inputs.  Saw a clear error.
- Ran on a model with too few bundled inputs.  Saw a clear error.
- Ran on a proper bundled input.  Model executed.

Differential Revision: D21142659

Pulled By: dreiss

fbshipit-source-id: d23c1eb9d1de882345b007bf2bfbbbd6f964f6fe
2020-04-20 15:32:57 -07:00
Peizhao Zhang
7374a00bef [pt]Supported benchmarking pytorch jit self-contained models. (#35279)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35279

Supported benchmarking pytorch jit self-contained models.
* By specifying flag `--no_inputs=True`, the binary supports benchmarking self-contained torchscript model (model runs without inputs, `model.forward()`)
* This allows moving data preparation part outside of this binary.

Reviewed By: kimishpatel

Differential Revision: D20585639

fbshipit-source-id: c28e50503534c90023c1430479d26f1c1ce740b1
2020-04-09 17:02:17 -07:00
Peng Xia
c3abcf83aa [AI Bench] Resumme speed_benchmark_torch.cc to origin
Summary: we removed all assistant specific code

Test Plan:
```
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
```

https://our.intern.facebook.com/intern/aibench/details/940147322057842

Reviewed By: kimishpatel

Differential Revision: D20686220

fbshipit-source-id: b7336d5ea15fa11be01abf4ad12747feaaf22ea8
2020-04-02 08:35:46 -07:00
Peng Xia
25e4e9eb86 [On-device Benchmark] speed_benchmark_torch switch to log latency from dataset level to row level (#34598)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34598

as above

Test Plan:
test.txt
```
what time is it now
could you set a reminder at 7 am
waht is the weather today
```
example json
```
{
    "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 5 --input_file {files.data} --report_pep true",
        "identifier": "{ID}",
        "metric": "delay",
        "iter": 15,
        "warmup": 2,
        "log_output": true
      }
    ]
  }

```

iter = 5 (--iter 5 ) *3(3 lintes in the test.txt)  = 15

arbabu123 I will provide a wrapper to compute the iter in future.

run following command
```
buck run aibench:run_bench -- -b aibench/specifications/models/pytorch/fbnet/assistant_mobile_inference.json --platform android/full_jit --framework pytorch --remote --devices  SM-G960U-8.0.0-26
```

results
https://our.intern.facebook.com/intern/aibench/details/275259559594003

**Note: this is compatible with the existing examples.**

Reviewed By: kimishpatel, ljk53

Differential Revision: D20389285

fbshipit-source-id: 80165ef394439a307ac7986cf540a80fdf3d85d6
2020-03-11 13:51:42 -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
Peng Xia
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
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
Jiakai Liu
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
Supriya Rao
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
Supriya Rao
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
Jiakai Liu
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
Supriya Rao
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
Jiakai Liu
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
Jiakai Liu
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
Edward Yang
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
Jiakai Liu
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