platform/upstream/pytorch.git
5 years agoclean up print from test
Michael Suo [Wed, 20 Feb 2019 01:43:38 +0000 (17:43 -0800)]
clean up print from test

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17279

Differential Revision: D14144264

Pulled By: suo

fbshipit-source-id: eec837d29c46e96be37c54192a841046b486cb8b

5 years agoFix dll loading process in newer Python on Windows (#17191)
peter [Wed, 20 Feb 2019 00:54:02 +0000 (16:54 -0800)]
Fix dll loading process in newer Python on Windows (#17191)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/17051.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17191

Differential Revision: D14138427

Pulled By: kostmo

fbshipit-source-id: 9f207105161ad0312eb09fd86072afd5f22de785

5 years agoFix dll loading issue for Caffe2 and Windows
peter [Wed, 20 Feb 2019 00:53:42 +0000 (16:53 -0800)]
Fix dll loading issue for Caffe2 and Windows

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17215

Reviewed By: orionr

Differential Revision: D14138445

Pulled By: kostmo

fbshipit-source-id: 0bb4f2f1ed5bda7416ba7e4c6b0618414b328934

5 years agoFix cuda softmax backward with empty input (#17259)
Tongzhou Wang [Wed, 20 Feb 2019 00:33:16 +0000 (16:33 -0800)]
Fix cuda softmax backward with empty input (#17259)

Summary:
Fixes #17256
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17259

Differential Revision: D14142196

Pulled By: soumith

fbshipit-source-id: 1f2dc202951b59b43da27684f9f924314bcd3040

5 years agoat::native batch norm kernel launch config update (#17047)
Jie [Wed, 20 Feb 2019 00:32:13 +0000 (16:32 -0800)]
at::native batch norm kernel launch config update (#17047)

Summary:
limit block dimension to avoid configuration error on batch norm kernel launch

This should resolve #16998
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17047

Differential Revision: D14142132

Pulled By: soumith

fbshipit-source-id: 9c8c52dcd1d108cda1f65f5227e625b8fe6e12a0

5 years agoFalse alarm about leak in TestNN.test_variable_sequence_cuda (#17242)
Sergei Nikolaev [Tue, 19 Feb 2019 23:47:55 +0000 (15:47 -0800)]
False alarm about leak in TestNN.test_variable_sequence_cuda (#17242)

Summary:
`TestNN.test_variable_sequence_cuda` sometimes brakes due to CUDA leak.
The cause appears to be too small tolerance breaking float16 sub-test of the test above.
When it breaks it calls abort disrupting correct tear down of the test
and false alarming about the leak.

~~Also, removed annoying **Upsample** module warning.
IMHO this warning is wrong because the module **Upsample** is not deprecated. Seems like it's been mixed
with `nn.functional.upsample` function which is indeed deprecated in favor of `nn.functional.interpolate`, see `torch/nn/functional.py:2387` for details (this replacement is also performed in `test_nn.py`).~~
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17242

Differential Revision: D14141686

Pulled By: soumith

fbshipit-source-id: faa8f87440d94bdc6ab0ff00be6dad82353115c4

5 years agoU/kostmo/gen circle conf (#17189)
Karl Ostmo [Tue, 19 Feb 2019 23:33:58 +0000 (15:33 -0800)]
U/kostmo/gen circle conf (#17189)

Summary:
Diagram preview:
![binarysmoketests-config-dimensions](https://user-images.githubusercontent.com/261693/53040977-a0f88d00-3437-11e9-9190-796cc243e0f9.png)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17189

Differential Revision: D14141362

Pulled By: kostmo

fbshipit-source-id: 0625a1234d0307c6be79f17e756ddb1cc445b374

5 years agoupdate doc for multinomial (#17269)
Ailing Zhang [Tue, 19 Feb 2019 23:23:27 +0000 (15:23 -0800)]
update doc for multinomial (#17269)

Summary:
Update documentation to raise awareness of the fix in #12490. Thanks matteorr for pointing this out!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17269

Reviewed By: ezyang

Differential Revision: D14138421

Pulled By: ailzhang

fbshipit-source-id: 6433f9807a6ba1d871eba8e9d37aa6b78fa1e1fd

5 years agoAutomatic update of fbcode/onnx to 4c091e048ca42682d63ccd3c1811560bc12b732d (#17264)
Lu Fang [Tue, 19 Feb 2019 22:35:07 +0000 (14:35 -0800)]
update of fbcode/onnx to 4c091e048ca42682d63ccd3c1811560bc12b732d (#17264)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17264

Previous import was 822d8df0a2a32233c6022f50a158817a0f19bdc7

Included changes:
- **[4c091e0](https://github.com/onnx/onnx/commit/4c091e0)**: Support defined ONNX_ML in parent cmake files (#1821) <Lu Fang>
- **[57372f3](https://github.com/onnx/onnx/commit/57372f3)**: Delete OpsetVersionConverter.md which is a duplicate of VersionConverter.md (#1818) <Prasanth Pulavarthi>
- **[ab1c57e](https://github.com/onnx/onnx/commit/ab1c57e)**: [ONNXIFI]Add extension to be implementable (#1796) <Rui Zhu>
- **[b92eee8](https://github.com/onnx/onnx/commit/b92eee8)**: Revert "Implement Op Annotation's for ONNX (#1648)" (#1812) <Ke Zhang>
- **[61f1e9e](https://github.com/onnx/onnx/commit/61f1e9e)**: Enable ONNX_ML by default (#1810) <Shinichiro Hamaji>
- **[4f064a1](https://github.com/onnx/onnx/commit/4f064a1)**: fix Greater and Less doc (#1811) <Guoliang Hua>
- **[0628582](https://github.com/onnx/onnx/commit/0628582)**: Implement Op Annotation's for ONNX (#1648) <Armen>
- **[ad9d2f7](https://github.com/onnx/onnx/commit/ad9d2f7)**: Versioning doc update for Opset 9 (#1805) <Vinitra Swamy>
- **[e71e3be](https://github.com/onnx/onnx/commit/e71e3be)**: add dilation case for ConvTranspose op (#1797) <Randy>

Reviewed By: yinghai

Differential Revision: D14135024

fbshipit-source-id: 1e4f9dda89abf48994798d080dd5d58207a6e4b6

5 years agoMake tril_ and triu_ actually in-place (#17031)
Will Feng [Tue, 19 Feb 2019 22:31:34 +0000 (14:31 -0800)]
Make tril_ and triu_ actually in-place (#17031)

Summary:
Currently, when the input tensor `self` is not contiguous, `tril_` and `triu_` calls `self = self.contiguous()`, which allocates a new contiguous tensor and assign it to `self`. This effectively changes the input tensor `self`'s pointer and will break downstream code after Variable/Tensor merge.

This PR fixes it so that `tril_` and `triu_` always update the input tensor in-place and preserve the input tensor's TensorImpl.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17031

Differential Revision: D14069592

Pulled By: yf225

fbshipit-source-id: d188218f426446a44ccc1d33fc28ac3f828c6a05

5 years agoFix remaining -Wreturn-std-move violations in fbcode
Michael Liu [Tue, 19 Feb 2019 20:35:37 +0000 (12:35 -0800)]
Fix remaining -Wreturn-std-move violations in fbcode

Summary:
Some value are copied when it could've been moved.
Detected by compiler flag -Wreturn-std-move

Reviewed By: igorsugak

Differential Revision: D14134303

fbshipit-source-id: 8fc3bb2017108b3d65097cb8447e33f5b6c743b4

5 years agoLightweight String check Utility (#16858)
Elias Ellison [Tue, 19 Feb 2019 20:25:30 +0000 (12:25 -0800)]
Lightweight String check Utility (#16858)

Summary:
light weight implementation of LLVM filecheck utility. Currently only handles string matching - regexes & saving a regex to a variable name can be added as needed.

Current intended usage is through FileCheckBuilder python handle, and is shown in the tests.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16858

Differential Revision: D14096244

Pulled By: eellison

fbshipit-source-id: c7c8d1457691c105e6ccbb3c1a378d96baac2569

5 years agomove prim::None to prim::Constant (again) (#17186)
eellison [Tue, 19 Feb 2019 19:34:46 +0000 (11:34 -0800)]
move prim::None to prim::Constant (again) (#17186)

Summary:
Trying to land again, make prim::None into a case of prim::Constant. Reverted the previous landing because it broke an important onnx export test.

https://github.com/pytorch/pytorch/pull/16160
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17186

Differential Revision: D14115304

Pulled By: eellison

fbshipit-source-id: 161435fc30460b4e116cdd62c7b2e5b94581dcb7

5 years agoClarification of Lerp operation on tensors (#17253)
Krishna Kalyan [Tue, 19 Feb 2019 19:19:38 +0000 (11:19 -0800)]
Clarification of Lerp operation on tensors (#17253)

Summary: The `tensor` be used as `end` clarified in the docs.

Differential Revision: D14132212

Pulled By: ezyang

fbshipit-source-id: e9bca14d5079e5f7adfc18afcb1eec832ef86e9e

5 years agoreenable rand_like fusion when there is no broadcast (#16087)
Natalia Gimelshein [Tue, 19 Feb 2019 18:56:44 +0000 (10:56 -0800)]
reenable rand_like fusion when there is no broadcast (#16087)

Summary:
Reenables rand_like fusion if no tensor is broadcasted in the fusion group. This is a sufficient but not necessary condition for fused rand_like to produce correct results, and it has an unpleasant side effect of falling back to non-fused path if rand_like was optimistically included in the fusion group, but there is a broadcast in the fusion group not necessarily related to rand_like. E.g. before this PR, if the network had (biasAdd -> relu -> dropout), fuser could fuse biasAdd and relu, now it will try fusing the whole thing (if dropout is expressed via rand_like) and fall back every time.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16087

Differential Revision: D13720232

Pulled By: zou3519

fbshipit-source-id: 1e19203bec4a59257bfc7078b054a19f00fab4ad

5 years agodiscrepancy in smoke_macos_libtorch_2.7_cpu job spec (#17224)
Karl Ostmo [Tue, 19 Feb 2019 18:05:19 +0000 (10:05 -0800)]
discrepancy in smoke_macos_libtorch_2.7_cpu job spec (#17224)

Summary:
closes #17223
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17224

Reviewed By: pjh5

Differential Revision: D14121612

Pulled By: kostmo

fbshipit-source-id: bfd5a392de5e614031389725535756d7fa7db784

5 years agoBool tensor. Part 0: Boolean storage implementation (#16810)
Iurii Zdebskyi [Tue, 19 Feb 2019 16:17:49 +0000 (08:17 -0800)]
Bool tensor. Part 0: Boolean storage implementation (#16810)

Summary:
This is the first commit from a series of planned changes in order to add boolean tensors to PyTorch. The whole plan looks like this:

0. Storage Implementation (this change)
1. Tensor Creation.
2. Tensor Conversions.
3. Tensor Indexing.
4. Tensor Operations.
5. Back compatibility related changes.

This feature was requested by the community:
https://github.com/pytorch/pytorch/issues/4764
https://github.com/pytorch/pytorch/issues/4219
https://github.com/pytorch/pytorch/issues/4288

**Change**:
Added boolean type to the Storage class for CPU and CUDA backends.

**Tested via**:
1. unit tests
2. running this:
-> import torch
-> torch.BoolStorage
<class 'torch.BoolStorage'>
-> torch.cuda.BoolStorage
<class 'torch.cuda.BoolStorage'>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16810

Reviewed By: gchanan

Differential Revision: D14087246

Pulled By: izdeby

fbshipit-source-id: 042642ced1cb0fd1bb6bff05f9ca871a5c54ee5e

5 years agoCorrect padding and activations docstrings in nn module
ZhuBaohe [Tue, 19 Feb 2019 16:14:01 +0000 (08:14 -0800)]
Correct padding and activations docstrings in nn module

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17197

Differential Revision: D14131284

Pulled By: soumith

fbshipit-source-id: 6edd225b47b1dde81b5ad0a23c588c6621987a69

5 years agoUse move to avoid copying (#17188)
Michael Liu [Tue, 19 Feb 2019 15:11:27 +0000 (07:11 -0800)]
Use move to avoid copying (#17188)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17188

Using flag "-Wreturn-std-move", compiler can identify the cases where a copy
operation
is performed when a move operation would have been available. Wrapped return
statement with std::move to fix.

For some reason, these files are not automatically modded. With D14115372
we should be able to turn on the compile flag

Reviewed By: soumith

Differential Revision: D14115786

fbshipit-source-id: e763b92eecbe4468027fc141d029618d1e9f280b

5 years agoReplace resize_dim() with set_sizes_and_strides() (#17127)
Zhonghao Liu [Tue, 19 Feb 2019 15:01:37 +0000 (07:01 -0800)]
Replace resize_dim() with set_sizes_and_strides() (#17127)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17127

Replace resize_dim() with set_sizes_and_strides() in   `THTensor_(squeeze1d) in aten/src/TH/generic/THTensor.cpp`

Reviewed By: ezyang

Differential Revision: D14088697

fbshipit-source-id: 518b72f7c0c4fbedf11a29a6ceb9fee8eefd9273

5 years agoC++ Frontend: adding two distributed samples (Random and Sequential) (#16910)
Jaliya Ekanayake [Tue, 19 Feb 2019 13:38:01 +0000 (05:38 -0800)]
C++ Frontend: adding two distributed samples (Random and Sequential) (#16910)

Summary:
Adding two distrbuted samplers, Random and Sequential to the mix. Similar to python counterpart, DistributedSampler introduces a new method `set_epoch(size_t epoch)` which can be use to shuffle data determinstically between distributed processes.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16910

Differential Revision: D14130980

Pulled By: soumith

fbshipit-source-id: ec08b7130c01e2fc6dc3693f7ac622a0a6d60f10

5 years agoCorrect recurrent/linear/dropout/sparse layers docstrings
ZhuBaohe [Tue, 19 Feb 2019 13:17:23 +0000 (05:17 -0800)]
Correct recurrent/linear/dropout/sparse layers docstrings

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17238

Differential Revision: D14130811

Pulled By: soumith

fbshipit-source-id: d3998ca7da46aec5a59220c6af489f71f3d60735

5 years agoOptional arg fixes (#17222)
surgan12 [Tue, 19 Feb 2019 12:29:14 +0000 (04:29 -0800)]
Optional arg fixes (#17222)

Summary:
fixes #17210.
cc : ezyang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17222

Differential Revision: D14130833

Pulled By: soumith

fbshipit-source-id: 19ff6020c47208e3436ae28cd16110a0f435b25e

5 years agoReset grad attribute when called using del (#16525)
bhushan [Tue, 19 Feb 2019 12:24:45 +0000 (04:24 -0800)]
Reset grad attribute when called using del (#16525)

Summary:
del Tensor.grad set PyObject to nullptr
and Tensor.grad = None set PyObject to Py_None
Handling both the cases now
fixes ##16471
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16525

Differential Revision: D14130800

Pulled By: soumith

fbshipit-source-id: ed85c38305bba94d5047311cb58e4e4cedd09832

5 years agoLogging stuffs (#17177)
Ying Zhang [Sun, 17 Feb 2019 21:39:08 +0000 (13:39 -0800)]
Logging stuffs (#17177)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17177

Add more logging and flag.

Reviewed By: yinghai

Differential Revision: D14111643

fbshipit-source-id: 4b1c005faf41c21f59100bc401120c6970a24c42

5 years agoImplement IRParser. (#16987)
Mikhail Zolotukhin [Sun, 17 Feb 2019 04:18:54 +0000 (20:18 -0800)]
Implement IRParser. (#16987)

Summary:
It might need some cleaning up and might be missing some features, but it should be already working for most cases.

This PR is based on top of PR16986 (so please review only the last commit here).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16987

Differential Revision: D14074577

Pulled By: ZolotukhinM

fbshipit-source-id: 712b598f423265655f574bb9903e2066628eaad3

5 years agoSkip onnx logsoftmax tests in rocm (#17170)
Junjie Bai [Sun, 17 Feb 2019 02:00:10 +0000 (18:00 -0800)]
Skip onnx logsoftmax tests in rocm (#17170)

Summary:
similar to softmax there are issues of getting nan randomly
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17170

Differential Revision: D14110515

Pulled By: bddppq

fbshipit-source-id: 5c97661184d45a02122fd69d35a839fdf4520c8c

5 years agoAdd namedtuple return for min, median, mode, kthvalue, add test for namedtuple return...
Gao, Xiang [Sat, 16 Feb 2019 07:55:38 +0000 (23:55 -0800)]
Add namedtuple return for min, median, mode, kthvalue, add test for namedtuple return API (#16186)

Summary:
This partially fixes https://github.com/pytorch/pytorch/issues/394 and depend on https://github.com/pytorch/pytorch/pull/15429. I suggest to review this only after https://github.com/pytorch/pytorch/pull/15429 get landed, otherwise the diff might be large to review.

The test only allows explicitly whitelisted operators to have named return.

Differential Revision: D14070735

Pulled By: ezyang

fbshipit-source-id: ace2a672998b4e4a8094f52cbda5aa1cea6e3b42

5 years agoRemove templates for GenericDict
David Riazati [Sat, 16 Feb 2019 05:32:34 +0000 (21:32 -0800)]
Remove templates for GenericDict

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17175

Differential Revision: D14113022

Pulled By: driazati

fbshipit-source-id: 5183e131cc8ccb58525875f76fa03133570a59ea

5 years agofix missing constant in adaptive_avg_pool2d AD (#17180)
Ailing Zhang [Sat, 16 Feb 2019 05:11:49 +0000 (21:11 -0800)]
fix missing constant in adaptive_avg_pool2d AD (#17180)

Summary:
Thanks ngimel for pointing this out!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17180

Differential Revision: D14113001

Pulled By: ailzhang

fbshipit-source-id: 78e7d7f2cda3889138e2bf26a54980c2cc665882

5 years agoImplement NetDef <--> JIT IR converters. Try 2. (#17123)
Mikhail Zolotukhin [Sat, 16 Feb 2019 04:33:04 +0000 (20:33 -0800)]
Implement NetDef <--> JIT IR converters. Try 2. (#17123)

Summary:
Currently the converters are very straightforward, i.e. there is no code for trying to
preserve semantics, we're purely perform conversion from one format to another.

Two things that we might want to add/change:

1. Add semantic conversion as well (but probably it would be a good idea to keep
   it separate as a temporary thing).
2. Make sure we don't mess with value names, as they are crucial for current
   uses of NetDefs.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17123

Differential Revision: D14090244

Pulled By: ZolotukhinM

fbshipit-source-id: 07175fa9235582e1d1da5f10a42a5c1280b1b394

5 years agochange the epsilon for fp32/fp16 to uint8 to be the same (#17062)
Hector Yuen [Sat, 16 Feb 2019 02:28:03 +0000 (18:28 -0800)]
change the epsilon for fp32/fp16 to uint8 to be the same (#17062)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17062

from jiyan's training jobs it seems like we found a quantization bug

fp32
fp32->rowwise int8 is fine
fp16 is fine
fp16->rowwise int8 is not fine

we are preconverting everything to fp32 and using the existing code, so there is no need to change the epsilon in the case of fp16 since at the time of converting, everything is a float

Reviewed By: jspark1105

Differential Revision: D14063271

fbshipit-source-id: 747297d64ed8c6fdf4be5bb10ac584e1d21a85e6

5 years agoRevert D14109636: [pytorch][PR] move prim::None to a case in prim::Constant
Elias Ellison [Sat, 16 Feb 2019 00:35:23 +0000 (16:35 -0800)]
Revert D14109636: [pytorch][PR] move prim::None to a case in prim::Constant

Differential Revision:
D14109636

Original commit changeset: d26fd3839761

fbshipit-source-id: c8c8113e2bff49ea93235732603e6ebc89356533

5 years agomove prim::None to a case in prim::Constant (#16160)
Elias Ellison [Sat, 16 Feb 2019 00:12:44 +0000 (16:12 -0800)]
move prim::None to a case in prim::Constant (#16160)

Summary:
This change simplifies analysis done on constants since prim::None does not need to be handled separately now.  To check if a constant node is None, use node->isNone().

Next step will be to remove prim::Undefined.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16160

Differential Revision: D14109636

Pulled By: eellison

fbshipit-source-id: d26fd383976163a2ddd4c24984bd672a541cc876

5 years agoMove outplace ops to ATen (#16788)
Xiang Gao [Fri, 15 Feb 2019 23:54:50 +0000 (15:54 -0800)]
Move outplace ops to ATen (#16788)

Summary:
Based on https://github.com/pytorch/pytorch/pull/12413, with the following additional changes:

-  Inside `native_functions.yml` move those outplace operators right next to everyone's corresponding inplace operators for convenience of checking if they match when reviewing
- `matches_jit_signature: True` for them
- Add missing `scatter` with Scalar source
- Add missing `masked_fill` and `index_fill` with Tensor source.
- Add missing test for `scatter` with Scalar source
- Add missing test for `masked_fill` and `index_fill` with Tensor source by checking the gradient w.r.t source
- Add missing docs to `tensor.rst`

Differential Revision: D14069925

Pulled By: ezyang

fbshipit-source-id: bb3f0cb51cf6b756788dc4955667fead6e8796e5

5 years agoFix for 16939:multinomial performance regressed
Igor Fedan [Fri, 15 Feb 2019 23:33:37 +0000 (15:33 -0800)]
Fix for 16939:multinomial performance regressed

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17121

Differential Revision: D14088558

Pulled By: ifedan

fbshipit-source-id: e03583135f1e797fe1d8081ec5e9e6b63d4015c1

5 years agoAdd special ops for BatchNorm symbolic differentiation (#15403)
Adam Paszke [Fri, 15 Feb 2019 23:31:33 +0000 (15:31 -0800)]
Add special ops for BatchNorm symbolic differentiation (#15403)

Summary:
The main problem there is with differentiating batch norm statically
is that we make a lot of complex run-time decisions about the backend
we choose. Then, the autograd derivatives are implemented for every
backend separately, which makes sense, because they might be saving
buffers containing different values. To resolve the issue, the forward
op returns an index of the chosen backend, and the backward function
takes it as an argument, such that it knows how to interpret the buffers.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15403

Differential Revision: D14098815

Pulled By: ailzhang

fbshipit-source-id: 7fcd3e6e0566433e81fe8286fb441c1ecaf198ad

5 years agoimprove error msg when module list isn't added to __constants__ (#17167)
Elias Ellison [Fri, 15 Feb 2019 23:00:59 +0000 (15:00 -0800)]
improve error msg when module list isn't added to __constants__ (#17167)

Summary:
Add suggestion to add to __constants__ when a ModuleList of Sequential module is used as a tuple

Addresses https://github.com/pytorch/pytorch/issues/13899
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17167

Differential Revision: D14107688

Pulled By: eellison

fbshipit-source-id: 8c07d1f3e25a9c6bdcfd96dbf6b72c2130838278

5 years agoKaiming Initialization (#14718)
Josh Varty [Fri, 15 Feb 2019 22:51:56 +0000 (14:51 -0800)]
Kaiming Initialization (#14718)

Summary:
/cc goldsborough

Working on #14582

The corresponding python implementations are at: [pytorch/torch/nn/init.py](https://github.com/pytorch/pytorch/blob/6302e4001ab54b3ddeca2b608d337fe7077e801c/torch/nn/init.py#L261-L327)

Here is my initial implementation of Kaiming Initialization. I have not been able to figure out how to successfully run tests locally so I haven't added any yet.

A couple questions:
- Are the enums defined in the right place? I copied their names from Python, but do you prefer different naming conventions for C++?
- To run tests locally do I use `python setup.py test`? Can I run just a subset of the tests somehow?
- Should I add my tests at [test/cpp/api/misc.cpp](https://github.com/pytorch/pytorch/blob/master/test/cpp/api/misc.cpp#L47-L54)?
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14718

Differential Revision: D14049159

Pulled By: goldsborough

fbshipit-source-id: 966ac5126875936e69b185b5041f16476ed4cf70

5 years agoPass torch.distributed launch process local rank as environment variable instead...
Andy Wei [Fri, 15 Feb 2019 22:42:09 +0000 (14:42 -0800)]
Pass torch.distributed launch process local rank as environment variable instead of argument (#16360)

Summary:
In `torch.distributed.launch.py`, it passes `local_rank` as argument and requires user's program to parse it. However, it would be more flexible for users and consistent with other variables, e.g. `RANK`, `MASTER_PORT`, `WORLD_SIZE`, if passing through environment variables.

https://github.com/pytorch/pytorch/blob/265ed8ff451c17eac82050b1767837ec924d9591/torch/distributed/launch.py#L200-L212
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16360

Differential Revision: D14070372

Pulled By: ezyang

fbshipit-source-id: c3f6a8e55ab513918cad09d1326eccdedb4d98c9

5 years agoAssert cases exist for unschematized ops in alias analysis
David Riazati [Fri, 15 Feb 2019 22:22:37 +0000 (14:22 -0800)]
Assert cases exist for unschematized ops in alias analysis

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16334

Differential Revision: D13901238

Pulled By: driazati

fbshipit-source-id: be99f89e7dc6a299b770ea92e217932a5271027d

5 years agoFix avg pool2d api (#17166)
Ailing Zhang [Fri, 15 Feb 2019 21:50:10 +0000 (13:50 -0800)]
Fix avg pool2d api (#17166)

Summary:
Fix xla breakage (partially).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17166

Differential Revision: D14106954

Pulled By: ailzhang

fbshipit-source-id: 35ae6713272d0517b66da2ee9209f49015492b89

5 years agoFix syntax error in set instantiation (#17174)
Karl Ostmo [Fri, 15 Feb 2019 21:46:11 +0000 (13:46 -0800)]
Fix syntax error in set instantiation (#17174)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17174

Use curly braces syntax to avoid Lint complaint

Reviewed By: yf225

Differential Revision: D14111368

fbshipit-source-id: 44aa21deb9feededb94f23d92262a4164fe0cc1c

5 years agoMake getting the dtype of a tensor work for backend extensions.
Gregory Chanan [Fri, 15 Feb 2019 21:44:18 +0000 (13:44 -0800)]
Make getting the dtype of a tensor work for backend extensions.

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17131

Differential Revision: D14093163

Pulled By: gchanan

fbshipit-source-id: 06638706e26505e3c741b7ae290000ca258599db

5 years agoStop reassigning (output) reference arguments in BinaryOps. (#17059)
Gregory Chanan [Fri, 15 Feb 2019 21:38:22 +0000 (13:38 -0800)]
Stop reassigning (output) reference arguments in BinaryOps. (#17059)

Summary:
The binary ops that are using TensorIterator do a trick in order to only write the code once for out and non-out variants:

1) Have the non-out variant call the out variant with an undefined tensor.
2) the out variant then reassigns the result tensor to the output of the TensorIterator; this is a no-op in the case where a valid tensor was passed and it correctly propagates the result back to the non-out variant, which is legal because it's just reassigning an undefined tensor.

I believe other solutions to this problem would require an unnecessary reference bump, e.g. defining another out variant that returns a Tensor rather than a reference.

Unfortunately, this doesn't work with const-references, which we want to move our output arguments to be (because const doesn't actually provide const correctness here, and writers mistakenly reassign the parameter in the case it isn't an out variant).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17059

Differential Revision: D14068402

Pulled By: gchanan

fbshipit-source-id: 89fef177a1e174dbe2858e2eae0f6d85460b07d1

5 years agoFix batch insert (#17158)
Yinghai Lu [Fri, 15 Feb 2019 20:20:55 +0000 (12:20 -0800)]
Fix batch insert (#17158)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17158

Because of Reshape op, batch size can be changed. This diff addresses first order issue raised from multiple batch size system. We need to export different real_batch_size for different max_batch_size input and attach it to the right output.

It also fixes a false exception.

Reviewed By: ipiszy

Differential Revision: D14099541

fbshipit-source-id: 0fa9e86826f417a11d2b5dd2ee60dff64a7ce8c4

5 years agoGenerate CircleCI config.yml from a script (#17039)
Karl Ostmo [Fri, 15 Feb 2019 20:14:54 +0000 (12:14 -0800)]
Generate CircleCI config.yml from a script (#17039)

Summary:
This initial PR splits the `.circleci/config.yml` file into several smaller files that are stitched verbatim back into the original.  A proof of concept of dynamically generating yaml for the job configuration list is also introduced.

Since the `config.yml` file must exist in the repo in its final form, there must exist a manual update and check-in step to regenerate `config.yml` from its constituent parts.
Consistency between the checked-in `config.yml` file and the authoritative source data is enforced at build time through TravisCI.

closes #17038
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17039

Reviewed By: yf225

Differential Revision: D14109059

Pulled By: kostmo

fbshipit-source-id: bc04a73145290358854f5a5e552a45e559118fc3

5 years agoAdd support for simpler for-in-list + tests (#16726)
Nikolay Korovaiko [Fri, 15 Feb 2019 19:38:26 +0000 (11:38 -0800)]
Add support for simpler for-in-list + tests (#16726)

Summary:
This PR add supports for simpler for-in-list loops such as the example below:

```python
torch.ji.python
def sum_list(a):
    # type: (List[int]) -> int
    sum = 0
    for i in a:
        sum += i

    return sum
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16726

Differential Revision: D14070007

Pulled By: ezyang

fbshipit-source-id: b4d971ee647729a6caa3099ceac34ec5c4f143de

5 years agoUpdate pybind11 (#17143)
David Riazati [Fri, 15 Feb 2019 19:20:27 +0000 (11:20 -0800)]
Update pybind11 (#17143)

Summary:
Fixes #17130
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17143

Differential Revision: D14107386

Pulled By: zdevito

fbshipit-source-id: 1834d14bcdcad6857c199bf4fb8f67298394bbf3

5 years agoEnforce module device at DataParallel construction time (#17129)
Shen Li [Fri, 15 Feb 2019 19:09:12 +0000 (11:09 -0800)]
Enforce module device at DataParallel construction time (#17129)

Summary:
closes #17065

CC douwekiela
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17129

Differential Revision: D14093353

Pulled By: mrshenli

fbshipit-source-id: 9a5a10f16e392337a7f7073223541cf69b402f82

5 years agoone_hot docs missing (#17142)
Krishna [Fri, 15 Feb 2019 18:34:16 +0000 (10:34 -0800)]
one_hot docs missing (#17142)

Summary:
one_hot docs is missing [here](https://pytorch.org/docs/master/nn.html#one-hot).

I dug around and could not find a way to get this working properly.

Differential Revision: D14104414

Pulled By: zou3519

fbshipit-source-id: 3f45c8a0878409d218da167f13b253772f5cc963

5 years agoadd pop support to list (#17015)
Michael Kösel [Fri, 15 Feb 2019 18:25:37 +0000 (10:25 -0800)]
add pop support to list (#17015)

Summary:
[WIP] add "pop" to list, see https://github.com/pytorch/pytorch/issues/16662
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17015

Differential Revision: D14071680

Pulled By: eellison

fbshipit-source-id: b49a318059c1cc131acda50713132e11b562568f

5 years agoUpdating submodules
svcscm [Fri, 15 Feb 2019 18:25:06 +0000 (10:25 -0800)]
Updating submodules

Reviewed By: cdelahousse

fbshipit-source-id: bbfb709d8681da60ccc9f3bafc6c296c32fcf835

5 years agomerge fully_connected_rowwise_dnnlowp_op into fully_connected_dnnlowp_op (#17105)
Jongsoo Park [Fri, 15 Feb 2019 17:44:32 +0000 (09:44 -0800)]
merge fully_connected_rowwise_dnnlowp_op into fully_connected_dnnlowp_op (#17105)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17105

To make FC with rowwise quantization faster, reduce code duplication, and make code consistent with Convolution

Reviewed By: csummersea

Differential Revision: D14080461

fbshipit-source-id: 2b0e67b86e7e3029c90751a8824bf80ae1223680

5 years agobug fix when we prepack weight and bias together (#17145)
Jongsoo Park [Fri, 15 Feb 2019 17:17:53 +0000 (09:17 -0800)]
bug fix when we prepack weight and bias together (#17145)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17145

Prepacked weight contains both weight and bias, so the bias should be obtained from input index 1, not from 2

Reviewed By: jianyuh

Differential Revision: D14097281

fbshipit-source-id: b8b836b85a7b240e2fd1734377c46d9bf2ce3390

5 years agocaffe2: fix PinnedCPUAllocator cudaHostRegister() leak (#16340)
Brian W. Hart [Fri, 15 Feb 2019 14:51:23 +0000 (06:51 -0800)]
caffe2: fix PinnedCPUAllocator cudaHostRegister() leak (#16340)

Summary:
In the NUMA case, PinnedCPUAllocator's allocate() would return a
DataPtr constructed by DefaultCPUAllocator, which would reference
the Default... Delete() rather than the Pinned... Delete(). That
meant Pinned... Delete() would never run, so cudaHostUnregister()
would never be called when regions were freed.

See: https://github.com/pytorch/pytorch/issues/16280

This change adds a 'naked_allocate()' method to the Default allocator
that just returns a pointer to the allocated memory rather than
wrapping it in a DataPtr. Pinned allocator uses that then constructs
a DataPtr with reference to its own Delete().
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16340

Reviewed By: dzhulgakov

Differential Revision: D13843206

Pulled By: ezyang

fbshipit-source-id: 9efb572e5a01b49ef2a4aceeccc13cd0b1066528

5 years agoAdd some missing docs to torch.rst, new unittest to enforce torch.rst no longer miss...
Xiang Gao [Fri, 15 Feb 2019 14:44:56 +0000 (06:44 -0800)]
Add some missing docs to torch.rst, new unittest to enforce torch.rst no longer miss anything (#16039)

Summary:
This prevent people (reviewer, PR author) from forgetting adding things to `torch.rst`.

When something new is added to `_torch_doc.py` or `functional.py` but intentionally not in `torch.rst`, people should manually whitelist it in `test_docs_coverage.py`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16039

Differential Revision: D14070903

Pulled By: ezyang

fbshipit-source-id: 60f2a42eb5efe81be073ed64e54525d143eb643e

5 years ago(#16825)
Jie [Fri, 15 Feb 2019 14:44:49 +0000 (06:44 -0800)]
(#16825)

Summary:
setting the correct math type for cudnn rnn, which is enforced starting from cudnn 7.5+

1. Updating persistent rnn check with input data type instead of rnn math type;
2. Updating rnn type promotion to set correct math type for accumulation;
3. Replace datatype check for filter descriptor from rnn.datatype to input.datatype;
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16825

Differential Revision: D14071190

Pulled By: ezyang

fbshipit-source-id: 1c9a1531ccf510cb0619e830be444c20c5e72f3f

5 years agoCorrect conv and pooling docstrings in nn module (#17052)
ZhuBaohe [Fri, 15 Feb 2019 14:44:01 +0000 (06:44 -0800)]
Correct conv and pooling docstrings in nn module (#17052)

Summary:
This PR fix conv and pooling docstrings in nn module
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17052

Differential Revision: D14068566

Pulled By: ezyang

fbshipit-source-id: 3ec1de232ff6334b6a544dadefbb0ee6193d443a

5 years agoFix AdaptiveLogSoftmaxWithLoss's constructor (#16694)
wbydo [Fri, 15 Feb 2019 14:43:40 +0000 (06:43 -0800)]
Fix AdaptiveLogSoftmaxWithLoss's constructor (#16694)

Summary:
t-ken1 and I are members of a same team.
I have added test codes about the pull request https://github.com/pytorch/pytorch/pull/16656.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16694

Differential Revision: D14070106

Pulled By: ezyang

fbshipit-source-id: ff784dbf45e96a6bcf9a4b5cb9544a661a8acad2

5 years agoUpdate Upsample docs to match nn.interpolate
David Riazati [Fri, 15 Feb 2019 14:35:33 +0000 (06:35 -0800)]
Update Upsample docs to match nn.interpolate

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17134

Reviewed By: ezyang

Differential Revision: D14095694

Pulled By: driazati

fbshipit-source-id: 79afec9ddd50b3b8ce39acf98c2543cf1a3d1127

5 years agoRemove static_cast insertion/kernel argument extration. (#17055)
Johannes M Dieterich [Fri, 15 Feb 2019 09:45:17 +0000 (01:45 -0800)]
Remove static_cast insertion/kernel argument extration. (#17055)

Summary:
In light of the antistatic feature being a part of the released ROCm 2.1, remove
the feature in pyHIPIFY for extraction of kernel arguments and insertion of
static_casts.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17055

Differential Revision: D14068478

Pulled By: bddppq

fbshipit-source-id: 6895f490c78247a129aa18c520ff8d4d1a3d3642

5 years agoUpgrade mkl-dnn to v0.17.3 to fix core dump issue (#17107)
Gu, Jinghui [Fri, 15 Feb 2019 09:19:33 +0000 (01:19 -0800)]
Upgrade mkl-dnn to v0.17.3 to fix core dump issue (#17107)

Summary:
Upgrade mkl-dnn to 0.17.3 to fix core dump issue in #16183
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17107

Differential Revision: D14097600

Pulled By: yinghai

fbshipit-source-id: 2baa44e211ce37fbdf01585344c98745f5ba008c

5 years agoUpdated bbox_transform and nms unit test for caffe2 ops. (#16722)
Peizhao Zhang [Fri, 15 Feb 2019 08:14:45 +0000 (00:14 -0800)]
Updated bbox_transform and nms unit test for caffe2 ops. (#16722)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16722

Updated bbox_transform and nms unit test for caffe2 ops.

Differential Revision: D13937416

fbshipit-source-id: 034743d29671c6e73d323a935e2d734ecc071bff

5 years agoExtend support for exporting reshape to onnx. (#16971)
BowenBao [Fri, 15 Feb 2019 08:14:25 +0000 (00:14 -0800)]
Extend support for exporting reshape to onnx. (#16971)

Summary:
Resolve issue with reshape_as test case.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16971

Differential Revision: D14098871

Pulled By: houseroad

fbshipit-source-id: ed6b966821462d374313256abbbe27f96ce11b2c

5 years agoadd std to autodiff, and mean/var/std to operator set (#17137)
Wanchao Liang [Fri, 15 Feb 2019 07:15:53 +0000 (23:15 -0800)]
add std to autodiff, and mean/var/std to operator set (#17137)

Summary:
supersedes #16684
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17137

Differential Revision: D14096724

Pulled By: wanchaol

fbshipit-source-id: d801d70029a6a1f5851400ff4094c0299c102b2b

5 years agoScript module data parallel (#16891)
Guoqiang Jerry Chen [Fri, 15 Feb 2019 06:43:46 +0000 (22:43 -0800)]
Script module data parallel (#16891)

Summary:
support data parallel for ScriptModule.

see unit tests for testing done for this PR. I also tried traced version of resnet18 from torchvision.

I'm yet to try a complete end-to-end data parallel training. This will be next steps.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16891

Differential Revision: D14002222

Pulled By: gqchen

fbshipit-source-id: fce3598169113215599815c6978e66d3c3a8c282

5 years agoadd pre-packing operation in README.md (#17151)
Jongsoo Park [Fri, 15 Feb 2019 06:41:18 +0000 (22:41 -0800)]
add pre-packing operation in README.md (#17151)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17151

As title

Reviewed By: jianyuh

Differential Revision: D14084272

fbshipit-source-id: e58c041e0374f6e82b337e5b6325ef06981ad8b4

5 years agoMinor fix of the histogram observer in FBL eval flows (#17118)
Summer Deng [Fri, 15 Feb 2019 05:58:22 +0000 (21:58 -0800)]
Minor fix of the histogram observer in FBL eval flows (#17118)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17118

Fix the bug in quantization eval workflow; Add mul_nets option in histogram observer pybind

Reviewed By: yinghai

Differential Revision: D14085321

fbshipit-source-id: 08e3153148522ebc9512a57144d9a8ad154bb6f8

5 years agomore test coverage on emitIf none dispatch (#16794)
Wanchao Liang [Fri, 15 Feb 2019 05:37:08 +0000 (21:37 -0800)]
more test coverage on emitIf none dispatch (#16794)

Summary:
Follow up of #14533, add more test coverage for emitif metaprogramming conditions. Also delete some unwrap optional usage.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16794

Differential Revision: D14096868

Pulled By: wanchaol

fbshipit-source-id: ee1cec609c58d0dd65211249a90207be06649e71

5 years agoSpeed-up adaptive average pooling for the common case of size=1 output (#17011)
ngimel [Fri, 15 Feb 2019 05:11:30 +0000 (21:11 -0800)]
Speed-up adaptive average pooling for the common case of size=1 output (#17011)

Summary:
When adaptive pooling has to produce a single pixel feature map, it is faster to do so by calling .mean(). Backward calls a pretty inefficient cuda kernel with atomics, which becomes ridiculously slow for halfs. For half this PR provides approx 30x speed-up for adaptive average pooling, which results in 30% end-to-end speed-up on senet. Improvements are smaller for float, but still significant (approx 5x).
Also this PR unifies handling of 3d (no batch dimension) and 4d tensors, using negative dimension indices.
cc ezyang for review.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17011

Reviewed By: ailzhang

Differential Revision: D14078747

Pulled By: soumith

fbshipit-source-id: 0eb9255da2351190a6bcaf68c30e2ae2402a2dd9

5 years agoImprove example for torch.mode (#17069)
Thomas Viehmann [Fri, 15 Feb 2019 02:41:35 +0000 (18:41 -0800)]
Improve example for torch.mode (#17069)

Summary:
This updates the example for `torch.mode` to show a case where there is a mode.
Also add a bit of a description to the explanation as well as being a bit more precise about "a" mode rather than "the" mode.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17069

Differential Revision: D14078722

Pulled By: soumith

fbshipit-source-id: 837a238d53a9b8e868511acbdc258633975bea48

5 years agoCreate BackendTransformerBase to host common functions used for backend lowering...
Yinghai Lu [Fri, 15 Feb 2019 01:45:36 +0000 (17:45 -0800)]
Create BackendTransformerBase to host common functions used for backend lowering (#17074)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17074

There are some common functionalities in backend lowering. This diff creates a base class which hosts these common stuff.

Reviewed By: ipiszy

Differential Revision: D14073192

fbshipit-source-id: 9617603d0e73db6f7fcc5572756b9dbab506dae5

5 years agoFix android crash when model detects nothing
Zhizhen Qin [Fri, 15 Feb 2019 01:22:34 +0000 (17:22 -0800)]
Fix android crash when model detects nothing

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17119

Reviewed By: sf-wind

Differential Revision: D14087835

Pulled By: ZhizhenQin

fbshipit-source-id: 32e61d46679bae645fd0bbec724513cfa5c553ab

5 years agoFix some documentation links in torch.tensor (#17109)
kngwyu [Fri, 15 Feb 2019 01:07:12 +0000 (17:07 -0800)]
Fix some documentation links in torch.tensor (#17109)

Summary:
Currently it's broken https://pytorch.org/docs/stable/tensors.html#torch.Tensor.norm
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17109

Differential Revision: D14093567

Pulled By: ezyang

fbshipit-source-id: b167cde2150ee97ccf5689fcf50ff8157acfce10

5 years agoApply modernize-use-override (2nd iteration)
Michael Liu [Fri, 15 Feb 2019 00:21:50 +0000 (16:21 -0800)]
Apply modernize-use-override (2nd iteration)

Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: Orvid

Differential Revision: D14086124

fbshipit-source-id: 2005227d095d776ca3b4309a57f54e25782b9b58

5 years agoGeneralize catArray for contiguous inputs and dim != 0 (#17032)
James Reed [Thu, 14 Feb 2019 23:58:06 +0000 (15:58 -0800)]
Generalize catArray for contiguous inputs and dim != 0 (#17032)

Summary:
I noticed that we were sinking a lot of time into `cat` operations in machine translation on CPU, and drilled down to us doing the cat element-by-element, even though all the inputs were contiguous. The reason was we were doing the cat along a dimension that was not 0, and that caused us to not use the fast `memcpy` branch. This PR generalizes that branch.

Quick benchmark script:
```
import torch, time

tensors = [torch.rand(6, 2, 1024) for i in range(5)]

NITER = 1000
s = time.time()
for i in range(NITER):
    torch.cat(tensors, dim=1)
print('time per iter ', (time.time() - s) / NITER)
```

Before:
```
time per iter  8.089399337768554e-05
```

After:
```
time per iter  2.183413505554199e-05
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17032

Differential Revision: D14090038

Pulled By: jamesr66a

fbshipit-source-id: 2c733a84915896008ac95f2233f44894bd2573de

5 years agofix test_jit canonicalize_tensor_iterator
Wanchao Liang [Thu, 14 Feb 2019 23:37:42 +0000 (15:37 -0800)]
fix test_jit canonicalize_tensor_iterator

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17104

Differential Revision: D14089928

Pulled By: wanchaol

fbshipit-source-id: 8b288514ab9ee8d24a11d39b75eef95783f28f20

5 years agoUse new constructor in USE_SIMPLE_CTOR_DTOR (#17080)
Sebastian Messmer [Thu, 14 Feb 2019 23:06:53 +0000 (15:06 -0800)]
Use new constructor in USE_SIMPLE_CTOR_DTOR (#17080)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17080

This changes all operators using this macro to the new format

Reviewed By: dzhulgakov

Differential Revision: D14078628

fbshipit-source-id: 67048e485e326765fd49567cc008633d3d500d5c

5 years agoCaffe2 TARGETS for HIP (#17076)
Xiaodong Wang [Thu, 14 Feb 2019 23:02:56 +0000 (15:02 -0800)]
Caffe2 TARGETS for HIP (#17076)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17076

OSS: slightely change the tools/amd_build/build_amd.py to add the output_directory for internal use. Also modify the renaming convention in hipify script to reflect the updated rules.

Reviewed By: bddppq

Differential Revision: D13767218

fbshipit-source-id: cbcadc51daab42197d545f204840dcc18176bb3d

5 years agomaskrcnn & bert AD coverage part 1 (#16689)
Ailing Zhang [Thu, 14 Feb 2019 22:55:44 +0000 (14:55 -0800)]
maskrcnn & bert AD coverage part 1 (#16689)

Summary:
- Moved a few functions from `autograd` namespace to `aten` namespace to be visible from JIT nativeResolver.
- Added a hack to loop up keyword only argument. Will add proper support for kw only later
- Simulate function overload in aten using `_<number>` as function name suffix.
- Even `forward` returns multiple outputs like in `kthvalue`, there's at most one requires grad that we currently support.
- Removed the `TensorList` related ops here since partial `TensorList` support is prone to bugs. Our symbolic diff for `cat` was never tested with autodiff, and it seems broken. Need to find another proper way to support these ops(either by properly supporting `TensorList` or sth like `prim::ConstantChunk`  and leave them for next PR.

Ops supported in this PR:
```
erf
expand_as
index
kthvalue
mean
permute
pow
rsub
select
sqrt
squeeze
t
to
topk
transpose
view
var
embedding
logsumexp
// grad is None
_dim_arange
contiguous
nonzero
ones_like
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16689

Differential Revision: D14020806

Pulled By: ailzhang

fbshipit-source-id: a5e2c144a7be5a0d39d7ac5f93cb402ec12503a5

5 years agoSecond PR to restore reverted commit (#16224) (#17040)
jiej [Thu, 14 Feb 2019 22:40:13 +0000 (14:40 -0800)]
Second PR to restore reverted commit (#16224) (#17040)

Summary:
update:
  1. global_reduce check for should_block_y_reduce first.
     This avoids the enabling global_reduce without block_y_reduce. Leading to
     accessing shared memory during global reduce without allocation.
  2. updating block_y_reduce heuristics. Improves perf on tiny tensors
  3. adding test case covering old cases where illegal memory access might occur

  TensorIterator cuda launch configs update (#16224)
    Update launch configs for TensorIterator gpu_reduce_kernel. Enable flexible
    block dimension to improve efficiency for reduction cases with small fast
    dimension.

    Previously TensorIterator launches blocks with fixed 32x16 threads.
    For cases like:

      import torch
      torch.randn(2**20, 4, device='cuda').sum(0)

    The fixed launch config does handle coalesced memory access efficiently.

    Updated launch configure enables flexible block dimension. Combining with
    improved reduction scheme (using flexible vertical / horizontal reduction
    instead of limited warp / block reduction in the old code), it ensures optimal
    memory access pattern even with reduction on dimension with small stride.

    Possible future improvements:
    1. Precise dynamic shared memory allocation.
    2. Using warp shuffle for vertical (block_y) reduction.
    Pull Request resolved: https://github.com/pytorch/pytorch/pull/16224
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17040

Differential Revision: D14078295

Pulled By: umanwizard

fbshipit-source-id: ecc55054a5a4035e731f0196d633412225c3b06c

5 years agoRemove fake inference for shape info in ONNXIFI transform (#17046)
Yinghai Lu [Thu, 14 Feb 2019 22:22:51 +0000 (14:22 -0800)]
Remove fake inference for shape info in ONNXIFI transform (#17046)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17046

As we are moving to use bound shape inference, we can remove the awkward fake inference run path and make the code cleaner.

Reviewed By: ipiszy

Differential Revision: D14061501

fbshipit-source-id: b3ace98b3dabef3c3359086a0bb1410518cefa26

5 years agoUpdate alexnet expect.
Gregory Chanan [Thu, 14 Feb 2019 21:45:04 +0000 (13:45 -0800)]
Update alexnet expect.

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17122

Reviewed By: colesbury

Differential Revision: D14090209

Pulled By: gchanan

fbshipit-source-id: 78c5961dd7d752b237782b6ed90c376bbd6d3145

5 years agoadd clear functionality to list (#17050)
Michael Kösel [Thu, 14 Feb 2019 21:42:27 +0000 (13:42 -0800)]
add clear functionality to list (#17050)

Summary:
Add clear functionality to list. See #16662

```python
import torch

torch.jit.script
def foo():
    a = [1, 2, 3, 4]
a.clear()

    return a
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17050

Differential Revision: D14071799

Pulled By: driazati

fbshipit-source-id: 305551c16f7db127c43de0ad5885d9f10678e101

5 years agoModerate the dim type after LengthsRangeFill (#17096)
Yinghai Lu [Thu, 14 Feb 2019 21:33:52 +0000 (13:33 -0800)]
Moderate the dim type after LengthsRangeFill (#17096)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17096

LengthsRangeFill will take a batch size of lengths input and expand it into sequence. Later op should follow this type until it hits another batch type moderating op, e.g. SparseLengthsSum.

Reviewed By: ipiszy

Differential Revision: D14079422

fbshipit-source-id: 1a26925d502c32875ea95c160268bf6a256cc955

5 years agofix behavior of ConcatDataset w/ negative indices (#15756)
jayleverett [Thu, 14 Feb 2019 19:46:55 +0000 (11:46 -0800)]
fix behavior of ConcatDataset w/ negative indices (#15756)

Summary:
Currently, when you pass a negative index to a `Dataset` created with `ConcatDataset`, it simply passes that index to the first dataset in the list. So if, for example, we took `concatenated_dataset[-1]`, this will give us the last entry of the *first* dataset, rather than the last entry of the *last* dataset, as we would expect.

This is a simple fix to support the expected behavior for negative indices.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15756

Reviewed By: ezyang

Differential Revision: D14081811

Pulled By: fmassa

fbshipit-source-id: a7783fd3fd9e1a8c00fd076c4978ca39ad5a8a2a

5 years agoAdd support of count_include_pad and test end to end test for AveragePool (#17034)
Dwarak Rajagopal [Thu, 14 Feb 2019 18:28:25 +0000 (10:28 -0800)]
Add support of count_include_pad and test end to end test for AveragePool (#17034)

Summary:
Add support of count_include_pad end to end test for AveragePool

We can export AveragePool from PyTorch with count_include_pad attribute. However, we don't directly support it in Caffe2's ONNX backend.
We also want to check whether we can pass the end to end test for average pool operator with count_include_pad attribute (pytorch => onnx => caffe2)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17034

Reviewed By: houseroad

Differential Revision: D14060186

Pulled By: dwarakrajagopal

fbshipit-source-id: 10dae532611c71f8c8cfc3fa701cc7c1c1c02695

5 years agoSupport nonzero onnx export
BowenBao [Thu, 14 Feb 2019 07:43:14 +0000 (23:43 -0800)]
Support nonzero onnx export

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17036

Differential Revision: D14079676

Pulled By: houseroad

fbshipit-source-id: 562b538dd9ab330c26f15fdb34c98dc7a23571a1

5 years agoAdd more headers to setup.py to make pytorch/benchmark work (#16890)
Dmytro Dzhulgakov [Thu, 14 Feb 2019 06:53:56 +0000 (22:53 -0800)]
Add more headers to setup.py to make pytorch/benchmark work (#16890)

Summary:
Since we don't do tmp_install any more it's better to include all necessary headers.

cc kostmo for better suggestions of how to list all headers here
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16890

Differential Revision: D14079848

Pulled By: dzhulgakov

fbshipit-source-id: 4522c80d05e5d91f99f6700cde46cac559330d28

5 years agoClean up Storage/StorageImpl constructors (#16948)
Dmytro Dzhulgakov [Thu, 14 Feb 2019 06:38:24 +0000 (22:38 -0800)]
Clean up Storage/StorageImpl constructors (#16948)

Summary:
Small cleanup while doing https://github.com/pytorch/pytorch/pull/16857:

- rename C2 constructors as create_legacy
- remove duplicated constructors
- make resizable flag non-default
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16948

Differential Revision: D14062755

Pulled By: dzhulgakov

fbshipit-source-id: 3b7b4ec9cdf67d2628cccc001156e040006b673e

5 years agoSafety check for negative alloc_cpu() attempt (#17071)
Dmytro Dzhulgakov [Thu, 14 Feb 2019 06:18:27 +0000 (22:18 -0800)]
Safety check for negative alloc_cpu() attempt (#17071)

Summary:
Some legacy TH code was relying on alloc to throw when called with negative number!!! E.g. `torch.linspace(0, 1, -1)`. And it breaks ASAN build. I still believe alloc should receive size_t, but I added a safety enforce inside.

It should fix ASAN. I'll follow up with a proper fix for empty_cpu (which is probably the right place to do it) separately
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17071

Differential Revision: D14074157

Pulled By: dzhulgakov

fbshipit-source-id: 3ed3bdb873e446edecb558e1df491310fd7179e3

5 years agoUpdating submodules
svcscm [Thu, 14 Feb 2019 05:38:37 +0000 (21:38 -0800)]
Updating submodules

Reviewed By: cdelahousse

fbshipit-source-id: b4e7a3850b01bbec56faa3eb0feb3bc6197c0393

5 years agoApply modernize-use-override - 2/2
Michael Liu [Thu, 14 Feb 2019 04:51:55 +0000 (20:51 -0800)]
Apply modernize-use-override - 2/2

Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: Orvid

Differential Revision: D14054721

fbshipit-source-id: 15d266fa1779b1e3ea6270f00841d7fb1e4d44ee

5 years agoUpdating submodules
svcscm [Thu, 14 Feb 2019 04:49:07 +0000 (20:49 -0800)]
Updating submodules

Reviewed By: cdelahousse

fbshipit-source-id: 5d9763a6f26ba53c6402b978004aaa7508f4e354

5 years ago#16627 convert weights using torch.as_tensor to avoid warning (#17067)
ptrblck [Thu, 14 Feb 2019 04:42:45 +0000 (20:42 -0800)]
#16627 convert weights using torch.as_tensor to avoid warning (#17067)

Summary:
Minor change which fixes #16627
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17067

Differential Revision: D14078726

Pulled By: soumith

fbshipit-source-id: c04a5f1eff44e4a4b04b981f0ae8de6ff018515b

5 years agoUpdating submodules
svcscm [Thu, 14 Feb 2019 04:26:10 +0000 (20:26 -0800)]
Updating submodules

Reviewed By: cdelahousse

fbshipit-source-id: e074a865b859fd72b34b012505dfbd3a27a0cc41

5 years agoRevert D14062537: [pytorch][PR] Implement NetDef <--> JIT IR converters.
Edward Yang [Thu, 14 Feb 2019 04:21:06 +0000 (20:21 -0800)]
Revert D14062537: [pytorch][PR] Implement NetDef <--> JIT IR converters.

Differential Revision:
D14062537

Original commit changeset: 88b184ee7276

fbshipit-source-id: 01971bbe20daade40cc2cbf85fc08edb380b445c

5 years agoPyTorch model metadata. (#16275)
Pritam Damania [Thu, 14 Feb 2019 03:41:25 +0000 (19:41 -0800)]
PyTorch model metadata. (#16275)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16275

Adding a generic string `metadata` field as part of the model to capture additional metadata with the model.

Reviewed By: dzhulgakov

Differential Revision: D13579029

fbshipit-source-id: 7456ef2edbe73bb70bbb31889cecd94e0db329a2

5 years agoTrim libshm deps, move tempfile.h to c10 (#17019)
Dmytro Dzhulgakov [Thu, 14 Feb 2019 03:28:05 +0000 (19:28 -0800)]
Trim libshm deps, move tempfile.h to c10 (#17019)

Summary:
libshm_manager doesn't need to depend on all of libtorch. It only uses tiny tempfile.h which can be moved to c10. I could just duplicate the file too, but it's not worth it as c10 is small enough.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17019

Differential Revision: D14052688

Pulled By: dzhulgakov

fbshipit-source-id: 8797d15f8c7c49c49d40b7ab2f43aa3bf6becb0c