Commit Graph

48 Commits

Author SHA1 Message Date
Junjie Bai
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
Junjie Bai
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
Junjie Bai
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
Lu Fang
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
Lu Fang
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
Lu Fang
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
Lu Fang
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
Lu Fang
9c426797a8 Expose is_compatible function (#8783) 2018-06-21 23:37:54 -07:00
Varun Jain
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
James Reed
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
anderspapitto
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
anderspapitto
2271e7d7ab
onnx->caffe2 output: better handling of init/pred splitting (#7820) 2018-05-24 14:49:14 -07:00
Lu Fang
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
bddppq
5316cad5c2
[Easy] Remove unused code (#7782) 2018-05-22 22:32:47 -07:00
anderspapitto
284f13b814
make sure that pytorch and caffe2 usage lines up with onnx rnn spec (#7511) 2018-05-14 15:42:56 -07:00
anderspapitto
43264c3c30
add cast to ensure correct type for sequence lens argument (#7483) 2018-05-10 14:58:00 -07:00
anderspapitto
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
anderspapitto
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
anderspapitto
9e3f5bb5fd
enable onnx shape inference when converting onnx -> caffe2 (#7260) 2018-05-04 10:27:30 -07:00
James Reed
892bef9aa3
[ONNX] Delay external value resolution as long as possible in ONNX backend (#7111) 2018-04-30 21:30:31 -07:00
James Reed
20cd27da42
[caffe2][ONNX] Implement CPU NumpyTileOp and corresponding ONNX backend (#7053)
* Implement CPU NumpyTileOp

* Address comments
2018-04-27 19:58:15 -07:00
James Reed
7599d0c3fe
[caffe2] ONNX backend support for control nodes (#6914) 2018-04-25 15:44:00 -07:00
anderspapitto
750a323ca1
Work around protobuf issues by importing onnx first (#6833) 2018-04-23 15:44:04 -07:00
Orion Reblitz-Richardson
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
anderspapitto
4dd29ac89f fix broken code from rebasing (#6681) 2018-04-17 15:44:56 -07:00
anderspapitto
e51e792cef
enable exporting bidirectional rnn with fixes seq len from onnx to caffe2 (#6566) 2018-04-17 12:27:16 -07:00
Yinghai Lu
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
bddppq
df2e1d2962
Disallow using the OOP api workspace as context managers (#6456) 2018-04-09 22:13:54 -07:00
Lu Fang
aab0bd3c13
Change onnx_optimizer API (#6290) 2018-04-06 13:46:53 -07:00
Andrew Tulloch
0df662c67f [Caffe2] [Int8] More exhaustive unit tests for int8 ops (+ bug fix in Int8Add in-place case)
As title. This catches one bug in the Int8Add in-place case,
which wasn't tested in int8_test.cc
2018-03-30 21:00:44 -07:00
James Reed
47a1fd208f Quick and dirty raw value substitution from zip file (#2454) 2018-03-29 19:18:58 -07:00
James Cross
16312e8123 [fbtranslate/onnx] decoder step (pytorch -> caffe2) exporter for fbtranlsate
This code introduces a new class for exporting decoder step (ensemble) models trained with fbtranslate pytorch to Caffe2 models via ONNX, for the purpose of use in "component beam search" being developed concurrently in C++ by @juancarabina.
2018-03-27 18:10:39 -07:00
Orion Reblitz-Richardson
1d5780d42c Remove Apache headers from source.
* LICENSE file contains details, so removing from individual source files.
2018-03-27 13:10:18 -07:00
bddppq
425361af6a Bump onnx opset version (#2402) 2018-03-23 10:48:12 -07:00
bddppq
f3b7b2f293 Remove ONNX consumed_inputs (#2278)
* Remove ONNX consumed_inputs

* Bump up opset version to 6 issued by onnx caffe2 frontend
2018-03-22 20:24:35 -07:00
Yinghai Lu
45da53f478 Remove Python onnx-caffe2 conversion code (#2362)
* WIP

* Remove Python onnx-caffe2 onversion code

* Fix build

* Comments

* Add comments

* Fix typo in comments
2018-03-22 11:59:03 -07:00
Joseph Spisak
b2c56eb219 Removed special handling for onnx sqrt (#2353) 2018-03-21 21:05:25 -07:00
bddppq
c155842cc1 Update onnx frontend to emit new onnx Reshape (with shape as input) (#2287)
* Update onnx frontend to emit new onnx Reshape (with shape as input)

* Address comments and revert submodule change
2018-03-16 16:32:35 -07:00
James Reed
e8f14f5d37 Fix ONNX backend for MatMul (#2273)
* Fix ONNX backend for MatMul

* Update Python implementation

* Address comments
2018-03-15 14:43:52 -07:00
Yinghai Lu
7e6693991d Onnx caffe2 backend (#2039)
* C++ version of ONNX->Caffe2 backend

* use namespace ONNX_NAMESPACE

* Fix Build

* Comments

* Change namespace from onnx_caffe2 to caffe2::onnx
2018-03-12 15:18:05 -07:00
James Reed
60299e03cf Report all errors during ONNX backend translation rather than failing fast (#2210) 2018-03-09 10:58:22 -08:00
Lu Fang
52460a0b30 Add outputs_info as parameter in run_node (#2161) 2018-03-09 10:44:51 -08:00
anderspapitto
c0304c83b1 Copy some outputs in order to decouple storage (#2105)
so that mutating one of them does not mutate the others
2018-03-01 13:25:31 -08:00
anderspapitto
749a17661c Introduce padding op to mimic pytorch semantics in ONNX export (#2069)
In pytorch, after pad_packed_sequence, the "extra" elements (after the
ends of the sequences) are reset. In the equivalent Caffe2 graph
exported via ONNX, they contained some leftover values, which caused
tests to fail. Probably no one depends on these values, but just in
case, set them to zero to mimic pytorch semantics.
2018-02-28 15:44:54 -08:00
anderspapitto
76304300a8 Transpose shape inference (#2057)
* fix variable name

* enhance shape inference to handle transpose

in the case arising from pack_padded(..., batch_first=True)
2018-02-27 11:51:10 -08:00
anderspapitto
ec547ce640 RNN ONNX export: concat hidden/cell states on the right axis (#2055)
Test Plan: existing tests in onnx-fb-universe catch this, modulo a bug
in the tests which I am fixing in a separate diff
2018-02-26 11:04:04 -08:00
anderspapitto
38f18c1daa add third output in onnx -> caffe2 lstm conversion (#2011) 2018-02-22 17:43:33 -08:00
Yinghai Lu
cc7e61c88d Move onnx-caffe2 inside caffe2 (#1921)
* Move onnx-caffe2 inside caffe2

* Update to the lastest onnx-caffe2 and update jenkins env

* Rename onnx_caffe2 to onnx

* Add __init__.py to caffe2/python/onnx

* Change CI check variable to JENKINS_URL

* Cherrypick recent onnx-caffe2 update
2018-02-20 13:56:52 -08:00