Commit Graph

978 Commits

Author SHA1 Message Date
Pawel Garbacki
fb50fcaa82 [C2] Add string equality operator (#45886)
Summary:
This diff adds a string equality checking operator.

Another attempt at reverted D24042344 (cf48872d28)

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

Test Plan: unit tests, github builds

Reviewed By: dzhulgakov

Differential Revision: D24129953

fbshipit-source-id: caa53c7eac5c67c414c37e9d93416104f72556b9
2020-10-06 12:08:26 -07:00
Dmytro Dzhulgakov
519c086418 Revert D24042344: [C2] Add string equality operator
Test Plan: revert-hammer

Differential Revision:
D24042344 (cf48872d28)

Original commit changeset: c8997c6130e3

fbshipit-source-id: 3d8aec1104a2a59c67ab4b7e77caeaf9fc94ae1d
2020-10-05 15:09:03 -07:00
Pawel Garbacki
cf48872d28 [C2] Add string equality operator
Summary: This diff adds a string equality checking operator.

Test Plan: Unit tests

Differential Revision: D24042344

fbshipit-source-id: c8997c6130e3438f2ae95dae69f76978e2e95527
2020-10-05 10:47:53 -07:00
Marcio Porto
c31066ac9d Torch Integration Test Formatting Changes (#45740)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/45740

Reviewed By: esqu1

Differential Revision: D23869021

fbshipit-source-id: 5910d44f9475bd7a53dc0478b69b39572dc8666f
2020-10-02 14:02:31 -07:00
Marcio Porto
b234acd414 Exposes SparseToDenseMask Caffe2 Operator (#45670)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/45670

Reviewed By: esqu1

Differential Revision: D23868280

fbshipit-source-id: d6afa129c073fe611cb43a170025bc3c880a4bec
2020-10-02 10:05:13 -07:00
Thomas Bredillet
0fa551f0ab [c2] Fix int types for learning rate
Summary: Currently GetSingleArgument is overflowing since it's expecting an int instead of an int64 when using a 1cycle (hill policy) annealing schedule

Test Plan:
unittest

buck test  caffe2/caffe2/python/operator_test:learning_rate_op_test

Differential Revision: D23938169

fbshipit-source-id: 20d65df800d7a0f1dd9520705af31f63ae716463
2020-09-26 10:59:29 -07:00
Dianshi Li
03dde4c62a Resend diff D23858329 (#45315)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45315

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

in D23858329 (721cfbf842), we put PriorCorrectionCalibrationPrediction unit test in OSS file which causes test failure issue in public trunk.

this diff moves it to FB only test file.

Test Plan:
```
 buck test //caffe2/caffe2/python/operator_test:torch_integration_test -- test_gather_ranges_to_dense_op

buck test //caffe2/caffe2/fb/python/operator_test:torch_integration_test -- test_prior_correct_calibration_prediction_op
```
all pass.

Reviewed By: houseroad

Differential Revision: D23899012

fbshipit-source-id: 1ed97d8702e2765991e6caf5695d4c49353dae82
2020-09-24 18:41:49 -07:00
Xiaomeng Yang
e2bcdc7b69 [Caffe2] Fix LayerNormOp when batch_size == 0. (#45250)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45250

[Caffe2] Fix LayerNormOp when batch_size == 0.

Test Plan: buck test mode/dev-nosan //caffe2/caffe2/python/operator_test:layer_norm_op_test

Reviewed By: houseroad

Differential Revision: D23892091

fbshipit-source-id: 9a34654dd6880c9d14b7111fcf850e4f48ffdf91
2020-09-24 12:30:03 -07:00
Mike Ruberry
956a25d061 Revert D23858329: [PT Model Split] Support 2 operators in PT by C2 conversion
Test Plan: revert-hammer

Differential Revision:
D23858329 (721cfbf842)

Original commit changeset: ed37118ca7f0

fbshipit-source-id: 30c700f80665be11afc608b00a77766064e60b35
2020-09-23 21:20:21 -07:00
Dianshi Li
721cfbf842 [PT Model Split] Support 2 operators in PT by C2 conversion (#45231)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45231

There are two operators:
`PriorCorrectionCalibrationPrediction` and `GatherRangesToDense` is not supported in PT which makes GLOW cannot work.

To unblock, we first try to use C2->PT conversion. In the long-term, we need to implement PT custom ops.

This diff does this conversion to unblock current project.

Test Plan:
Run unit test. the Test input is from current DPER example.
All pass.
```buck test //caffe2/caffe2/python/operator_test:torch_integration_test -- test_prior_correct_calibration_prediction_op  --print-passing-details

> c2 reference output
> [0.14285715 0.27272728 0.39130434 0.5 ]

> PT converted output
> tensor([0.1429, 0.2727, 0.3913, 0.5000])

buck test //caffe2/caffe2/python/operator_test:torch_integration_test -- test_gather_ranges_to_dense_op  --print-passing-details

c2 reference output
> [array([[6, 5, 4, 3], [0, 0, 0, 0]], dtype=int64)]

> PT converted output
> [tensor([[6, 5, 4, 3], [0, 0, 0, 0]])]
```

Reviewed By: allwu, qizzzh

Differential Revision: D23858329

fbshipit-source-id: ed37118ca7f09e1cd0ad1fdec3d37f66dce60dd9
2020-09-23 18:31:57 -07:00
Bugra Akyildiz
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
Yan Xie
285ba0d068 Enable fp16 for UniformFill (#44540)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/44540

Support output type to be fp16 for UniformFill

Reviewed By: jianyuh

Differential Revision: D23558030

fbshipit-source-id: 53a5b2c92cfe78cd11f55e6ee498e1bd682fe4a1
2020-09-15 15:09:18 -07:00
Yan Xie
4ce6af35c4 Enable fp16 for CUDA SparseLengthsSum/Mean (#44089)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/44089

Add support of fp16 as input type in SparseLengthSum/Mean caffe2 operator

Reviewed By: xianjiec

Differential Revision: D23436877

fbshipit-source-id: 02fbef2fde17d4b0abea9ca5d17a36aa989f98a0
2020-09-15 11:10:54 -07:00
Brandon Lin
ea55820606 [dper3] Export PackSegments and UnpackSegments to Pytorch
Summary: As title.

Test Plan:
```
buck test //caffe2/caffe2/python/operator_test/:torch_integration_test -- test_pack_segments
```

Reviewed By: yf225

Differential Revision: D23610495

fbshipit-source-id: bd8cb61f2284a08a54091a4f982f01fcf681f215
2020-09-11 09:29:24 -07:00
Xiaomeng Yang
135ebbde6d [Caffe2] Add RMSNormOp (#44338)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/44338

Add RMSNormOp in Caffe2

Test Plan: buck test mode/dev-nosan //caffe2/caffe2/python/operator_test:rms_norm_op_test

Reviewed By: houseroad

Differential Revision: D23546424

fbshipit-source-id: 8f3940a0bb42230bfa647dc66b5e359cc84491c6
2020-09-08 23:50:44 -07:00
Brandon Lin
5de805d8a7 [dper3] Export Caffe2 operator LearningRate to PyTorch
Summary: Exports the operator to PyTorch, to be made into a low-level module.

Test Plan:
```
buck test //caffe2/caffe2/python/operator_test:torch_integration_test -- test_learning_rate
```

Reviewed By: yf225

Differential Revision: D23545582

fbshipit-source-id: 6b6d9aa6a47b2802ccef0f87c1263c6cc2d2fdf6
2020-09-08 08:50:09 -07:00
kshitij12345
c7787f7fbf [numpy compatibility]Fix argmin/argmax when multiple max/min values (#42004)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/41998
Fixes https://github.com/pytorch/pytorch/issues/22853

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

Reviewed By: ngimel

Differential Revision: D23049003

Pulled By: mruberry

fbshipit-source-id: a6fddbadfec4b8696730550859395ce4f0cf50d6
2020-08-28 06:42:42 -07:00
Sean Lynch
f9a766bb39 Increase deadline time for load_save tests (#43205)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/43205

A number of tests that forward to `TestLoadSaveBase.load_save` are all marked as flaky due to them regularly taking much longer to start up than hypothesis' default timeout of 200ms. This diff fixes the problem by removing the timeout for `load_save`. This is alright as these tests aren't meant to be testing the performance of these operators.

I would set the deadline to 60s if I could however it appears the that caffe2 github CI uses a different version of hypothesis that doesn't allow using `dateutil.timedelta` so instead of trying to figure out an approach that works on both I've just removed the deadline time.

I've also tagged all existing tasks WRT these failures.

Differential Revision: D23175752

fbshipit-source-id: 324f9ff034df1ac4874797f04f50067149a6ba48
2020-08-20 08:41:24 -07:00
Edson Romero
5014cf4a4d Export MergeIdLists Caffe2 Operator to PyTorch
Summary: As titled.

Test Plan: buck test //caffe2/caffe2/python/operator_test:torch_integration_test -- test_merge_id_lists

Reviewed By: yf225

Differential Revision: D23076951

fbshipit-source-id: c37dfd93003590eed70b0d46e0151397a402dde6
2020-08-14 14:46:17 -07:00
Ren Chen
e182ec97b3 Fix illegal memory acess issue for CUDA versionn of SplitByLengths operator.
Summary:
1. Fix illegal memory access issue for SplitByLengths operator in the CUDA context.
2. Add support to scaling lengths vector for SplitByLengths operator.
3. Add support to test SplitByLengths operator in the CUDA context.

Example for SplitByLengths operator processing scaling lengths vector:
value vector A = [1, 2, 3, 4, 5, 6]
length vector B = [1, 2]
after execution of SplitByLengths operator,
the output should be [1,2] and [3,4,5,6]

Test Plan: buck test mode/dev-nosan caffe2/caffe2/python/operator_test:concat_split_op_test

Reviewed By: kennyhorror

Differential Revision: D23079841

fbshipit-source-id: 3700e7f2ee0a5a2791850071fdc16e5b054f8400
2020-08-14 01:04:08 -07:00
Christopher Whelan
7a9ae52550 [hypothesis] Deadline followup (#42842)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42842

Test Plan: `buck test`

Reviewed By: thatch

Differential Revision: D23045269

fbshipit-source-id: 8a3f4981869287a0f5fb3f0009e13548b7478086
2020-08-11 15:33:23 -07:00
Edson Romero
71dbfc79b3 Export BatchBucketOneHot Caffe2 Operator to PyTorch
Summary: As titled.

Test Plan:
```
buck test caffe2/caffe2/python/operator_test:torch_integration_test -- test_batch_bucket_one_hot_op
```

Reviewed By: yf225

Differential Revision: D23005981

fbshipit-source-id: 1daa8d3e7d6ad75e97e94964db95ccfb58541672
2020-08-11 14:00:19 -07:00
Mike Ruberry
dedcc30c84 Fix ROCm CI by increasing test timeout (#42827)
Summary:
ROCm is failing to run this test in the allotted time. See, for example, https://app.circleci.com/pipelines/github/pytorch/pytorch/198759/workflows/f6066acf-b289-46c5-aad0-6f4f663ce820/jobs/6618625.

cc jeffdaily

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

Reviewed By: pbelevich

Differential Revision: D23042220

Pulled By: mruberry

fbshipit-source-id: 52b426b0733b7b52ac3b311466d5000334864a82
2020-08-10 20:26:20 -07:00
Christopher Whelan
5cd0f5e8ec [PyFI] Update hypothesis and switch from tp2 (#41645)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/41645

Pull Request resolved: https://github.com/facebookresearch/pytext/pull/1405

Test Plan: buck test

Reviewed By: thatch

Differential Revision: D20323893

fbshipit-source-id: 54665d589568c4198e96a27f0ed8e5b41df7b86b
2020-08-08 12:13:04 -07:00
Edson Romero
2b04712205 Exposing Percentile Caffe2 Operator in PyTorch
Summary: As titled.

Test Plan:
```
buck test caffe2/caffe2/python/operator_test:torch_integration_test -- test_percentile
```

Reviewed By: yf225

Differential Revision: D22999896

fbshipit-source-id: 2e3686cb893dff1518d533cb3d78c92eb2a6efa5
2020-08-07 16:22:37 -07:00
Rui Liu
92b7347fd7 Enforce counter value to double type in rowwise_counter
Summary:
Enforce counter value to double type in rowwise_counter.

**Context:**
The existing implementation is using float type for counter value. But due to the precision limit of a floating number [1], we observed that the counter value can't increment beyond 16777216.0 (i.e., the max value is 16777216.0) in our earlier experiments. We decide to enforce double type to avoid this issue.

[1] https://stackoverflow.com/questions/12596695/why-does-a-float-variable-stop-incrementing-at-16777216-in-c

Test Plan:
op test
```
ruixliu@devvm1997:~/fbsource/fbcode/caffe2/caffe2/python/operator_test(f0b0b48c)$ buck test :rowwise_counter_test
Trace available for this run at /tmp/testpilot.20200728-083200.729292.log
TestPilot test runner for Facebook. See https://fburl.com/testpilot for details.
Testpilot build revision cd2638f1f47250eac058b8c36561760027d16add fbpkg f88726c8ebde4ba288e1172a348c7f46 at Mon Jul 27 18:11:43 2020 by twsvcscm from /usr/local/fbprojects/packages/testinfra.testpilot/887/t.par
Discovering tests
Running 1 test
Started new test run: https://our.intern.facebook.com/intern/testinfra/testrun/7881299364977047
      ✓ caffe2/caffe2/python/operator_test:rowwise_counter_test - test_rowwise_counter (caffe2.caffe2.python.operator_test.rowwise_counter_test.TestRowWiseCounter) 0.265 1/1 (passed)
      ✓ caffe2/caffe2/python/operator_test:rowwise_counter_test - main 14.414 (passed)
Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/7881299364977047
Summary (total time 18.51s):
  PASS: 2
  FAIL: 0
  SKIP: 0
  FATAL: 0
  TIMEOUT: 0
  OMIT: 0
```

optimizer test
```
ruixliu@devvm1997:~/fbsource/fbcode/caffe2/caffe2/python(7d66fbb9)$ buck test :optimizer_test
Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/7036874434841896
Summary (total time 64.87s):
  PASS: 48
  FAIL: 0
  SKIP: 24
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestMomentumSgd)
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestGFtrl)
    caffe2/caffe2/python:optimizer_test - test_caffe2_cpu_vs_numpy (caffe2.caffe2.python.optimizer_test.TestYellowFin)
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestSparseRAdam)
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestRowWiseAdagradWithCounter)
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestAdagrad)
    caffe2/caffe2/python:optimizer_test - test_caffe2_gpu_vs_numpy (caffe2.caffe2.python.optimizer_test.TestYellowFin)
    caffe2/caffe2/python:optimizer_test - testDense (caffe2.caffe2.python.optimizer_test.TestRowWiseAdagrad)
    caffe2/caffe2/python:optimizer_test - testGPUDense (caffe2.caffe2.python.optimizer_test.TestFtrl)
    caffe2/caffe2/python:optimizer_test - testSparse (caffe2.caffe2.python.optimizer_test.TestRmsProp)
    ...and 14 more not shown...
  FATAL: 0
  TIMEOUT: 0
  OMIT: 0
```

param download test
```
ruixliu@devvm1997:~/fbsource/fbcode/caffe2/caffe2/fb/net_transforms/tests(7ef20a38)$ sudo buck test :param_download_test
Finished test run: Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/6473924481526935
```

e2e flow:
f208394929
f207991149
f207967273

ANP notebook to check the counter value loaded from the flows
https://fburl.com/anp/5fdcbnoi

screenshot of the loaded counter (note that counter max is larger than 16777216.0)

{F250926501}

Reviewed By: ellie-wen

Differential Revision: D22711514

fbshipit-source-id: 426fed7415270aa3f276dda8141907534734337f
2020-08-05 20:40:51 -07:00
Mike Ruberry
24e2a8a171 Revert D22780307: Fix illegal memory acess issue for CUDA versionn of SplitByLengths operator.
Test Plan: revert-hammer

Differential Revision:
D22780307 (76905527fe)

Original commit changeset: c5ca60ae16b2

fbshipit-source-id: f3c99eec5f05121e2bed606fe2ba84a0be0cdf16
2020-08-05 12:47:56 -07:00
Ren Chen
76905527fe Fix illegal memory acess issue for CUDA versionn of SplitByLengths operator.
Summary:
1. Fix illegal memory access issue for SplitByLengths operator in the CUDA context.
2. Add support to scaling lengths vector for SplitByLengths operator.
3. Add support to test SplitByLengths operator in the CUDA context.

Example for SplitByLengths operator processing scaling lengths vector:
value vector A = [1, 2, 3, 4, 5, 6]
length vector B = [1, 2]
after execution of SplitByLengths operator,
the output should be [1,2] and [3,4,5,6]

Test Plan: buck test mode/dev-nosan caffe2/caffe2/python/operator_test:concat_split_op_test

Reviewed By: kennyhorror

Differential Revision: D22780307

fbshipit-source-id: c5ca60ae16b24032cedfa045a421503b713daa6c
2020-08-05 11:46:00 -07:00
Xiaomeng Yang
5769b06ab5 [Caffe2] Remove explicitly divide by zero in SpatialBN training mode (#42380)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42380

[Caffe2] Remove explicitly divide by zero in SpatialBN training mode

Test Plan: buck test mode/dev-nosan //caffe2/caffe2/python/operator_test:spatial_bn_op_test

Reviewed By: houseroad

Differential Revision: D22873214

fbshipit-source-id: 70b505391b5db02b45fc46ecd7feb303e50c6280
2020-08-01 11:54:58 -07:00
Yan Xie
bdd9ef1981 Support RowWiseSparseAdam on GPU (#35404)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35404

Implement RowWiseSparseAdam on CUDA

Reviewed By: xw285cornell

Differential Revision: D20650225

fbshipit-source-id: 5f871e2f259e362b713c9281b4d94534453995cf
2020-07-31 10:47:29 -07:00
Xiaomeng Yang
60f51542dc [Caffe2] Fix spatial_bn bug for computing running_var on CPU or on CUDA without CuDNN (#42151)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42151

Previously our Caffe2 SpatialBN op impl was incorrect for computing running_var without unbias coefficent. Actually it should fail the test because the output will be different with CuDNN's output. However, our tests are too weak to find this bug. This diff fix all of them.

Test Plan: buck test mode/dev-nosan //caffe2/caffe2/python/operator_test:spatial_bn_op_test

Reviewed By: houseroad

Differential Revision: D22786127

fbshipit-source-id: db80becb67d60c44faae180c7e4257cb136a266d
2020-07-29 11:20:03 -07:00
Nikita Shulga
2f61aca17b Skip DataIO tests relying on LevelDB if compiled without it (#42169)
Summary:
Found while trying to get RocM Caffe2 job green

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

Reviewed By: seemethere

Differential Revision: D22791896

Pulled By: malfet

fbshipit-source-id: 9df6233876aec5ead056365499bab970aa7e8bdc
2020-07-28 10:18:26 -07:00
Lingyi Liu
d6f1346c37 Add a new op for converting the dense feature to sparse representation
Summary: we need this op to avoid the splicing of a dense tensor and then use the Mergesinglescaler op

Test Plan: integrated test with dper2

Differential Revision: D22677523

fbshipit-source-id: f4f9a1f06841b0906ec8cbb435482ae0a89e1721
2020-07-27 12:45:37 -07:00
Hongzheng Shi
581e9526bb [GradualGating] support better k value change (#41557)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/41557

 - add new learning rate functor "slope"
 - use "slope" learning rate in gated_sparse_feature module

Test Plan:
buck test dper3/dper3/modules/tests:core_modules_test -- test_gated_sparse_features_shape_num_warmup_tensor_k
buck test caffe2/caffe2/python/operator_test:learning_rate_op_test -- test_slope_learning_rate_op

Reviewed By: huayuli00

Differential Revision: D22544628

fbshipit-source-id: f2fcae564e79e1d8bcd3a2305d0c11ca7c0d3b3c
2020-07-17 20:44:28 -07:00
Stanislau Hlebik
b774ce54f8 remediation of S205607
fbshipit-source-id: 798decc90db4f13770e97cdce3c0df7d5421b2a3
2020-07-17 17:19:47 -07:00
Stanislau Hlebik
8fdea489af remediation of S205607
fbshipit-source-id: 5113fe0c527595e4227ff827253b7414abbdf7ac
2020-07-17 17:17:03 -07:00
Yavuz Yetim
d04a2e4dae Back out "Revert D22329069: Self binning histogram" (#41313)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/41313

This diff backs out the backout diff.  The failure was due to C++ `or`
not being supported in MSVC. This is now replaced with ||

Original commit changeset: fc7f3f8c968d

Test Plan: Existing unit tests, check github CI.

Reviewed By: malfet

Differential Revision: D22494777

fbshipit-source-id: 3271288919dc3a6bfb82508ab9d021edc910ae45
2020-07-13 11:46:34 -07:00
Nikita Shulga
7bae5780a2 Revert D22329069: Self binning histogram
Test Plan: revert-hammer

Differential Revision:
D22329069 (16c8146da9)

Original commit changeset: 28406b94e284

fbshipit-source-id: fc7f3f8c968d1ec7d2a1cf7a4d05900f51055d82
2020-07-10 16:22:29 -07:00
Yavuz Yetim
16c8146da9 Self binning histogram (#40875)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40875

This op uses the given num_bins and a spacing strategy to automatically bin and compute the histogram of given matrices.

Test Plan: Unit tests.

Reviewed By: neha26shah

Differential Revision: D22329069

fbshipit-source-id: 28406b94e284d52d875f73662fc82f93dbc00064
2020-07-10 13:55:42 -07:00
rohithkrn
df252c059c [ROCm] Skip caffe2 unique op test for rocm3.5 (#41219)
Summary:
unique op test failure in caffe2 blocks upgrading CI to rocm3.5.1. Skipping the test to unblock will re-enable after root causing and fixing the issue.
jeffdaily sunway513

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

Differential Revision: D22471452

Pulled By: xw285cornell

fbshipit-source-id: 9e503c8b37c0a4b92632f77b2f8a90281a9889c3
2020-07-09 20:00:29 -07:00
lcskrishna
302cf6835e [ROCm][Caffe2] Enable MIOpen 3D Pooling (#38260)
Summary:
This PR contains the following updates:
1. MIOpen 3D pooling enabled in Caffe2.
2. Refactored the MIOpen pooling code in caffe2.
3. Enabled unit test cases for 3D pooling.

CC: ezyang jeffdaily ashishfarmer

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

Differential Revision: D21524754

Pulled By: xw285cornell

fbshipit-source-id: ddfe09dc585cd61e42eee22eff8348d326fd0c3b
2020-07-08 17:42:55 -07:00
Alyssa Wang
e0e8b98c43 Export logic op to pytorch
Summary: Export logit op to pt for better preproc perf

Test Plan:
unit test
Also tested with model re-generation

Reviewed By: houseroad

Differential Revision: D22324611

fbshipit-source-id: 86accb6b4528e5c818d2c3f8c67926f279d158d6
2020-07-08 02:27:09 -07:00
Dongxin Liu
cbe52d762c Mish Activation Function (#40856)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40856

Add a new activation function - Mish: A Self Regularized Non-Monotonic Neural Activation Function https://arxiv.org/abs/1908.08681

Test Plan:
buck test //caffe2/caffe2/python/operator_test:elementwise_ops_test -- 'test_mish'

{F242275183}

Differential Revision: D22158035

fbshipit-source-id: 459c1dd0ac5b515913fc09b5f4cd13dcf095af31
2020-07-06 15:51:23 -07:00
Vitaly Fedyunin
a1c234e372 Revert D22330340: [C2] Fixed a bug in normalization operator
Test Plan: revert-hammer

Differential Revision:
D22330340 (ce63f70981)

Original commit changeset: 0bccf925bb76

fbshipit-source-id: e27d70dee0fbe9e708b0cf3be81dbd33c4015026
2020-07-02 16:05:23 -07:00
Pawel Garbacki
ce63f70981 [C2] Fixed a bug in normalization operator (#40925)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40925

normalization operator does not handle empty tensors correctly. This is a fix.

Test Plan: unit tests

Differential Revision: D22330340

fbshipit-source-id: 0bccf925bb768ebb997ed0c88130c5556308087f
2020-07-02 13:24:56 -07:00
Neha Shah
5ad885b823 [Caffe2][Pruning] Make the caffe2 Sum operator support long types (#40379)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40379

The current sum operator doesn't support Long .. hence modify the code

Test Plan: Write a test case

Reviewed By: jspark1105, yinghai

Differential Revision: D21917365

fbshipit-source-id: b37d2c100c70d17d2f89c309e40360ddfab584ee
2020-06-23 14:18:29 -07:00
Jongsoo Park
7a837019a4 [caffe2] optimize 2/4-bit row-wise quantization (#387)
Summary:
Pull Request resolved: https://github.com/pytorch/FBGEMM/pull/387

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

avx2 optimized 2/4-bit row-wise quantization/dequantization in perfkernels.
This diff slightly change the numerics of quantization by multiplying with the inverse of scale instead of dividing with scale.

Test Plan:
In my devserver

for i in 2 4 8; do echo $i; buck run mode/opt :fused_rowwise_nbit_conversion_bench -- --bit-rate=$i; done

Before this diff
2-bit
        3.35394 ms.        100%. FloatToFused2BitRowwiseQuantized
4-bit
        3.60351 ms.        100%. FloatToFused4BitRowwiseQuantized
8-bit
       0.434467 ms.        100%. FloatToFused8BitRowwiseQuantized

After this diff

2-bit
       0.606386 ms.        100%. FloatToFused2BitRowwiseQuantized
4-bit
       0.446683 ms.        100%. FloatToFused4BitRowwiseQuantized
8-bit
         0.4349 ms.        100%. FloatToFused8BitRowwiseQuantized

Reviewed By: choudharydhruv, jianyuh

Differential Revision: D22033195

fbshipit-source-id: d3a219e47b8345268d90a160c9314ed0d5b71467
2020-06-19 21:28:31 -07:00
Nikita Shulga
e2a178ca21 Update cafe2 hypothesis_test_util to support hypothesis-5 (#39498)
Summary:
Extracting forward-backward `hypothesis` interface update  parts of https://github.com/pytorch/pytorch/pull/39430 into a separate PR
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39498

Differential Revision: D21900210

Pulled By: malfet

fbshipit-source-id: 75e637cf839f49dc141d37e1686ce45ff4721245
2020-06-05 08:27:50 -07:00
Jongsoo Park
fca928cabf [caffe2] fix test error in video_input_op_test (#39382)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/39382

Test Plan: buck test caffe2/caffe2/python/operator_test:video_input_op_test

Reviewed By: dutran

Differential Revision: D21832355

fbshipit-source-id: 47b1b0610b9600437fe1ed317d5af47d624767fb
2020-06-02 11:48:01 -07:00
Jongsoo Park
04ac41fe70 [caffe2] format video_input_op_test.py (#39381)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39381

To prepare D21832355

Test Plan: Just formatting

Reviewed By: dutran

Differential Revision: D21832354

fbshipit-source-id: bbf6a1377752adaa115ee2e2a5ba546964e3fd08
2020-06-02 11:46:01 -07:00
Jamie King
7f1a96d43c Adding sparse Lp regularization operator to Caffe2 (#38574)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38574

Adding sparse L1 and L2 regularization operator to Caffe2.  This doesn't work using run_on_loss, only run_after_optimize.  Applying it to run_after_optimize rather than run_on_loss was easier to implement, particularly for the L1 norm which is preferable in some cases and is non-differentiable at zero.

Test Plan: Wrote and ran unit tests in operator_test:sparse_lp_regularizer_test.

Differential Revision: D21003029

fbshipit-source-id: 81070a621752560ce03e320d065ce27807a5d278
2020-06-01 15:21:19 -07:00
Xiaodong Wang
fcef43965b [AMD] Fix broken test (#39297)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39297

histogram op doesn't have GPU implementation. It's breaking the CI GPU test. Make the test run cpu only.

Test Plan: CI

Reviewed By: hwangjeff

Differential Revision: D21800824

fbshipit-source-id: 9c835786f22bac7d420ce610397a6ee69084c19a
2020-05-30 13:12:24 -07:00
Jeff Hwang
0b9d537056 [dper][pruning] add histogram op (#38514)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38514

this diff introduces the `Histogram` caffe2 op, which computes a histogram tensor for a list of input tensors. the bin edges of the histogram are defined by arg `bin_edges`.

Test Plan: tests

Reviewed By: chocjy

Differential Revision: D21553956

fbshipit-source-id: fc98c8db691d66d2dad57b6ad14867109913cb6f
2020-05-28 15:45:04 -07:00
Yan Zhu
c40a79a027 [c2] cuda impl for WeightScale op (#38712)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38712

as title

Test Plan: buck test;

Reviewed By: ustctf

Differential Revision: D21586705

fbshipit-source-id: 12cd34f04f074ee12b77304055f3ba6068cf38fb
2020-05-26 12:50:54 -07:00
Yan Zhu
dfbf9f397f Back out "Back out "[c2] register cuda op for LpNorm (fallback)"" (#38566)
Summary:
Previously we got a CI issue in original submission (D21562485), so we backout the original diff (D21588831). Resubmitting here to reprod the CI issue and ask caffe2 dev to take a look.

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

Original commit changeset: 6dda4b71904d

Test Plan: buck test

Reviewed By: houseroad

Differential Revision: D21589352

fbshipit-source-id: de40ff2884019e14476e31c4c952f24d6e438f5f
2020-05-19 10:37:25 -07:00
Yan Zhu
fac9f36563 Back out "[c2] register cuda op for LpNorm (fallback)"
Summary: Original commit changeset: 573419e5a8da

Test Plan: D21562485  breaks CI build. Unlanding

Reviewed By: olittle

Differential Revision: D21588831

fbshipit-source-id: 6dda4b71904d7765f32f570f9722e4a9a6cbc97b
2020-05-14 20:25:30 -07:00
Yan Zhu
bbfd0ef244 [c2] register cuda op for LpNorm (fallback) (#38517)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38517

as title

Test Plan: buck test

Reviewed By: olittle

Differential Revision: D21562485

fbshipit-source-id: 573419e5a8dae4121d99d5b72ed3960a92db7a54
2020-05-14 16:54:12 -07:00
Jongsoo Park
6be3e5d3bb [caffe2] weight_decay in reduced precision adagrad
Summary: As title

Test Plan: CI

Reviewed By: taiqing

Differential Revision: D21512729

fbshipit-source-id: 0777c90954ebad0cbd5785460e7b2a7c8c146316
2020-05-12 20:33:40 -07:00
Taiqing Wang
8cb1f2f9dc implement L2 regularization for Adagrad in caffe2 and dper (#37705)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37705

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

Posted note: [Regularizing SparseNN Against Over-fitting](https://fb.workplace.com/notes/taiqing-wang/regularizing-sparsenn-against-over-fitting/220306075902708/)

**Problem formulation**

L(w) = J(w) + lambda/2 * ||w||^2
J(w) is the empirical loss, and ||w||^2 is the squared L2 norm of the parameters, a.k.a. L2 regularizer.

dL(w)/ dw_i = dJ(w)/dw_i + lambda w_i
dL(w)/ dw_i is the gradient of L(w) w.r.t. w_i.

To implement the L2 regularizer, the gradient of J(w) w.r.t. w_i is added with w_i. lambda is called as weight decay in this implementation.

**Code changes**
* In the initialization method of AdagradOptimizer, a new input argument, weight_decay, is added.
* In the _run function of AdagradOptimizer, the weight decay will be skipped for 1d bias vectors.
* In the parameter update functions of Adagrad, the gradient is updated by weight_decay * w_i. The default value for weight_decay is zero.

Test Plan:
`
buck build caffe2/caffe2/fb/dper/layer_models/tests/split_1:sparse_nn_test_weight_decay
`

`
./buck-out/gen/caffe2/caffe2/fb/dper/layer_models/tests/split_1/sparse_nn_test_weight_decay#binary.par
`

Reviewed By: jspark1105

Differential Revision: D21258652

fbshipit-source-id: d2366ddcd736a03205a2d16f914703b16d9fce8f
2020-05-03 10:42:49 -07:00
Nikita Shulga
527cf877d6 Delete old mkl_speed_test.py
Summary: It was always skipped for last 1.5 years (since D10372230 was landed)

Test Plan: CI

Reviewed By: ailzhang

Differential Revision: D21036194

fbshipit-source-id: 9ace60b45a123a9372a88310b91f33a69ae8880c
2020-04-15 11:02:01 -07:00
Yuxi Hu
f7c9faab05 Implementation and operator test for STORM optimizer (#36225)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36225

Implemented the [STORM](https://arxiv.org/abs/1905.10018) optimizer operator for dense and sparse cases.

Test Plan:
All newly added unit tests passed using "buck test //caffe2/caffe2/python/operator_test:storm_test".

{F233643713}

Reviewed By: chocjy

Differential Revision: D18702897

fbshipit-source-id: d25eeb492aa2a03c69754d3f076a8239230b3bf4
2020-04-14 23:04:26 -07:00
Hao Lu
fb70b4fb93 [caffe2] Add support for std::shared_ptr<std::vector<TensorList>> in PackRecordsOp and UnPackRecordsOp (#36550)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36550

Separate dataset_ops changes into a separate diff.

Test Plan:
```
buck test caffe2/caffe2/python/operator_test:dataset_ops_test
```

AI/AF canary (tested with D20959214):
https://our.intern.facebook.com/intern/experiment_store/experiment/3298538636995/#commit1-commit2
https://our.intern.facebook.com/intern/experiment_store/experiment/2199027015376/#commit1-commit2

Reviewed By: yinghai

Differential Revision: D20988910

fbshipit-source-id: b37a7bfd131813e9472a5e2fa24d681d1ef19018
2020-04-14 03:43:21 -07:00
Devin He
b46fddf506 idtt + zch distributed inference (#35763)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35763

Adds inference function and test for ScatterAssign

Test Plan: Updated unit test

Reviewed By: yyetim, shunting1986

Differential Revision: D20501079

fbshipit-source-id: 7ec6ef0127a151250dd699c90c2b80c35cfb1fe4
2020-04-03 12:09:34 -07:00
Tristan Rice
676fc929b7 [caffe2] fix type and shape inference for common gradient ops (#35857)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35857

This fixes a lot of common ops for InferBlobShapesAndTypes as well as adds support for testing the inferred shapes and types of gradient ops.

Ops:
* Concat
* Split
* LeakyReLU
* Relu
* Prelu
* Gelu
* Elu
* Sinh, Tanh, Cosh
* Abs
* ... and a number of other simple element wise ops

Test Plan:
Added support to hypothesis test to check the shape and type of gradient ops.

Enabled it for all the ops I fixed the shape and type inference for.

  buck test caffe2/caffe2/python/operator_test:

Reviewed By: pradeepd24

Differential Revision: D20806284

fbshipit-source-id: 77f796d9ff208e09e871bdbadf9a0a7c196b77f2
2020-04-02 11:17:04 -07:00
Yinghai Lu
af4d86788c Split SparseLengthsSumSparse into SparseLengthsSumSparseLookup + SparseLengthsSum (#35507)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35507

We want to split up the SparseLengthsSumSparse op into an indirection op and the SparseLengthsSum op so that we can lower the later part.  The indirection part is a plain impl now.

Test Plan:
```
for i in `seq 10`; do buck test caffe2/caffe2/python/operator_test:lengths_reducer_fused_nbit_rowwise_ops_test -- test_sparse_lengths_sum_rowwise_sparse; done
```

Reviewed By: jspark1105

Differential Revision: D20683478

fbshipit-source-id: 509effe88719d20aa0c4783bbe0ce1f183ee473c
2020-03-30 13:33:29 -07:00
Tristan Rice
d4f3bc7f8e [dt] [caffe2] add/fix shape inference for StumpFunc, SliceGradient and ResizeLike (#35430)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35430

This fixes and adds tests for several commonly used operators.

There's some formatting differences due to running clang-format on one of the files.

Test Plan: buck test //caffe2/caffe2/fb/operators:hypothesis_test //caffe2/caffe2/python/operator_test:utility_ops_test //caffe2/caffe2/python/operator_test:concat_split_op_test

Reviewed By: yyetim

Differential Revision: D20657405

fbshipit-source-id: 51d86d0834003b8ac8d6acb5149ae13d7bbfc6ab
2020-03-26 17:50:32 -07:00
Xiaodong Wang
53fceff1e1 Change weight scale test to cpu only (#35346)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35346

weight scale op doesn't have GPU impl. This is breaking OSS CI from D20506032. Making it cpu only

Test Plan: OSS CI

Reviewed By: ustctf

Differential Revision: D20637440

fbshipit-source-id: 9aa6cce63ce637ab7856788e5d02f527decb2a26
2020-03-25 09:18:58 -07:00
Fei Tian
845b19c4ef Add weight_scale in Adagrad (#34944)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/34944

Reviewed By: chonglinsun

Differential Revision: D20506032

fbshipit-source-id: ef025e536da01fdcabc783466bc065685b80ab9a
2020-03-20 22:36:51 -07:00
Edward Yang
d927d58c2a Revert D20289209: Support RowWiseSparseAdam on GPU
Test Plan: revert-hammer

Differential Revision:
D20289209

Original commit changeset: a7a8a21bd18c

fbshipit-source-id: 4a8ae684d099a5499c28b7e65578fc7ab10b248d
2020-03-18 07:35:07 -07:00
Jongsoo Park
bcbdba450c [caffe2] open source 2/4-bit SLS operators (#34903)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34903

Reattempt of D20461609

Moving 2/4-bit SLS and row-wise 2/4-bit conversion operator to open source to be used by DLRM

Test Plan: CI

Reviewed By: jianyuh

Differential Revision: D20495304

fbshipit-source-id: 66a99677583f50fd40e29c514710c7b1a8cdbc29
2020-03-17 22:55:10 -07:00
Yan Xie
959a7138fd Support RowWiseSparseAdam on GPU (#34341)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34341

Implement RowWiseSparseAdam on CUDA

Reviewed By: xianjiec

Differential Revision: D20289209

fbshipit-source-id: a7a8a21bd18c1b9891f04f202d3ecaf183e30cad
2020-03-17 15:08:24 -07:00
Edward Yang
3e68d0c5d0 Revert D20461609: [caffe2] open source 2/4-bit SLS operators
Test Plan: revert-hammer

Differential Revision:
D20461609

Original commit changeset: b3ef73ff10f2

fbshipit-source-id: e90ee5e34b1feab5b0bd582ed7e96e37de7044b0
2020-03-17 11:10:10 -07:00
Jongsoo Park
d9b97a4ffd [caffe2] open source 2/4-bit SLS operators (#34783)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34783

Moving 2/4-bit SLS and row-wise 2/4-bit conversion operator to open source to be used by DLRM

Test Plan: CI

Reviewed By: yinghai

Differential Revision: D20461609

fbshipit-source-id: b3ef73ff10f2433afe06ffa73fe1145282d9ec4c
2020-03-17 01:00:31 -07:00
Xinyi Zhang
99b91ee2ad [fix][tiny][caffe2] Avoid triggering errors when allow ratio is 100% (#34757)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/34757

Reviewed By: Wakeupbuddy

Differential Revision: D20451255

fbshipit-source-id: 07997cf31dba653b61d082ec3f28357c3b90c4eb
2020-03-16 11:39:32 -07:00
Alex Cheparukhin
ee23944f46 [Caffe2] Fix shape inference for element-wise operators (#33431)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33431

Some elementwise operators don't have shape and type inference specified for the output tensor: `BitwiseOr`, `BitwiseAnd`, `BitwiseXor`, `Not`, `Sign`.

This change fixes this issue:
- For `Not` and `Sign` operators, the output has the same type and shape as the input, so `IdenticalTypeAndShapeOfInput` function is used to specify that.
- For bitwise operators created by `CAFFE2_SCHEMA_FOR_BINARY_BITWISE_OP` macro, the type and shape inference rules should be the same as for other binary element-wise operators, so `TensorInferenceFunction(ElementwiseOpShapeInference)` is used to specify that.

Also some tests were modified to ensure that the shape and type are inferred (`ensure_outputs_are_inferred` parameter)

Test Plan:
```
CAFFE2_ASSERT_SHAPEINFERENCE=1 buck test caffe2/caffe2/python/operator_test:elementwise_ops_test
CAFFE2_ASSERT_SHAPEINFERENCE=1 buck test caffe2/caffe2/python/operator_test:math_ops_test
```

Note that the tests have to be executed with `CAFFE2_ASSERT_SHAPEINFERENCE=1` in order to fail upon shape inference failure.

Reviewed By: idning

Differential Revision: D19880164

fbshipit-source-id: 5d7902e045d79e5669e5e98dfb13a39711294939
2020-02-25 09:03:06 -08:00
Xinyi Zhang
696527e659 [caffe2] Add embedding empty ratio checker (disabled by default) (#33145)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33145

Reviewed By: xianjiec

Differential Revision: D19716574

fbshipit-source-id: 42a636600ac3977910d35093916865790bbe5b10
2020-02-24 16:10:01 -08:00
Johannes M Dieterich
6ade7e3a15 [ROCm] Enable 3D convolutions through ROCm (#33067)
Summary:
For both the Caffe2 and PyTorch backends, enable 3D convolutions through MIOpen.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33067

Reviewed By: BIT-silence

Differential Revision: D19880495

Pulled By: bddppq

fbshipit-source-id: 8f6f970910654c1c5aa871b48a04c1054875691c
2020-02-14 13:19:10 -08:00
Chaitanya Sri Krishna Lolla
2635055229 [ROCm] Enable 3D batch norms through MIOpen (#33262)
Summary:
Enable test for Caffe2
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33262

Differential Revision: D19880486

Pulled By: bddppq

fbshipit-source-id: af663a11137a53302e55198f38117ab6bdc9ec89
2020-02-13 11:29:51 -08:00
Lin Yang
9d9fa2eace [2/3] Bind Bucketize to PyTorch (#33014)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33014

Export Bucketize to PyTorch.

Test Plan: buck test caffe2/caffe2/python/operator_test:torch_integration_test

Reviewed By: bddppq

Differential Revision: D19737534

fbshipit-source-id: be1c892bb8d01da9892f221f150f1a2788ac732e
2020-02-11 23:20:10 -08:00
Lin Yang
6f46962f21 [1/3] Bind IndexHash to PyTorch (#33015)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33015

Export IndexHash to PyTorch

Test Plan:
buck test caffe2/caffe2/python/operator_test:torch_integration_test

      ✓ caffe2/caffe2/python/operator_test:torch_integration_test-2.7 - test_index_hash_op (caffe2.caffe2.python.operator_test.torch_integration_test.TorchIntegration) 0.151 44/50 (passed)

Reviewed By: bddppq

Differential Revision: D19727301

fbshipit-source-id: a65c954539e81a15577fe5c3c0deb3614e983534
2020-02-10 17:47:38 -08:00
Xinyi Zhang
1f78bd0774 [caffe2] Early error throwing for currupted embeddings
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/32717

Reviewed By: xianjiec

Differential Revision: D19604954

fbshipit-source-id: c02eccf048c0dba3f66d729ab1fda50f3cacef63
2020-01-28 16:55:29 -08:00
Jongsoo Park
e735395fc6 [caffe2] use 2-stage EmbeddingSpMDM interface (#32271)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32271

Use the 2-stage EmbeddingSpMDM interface in D19425982 to reduce the overhead of code cache lookup and lock contention.
Fix an issue in sparse_lengths_sum_benchmarks generating empty indices when average length is small like 1.

Test Plan: CI

Reviewed By: dskhudia

Differential Revision: D19425987

fbshipit-source-id: d5c5f0d46e0072403901809c31d516fa0f4b9b31
2020-01-22 19:05:36 -08:00
Dehua Cheng
685f090ac8 [Rowwise Pruning][c2 op] Add Quantile Op (#32448)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32448

Using binary search to compute the value for the given quantile among the input tensors.

Test Plan: Newly added unittests;

Reviewed By: jspark1105

Differential Revision: D19487604

fbshipit-source-id: 0dc6627b78d1310ac35b3f1d53b89cc89a697ece
2020-01-22 16:59:56 -08:00
Jongsoo Park
14e0bec9f2 [caffe2] remove unnecessary np.set_printoptions and fix test errors (#32475)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32475

As title

Test Plan: CI

Reviewed By: houseroad

Differential Revision: D19508778

fbshipit-source-id: fd9ad63607535980505d155f3e3c3b7c6b95daf7
2020-01-22 14:49:47 -08:00
Brian Wignall
f326045b37 Fix typos, via a Levenshtein-type corrector (#31523)
Summary:
Should be non-semantic.

Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos, with https://github.com/bwignall/typochecker to help automate the checking.

Uses an updated version of the tool used in https://github.com/pytorch/pytorch/pull/30606 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31523

Differential Revision: D19216749

Pulled By: mrshenli

fbshipit-source-id: 7fd489cb9a77cd7e4950c1046f925d57524960ea
2020-01-17 16:03:19 -08:00
Yanghan Wang
9b6ec61bfd exposing CPU/GPU Copy ops (#32248)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32248

expose CPU/GPU copy ops

Test Plan: buck test mode/dev-nosan caffe2/caffe2/python/operator_test:torch_integration_test

Reviewed By: houseroad

Differential Revision: D19405856

fbshipit-source-id: 1df4aa202e26647cb81e9fe7e4478e594a5f7f3e
2020-01-17 12:40:43 -08:00
Alexander Melnikov
4e69352713 Add 64bit atomic fetch add (#32354)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32354

adding int_64 version of AtomicFetchAdd

Reviewed By: bwasti

Differential Revision: D19434349

fbshipit-source-id: b2358e8c5c6b7cd7e7b21de974b4ee1b5258fcf4
2020-01-17 11:43:43 -08:00
Jing Huang
ef5ae4823a Register RoIAlignRotated with C10
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/30785

Reviewed By: wat3rBro

Differential Revision: D18415056

fbshipit-source-id: e00376bec948309d53f2172697cd477449f769b2
2020-01-16 16:32:28 -08:00
Shu Liu
8c3ee9f2ba [Python] Deprecate use of scipy.misc.logsumexp and scipy.misc.comb (#32209)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32209

* Deprecate use of scipy.misc.logsumexp and scipy.misc.comb.
* Removed in 1.0.0 https://docs.scipy.org/doc/scipy-1.1.0/reference/generated/scipy.misc.logsumexp.html and https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.comb.html
* Use scipy.special.logsumexp and scipy.special.comb instead.
* This diff updates most usages of except those in experimental folders.
* This diff does NOT fix existing lint/code/TARGETS issues.
* This diff does NOT autoformat codes.

Test Plan: sandcastle auto unittests

Differential Revision: D19406460

fbshipit-source-id: 2103fa0d674d9671a0175f4ce54b3c887d22f04e
2020-01-15 10:40:47 -08:00
Hector Yuen
9e9ca6ec37 add conversion functions to embedding tables (#31083)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31083

add (fp32/fp16)<->(int8 rowwise quantized fp32/fp16 scale biases)

Test Plan:
added unit tests
enhanced shape inference tests

Reviewed By: jspark1105

Differential Revision: D18920547

fbshipit-source-id: 6b3d7cb93f9d1669ecf511817d73976177632891
2020-01-08 16:56:12 -08:00
Xinyi Zhang
f4e955ff62 Change PackSegments to ensure consistent behavior between CPU and GPU
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/31673

Reviewed By: Wakeupbuddy, BIT-silence

Differential Revision: D18925762

fbshipit-source-id: e0c318e97f69b14a54f43c176af57d98fbc16c9f
2019-12-30 13:31:45 -08:00
Dehua Cheng
35bee0c729 separate op for rowwise counter (#31612)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31612

Count the number recent update on rows. Exponential decay is applied on the counter with decay rate r, such that
    r^{counter_halflife} = 0.5;
If counter_halflife is nonpositive, this operator is turned off.

Test Plan: added unittest

Reviewed By: chocjy

Differential Revision: D19217921

fbshipit-source-id: 96d850123e339212cc0e0ef352ea8a1b1bf61dfa
2019-12-27 12:18:39 -08:00
Yanghan Wang
d08250c223 fix zero-batch handling in convtranspose (#24341)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/24341

ConvTransposeOp doesn't crash for zero-batch, but it doesn't modify the output blob. This leads to buggy behaviour especially when running the same network twice using different input, or backprop during training.

Seems `ConvTransposeUnpoolBase<Context>::GetOutputSize` works for zero-batch, so I remove the check for `input.numel() > 0`, and reshape the output blob before returning.

For CudnnConvTransposeGradientOp, it's a bit verbose to set `dfilter` and `dbias`, it's a  seems the Cudnn can handle it, so simply remove the `X.numel() == 0` branch.

Test Plan: buck test mode/dev-nosan caffe2/caffe2/python/operator_test:conv_transpose_test -- --run-disabled

Reviewed By: BIT-silence

Differential Revision: D16807606

fbshipit-source-id: 0d72c5bd8f2e03c34465e7b530cca548d9bdd5e1
2019-12-18 15:06:36 -08:00
Vitaly Fedyunin
c5d2758c35 Disable flaky TestMomentumSGD.test_fp16momentum_sgd (#31369)
Summary:
Related to https://github.com/pytorch/pytorch/issues/31368
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31369

Differential Revision: D19147072

Pulled By: VitalyFedyunin

fbshipit-source-id: 6fad13be7b35f992d84a20f23877cad05ff18616
2019-12-17 19:16:54 -08:00
Yanghan Wang
52b8a52e4d move AliasWithNameOp to caffe2/operators
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/31281

Reviewed By: houseroad

Differential Revision: D19053453

fbshipit-source-id: 350bfd5c001db9c17916dcae7ade8f56db1e9841
2019-12-17 02:39:40 -08:00
Yuchen Hao
4a751dfc20 optimize MulGradient for common shapes (#19705)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19705

Optimizing for a case when there's a consecutive dims that are not broadcasted followed by another consecutive dims that are broadcasted.
For example, MulGradient(["dC", "A", "B"], ["dA", "dB"], broadcast=True, axis=0) where A.shape == dC.shape == [9508, 80] and B.shape == [80] .

Test Plan:
In SKL T6,

Running mul_gradient_benchmark without this optimization
Operator #0 (dA, MulGradient) 11.9119 ms/iter

After this optimization,
Operator #0 (dA, MulGradient) 0.672759 ms/iter

Need to land D15291800 before to fix the unit test error

Reviewed By: dmudiger

Differential Revision: D15075415

fbshipit-source-id: 0f97be17cf8f1dacbafa34cd637fb8bc1c5e5387
2019-12-11 11:39:52 -08:00
Brian Wignall
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
Chuan Jiang
6c9b188262 Support in-place update in IndexHashOp (#30275)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30275

`IndexHash` did not support in-place update.

Reviewed By: kennyhorror

Differential Revision: D18612231

fbshipit-source-id: adeccdf1ceb6107454555ff9cdf66fd5e5773f2a
2019-11-22 14:49:28 -08:00
Huan Gui
be757957ba Support softmax with D == 0 (#29167)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29167

As titled.

This fix is crucial as multi_channel splitting would create history that has no items (i.e., D == 0), which leads to flow failure.

Test Plan:
Unittest

flow test:

before fix: f148783160

after fix: f149082299

buck test mode/dev-nosan caffe2/caffe2/python/operator_test:softmax_ops_test

Reviewed By: xianjiec

Differential Revision: D18296081

fbshipit-source-id: e0bb2dc2c4e5b465e213f31e5c5ced3a7e1fd574
2019-11-11 00:46:10 -08:00
Mike Ruberry
991c2ac383 Disables flaky test_rand_quantization (#29463)
Summary:
See https://github.com/pytorch/pytorch/issues/28550.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29463

Differential Revision: D18405669

Pulled By: mruberry

fbshipit-source-id: 2984c3896a9260a06fbf052afb06e0cb8d28b53d
2019-11-08 13:51:22 -08:00