Commit graph

1650 commits

Author SHA1 Message Date
Yan Shang
40683cdf42 Allow calculating average margin rank loss
Similar to LrLoss, we allow for average loss of margin rank loss.
2018-03-20 13:34:22 -07:00
Kittipat Virochsiri
72f2cd8bcc Making preproc_output_schema explicit
Make it easier to plug in intermediate steps between preprocessing & trainer by maintaining a stable schema.

I also fixed enqueue() so that we can pass in the same blob in multiple location without causing data corruption.
2018-03-20 13:34:22 -07:00
Zhanibek Datbayev
7aeda25cfb Add type / shape inference for IndexHash op
just as title says
2018-03-20 13:34:22 -07:00
Edoardo Conti
6af3429f4f Add 2D Row-wise Arg Max Operator
Add operator to return row-wise arg max of 2D matrix.
2018-03-20 13:34:22 -07:00
Kittipat Virochsiri
9be2de507b Cleaning up ReaderBuilder interface
The way `splits()` is currently used is so convoluted. It's impossible to compose ReaderBuilder. I'm working on a composite reader so this is a prerequisite for it.

The idea is that the ReaderBuilder should maintain the states it needs to create a reader. Any setup is done through the new `setup()` method. Currently, `setup()` should only be called once, but, if needed, it should be safe to call it multiple times.
2018-03-20 13:34:22 -07:00
Kittipat Virochsiri
a4d0ef2621 Fix stop blob of processing reader
See inline comment
2018-03-20 13:34:22 -07:00
Yinghai Lu
efe1c2bd13 hypen as a valid part of model names (#2312) 2018-03-20 08:52:54 -07:00
Lu Fang
cda2f02f89 Skip the test average pool same mode tests (#2324) 2018-03-20 00:13:31 -07:00
Yinghai Lu
b0fe67aca8 Expose more APIs for onnx cpp backend (#2317) 2018-03-19 22:46:26 -07:00
Bram Wasti
aa4af1a5f9 [tiny] make debug info optional, CAFFE2_DEBUG env variable driven 2018-03-19 16:58:04 -07:00
Qinqing Zheng
23631eee5a [C2] Fix the check of current scope in optimizer (#2316)
scope.CurrentDeviceScope() can return a None type, which was not considered.
2018-03-19 16:38:55 -07:00
Yan Zhu
fb77b423f4 refactor histogram as net modifier (#2314) 2018-03-19 16:04:58 -07:00
Orion Reblitz-Richardson
00603b5e0a Add CollectAndDistributeFpnRpnProposalsOp for FPN support (#2254)
* Add CollectAndDistributeFpnRpnProposalsOp for FPN support

* Adds a C++ operator equivalent to the Python op in Detectron
* Once some additional GenerateProposalsOp changes are made this will
 let us support Detectron FPN models with straight Caffe2 C++ ops
* RetinaNet and segmentation models require additional work

* Remove some uses of conservativeResize

* Add notes about training and inputs/outputs to operator documentation
2018-03-19 14:04:43 -07:00
Lu Fang
334fc98fb0 Handle the legacy padding in global pooling case (#2292) 2018-03-18 21:28:15 -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
Paul Jesse Hellemn
74f0b270ea Fixing conda (#2123)
* Fixing conda

* Adding hypothesis and onnx to conda builds

* Updates but still not working

* Adding required changes to conda_full

* Updates

* Moving to more general build_anaconda script

* Adding check for gcc version

* Adding general ways to add/remove packages from meta.yaml?

* Changes for specific packages to build on gcc 5.4

* Fix with glog spec

* Requiring >numpy 1.12 for python 3 to satisfy opencv dependency

* Adding pydot to required testing packages

* Adding script to read conda versions for gcc ABI

* Trying to fix segfault by installing in env instead

* conda activate -> source activate

* Trying adding back leveldb

* Setting locale for ONNX + conda-search changed its format

* read_conda_versions handles libprotobuf

* Conda script updates

* Adding a protobuf-working test

* Removing changes to proto defs b/c they will require internal changes in a separate diff
2018-03-14 12:24:37 -07:00
Lu Fang
8a9925f03f Fix useless opset_import in onnx (#2243)
* Fix useless opset_import in onnx

* Set the default ir version in make_model

* Use the target_opset_version in Caffe2Frontend

* remove make_model from helper in caffe2.python.onnx
2018-03-14 10:17:32 -07:00
Mohammad Hossain
28eda01809 Reduce Sum and Reduce Mean (#2189)
* Reduce Sum and Reduce Mean

* Handle reductions with empty 'axes'

* Merge codebase and simplify tesnor reduction logic

* Restructure code and add comments.

* Fix parameter to scale

* Fix parameter to scale
2018-03-13 19:13:47 -07:00
Qinqing Zheng
edd138ba00 [C2] Support optional lengths input to ReduceFront/Back operators (#2250) 2018-03-13 13:20:26 -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
jmp84
b465bb9a8e fix post eos penalty (#2235) 2018-03-12 12:42:22 -07:00
sf-wind
602a09dde7 Update caffe2 from facebook 4f527ef46abf (#2234)
* [GanH]: two_task_discriminator

as titled

and adding label smooth

* [Dper2] Simplified UI options needed for blob magnitude visualization

* [GanH]: fix tags

as titled

* Added type and shape inference for GatherRange operator

This helps with type / shape inference when using this operator in layers.
Also just a nice to have in general.

* Demonstrate Caffe2 exception handling with StoreHandlerTimeoutError in Python

We'd like to catch and recover from certain Caffe2 net exceptions. Use this diff to demonstrate a pattern of registering a pybind exception mapping and catching in Pythonusing caffe2::StoreHandlerTimeoutException.

* Bind Gloo IoException to IoError in Python

Allow peer failure handling and recovery using an exception based mechanism. This diff registers gloo::IoException with pybind.

* [GanH]: add label smoothing to softmax with loss

as titled

* [C2] Enable LARS in Adagrad and hook it to DPER

* [DPER] Don't pass LayerModelHelper in create_trainer_nodes

Since we're planning to get rid of it eventually and I want to get access to
NetDef only interface ASAP - I'm looking towards removing all references to
LMH, where we don't really need them.

* fix bugs in LambdaRankNdcgOp

the loss and gradient in LambdaRankNdcgOp are incorrect. The loss should be negative log of probs instead of log.

* Restrict thread pool on iOS to only big cores

Historically, iPhones exposed only one type of cores, and Caffe2 thread pool used all of them.
However, iPhone 8/iPhone X exposes 2 big + 4 LITTLE cores. As our thread pool doesn't support work stealing or other forms of load balancing, fast cores end up waiting for the slow ones, and it may be better to restrict execution to only 2 fast cores, like we do on Android.

* Remove SparseLength Sum/WeightedSum/Mean operators with fp16 engine

Remove SparseLength Sum/WeightedSum/Mean operators with fp16 engine

* make clang happy and get fewer warnings

make clang happy and get fewer warnings

* [Personalization] Support add_output_schema() in layer_model_helper

Problem:
Currently the output_schema of sparse_nn can only be set once. https://fburl.com/efth5zer.

Solution:
For flexibility, we want to add fields to output_schema incrementally.

Plan:
Wrap the change of `model._output_schema` into a new function `add_output_schema()` for adding additional output_schema.

Callsite:
The add_output_schema() should be called instead at https://fburl.com/efth5zer

Reference:
The newly added `add_output_schema()` will be similar to `add_loss()` in https://fburl.com/t2ii8njh
2018-03-12 12:22:59 -07:00
Kutta Srinivasan
0ee53bf7fe Fix one more naming issue in resnet50_trainer.py for PR 2205 2018-03-09 13:51:42 -08:00
Kutta Srinivasan
ed05ca9fec Clean up naming of FP16-related code, add comments 2018-03-09 13:51:42 -08: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
Jongsoo Park
64b33672af add GatherFused8BitRowwise operator (#2167)
* add GatherFused8BitRowwise operator

* Update gather_fused_8bit_rowwise_op.cc

* Update gather_fused_8bit_rowwise_op.cc
2018-03-09 07:42:17 -08:00
Qinqing Zheng
9acac2a513 Pass in task groups to PipedReaderBuilder (#2182) 2018-03-08 16:16:57 -08:00
Jiyan Yang
f4b1e8b334 [Dper2] Add NetModifier abstraction and support for plotting the norm of blobs (#2201) 2018-03-08 13:41:32 -08:00
Joseph Spisak
cebf44e960 Element-wise tests now use or seeded with hypothesis (#2181)
* Updated all element-wise tests to use hypothesis testing or at least use hypothesis seeds

* Updated tests to add seed to sqr function
2018-03-08 07:51:45 -08:00
Alexander Sidorov
60aa8c793d Update caffe2 from facebook (#2178)
* [C2] Don't crash kernel in case of invalid shapes for ConcatOp

Enforce correctness of the shapes for input tensors so we won't access invalid index.

* [Caffe2] Add analytical performance counters to Dynolog

Initial diff for counting analytical flops and memory writes for C2 operators.

* BBoxTransform op: Handle RoIs from multiple images per batch

BBoxTransform op used during typical Faster-RCNN inference operates only on
RoIs from a single image (no batching). Adding support to handle that with an
optional output blob containing the batch splits (i.e., the number of RoIs
belonging to each item in the batch). The code is perfectly backward compatible
and shouldn't break any existing models..

* [mkl] Make MKL-DNN cooperate with memongered nets

C2's MKL-DNN implementation caches input dims and reuses intermediate and
output buffers across net runs, which prevents memonger from being used. This
may not always be useful since input dims may vary widely in many cases and
we'll end up reallocating anyway. Added an option to force reallocation when
memonger is used.

* [oncall] fix batch gather ops for empty input

still need to bisect for the breaking change, but this shall fix the case for empty input.

the error logging is like: https://interncache-ftw.fbcdn.net/t49.3276-7/23938497_293562711176943_6500112636590424064_n.txt?_nc_log=1

@[557759185:raychen] can you help to subscribe oncall from ads side. this may affect the Sigrid online trainer.

* optimize BatchOneHotOp

We want to iterate in row-major as opposed to column-major for better
locality.

* Supported exporting model with int blobs.

Supported exporting model with int blobs. Needed by condensenet.

* BoxWithNMSLimit op: Handle boxes from mutiple images per batch

Similar to D7135360. Added support for multiple images per batch in the op.
Takes an optional additional input "batch_splits" as output by BBoxTransform
op, and returns new batch_splits after applying NMS and filtering. Otherwise,
backward compatibility is maintained.
2018-03-07 16:41:22 -08:00
Kutta Srinivasan
0a18608b43 hacks to test exception handling and python operator backtraces
Add exception handling & re-throwing to worker threads of DAGNetBase
2018-03-07 15:09:17 -08:00
ilia-cher
0c6e843028 [caffe2] Add scopes into ONNX While op (#2149)
Summary:
Executing loop's body in a separate workspace, using WorkspaceStack to
support saving and reusing of workspaces

Test Plan:
python caffe2/python/operator_test/onnx_while_test.py

Reviewers: caffe2-review, jamesreed

Subscribers:

Tasks:

Tags:
2018-03-07 12:34:11 -08:00
Dmytro Dzhulgakov
7d141d4243 Changes done internally at Facebook (#2154)
f679c644e332 dzhulgakov [caffe2] Sync script - add ability to handle rebase conflicts
51729b061a15 dzhulgakov [caffe2] Changes done on GitHub
2018-03-06 01:23:54 -08:00
Dmytro Dzhulgakov
bec8923e02 [C2] Adding Clip Tensor by Scaling op
This op is used for gradient clipping to take care of exploding / vanishing gradients.

If original_norm is larger than the threshold,
then each element of the tensor is scaled by threshold / original_norm.
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
6b98315a28 [GanH] Model Test
as titled
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
16ba087b64 [oncall]fix unittest dper/layer_models/tests:utils_test
as titled -- fix offending diff D7091725 due to added debug_info in operator
proto
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
496c999f7d [core] NUMA-aware pinned allocator
Using cudaHostRegister/Unregister instead of cudaMallocHost to move memory to a
specific NUMA node
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
9e71de398b [core] Graph-level NUMA awareness in Caffe2
Adding NUMA awareness through numa_node_id in DeviceOption. Blobs of operators
with numa_node_id are allocated on corr. memory banks, using CPU pools with
NUMA affinity set to run operators.
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
8b0b090ff1 fix Caffe2TensorToNumpyArray for py3
with python3 np.int defaults to int64.  This diff should fix it. I don't know if test exist for this function already, however following ASR test was breaking when i switch to py3

```
buck test caffe2/caffe2/fb/speech/asr_training/:tensor_parser_test
```
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
968ebb3b82 [GanH]fuse jsd with lr loss/xent
as titled
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
08dbd96642 Add TensorInferenceFunction for PowOp
Add TensorInferenceFunction for PowOp so that we can infer the shape and datatype of Pow output.
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
f2ec5b7b0e [DPER] Fix bug in uint8 quantization shortcut.
After D6953547 some of the blobs were no longer impacted by uint8 quanitzation,
but they would still generate operators expecting uint8 inputs and thus fail.

This diff is adding a temporal hack to avoid doing this quantization when layer
is not quantized.

Will fix it with switching to Net rewriting instead.
2018-03-06 00:33:11 -08:00
Dmytro Dzhulgakov
1f0a833d8e JSD fwd/bwd op
as titled
2018-03-06 00:33:11 -08:00
Kutta Srinivasan
b4b2f0d2cc Work on fp16 conv op 2018-03-05 21:13:03 -08:00
Pooya Davoodi
37dec493a5 Scope MultiRNN blobs with name as well as layers (#2025)
* Scope MultiRNN blobs with name as well as layers

Also don't double scope MultiRNN in case of multiple layers.

* Scope input projection of first layer with name

We don't scope it with layers because the projection is done
outside of the layer.

* Avoid scoping input blob in MemongerTest.test_rnn

* Rectify input_blob in prepare_input

Revert change in memonger_test because rectifying input will solve the problem.
2018-03-02 22:21:07 -08:00
Qinqing Zheng
d013e16cf4 [C2] Enable LARS on GPU (#2115) 2018-03-02 18:06:19 -08:00
Joseph Spisak
11a736b682 Sqrt op (#2101)
* First attempt on sqrt op

* Adding the Sqrt op along with the test cases

* Made changes per @Yangqing's questions re: tensor format and used hypothesis to generate input tensor
2018-03-02 16:19:45 -08:00
Mohammad Hossain
349238f5bf Mean Op (#2072)
* Mean Op

* Mean Op

* Mean Op

* Fix gradients and include seed for randomized input generation

* Update test strategies parameters
2018-03-02 16:18:17 -08:00