Commit graph

476 commits

Author SHA1 Message Date
Di Yu
cd3e90c16f Fix failed test due to D6665466
Summary: Test in Jenkins fail becasue test_global_pooling_3d filtered too many tests.  We made use of infered value of global_pooling (pad and stride will be constant) to reduce the test samples generated.

Reviewed By: pietern

Differential Revision: D6686840

fbshipit-source-id: d316c0e9f9070b12770170ab9f36e33de68a9ab9
2018-01-09 16:40:35 -08:00
Di Yu
82198831e7 Fix pool op custom path issue 2, wrongful routing to global pooling
Summary:
In D5681122 - when routing to global maxpool and average pool, the condition is not correct.
see T24876217 for discussion

Reviewed By: Yangqing

Differential Revision: D6665466

fbshipit-source-id: dcb5b4686249e6ee8e1e976ab66b003ef09b32fd
2018-01-09 00:54:45 -08:00
Anders Papitto
12309f4aa6 GRU cell: add linear_before_reset boolean parameter
Summary:
This matches the semantics of cudnn (and others, like pytorch)
Closes https://github.com/caffe2/caffe2/pull/1695

Reviewed By: dzhulgakov

Differential Revision: D6658208

Pulled By: anderspapitto

fbshipit-source-id: 00e1716fba47b0ac296d1e9e0131165f4997ac7d
2018-01-08 13:22:56 -08:00
Manoj Krishnan
6d32e36682 Caffe2 Operator: GPU implementation of Swish Activation
Summary: GPU (CUDA) implementation of the Swish activation function in Caffe2.

Reviewed By: Yangqing, xianjiec

Differential Revision: D6656907

fbshipit-source-id: f5f2c667055abf679728d2b5d43998895ddec708
2018-01-05 12:04:25 -08:00
Yangqing Jia
3725d8ea97 Disable the python op test numba import in asan
Summary:
Some installations of numba seems to be not compatible with asan, so we
will disable its import.

Reviewed By: dzhulgakov

Differential Revision: D6664055

fbshipit-source-id: 311774667e54bdbf328ef280ab2a52ecba1361f2
2018-01-04 17:49:21 -08:00
Alexander Sidorov
64b0039ef9 rnn_cell_test: make it determinitistic and speed up
Summary:
In this PR I do the following:

1. split lstm_test_main into several tests for LSTM, MiLSTM and various Norm based versions
2. instead of looping over various gradient / optimization parameters now they are random inputs through hypothesis.
3.  These change make the test faster and we can avoid limiting number of examples
4. Fix a minor bug with gradient checker in RNN unroll test running twice
5. Generate seed for numpy in hypothesis. This make hypothesis avoid having fluky tests

Also note that Norm tests sometimes fail. I haven't looked into it much, it could be just precision issues. New test split should help identify these issues.
Closes https://github.com/caffe2/caffe2/pull/1678

Reviewed By: pietern

Differential Revision: D6657076

Pulled By: salexspb

fbshipit-source-id: 9f59c71ccd2c818156e9d2424c3423d450b8c8e2
2018-01-04 15:00:42 -08:00
Lei Tian
3329f36f1a Move load_save_test.py from caffe2/python/ to caffe2/python/operator_test/
Summary: Move load_save_test.py from caffe2/python to caffe2/python/operator_test/

Reviewed By: boryiingsu

Differential Revision: D6657724

fbshipit-source-id: 030942316444ec93c3bc2970902d7b3980e60cfc
2018-01-03 17:42:55 -08:00
Pieter Noordhuis
9835ca9bac Ensure indices list in sparse optimizer tests is unique
Summary:
There were no dimensionality constraints to the generated indices
array, causing many examples being generated and filtered out. Instead,
we should ensure the probability of unique indices is high.

There is a better fix for this by using the `unique` keyword argument
to `hypothesis.extra.numpy.arrays`, but this is available only in
hypothesis version 3.28.0 and later.

This is related to #1536 and #1599.

Once this change has proven to be OK, we can modify the other tests
that now have health check suppression enabled as well.
Closes https://github.com/caffe2/caffe2/pull/1686

Reviewed By: Yangqing

Differential Revision: D6651789

Pulled By: pietern

fbshipit-source-id: d80886c9ccf0a7a842a7580a279f33a2d6cca97c
2018-01-03 12:19:14 -08:00
Yangqing Jia
77484ecc45 Manually applying cudnn5 pull request.
Summary: TSIA. Closes #1631

Reviewed By: pietern, Maratyszcza

Differential Revision: D6626887

