Commit Graph

70 Commits

Author SHA1 Message Date
473e78c0fa Remove redundant code for unsupported Python versions (#49486)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49486

Remove code for Python 3.5 and lower.

There's more that can be removed/modernised, but sticking mainly to redundant version checks here, to keep the diff/PR smaller.

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

Reviewed By: zou3519

Differential Revision: D24453571

Pulled By: ezyang

fbshipit-source-id: c2cfcf05d6c5f65df64d89c331692c9aec09248e
2021-01-06 12:45:46 -08:00
9945fd7253 Drop unused imports from caffe2/python (#49980)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49980

From
```
./python/libcst/libcst codemod remove_unused_imports.RemoveUnusedImportsWithGlean --no-format caffe2/
```

Test Plan: Standard sandcastle tests

Reviewed By: xush6528

Differential Revision: D25727359

fbshipit-source-id: c4f60005b10546423dc093d31d46deb418352286
2021-01-05 13:17:46 -08:00
bdf360f9f2 [ONNX] Update onnx submodule (#47366)
Summary:
Update onnx submodule to 1.8 release

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

Reviewed By: hl475

Differential Revision: D24968733

Pulled By: houseroad

fbshipit-source-id: 2f0a3436ab3c9380ed8ff0887a483743c1209721
2020-11-30 00:05:46 -08:00
27c7158166 Remove __future__ imports for legacy Python2 supports (#45033)
Summary:
There is a module called `2to3` which you can target for future specifically to remove these, the directory of `caffe2` has the most redundant imports:

```2to3 -f future -w caffe2```

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

Reviewed By: seemethere

Differential Revision: D23808648

Pulled By: bugra

fbshipit-source-id: 38971900f0fe43ab44a9168e57f2307580d36a38
2020-09-23 17:57:02 -07: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
a6a7f35481 Better error messages in C2 ONNX backend (#25809)
Summary:
Just a tiny fix to make debugging easier (output errors to stderr and include in the exception message)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25809

Reviewed By: zrphercule

Differential Revision: D17329957

Pulled By: houseroad

fbshipit-source-id: 0d73dd9f62c735fbc5096e6a7c0e5f58e4cd90ae
2019-09-11 17:00:42 -07:00
22865d4ce1 Add ONNX export support for torch.rand. (#20559)
Summary:
This PR adds support for torch.rand export in the PyTorch ONNX exporter. There are other generator ops that need to be supported for export and they will added in subsequent PRs. This op is needed with priority for a model on our end.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20559

Differential Revision: D15379653

Pulled By: houseroad

fbshipit-source-id: d590db04a4cbb256c966f4010a9361ab8eb3ade3
2019-06-03 16:09:01 -07:00
9ef8eb4cbc Fix case for activations attribute in nn.RNN ONNX export. (#19368)
Summary:
This PR addresses the https://github.com/pytorch/pytorch/issues/19366 issue.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19368

Reviewed By: zrphercule

Differential Revision: D15043949

Pulled By: houseroad

fbshipit-source-id: 9b90410307d31bc5f2fd14aa0cdd33b22572ed7c
2019-04-25 16:31:25 -07:00
aa88c2c0b6 Unify gpu_support variable in python tests (#16748)
Summary:
Assign `has_gpu_support = has_cuda_support or has_hip_support` and make according changes in python tests.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16748

Differential Revision: D13983132

Pulled By: bddppq

fbshipit-source-id: ca496fd8c6ae3549b736bebd3ace7fa20a6dad7f
2019-02-07 00:29:51 -08:00
5fe2697655 Initialize tensor with fp32 in Caffe2Backend.prepare() (#15832)
Summary:
Fix https://github.com/pytorch/pytorch/issues/14104
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15832

Reviewed By: bddppq

Differential Revision: D13598332

Pulled By: yinghai

fbshipit-source-id: 3302ac47928974f49353c5da8af440e5c1716c22
2019-01-08 22:33:52 -08:00
855d9e1f19 Run ONNX cuda backend test cases via ROCm
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15069

Differential Revision: D13427757

Pulled By: bddppq

fbshipit-source-id: ba0273d75986cd5b146f7041a83c63ddf9c6c0cf
2018-12-13 15:10:00 -08:00
02d3787a19 Support new upsample in symbolic, caffe2 backend & caffe2 frontend (#13272)
Summary:
We updated the description of upsample_op in onnx: https://github.com/onnx/onnx/pull/1467
Therefore, we need to support the new upsample_op in caffe2-onnx backend as well.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13272

Reviewed By: houseroad

Differential Revision: D12833656

Pulled By: zrphercule

fbshipit-source-id: 21af5282abaae12d2d044e4018a2b152aff79917
2018-11-05 19:13:57 -08:00
c6defa0847 Add randn in onnx symbolic (#12880)
Summary:
In this pr we added operator randn in onnx symbolic. Also, related tests are added.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12880

Reviewed By: houseroad

Differential Revision: D10501788

Pulled By: zrphercule

fbshipit-source-id: ba8bb00ca848c4b95decabf638a1bc13fe11d03e
2018-10-25 14:11:23 -07:00
8aa23907e8 Make if block also take control_inputs, preserve SSA (#12224)
Summary:
If block is missing control inputs when do caffe2 net execution, this PR add them back and remove the un-SSA semantics

jamesr66a
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12224

Differential Revision: D10135408

Pulled By: wanchaol

fbshipit-source-id: 746c870bde54ed4ca627167361db1b3f36cd235c
2018-10-03 14:29:01 -07:00
05e06f7de2 migrating deprecated calls without abc module for containers (#11515)
Summary:
Implementing #10540.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11515

Reviewed By: apaszke

Differential Revision: D9771045

Pulled By: jeffreyksmithjr

fbshipit-source-id: 85ea39abaa9b465805a969f122b626b11fc85ef6
2018-09-13 15:09:22 -07:00
0f1ca569ce End-to-end dynamic slicing with ONNX DynamicSlice experimental operator (#11255)
Summary:
Requires https://github.com/onnx/onnx/pull/1377

This PR makes it so that slices with dynamic boundary values can be exported from pytorch and run in caffe2 via ONNX.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11255

Differential Revision: D9790216

Pulled By: jamesr66a

fbshipit-source-id: 6adfcddc5788df4d34d7ca98341077140402a3e2
2018-09-13 12:39:52 -07:00
02114e877f fix #10838 incorrect bidirectional output format (#11368)
Summary:
Fixes the issue discussed in #10838. `hidden_size` should be the last dimension regardless if we're in ONNX or PyTorch.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11368

Differential Revision: D9734814

Pulled By: soumith

fbshipit-source-id: 7f69947a029964e092c7b88d1d79b188a417bf5f
2018-09-08 17:09:57 -07:00
342517e6e7 Back out "Add aten_op to caffe2 onnx (python) backend" (#10589)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10589

Original commit changeset: 2cc6fedbaf08

Reviewed By: houseroad

Differential Revision: D9365208

fbshipit-source-id: 3871d8e70f0d8e48c8af9593c78587d16c45afc2
2018-08-16 15:15:27 -07:00
84427d26db Add aten_op to caffe2 onnx (python) backend
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/10579

Reviewed By: houseroad

Differential Revision: D9357837

fbshipit-source-id: 2cc6fedbaf088df7e11b52a91dfe3b8f0d7fd599
2018-08-16 00:39:30 -07:00
76da0b34c2 Remove an unused variable found by linter
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/10578

Differential Revision: D9357880

Pulled By: bddppq

fbshipit-source-id: 6b56c2dbd02258124b5a4656cdf44d14a59e1b71
2018-08-16 00:25:44 -07:00
ee17ed672b Add missing dependencies (#10086)
Summary:
Fix the master
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10086

Differential Revision: D9093741

Pulled By: houseroad

fbshipit-source-id: 65e42994ae7d8e0b449d10a8116a7609434aad04
2018-07-31 13:54:38 -07:00
56d1a82b31 Add shape inference when converting from onnx to caffe2 (#10037)
Summary:
Otherwise, some RNN case conversion may fail.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10037

Reviewed By: orionr

Differential Revision: D9072298

Pulled By: houseroad

fbshipit-source-id: 080f589eba8618719453feb15a7a494fe5380dd0
2018-07-31 12:42:02 -07:00
0c84a5c27e Pass shape infos to ONNX -> Caffe2 C++ conversion backend (#9870)
Summary:
And let Gemm conversion to inspect the input `C` to try converting to FC.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9870

Reviewed By: houseroad

Differential Revision: D9013198

Pulled By: bddppq

fbshipit-source-id: b4c509cfccca238262e1c406b004e66cef256321
2018-07-26 12:00:32 -07:00
a7afba7308 Remove duplicated functions (#9601)
Summary:
found by linter, duplication was likely introduced in previous code sync
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9601

Differential Revision: D8922379

Pulled By: bddppq

fbshipit-source-id: 1f61bd7f539d823e62920615674a532ec0149623
2018-07-24 10:23:46 -07:00
f521823b7b Do not always set broadcast argument when exporting new onnx add and sub to caffe2
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/9597

Reviewed By: colesbury

Differential Revision: D8920575

Pulled By: bddppq

fbshipit-source-id: 97423e1bf6a20559d466d2ac56c9e74e10bfc129
2018-07-19 14:10:05 -07:00
04a7fc1dc4 Add Upsample support in C2 onnx backend for opset 1
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/9327

Reviewed By: ailzhang

Differential Revision: D8798462

Pulled By: houseroad

fbshipit-source-id: d7d1127a853de6a7bb8fdef146f283487e1e5569
2018-07-10 22:43:25 -07:00
e06abab264 Fix Upsample ONNX Symbolic (#9288)
Summary:
Adjust the change to changes in ATen
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9288

Reviewed By: ailzhang

Differential Revision: D8779078

Pulled By: houseroad

fbshipit-source-id: 7f387eeb35ae1f5a1494afc6287853a87a6173b4
2018-07-09 23:25:26 -07:00
181d2a5e60 Add support of is_compatible for old version of onnx (#9284)
Summary:
Fix the problem if caffe2 works with old version of onnx
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9284

Reviewed By: yinghai

Differential Revision: D8773894

Pulled By: houseroad

fbshipit-source-id: 99b5a962099f854edc85a2ea815cb88c82a6e175
2018-07-09 21:09:14 -07:00
b75490414c Bump up the C2 onnx frontend opset to 8 (#9006)
Summary:
Now ONNX master has bump up to opset 8.
Closes https://github.com/pytorch/pytorch/pull/9006

Reviewed By: yinghai

Differential Revision: D8685417

Pulled By: houseroad

fbshipit-source-id: f0c0a3682417b8803a856e232c2740cf3e68e554
2018-06-29 11:56:11 -07:00
9c426797a8 Expose is_compatible function (#8783) 2018-06-21 23:37:54 -07:00
68948306bc Support to run ONNX Upsample operator (mode=nearest) in Caffe2 (#8037)
* Added support to run ONNX Upsample operator (mode=nearest) in Caffe2

* adding error checks to upsample

* adding error checks to upsample

* adding error checks to upsample

* changing to np.isclose

* Revert onnx submodule update

* still fixing
2018-06-02 08:45:44 -07:00
5419c6ecb7 Add unsafe flag to skip checking in prepare (#7832)
* Add unsafe flag to skip checking in prepare

* pop
2018-05-30 11:48:01 -07:00
d5c466e5ce RNN export: add transpose to match onnx spec (#7825)
Didn't quite get it right the first time.

fixes https://github.com/pytorch/pytorch/issues/7817
2018-05-25 12:56:57 -07:00
2271e7d7ab onnx->caffe2 output: better handling of init/pred splitting (#7820) 2018-05-24 14:49:14 -07:00
f9633b9542 [Caffe2] Skip some tests to unbreak CI (#7804)
* Skip some tests to unbreak CI

* Pass the opset_version to run_node

* Remove the stale check_graph call, caffe2_net_to_onnx_model will invoke check_model
2018-05-24 00:12:00 -07:00
5316cad5c2 [Easy] Remove unused code (#7782) 2018-05-22 22:32:47 -07:00
284f13b814 make sure that pytorch and caffe2 usage lines up with onnx rnn spec (#7511) 2018-05-14 15:42:56 -07:00
43264c3c30 add cast to ensure correct type for sequence lens argument (#7483) 2018-05-10 14:58:00 -07:00
ab5c391100 onnx rnn export: use spec-respecting dimensions (#7394)
fixes https://github.com/pytorch/pytorch/issues/6879
2018-05-10 08:19:17 -07:00
67a9948d87 Refactor rnn export (#7263)
* rnn refactor: extract rnn weights and biases

* rnn refactor: make rnn with converted outputs

* rnn refactor: finish it off
2018-05-04 14:00:09 -07:00
9e3f5bb5fd enable onnx shape inference when converting onnx -> caffe2 (#7260) 2018-05-04 10:27:30 -07:00
892bef9aa3 [ONNX] Delay external value resolution as long as possible in ONNX backend (#7111) 2018-04-30 21:30:31 -07:00
20cd27da42 [caffe2][ONNX] Implement CPU NumpyTileOp and corresponding ONNX backend (#7053)
* Implement CPU NumpyTileOp

* Address comments
2018-04-27 19:58:15 -07:00
7599d0c3fe [caffe2] ONNX backend support for control nodes (#6914) 2018-04-25 15:44:00 -07:00
750a323ca1 Work around protobuf issues by importing onnx first (#6833) 2018-04-23 15:44:04 -07:00
6223bfdb1d Update from Facebook (#6692)
* [GanH][Easy]: Add assertion to adaptive weighting layer

0 weight causes numeric instability and exploding ne

* [Easy] Add cast op before computing norm in diagnose options

As LpNorm only takes floats we add a manual casting here.

* Introduce a new caching device allocator

`cudaMalloc` and `cudaFree` calls are slow, and become slower the
more GPUs there are. Essentially, they grab a host-wide (not device-wide) lock
because GPU memory is transparently shared across all GPUs. Normally, this
isn't much of a concern since workloads allocate memory upfront, and reuse it
during later computation.

However, under some computation models (specifically, memory conserving
approaches like checkpoint-and-recompute, see
https://medium.com/@yaroslavvb/fitting-larger-networks-into-memory-583e3c758ff9)
this assumption is no longer true. In these situations, `cudaMalloc` and
`cudaFree` are common and frequent. Furthermore, in data parallel contexts,
these calls happen at nearly the same time from all GPUs worsening lock
contention.

A common solution to this problem is to add a custom allocator. In fact,
nVIDIA provides one out of the box: CUB, which Caffe2 already supports.
Unfortunately, the CUB allocator suffers from very high fragmentation. This is
primarily because it is a "buddy" allocator which neither splits nor merges
free cached blocks. Study
https://github.com/NVlabs/cub/blob/1.8.0/cub/util_allocator.cuh#L357 if you
want to convince yourself.

This diff adapts a caching allocator from the Torch codebase
https://github.com/torch/cutorch/blob/master/lib/THC/THCCachingAllocator.cpp
which does splitting and merging and ends up working really well, at least for
workloads like the checkpoint-and-recompute computation models noted above.

I simplified the implementation a little bit, made it a bit more C++-like. I
also removed a bunch of stream synchronization primitives for this diff. I
plan to add them back in subsequent diffs.

* Report reader progress in fblearner workflows

Integrate with fblearner progress reporting API and add support to report training progress from reader nodes.
If reader is constructed with batch limits, report based on finished batch vs total batch. The finished batch may be more than total batch because we evaludate if we should stop processing everytime we dequeue a split.
If no limit for the reader, report based on finished splits (Hive files) vs total splits. This is fairly accurate.

* [GanH][Diagnose]: fix plotting

1. ganh diagnose needs to set plot options
2. modifier's blob name is used for metric field can need to be fixed before
generating net

* Automatic update of fbcode/onnx to 985af3f5a0f7e7d29bc0ee6b13047e7ead9c90c8

* Make CompositeReader stops as soon as one reader finishes

Previously, CompositeReader calls all readers before stopping. It results in flaky test since the last batch may be read by different threads; resulting in dropped data.

* [dper] make sure loss is not nan

as desc.

* [rosetta2] [mobile-vision] Option to export NHWC order for RoIWarp/RoIAlign

Thanks for finding this @stzpz and @wangyanghan. Looks like NHWC is more
optimized. For OCR though it doesn't yet help since NHWC uses more mem b/w but
will soon become important.

* Intra-op parallel FC operator

Intra-op parallel FC operator

* [C2 Proto] extra info in device option

passing extra information in device option

design doc: https://fb.quip.com/yAiuAXkRXZGx

* Unregister MKL fallbacks for NCHW conversions

* Tracing for more executors

Modified Tracer to work with other executors and add more tracing

* Remove ShiftActivationDevices()

* Check for blob entry iff it is present

When processing the placeholders ops, ignore if the blob is not present in the blob_to_device.

* Internalize use of eigen tensor

Move use of eigen tensor out of the header file so we don't get template partial specialization errors when building other libraries.

* feature importance for transformed features.

* - Fix unused parameter warnings

The changes in this diff comments out unused parameters.
This will allow us to enable -Wunused-parameter as error.

#accept2ship

* add opencv dependencies to caffe2

The video input op requires additional opencv packages. This is to add them to
cmake so that it can build

* Add clip_by_value option in gradient clipping

Add clip_by_value option in gradient clipping

when the value is bigger than max or smaller than min, do the clip

* std::round compat
2018-04-17 23:36:40 -07:00
4dd29ac89f fix broken code from rebasing (#6681) 2018-04-17 15:44:56 -07:00
e51e792cef enable exporting bidirectional rnn with fixes seq len from onnx to caffe2 (#6566) 2018-04-17 12:27:16 -07:00
582d47e986 [Caffe2] Scoped dummy name generator (#6458)
* Scoped dummy name generator

* Fix

* Fix

* Use class variable

* Fix build

* comment
2018-04-16 11:58:02 -07:00
df2e1d2962 Disallow using the OOP api workspace as context managers (#6456) 2018-04-09 22:13:54 -07:00