fbshipit-source-id: 1a2dc7c47bc6ce794fdf598fbd547c04029edce4
2018-01-02 15:31:33 -08:00
Lu Fang
fab5885df6 Add Min and MinGradient Op in Caffe2
Summary: Add Min and MinGradient Op

Reviewed By: jamesr66a

Differential Revision: D6608668

fbshipit-source-id: 7e1f8fa7a42a94f26152da0109d597e5deeb21c0
2017-12-20 14:49:55 -08:00
Xiaolong Wang
257a9e5279 add hill learning rate scheduling
Summary:
hill: the learning rate changes according to following 3 stages
1) linear warmup (increasing) at first num_iter steps from start_multiplier
2) inverse shrink (decreasing) afterwards (gamma, power)
3) lower bounded by end_multiplier

Differential Revision: D6565379

fbshipit-source-id: 9c0e51fc825ba6a7765803a1f09479497057a9d9
2017-12-19 23:35:44 -08:00
Qinqing Zheng
97c33a22a6 GPU fallback for LengthsRangeFill Op
Summary: Simple fallback implementation to support LengthsRangeFill, we can have native CUDA implementation later

Reviewed By: pietern

Differential Revision: D6594031

fbshipit-source-id: b705234a591a61e8d1ee5f7524aceec3f4581f9c
2017-12-19 15:42:13 -08:00
Ahmed Taei
0a25926f4b CUDA implementation for GatherPadddingOp
Summary: AT

Reviewed By: enosair

Differential Revision: D6561996

fbshipit-source-id: ad03d6db8d4318e426ff96569bb3c93cba696926
2017-12-15 16:05:31 -08:00
Do Huy Hoang
db0a2ff4eb selu op
Summary: selu operator for cuda

Reviewed By: prigoyal

Differential Revision: D5703418

fbshipit-source-id: 06b16a30fe1c67c1d45505e2f5cffc6408674ef3
2017-12-15 15:38:44 -08:00
Qinqing Zheng
28ea5ac069 Refactor Reduce{Front,Back}{Sum,Mean} Operators
Summary: Currently these operators are implemented in a complex meta-programming fashion, I removed the definitions and put modified CPU/CUDA implementions into reduction_front_back_ops.{cc,cu}. This will help future extension of these ops to support lengths input.

Reviewed By: asaadaldien

Differential Revision: D6506568

fbshipit-source-id: 7323baf7c8e0eca37912f3ae28c02e37ad2e1103
2017-12-14 20:02:36 -08:00
Pieter Noordhuis
d4db1b90a1 Resuppress adagrad health checks
Summary:
Commit 479e4ce5 didn't end up solving the health checks firing and
they are likely still caused by the remaining `assume` calls.
Closes https://github.com/caffe2/caffe2/pull/1625

Differential Revision: D6573036

Pulled By: pietern

fbshipit-source-id: eeb21bdd61dca0a632eb1ba9e529177ac2569bfd
2017-12-14 16:34:41 -08:00
Ahmed Taei
0867120f1e SortedSegmentMean/SortedSegmentLogMeanExp Gradients CUDA implementation.
Summary: AT

Reviewed By: enosair

Differential Revision: D6525541

fbshipit-source-id: dc095af1c3485d029f7744aadb66f8c51acf8ffe
2017-12-14 13:05:19 -08:00
James Cross
ca44c16e72 LayerConfigMILSTMCell
Summary: A version of MILSTMCell which uses layer normalization (see https://arxiv.org/pdf/1607.06450.pdf). There's a lot of copypasta because we don't want to make the existing RNNCell classes harder to approach / understand by adding new options.

Differential Revision: D6564208

fbshipit-source-id: 0bc43e12b6c08ebdf5ea6af2c631f785c302bdb4
2017-12-14 10:17:53 -08:00
Xiaomeng Yang
3842128ce1 Fix gpu test for FCTransposed
Summary: Fix gpu test for FCTransposed.

Reviewed By: pietern

Differential Revision: D6560213

fbshipit-source-id: 3b5a3e2f1f2f1c144599967d3565d71dc4340cec
2017-12-13 15:48:18 -08:00
Xiaomeng Yang
dbbfdee4c0 Implement FCTransposed gradient
Summary: Add FCTranposed gradient implementation

Reviewed By: salexspb

Differential Revision: D6551998

fbshipit-source-id: 0ee8ac7df8c33e55d715bfe65d58bb9bbe1afa50
2017-12-13 11:33:07 -08:00
Dong Li
c16a21b67d removed the device_type assumption in adagrad_test
Summary: the "assume" statement in adagrad_test leads to health check failure. here we remove it by checking dc == hu.gpu_do

Reviewed By: pietern

Differential Revision: D6513314

fbshipit-source-id: 4caf2d938e5f5935a95cca8abd99185182223d63
2017-12-13 03:35:51 -08:00
Ahmed Taei
98143776f5 SortedSegmentMean /LogExp Reduction CUDA implementation.
Summary: As titled.

Differential Revision: D6506412

fbshipit-source-id: 69f5a4f89f56a5b90905112a59fa3e99e51b46bb
2017-12-12 23:42:33 -08:00
Xue Feng
0000766566 Gan for ranking alternate learning rate
Summary:
This enables two learning rate for Generator and Discrimintor in GAN. For each iteration i, it will decide
whether to enable training on G (or D) based on the desired active_period and inactive_period for G (or D).

Reviewed By: dragonxlwang

Differential Revision: D6379325

fbshipit-source-id: 926f1041e25f48791b2ac1fc1a8eaa08db9639b8
2017-12-12 16:06:28 -08:00
Pieter Noordhuis
fca617c62f Suppress hypothesis health check in adagrad_test.py
Summary:
PR #1536 suppressed test_sparse_adagrad but test_row_wise_sparse_adagrad also filters too many examples. Suppress health checks for this test as well.
Closes https://github.com/caffe2/caffe2/pull/1599

Differential Revision: D6530850

Pulled By: pietern

fbshipit-source-id: c73f30d2e104565421e3e381b1cf66185edc833e
2017-12-10 11:47:15 -08:00
James Reed
dc47319074 Implement AssertOp
Summary:
This can be used for testing and debugging. zdevito and I will primarily use this for our caffe2 script project
Closes https://github.com/caffe2/caffe2/pull/1585

Reviewed By: zdevito

Differential Revision: D6501209

Pulled By: jamesr66a

fbshipit-source-id: fdd65e422c44b74bb6926320af506dcae13327f3
2017-12-06 17:18:52 -08:00
Simon Layton
a8250280bb Py3 test fixes
Summary:
\cc pietern
Closes https://github.com/caffe2/caffe2/pull/1555

Differential Revision: D6479902

Pulled By: pietern

fbshipit-source-id: 84647eddec45620b1ed603f4882ded2dd49adc43
2017-12-05 10:34:41 -08:00
James Reed
ea56e0d424 Implement BatchMatMul with Numpy-style batch broadcast semantics
Summary:
ONNX has decided to implement a single MatMul operator that borrows semantics from np.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

This PR introduces a new op that we can target for ONNX that mimics the numpy-style broadcast semantics
Closes https://github.com/caffe2/caffe2/pull/1507

Reviewed By: dzhulgakov

Differential Revision: D6389022

Pulled By: jamesr66a

fbshipit-source-id: a2270ad0042b1ddf6c65ba7cb10d83e0763cf950
2017-12-05 10:34:35 -08:00
Jesse Hellemn
32500fe800 Reducing array sizes used in pack_ops_test to prevent time outs during Travis CI builds
Summary:
Reduced the array sizes used in pack_ops_test to prevent time outs
during Travis CI builds.

Reviewed By: enosair

Differential Revision: D6476703

fbshipit-source-id: 20ab871ae40349ca27186447a84135bbc5c351b1
2017-12-04 12:48:53 -08:00
Peter Goldsborough
540a9c279e Add LayerNormLSTM
Summary:
Adds a new `LSTMCell` subclass to the `rnn_cell` module that performs layer normalization on the fused input matrix. Moves around some code in `rnn_cell.py` to avoid copy-pasta. Adds relevant test cases to `rnn_cell_test.py`.

Had to fix `brew.layer_norm` first. See T24013870.

Reviewed By: jhcross

Differential Revision: D6454883

fbshipit-source-id: 0f4ea7a778cc5be6a7274f7b28c793f5dd7c6095
2017-12-04 10:48:37 -08:00
Pieter Noordhuis
e1e08d631a Always check cuDNN support in test_convolution_gradients
Summary:
Regardless of device checker/gradient checker we cannot run a
backwards pass with cuDNN when NHWC is used.
Closes https://github.com/caffe2/caffe2/pull/1566

Differential Revision: D6474181

Pulled By: pietern

fbshipit-source-id: 727d7b4f2a1431a4d6675ffb76c5b60d3d7fa712
2017-12-04 08:50:39 -08:00
Pieter Noordhuis
41897e3e78 Supress hypothesis health check in glu_op_test.py
Summary: Closes https://github.com/caffe2/caffe2/pull/1564

Differential Revision: D6472568

Pulled By: pietern

fbshipit-source-id: 4f1bd3a1ced6d77991531eb864d2cf5d39bc7c4f
2017-12-03 22:51:46 -08:00
James Cross
2c190d2f05 update transformer code for layer_norm() API change
Summary: Quick fix for unit test broken by D6454290. This is my fault for approving while the tests covering the single callsite were broken.

Reviewed By: goldsborough

Differential Revision: D6466566

fbshipit-source-id: 2683be3d6bb184286e64fbde3e572946e39030c7
2017-12-01 20:19:31 -08:00
Peter Goldsborough
b43c1b2bed Fix and upgrade brew.layer_norm
Summary:
While working on layer normalization for LSTMs I encountered an issue where the layer norm parameters (which are the scale/gain and bias/shift from the paper) were not registered in the model for `brew.layer_norm`. salexspb explained that this is because it was using the `init_net_param` API instead of `create_param`. This diff fixes this.

While fixing I noticed that I noticed that `brew.layer_norm` actually had a bug where it was multiplying with the bias instead of adding it. Another issue was that the function giving the scale and bias a shape of `[1]`, however the paper (https://arxiv.org/pdf/1607.06450.pdf) specifies that, like for batch norm, there is one scale and bias parameter per neuron, i.e. the shape should be `[1, axis_dimension]`. The API now takes an explicit `dim_in` parameter (also more consistent with other normalization functions in that module) so that this can be specified. See tests for how this now looks.

Reviewed By: jhcross

Differential Revision: D6454290

fbshipit-source-id: fc00ca614de3190c40ab743e8984bec9e85fb58c
2017-12-01 14:18:28 -08:00
Jesse Hellemn
3af2b8f428 Adding length verification check to pack_segments
Summary:
Adding a check to pack_segments to make sure the lengths passed in add up as expected.

Additionally started to address https://fb.facebook.com/groups/1405155842844877/permalink/1977332432293879/ , but it might not fix that issue, but is still useful if it does not help that issue.

Reviewed By: salexspb

Differential Revision: D6443490

fbshipit-source-id: 680dc763a788a550d321d97a556c5b46e3402dd1
2017-12-01 10:47:25 -08:00
Pieter Noordhuis
3d1135c842 Skip remove_padding test because it is flaky
Summary:
Must be fixed in #1547
Closes https://github.com/caffe2/caffe2/pull/1548

Reviewed By: jhcross

Differential Revision: D6456373

Pulled By: pietern

fbshipit-source-id: 484a58e31506acfc8b8a0954f76796d14dfdfda3
2017-12-01 09:47:31 -08:00
Qinqing Zheng
7374c981d8 CUDA support for PackSegments Op
Summary: Replace GPUFallbackOp by native CUDA implementation

Reviewed By: akyrola

Differential Revision: D6423200

fbshipit-source-id: 47dfecbc486e9a8bf0cc6b897ab8b6a2488caa34
2017-11-29 22:01:42 -08:00
James Cross
0e21cd2eae CUDA implementation of RemovePadding operator
Summary:
This is a CUDA implementation of the RemovePadding operator, modeled on akyrola's implementation for AddPadding.

There's also an incidental spelling correction: GetAddPadingGradient -> GetAddPaddingGradient.

Reviewed By: akyrola

Differential Revision: D6439594

fbshipit-source-id: b29cd0c252021c58e150b901bbaad28a3bd3cc4a
2017-11-29 18:48:01 -08:00
Pieter Noordhuis
6f218cef25 Supress hypothesis health check in adagrad_test.py
Summary:
With some test seeds this warning starts firing.

Should be addressed in a better way, not generating as many invalid examples.
Closes https://github.com/caffe2/caffe2/pull/1536

Reviewed By: bddppq

Differential Revision: D6437138

Pulled By: pietern

fbshipit-source-id: c619d928a585e3d887f686db5d98f841af10c56b
2017-11-29 11:35:04 -08:00
Yangqing Jia
4beb3ac3ab Properly guard cudnn backward path - NHWC is still not supported.
Summary:
TSIA. This is found in

https://github.com/caffe2/caffe2/pull/1530

Reviewed By: dzhulgakov

Differential Revision: D6434417

fbshipit-source-id: 2285c2f6252eb7f24e83357eb4887851b3adf690
2017-11-28 23:03:02 -08:00
Aapo Kyrola
a08909160e fix bug in CUDA AddPadding when lenghts output is not provided
Summary:
enosair caught bug that the operator returned too early if the lengths output was not provided. Fixed and added testing.

+ noticed the op does not support case when no lengths-input is provided. Added a temporary CAFFE_THROW for this case, will fix later

Reviewed By: enosair

Differential Revision: D6405585

fbshipit-source-id: a81717e1b39afde6e900ddd9049b820943aea9f1
2017-11-27 15:14:07 -08:00
Aapo Kyrola
0954775d28 AddPadding CUDA version
Summary: CUDA version of the AddPadding op. It first executes a prefix-sum using Cub to compute the cumulative lenghts array. Then it launches a kernel that uses this information to fill the output tensor with start, end paddding and the actual contents.

Reviewed By: asaadaldien

Differential Revision: D6391413

fbshipit-source-id: 45b431e5976674729e53cb4752c7753c1d8a69e8
2017-11-22 18:17:21 -08:00
Andrew Tulloch
48415d83c8 Fix instance_norm_test.test_instance_norm_model_helper
Reviewed By: jerryzh168

Differential Revision: D6391749

fbshipit-source-id: ba861d401e358290782db8f360c430e3f3daae96
2017-11-22 15:05:29 -08:00
Yiming Wu
127a55ae49 cast op for empty batch
Summary: Cast op cuda can deal with empty batch now.

Reviewed By: azzolini

Differential Revision: D6350138

fbshipit-source-id: 2f3d19f4d42ff34806aa9597690e66f6b4de1a6b
2017-11-16 12:20:20 -08:00
Wenyi Huang
d8dfaeeef7 Add batch-based/row-based sparse from/to dense operator
Summary:
Two ops: BatchSparseToDenseOp and DenseToBatchSparseOp
Inverse operations of each other.

Details are described in op Doc

These op is used along with flexible topK, where the output is
lengths, indices, and values.
We want to do softmax on the values, but the dimension of each batch is different. So these op will convert sparse representation to dense and vice versa. The two ops are also gradient op for each other.

Reviewed By: chocjy

Differential Revision: D6288338

fbshipit-source-id: 0ba9e611058b39e46e7414dcc5f39cab29915fa3
2017-11-16 00:59:21 -08:00
Xiaolong Wang
3bde37fbf0 Listwise Ranking -- LambdaNDCG
Summary:
This is part one: It adds lambdaNDCG loss which can be used to heuristically
optimize the NDCG metric.

Differential Revision: D5830650

fbshipit-source-id: 1eb696337c9a77727ad40219c68f6468e2e097a5
2017-11-16 00:05:48 -08:00
Simon Layton
1ab3fd1a29 Fix Batched Matmul test accuracy
Summary:
Datatypes was being handled badly in reference check, causing sporadic fails in CI. All batched mat-mul with fp16 data is performed as pseudo-fp16, with all math in fp32. Adjusted the reference implementation to reflect this.

Adjusted the gradient check threshold to the best I could get to consistently pass.
Closes https://github.com/caffe2/caffe2/pull/1406

Differential Revision: D6324431

Pulled By: pietern

fbshipit-source-id: 83ff2584438a11f7a6db4599a4fb0e75e9e15a3d
2017-11-14 09:31:18 -08:00
James Reed
8701a2dfa3 Allow negative indices in Concat/Split ops
Summary: Closes https://github.com/caffe2/caffe2/pull/1440

Reviewed By: dzhulgakov

Differential Revision: D6290009

Pulled By: jamesr66a

fbshipit-source-id: 93eaff6103211ff89ed63ecaf4aa96d38e6bed63
2017-11-13 18:32:24 -08:00
Yan Zhu
7b047c161d NegateGradientOp and test
Summary: add NegateGradientOp: in forward pass, this op simply copies the input to output. In backward pass, it flips the sign of gradients.

Reviewed By: dragonxlwang

Differential Revision: D6314456

fbshipit-source-id: 56afd8b131eff9f7e120ab7e4e87461df49649d4
2017-11-13 18:05:14 -08:00
Xianjie Chen
c04ec84e1a disable uniform fill large blob
Reviewed By: pietern

Differential Revision: D6299413

fbshipit-source-id: 2ea4a5f1434060c3ab6fd42abd4052bdb10a37cc
2017-11-10 12:10:14 -08:00
Jeff Johnson
0440f3bf93 Reduce caffe2 GPU topk test sizes
Summary: The topk GPU test was taking too much time, but there are still a variety of codepaths to test (k <= 1024, k > 1024, k == 1, k == n). Reduce the batch sizes and n to reduce time taken by the in-python CPU code equivalent.

Reviewed By: pietern

Differential Revision: D6272628

fbshipit-source-id: b8b8f3601f28bf64f144c73d7c9e915f40c84d70
2017-11-10 07:47:00 -08:00