platform/upstream/pytorch.git
5 years agoImplement rotated generate_proposals_op without opencv dependency (CPU version)
Jing Huang [Thu, 28 Mar 2019 23:58:54 +0000 (16:58 -0700)]
Implement rotated generate_proposals_op without opencv dependency (CPU version)

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

Reviewed By: ezyang

Differential Revision: D14648083

fbshipit-source-id: e53e8f537100862f8015c4efa4efe4d387cef551

5 years agoUse SetOutputTensor instead of copying outputs manually (#17770)
Ahmed Aly [Thu, 28 Mar 2019 22:58:24 +0000 (15:58 -0700)]
Use SetOutputTensor instead of copying outputs manually (#17770)

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

As title

Reviewed By: dzhulgakov

Differential Revision: D14370937

fbshipit-source-id: f415490c38556cf03bb13dce3643775331483448

5 years agoFix NCCL/Gloo process groups and DDP stream sync bug (#18465)
Shen Li [Thu, 28 Mar 2019 22:05:53 +0000 (15:05 -0700)]
Fix NCCL/Gloo process groups and DDP stream sync bug (#18465)

Summary:
DDP with NCCL backend uses a [worker stream](https://github.com/pytorch/pytorch/blob/d3eb941ed96774efb8d89a0b20c9e49807ea85a7/torch/csrc/distributed/c10d/ddp.cpp#L142) to flatten grand batch
tensors, and passes the flattened tensor to [another stream](https://github.com/pytorch/pytorch/blob/d3eb941ed96774efb8d89a0b20c9e49807ea85a7/torch/lib/c10d/ProcessGroupNCCL.cpp#L379) to
conduct ncclAllReduce. The flattened tensor has to record the
ncclAllReduce stream, otherwise multiple streams might access the
same memory space.

cc ppwwyyxx
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18465

Differential Revision: D14613449

Pulled By: mrshenli

fbshipit-source-id: b62773732552d12cc87b7adeb6897e9e11753ea9

5 years agoInference LSTM integration test (#18559)
Ahmed Aly [Thu, 28 Mar 2019 18:23:22 +0000 (11:23 -0700)]
Inference LSTM integration test (#18559)

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

Adding integration test for inference LSTM

Reviewed By: houseroad

Differential Revision: D14656698

fbshipit-source-id: 80fb2a72be30fcb695f4471b72bf9d6e3965bf81

5 years agoAdd Slot type to abstract the raw pointers being used for slots. (#18226)
Zachary DeVito [Thu, 28 Mar 2019 17:31:45 +0000 (10:31 -0700)]
Add Slot type to abstract the raw pointers being used for slots. (#18226)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18226
ghimport-source-id: b9ec8651212875b30971cc6859d2ddec6559ae3a

If modules become first-class IValues, then the slots will no longer be raw pointers but (IValue, index) pairs. This commit inserts the Slot abstraction so that this change can be made in later patches.

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18226 Add Slot type to abstract the raw pointers being used for slots.**

Differential Revision: D14542022

fbshipit-source-id: b81d7f4334c983d663e7551bda82df43680d7c5f

5 years agoRevert D14635130: Improved onnx export for 3 onnx ops.
Junjie Bai [Thu, 28 Mar 2019 17:18:46 +0000 (10:18 -0700)]
Revert D14635130: Improved onnx export for 3 onnx ops.

Differential Revision:
D14635130

Original commit changeset: d54a2b6e2950

fbshipit-source-id: f624e2befdde245cb88435a95508b2a8e6b12e61

5 years agoImproved onnx export for 3 onnx ops. (#18512)
Benoit Steiner [Thu, 28 Mar 2019 15:52:01 +0000 (08:52 -0700)]
Improved onnx export for 3 onnx ops. (#18512)

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

Ceil and Floor have been supported since version 6 of ONNX: export them using the native onnx ops instead of an Aten op.
Similarly, support for the Where op has been added in version 9, so we don't need to wrap these op in an Aten op.

Reviewed By: houseroad

Differential Revision: D14635130

fbshipit-source-id: d54a2b6e295074a6214b5939b21051a6735c9958

5 years agoRevert D14652372: [pytorch][PR] Add parsing to file check
Elias Ellison [Thu, 28 Mar 2019 07:09:36 +0000 (00:09 -0700)]
Revert D14652372: [pytorch][PR] Add parsing to file check

Differential Revision:
D14652372

Original commit changeset: 7430b9d1dc2b

fbshipit-source-id: fa3d0f68515fe53447746469844d2db20c1292e0

5 years agoC++17.h: forward -> c10::guts::forward (#18492)
Ilia Cherniavskii [Thu, 28 Mar 2019 04:07:36 +0000 (21:07 -0700)]
C++17.h: forward -> c10::guts::forward (#18492)

Summary:
Use c10::guts::forward instead of forward
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18492

Reviewed By: smessmer

Differential Revision: D14625513

Pulled By: ilia-cher

fbshipit-source-id: 8bc4e20f102fe2a107a22f3e172882d60b95ab0e

5 years agoUse __ldg for CUDA kernels in fuser (#18540)
Thomas Viehmann [Thu, 28 Mar 2019 03:17:01 +0000 (20:17 -0700)]
Use __ldg for CUDA kernels in fuser (#18540)

Summary:
While benchmarking a kernel with broadcasted inputs, I noticed
that is was much slower than a hand-coded kernel for the smae task.

The kernel in question computed a * b + c for a of shape
32 x 32 x 10240 and b and c of shape 1 x 32 x 1.

This patch accellerates said kernel from 450us to 250us on my GTX1080Ti.

I didn't change half because there doesn't seem to be __ldg for
half.

An alternative could be to sprinkle const and restrict.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18540

Differential Revision: D14657840

Pulled By: soumith

fbshipit-source-id: 408847346ec12d1d1d9b119ac50bbc70f0d9ed33

5 years agoAdds Cyclical Learning Rate and Momentum (#18001)
Sam Pepose [Thu, 28 Mar 2019 02:47:43 +0000 (19:47 -0700)]
Adds Cyclical Learning Rate and Momentum (#18001)

Summary:
This implements a cyclical learning rate (CLR) schedule with an optional inverse cyclical momentum. More info about CLR: https://github.com/bckenstler/CLR

This is finishing what #2016 started. Resolves #1909.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18001

Differential Revision: D14451845

Pulled By: sampepose

fbshipit-source-id: 8f682e0c3dee3a73bd2b14cc93fcf5f0e836b8c9

5 years agoCompletely synchronize behavior of Facebook flake8 and public flake8. (#18538)
Edward Yang [Thu, 28 Mar 2019 02:46:23 +0000 (19:46 -0700)]
Completely synchronize behavior of Facebook flake8 and public flake8. (#18538)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18538
ghimport-source-id: 665b09f158d1c5dd94686d4212792504b55b7f73

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18538 Completely synchronize behavior of Facebook flake8 and public flake8.**

Previously, developers at Facebook had the very funny experience
wherein /usr/local/bin/flake8 behaved differently than a freshly
installed flake8 from pip.  In this commit, I add enough ignores to
.flake8 and install enough plugins to make the Facebook flake8
and public flake8 line up exactly.  These means you don't have
to care which flake8 you use; they all will report accurate information
on your Python files.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14652336

fbshipit-source-id: ba7776eaa139cf2e3df2e65349da6fd7c99acca4

5 years agoadd slow tests annotation to some jit tests (#18545)
Elias Ellison [Thu, 28 Mar 2019 02:21:32 +0000 (19:21 -0700)]
add slow tests annotation to some jit tests (#18545)

Summary:
Adds slow test annotation to the following very slow tests -

70.33s     test/test_jit.py::TestScript::test_script_module_script_resnet
32.33s     test/test_jit.py::TestBatched::test_beam_search
17.70s     test/test_jit.py::TestBatched::test_greedy_search
15.58s     test/test_jit.py::TestScript::test_script_module_trace_resnet18

The list of remaining slow tests is below. Let me know if you think any of the others should be added to slow tests as well. Slow tests will only run on master.

15.28s call     test/test_jit.py::TestJit::test_export_batchnorm
12.96s call     test/test_jit.py::TestEndToEndHybridFrontendModels::test_snli
11.65s call     test/test_jit.py::TestEndToEndHybridFrontendModels::test_neural_style
6.38s call     test/test_jit.py::TestJitGeneratedModule::test_nn_LocalResponseNorm_1d
5.96s call     test/test_jit.py::TestJitGeneratedModule::test_nn_LocalResponseNorm_2d_uneven_pad
5.91s call     test/test_jit.py::TestJitGeneratedModule::test_nn_LocalResponseNorm_3d_custom_params
4.76s call     test/test_jit.py::TestJit::test_alexnet
3.82s call     test/test_jit.py::TestScript::test_number_math
3.81s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_no_bias
3.76s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_groups_thnn
3.65s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_stride_pad1circular
3.49s call     test/test_jit.py::TestBatched::test_lstm
3.33s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_pad2circular
3.19s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv1d_stride1_pad2circular
3.11s call     test/test_jit.py::TestEndToEndHybridFrontendModels::test_dcgan_models
3.11s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_stride_padding
3.11s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_stride
3.08s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_no_bias
3.08s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv1d_stride1_pad1circular
3.07s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_groups
3.05s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_dilated
3.05s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_depthwise_with_multiplier
3.04s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_groups
3.03s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_dilated
3.02s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv2d_depthwise_dilated
3.02s call     test/test_jit.py::TestJitGeneratedModule::test_nn_Conv3d_dilated_strided
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18545

Differential Revision: D14656064

Pulled By: eellison

fbshipit-source-id: d17ee23c3b3679276cee983555d43e83ce099356

5 years agoAdd parsing to file check (#18304)
Elias Ellison [Thu, 28 Mar 2019 01:11:45 +0000 (18:11 -0700)]
Add parsing to file check (#18304)

Summary:
This allows you to embed checks in IR, making the test more readable.

E.g.
```
graph_str = 'graph(%0 : Double(5, 5)):
          # CHECK: aten::relu
          %1 : Double(5, 5) = aten::relu(%0)
          return (%1)'
FileCheck().run(graph_str, parseIR(graph_str))
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18304

Differential Revision: D14652372

Pulled By: eellison

fbshipit-source-id: 7430b9d1dc2b7584704375aac02d7392ecec76a0

5 years agobug fix for node with writers in create autodiff subgraph (#18491)
Elias Ellison [Wed, 27 Mar 2019 23:02:10 +0000 (16:02 -0700)]
bug fix for node with writers in create autodiff subgraph (#18491)

Summary:
Previously we were moving nodes with writers into differentiable subgraphs, without necessarily preserving whether or not they were written to. This can lead to bugs with CSE, which needs that context.

I'm not completely sure if there's anything else we can do to be more aggresive here - inline these nodes and not run CSE and just run constant pooling, or possibly something else, but I think we should land this correctness condition first and then possibly think further.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18491

Differential Revision: D14648562

Pulled By: eellison

fbshipit-source-id: bc1e444774ccdb708e22f0e06a477a221a231f9e

5 years agoadd extra info for the auto gen sum ops
Xianjie Chen [Wed, 27 Mar 2019 21:52:13 +0000 (14:52 -0700)]
add extra info for the auto gen sum ops

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

Reviewed By: iroot900

Differential Revision: D14418689

fbshipit-source-id: 9e11e461001467f0000ea7c355d5b0f0d738fa85

5 years agoClarify error text of the pin_memory function
Vitaly Fedyunin [Wed, 27 Mar 2019 21:44:00 +0000 (14:44 -0700)]
Clarify error text of the pin_memory function

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

Reviewed By: ezyang

Differential Revision: D14647578

Pulled By: VitalyFedyunin

fbshipit-source-id: ddd70240d52d2e9a96e26f5a0dfea8d76fe25078

5 years agoMove fast rnn benchmark to pytorch/pytorch
Wanchao Liang [Wed, 27 Mar 2019 21:39:33 +0000 (14:39 -0700)]
Move fast rnn benchmark to pytorch/pytorch

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

Differential Revision: D14652039

Pulled By: wanchaol

fbshipit-source-id: 1177b1f60d96672c3e2c9d527b56ee06ca7c0af1

5 years agoRename isTensor api -> isCompleteTensor (#18437)
eellison [Wed, 27 Mar 2019 21:29:45 +0000 (14:29 -0700)]
Rename isTensor api -> isCompleteTensor (#18437)

Summary:
Is Tensor has been brought up as misleading a couple times, rename it isCompleteTensor for clarity.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18437

Differential Revision: D14605223

Pulled By: eellison

fbshipit-source-id: 189f67f12cbecd76516a04e67d8145c260c79036

5 years agoConst trace error v2 (#18535)
Elias Ellison [Wed, 27 Mar 2019 21:28:11 +0000 (14:28 -0700)]
Const trace error v2 (#18535)

Summary:
Trying to reland https://github.com/pytorch/pytorch/pull/18298
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18535

Differential Revision: D14652391

Pulled By: eellison

fbshipit-source-id: 699e30045dd5f14f0a2b98378272045a292e1e2a

5 years agoenable more unit tests (#18537)
jithunnair-amd [Wed, 27 Mar 2019 21:16:01 +0000 (14:16 -0700)]
enable more unit tests (#18537)

Summary:
Enable unit tests working with ROCm 2.3. In particular, these are unit tests where we skipped for double data types previously and some tests for multi-GPU setups.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18537

Differential Revision: D14651822

Pulled By: ezyang

fbshipit-source-id: 7dd575504ebe235a91489866c91000e9754b1235

5 years agoSkip tests if C2/ONNX models cannot be read (#18494)
Min Ni [Wed, 27 Mar 2019 18:14:32 +0000 (11:14 -0700)]
Skip tests if C2/ONNX models cannot be read (#18494)

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

Today we have some C2 end2end test run requiring reading model data from external filesystem (for example, Gluster and AWS). This could be a source for flaky test when the external filesystems are not reachable during the tests.

In this diff, we add try/catch logic around where we download models and open model files from external system. In case such attempts fails, we will catch the excption and let the unittest skip the current test instead of failure.

I also refactor the code a little bit by removing some duplicated logic on downloading and build the c2 model data. It has been duplicated in two classes and a few functions...

Reviewed By: yinghai

Differential Revision: D14442241

fbshipit-source-id: da8bf56c8d096efa34ca2070de5cd10a18aad70c

5 years agoAdd qtensors in caffe2 protobuf argument (#18486)
zrphercule [Wed, 27 Mar 2019 18:11:01 +0000 (11:11 -0700)]
Add qtensors in caffe2 protobuf argument (#18486)

Summary:
We are about to merge onnxifi quantization support soon. Before that, I would like to merge this diff seperately to make sure it doesnt break anything.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18486

Reviewed By: bddppq, houseroad

Differential Revision: D14626419

Pulled By: yinghai

fbshipit-source-id: 504c1eae60be1e629203267b59defb8b69d82c0a

5 years agoGenerate sphinx docs with secure content. (#18508)
Paul O’Shannessy [Wed, 27 Mar 2019 17:55:12 +0000 (10:55 -0700)]
Generate sphinx docs with secure content. (#18508)

Summary:
There are a number of pages in the docs that serve insecure content. AFAICT this is the sole source of that.

I wasn't sure if docs get regenerated for old versions as part of the automation, or if those would need to be manually done.

cf. https://github.com/pytorch/pytorch.github.io/pull/177
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18508

Differential Revision: D14645665

Pulled By: zpao

fbshipit-source-id: 003563b06048485d4f539feb1675fc80bab47c1b

5 years agoFix loss functions doc (#18420)
ZhuBaohe [Wed, 27 Mar 2019 17:15:20 +0000 (10:15 -0700)]
Fix loss functions doc (#18420)

Summary:
Correct docstring display error on web page caused by my previous PR
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18420

Differential Revision: D14642467

Pulled By: soumith

fbshipit-source-id: 16fdd3301a4c5bad27fbcd8686f7fbfcc1e908ee

5 years agoUpgrade flake8-bugbear to master, fix the new lints. (#18507)
Edward Yang [Wed, 27 Mar 2019 15:01:15 +0000 (08:01 -0700)]
Upgrade flake8-bugbear to master, fix the new lints. (#18507)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18507
ghimport-source-id: 1c3642befad2da78a7e5f39d6d58732b85c76267

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18507 Upgrade flake8-bugbear to master, fix the new lints.**

It turns out Facebobok is internally using the unreleased master
flake8-bugbear, so upgrading it grabs a few more lints that Phabricator
was complaining about but we didn't get in open source.

A few of the getattr sites that I fixed look very suspicious (they're
written as if Python were a lazy language), but I didn't look more
closely into the matter.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14633682

fbshipit-source-id: fc3f97c87dca40bbda943a1d1061953490dbacf8

5 years agoAdd export annotations for functions in c10 (#18464)
peter [Wed, 27 Mar 2019 14:55:48 +0000 (07:55 -0700)]
Add export annotations for functions in c10 (#18464)

Summary:
Fixes #18461.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18464

Differential Revision: D14620963

Pulled By: ezyang

fbshipit-source-id: c11f3967de2ac69c7140767c8fe73a85555e9f40

5 years agoBack out "Revert D14613517: [pytorch][PR] Updating onnxtrt submodule to master branch...
Li Yu [Wed, 27 Mar 2019 06:41:35 +0000 (23:41 -0700)]
Back out "Revert D14613517: [pytorch][PR] Updating onnxtrt submodule to master branch" (#18514)

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

Original commit changeset: d6267ddfc339

Reviewed By: bddppq

Differential Revision: D14634476

fbshipit-source-id: 2633b0b4c512d71001e5c20cd79c0c0d7856f942

5 years agoAutomatic update of fbcode/onnx to b29e78a4efb8e5d8995f576bbf19a846807829b6 (#18503)
Lu Fang [Wed, 27 Mar 2019 04:51:10 +0000 (21:51 -0700)]
update of fbcode/onnx to b29e78a4efb8e5d8995f576bbf19a846807829b6 (#18503)

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

Previous import was c05f2ae412daf8fd64136ca354b97ccf73e0ea6c

Included changes:
- **[b29e78a4](https://github.com/onnx/onnx/commit/b29e78a4)**: update copyright for open governance (#1885) <Prasanth Pulavarthi>
- **[3b0ecd55](https://github.com/onnx/onnx/commit/3b0ecd55)**: open governance (#1881) <Prasanth Pulavarthi>
- **[bbe28349](https://github.com/onnx/onnx/commit/bbe28349)**: Revert "Adding Reverse op (#1804)" (#1882) <Lu Fang>
- **[5be3e223](https://github.com/onnx/onnx/commit/5be3e223)**: Adding Reverse op (#1804) <Peyman Manikashani>

Reviewed By: zrphercule

Differential Revision: D14632717

fbshipit-source-id: 2637a4090e7071a59caff3a910fa4f077906bf3c

5 years agoMove weight offload inside backend construction functor (#18385)
Yinghai Lu [Wed, 27 Mar 2019 03:57:18 +0000 (20:57 -0700)]
Move weight offload inside backend construction functor (#18385)

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

By moving the weight offload into the backend initialization function, we can instantiate the backend once by creating the OnnxifiOp once and then clean up the parameter workspace. And we need to keep hold of that instantiated net (OnnxifiOp) without cleaning it. Subsequent ctor of OnnxifiOp of the same model will hit the cached backend and they will not look into weight offloading, which is safe as the weight is already gone.

Reviewed By: ipiszy

Differential Revision: D14590379

fbshipit-source-id: f7f34016e09777ad3df0af487885cd14658e1044

5 years agofix #16448 (#18479)
Tongzhou Wang [Wed, 27 Mar 2019 03:55:25 +0000 (20:55 -0700)]
fix #16448 (#18479)

Summary:
Fixes #16448

bddppq
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18479

Differential Revision: D14635360

Pulled By: ezyang

fbshipit-source-id: 4010319fbce050dd0bdf4da3cd1171b9737f3c4c

5 years agoAdd section about .code to docs
James Reed [Wed, 27 Mar 2019 03:47:23 +0000 (20:47 -0700)]
Add section about .code to docs

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

Differential Revision: D14634677

Pulled By: jamesr66a

fbshipit-source-id: 9ee065f6ce4218f725b93deb4c64b4ef55926145

5 years agohow to use the `ccache` package on Ubuntu (#18495)
Stas Bekman [Wed, 27 Mar 2019 02:56:39 +0000 (19:56 -0700)]
how to use the `ccache` package on Ubuntu (#18495)

Summary:
Added full instructions for how to use the `ccache` package. Thanks.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18495

Differential Revision: D14635351

Pulled By: ezyang

fbshipit-source-id: 158e1052bae580e95f73644252fdbddcc0213128

5 years agoAppend c10 libs to TorchConfig.cmake (#18418)
peterjc123 [Wed, 27 Mar 2019 02:47:37 +0000 (19:47 -0700)]
Append c10 libs to TorchConfig.cmake (#18418)

Summary:
Fixes #18416.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18418

Differential Revision: D14635322

Pulled By: ezyang

fbshipit-source-id: 81cb658f73583e4cd0358173617f747ebf4f7f8a

5 years agoAdd some missing docs for tensor methods and attributes, new unittest to enforce...
Xiang Gao [Wed, 27 Mar 2019 01:00:15 +0000 (18:00 -0700)]
Add some missing docs for tensor methods and attributes, new unittest to enforce tensors.rst no longer miss anything (#16057)

Summary:
This depend on https://github.com/pytorch/pytorch/pull/16039

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

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

Differential Revision: D14619550

Pulled By: ezyang

fbshipit-source-id: e1c6dd6761142e2e48ec499e118df399e3949fcc

5 years agoRevert D14613517: [pytorch][PR] Updating onnxtrt submodule to master branch
Li Yu [Wed, 27 Mar 2019 00:30:17 +0000 (17:30 -0700)]
Revert D14613517: [pytorch][PR] Updating onnxtrt submodule to master branch

Differential Revision:
D14613517

Original commit changeset: dd20d718db55

fbshipit-source-id: d6267ddfc339d04f182e2de1750a601c8d6bf8c6

5 years agoFix direct comparison of OperatorDef proto structs (#18466)
Junjie Bai [Wed, 27 Mar 2019 00:16:23 +0000 (17:16 -0700)]
Fix direct comparison of OperatorDef proto structs (#18466)

Summary:
arguments order is okay to be different

ajyu
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18466

Differential Revision: D14627258

Pulled By: bddppq

fbshipit-source-id: 430e1fb1bea2c5639a547ae7c1652368788c86b9

5 years agoRevert D14605905: [pytorch][PR] Add return_counts to torch.unique
Soumith Chintala [Wed, 27 Mar 2019 00:14:26 +0000 (17:14 -0700)]
Revert D14605905: [pytorch][PR] Add return_counts to torch.unique

Differential Revision:
D14605905

Original commit changeset: 555f5a12a8e2

fbshipit-source-id: c7874f5987893e956c022180a37763d88bba38db

5 years agoFix typo in Github links in elementwise_ops_schema.cc (#18018)
Sameer Indarapu [Tue, 26 Mar 2019 22:29:55 +0000 (15:29 -0700)]
Fix typo in Github links in elementwise_ops_schema.cc (#18018)

Summary:
s/elementwise_op_schema.cc/elementwise_ops_schema.cc
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18018

Differential Revision: D14612291

Pulled By: soumith

fbshipit-source-id: 09276283b9ff92c039ce530165c62cc8421fb443

5 years agoImprove numerical precision of (s)logdet (#18449)
Tongzhou Wang [Tue, 26 Mar 2019 22:25:26 +0000 (15:25 -0700)]
Improve numerical precision of (s)logdet (#18449)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/18448 and https://github.com/pytorch/pytorch/issues/18450
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18449

Differential Revision: D14611638

Pulled By: soumith

fbshipit-source-id: 4f1f27ab5316a92d2783e734169f599afed743cf

5 years agofix arange shape issue inconsistency across cpu and cuda (#18462)
Soumith Chintala [Tue, 26 Mar 2019 22:23:43 +0000 (15:23 -0700)]
fix arange shape issue inconsistency across cpu and cuda (#18462)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/18363
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18462

Differential Revision: D14620263

Pulled By: soumith

fbshipit-source-id: 223524cdda2f5d55c2ca8d4cdcf6f7a05a6c15eb

5 years agoUpdating onnxtrt submodule to master branch
Kevin Chen [Tue, 26 Mar 2019 21:15:39 +0000 (14:15 -0700)]
Updating onnxtrt submodule to master branch

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

Differential Revision: D14613517

Pulled By: bddppq

fbshipit-source-id: dd20d718db55942df9cce7acd1151d6902bc57ff

5 years agoMinor fix for onnx ConstantOfShape export (#18199)
BowenBao [Tue, 26 Mar 2019 20:00:29 +0000 (13:00 -0700)]
Minor fix for onnx ConstantOfShape export (#18199)

Summary:
Set value as tensor of 1 element instead of scalar, according to ONNX spec.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18199

Reviewed By: dzhulgakov

Differential Revision: D14542588

Pulled By: houseroad

fbshipit-source-id: 70dc978d870ebe6ef37c519ba4a20061c3f07372

5 years agoNamedtuple return for solve, slogdet, sort, topk (#17093)
Xiang Gao [Tue, 26 Mar 2019 19:33:09 +0000 (12:33 -0700)]
Namedtuple return for solve, slogdet, sort, topk (#17093)

Summary:
More ops for https://github.com/pytorch/pytorch/issues/394. ~~Also need to rebase after landing #16186, because we need to update the whitelist of the new unit test added in #16186.~~

cc: ezyang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17093

Differential Revision: D14620068

Pulled By: ezyang

fbshipit-source-id: deec5ffc9bf7624e0350c85392ee59789bad4237

5 years agoExpose c10 operators to caffe2 by operator name (#18160)
Sebastian Messmer [Tue, 26 Mar 2019 19:29:02 +0000 (12:29 -0700)]
Expose c10 operators to caffe2 by operator name (#18160)

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

When exposing a c10 operator to the caffe2 frontend, don't use the operator schema but use the operator name instead.
This allows us to get rid of the existing mechanism for operator schema registration in a diff stacked on top.

Reviewed By: dzhulgakov

Differential Revision: D14513420

fbshipit-source-id: 6b08a9c6d9497eaf18b62361dd44bc07c7b4b76b

5 years agoTest running a CUDA build on CPU machine. (#18242)
Edward Yang [Tue, 26 Mar 2019 19:19:14 +0000 (12:19 -0700)]
Test running a CUDA build on CPU machine. (#18242)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18242
ghimport-source-id: b949d312a48226a34f90304162e910acee7c95cd

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18242 Test running a CUDA build on CPU machine.**
* #18362 Add ability to query if built with CUDA and MKL-DNN.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14584429

fbshipit-source-id: b54de5b33f0c795a7d9605d30576cdf9b74050fd

5 years agoProperly use cudaGetLastError return code. (#18485)
Edward Yang [Tue, 26 Mar 2019 19:17:31 +0000 (12:17 -0700)]
Properly use cudaGetLastError return code. (#18485)

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

I don't know how (1) we landed the wrong version of the patch and (2) how
this passed the push blocking test

Reviewed By: pjh5

Differential Revision: D14621961

fbshipit-source-id: 0a3953d7adcdc79727a61c2acff65f436dcafe55

5 years agoMove math::Axpy function to elementwise lib (#18316)
Xiaomeng Yang [Tue, 26 Mar 2019 19:13:51 +0000 (12:13 -0700)]
Move math::Axpy function to elementwise lib (#18316)

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

Move math::Axpy function to elementwise lib

i-am-not-moving-c2-to-c10

Reviewed By: houseroad

Differential Revision: D14574697

fbshipit-source-id: 7cfbb2da295c8966c5328bd6b577cce2638eea62

5 years agoUpgrade mkldnn to version 0.18.1 (#18463)
Gu, Jinghui [Tue, 26 Mar 2019 17:52:52 +0000 (10:52 -0700)]
Upgrade mkldnn to version 0.18.1 (#18463)

Summary:
Upgrade mkldnn to version 0.18.1
Fix the MKLDNN build issue if linking with MKL 2019.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18463

Differential Revision: D14620228

Pulled By: ezyang

fbshipit-source-id: 136074ad0e4631e1dde4ca1b0af4ee6a41e50913

5 years agoAdd Google tag (#17690)
Pat Mellon [Tue, 26 Mar 2019 17:25:01 +0000 (10:25 -0700)]
Add Google tag (#17690)

Summary:
This PR adds a Global Site Tag to the site.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17690

Differential Revision: D14620816

Pulled By: zou3519

fbshipit-source-id: c02407881ce08340289123f5508f92381744e8e3

5 years agoremove redundant --install_dir parameter in GEN_COMMAND (#18473)
Gemfield [Tue, 26 Mar 2019 17:14:11 +0000 (10:14 -0700)]
remove redundant --install_dir parameter in GEN_COMMAND (#18473)

Summary:
remove redundant --install_dir parameter in GEN_COMMAND, since "--install_dir parameter " already contained in ${GEN_COMMAND}.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18473

Differential Revision: D14620193

Pulled By: ezyang

fbshipit-source-id: ee9953b5d055f4b8beb3557f95f6539051b0028a

5 years agoResolving comments from Bool Tensor for CPU PR (#18165)
Iurii Zdebskyi [Tue, 26 Mar 2019 16:55:50 +0000 (09:55 -0700)]
Resolving comments from Bool Tensor for CPU PR (#18165)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18165
ghimport-source-id: 55cb3fb63a25c2faab1725b4ec14c688bf45bd38

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18166 Bool Tensor for CUDA
* **#18165 Resolved comments from Bool Tensor for CPU PR**
-------
------------
This is a follow up PR that resolves some additional feedback on one the of previous Bool Tensor PRs.

gchanan, here is a list of almost all the comments from the original PR with respective fixes and replies:

**[utils/python_scalars.h]** why is this converting from uint8_t and not bool? (comment?)
When i was adding this, i was testing by creating a tensor and then calling its .tolist(). it worked for bool and uint8_t equally good so i left uint8_t as thought it makes more sense as we are calling PyBool_FromLong. �Changing it to bool.

**[ATen/Dispatch.h]**better name?.
fixed.

**[test/test_torch.py]** what about other factories, such as full? (and more).
There is a test that goes through the factory methods - test_tensor_factories_empty. i added some bool cases above it and added a comment that once CUDA will be done, i will unite them and it will iterate not just between CUDA and CPU but also all types. ��Adding all bool cases now. Will unite in CUDA PR.

**[generic/THTensorMath.h]** any changes in this file actually needed?
Bad merge. Fixed.

**[TH/THTensor.h]** this generates code for random, clampedRandom, and cappedRandom -- do we have tests for all of these with bool?
Added

**[c10/core/ScalarType.h]** I'm not very confident about the lack of Bool here -- can you look at the call sites and see what makes sense to do here?
Added bool to the macro and created a similar one without for a single case which fails the build with errors:

_./torch/csrc/jit/symbolic_variable.h:79:20: error: ambiguous overload for ‘operator*’ (operand types are ‘const torch::jit::SymbolicVariable’ and ‘torch::jit::Value*’)
return (*this) * insertConstant(rhs);_

Differential Revision: D14605105

fbshipit-source-id: abf82d50e8f8c50b386545ac068268651b28496d

5 years agoUnify cudaGetDeviceCount implementations. (#18445)
Edward Yang [Tue, 26 Mar 2019 16:42:41 +0000 (09:42 -0700)]
Unify cudaGetDeviceCount implementations. (#18445)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18445
ghimport-source-id: 30d018737bf6989bc68b7e3676f44e0ca6141fde

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18242 Test running a CUDA build on CPU machine.
* **#18445 Unify cudaGetDeviceCount implementations.**

I went about doing this by searching for calls to cudaGetDeviceCount,
and then methodically replacing them with references to c10::cuda::device_count()
or at::cuda::device_count().

There is a point to doing this: the various implementations wildly differed
in their handling of what to do when cudaGetDeviceCount returns an error.
The final standardized behavior is that **all errors are swallowed** and
we return device count of zero.  This indirectly fixes running CUDA builds
on CPU, which was broken in #17847.

I added 'noexcept' to the 'deviceCount' virtual method on DeviceGuardImpl.
This is a BC-breaking change for anyone inheriting from DeviceGuardImpl
but all you need to do is put 'noexcept' on your method and it is backwards
compatible with older libtorch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14612189

fbshipit-source-id: 3c8d186e3dd623c0e27625212c7ce30f75d943cb

5 years agoUse TensorIterator for unary operations
Christian Puhrsch [Tue, 26 Mar 2019 16:19:51 +0000 (09:19 -0700)]
Use TensorIterator for unary operations

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

Differential Revision: D14591533

Pulled By: cpuhrsch

fbshipit-source-id: a3b0788a481bddf1803c9f2d3289263d7364f8d7

5 years agoIntroduce SobolEngine (#10505)
vishwakftw [Tue, 26 Mar 2019 14:49:58 +0000 (07:49 -0700)]
Introduce SobolEngine (#10505)

Summary:
`SobolEngine` is a quasi-random sampler used to sample points evenly between [0,1]. Here we use direction numbers to generate these samples. The maximum supported dimension for the sampler is 1111.

Documentation has been added, tests have been added based on Balandat 's references. The implementation is an optimized / tensor-ized implementation of Balandat 's implementation in Cython as provided in #9332.

This closes #9332 .

cc: soumith Balandat
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10505

Reviewed By: zou3519

Differential Revision: D9330179

Pulled By: ezyang

fbshipit-source-id: 01d5588e765b33b06febe99348f14d1e7fe8e55d

5 years agofix str of autogradzero
Wanchao Liang [Tue, 26 Mar 2019 06:44:15 +0000 (23:44 -0700)]
fix str of autogradzero

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

Differential Revision: D14602880

Pulled By: wanchaol

fbshipit-source-id: ebd00f9bb5f1f7e33964c10d8c9f165b7bb4985f

5 years agoOptimize boolean expressions & unwraps (#18259)
eellison [Tue, 26 Mar 2019 04:48:11 +0000 (21:48 -0700)]
Optimize boolean expressions & unwraps (#18259)

Summary:
Simplify or eliminate boolean and/or expressions, optimize unwrapping a value that cannot be None, and optimize using `is` with a None and a non-None value

Since peephole optimize is now introducing constants, i added another constant propagation pass after running it.

Previously i had a PR that did this & optimized shape ops - i will add the shape optimizations in a separate PR.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18259

Differential Revision: D14602749

Pulled By: eellison

fbshipit-source-id: 1c3f5a67067d8dfdf55d7b78dcb616472ea8a267

5 years agoFix python resolution in caffe2 CI scripts
Junjie Bai [Tue, 26 Mar 2019 03:50:49 +0000 (20:50 -0700)]
Fix python resolution in caffe2 CI scripts

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

Differential Revision: D14612704

Pulled By: bddppq

fbshipit-source-id: 0942048a9c3990afc50ce73c1fa1005c4d4097aa

5 years agoSupport dim=None for argmax and argmin (#18264)
Xiang Gao [Tue, 26 Mar 2019 03:36:44 +0000 (20:36 -0700)]
Support dim=None for argmax and argmin (#18264)

Summary:
Fixes: https://github.com/pytorch/pytorch/issues/18263
cc: houseroad
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18264

Reviewed By: ezyang

Differential Revision: D14559234

Pulled By: houseroad

fbshipit-source-id: c5b8623752d6c6af41c6d715fd9585a65294868d

5 years agoAdd return_counts to torch.unique (#18391)
Xiang Gao [Tue, 26 Mar 2019 03:30:33 +0000 (20:30 -0700)]
Add return_counts to torch.unique (#18391)

Summary:
Fixes: https://github.com/pytorch/pytorch/issues/12598

This PR was originally authorized by ptrblck at https://github.com/pytorch/pytorch/pull/15495, but since there was no update for months after the request change, I clone that branch and resolve the code reviews here. Hope everything is good now. Especially, the implementation of count is changed from ptrblck's original algorithm to the one ngimel suggest, i.e. using `unique_by_key` and `adjacent_difference`.

The currently implementation of `_unique_dim` is VERY slow for computing inverse index and counts, see https://github.com/pytorch/pytorch/issues/18405. I will refactor `_unique_dim` in a later PR. For this PR, please allow me to keep the implementation as is.

cc: ptrblck ezyang ngimel colesbury
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18391

Reviewed By: soumith

Differential Revision: D14605905

Pulled By: VitalyFedyunin

fbshipit-source-id: 555f5a12a8e28c38b10dfccf1b6bb16c030bfdce

5 years agochange dropout lowering in symbolic_script (#18375)
Natalia Gimelshein [Tue, 26 Mar 2019 02:57:06 +0000 (19:57 -0700)]
change dropout lowering in symbolic_script (#18375)

Summary:
Dropout is now eligible for fusion, and generated fused kernels are just as fast as dropout in ATen. Change its lowering in symbolic script so that it can actually be fused. Still special-cased for cuda, because without fusion this lowering is less efficient than current (bernoulli_ * input). Testing is covered by the test case that ailzhang added (test_dropout_cuda).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18375

Differential Revision: D14611938

Pulled By: soumith

fbshipit-source-id: 11b18f4784e6c9265e382a8f8deca7add8df3b37

5 years agoAdd torch.version.git_version (#18299)
Gao, Xiang [Tue, 26 Mar 2019 02:54:27 +0000 (19:54 -0700)]
Add torch.version.git_version (#18299)

Summary:
Fixes: https://github.com/pytorch/pytorch/issues/18293
cc: colesbury
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18299

Differential Revision: D14611972

Pulled By: soumith

fbshipit-source-id: cdb48ef37c8869713a9a43ea0da08e1bed9279a2

5 years agoChange deprecated IntList to IntArrayRef
Xiang Gao [Tue, 26 Mar 2019 02:42:01 +0000 (19:42 -0700)]
Change deprecated IntList to IntArrayRef

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

Differential Revision: D14612244

Pulled By: ezyang

fbshipit-source-id: 5d21c7b94d64104fececcb15c6d38d9bd2a1fc70

5 years agoEnable printing to stderr for test_proper_exit for better debugging (#18458)
Tongzhou Wang [Tue, 26 Mar 2019 02:17:00 +0000 (19:17 -0700)]
Enable printing to stderr for test_proper_exit for better debugging (#18458)

Summary:
related to https://github.com/pytorch/pytorch/issues/16608
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18458

Differential Revision: D14611718

Pulled By: soumith

fbshipit-source-id: 6dc903ff2d32b9c3b76470869d1f4e9a67f706df

5 years agoDon't require pygraphviz for regenerate.sh (#17485)
Karl Ostmo [Tue, 26 Mar 2019 01:01:39 +0000 (18:01 -0700)]
Don't require pygraphviz for regenerate.sh (#17485)

Summary:
closes #17336

Do not overwrite config.yml if script throws an error
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17485

Differential Revision: D14604388

Pulled By: kostmo

fbshipit-source-id: 5024545e3a8711abdbc0800911c766929dbca196

5 years agoAdd quant-passes stubs. (#18151)
Mikhail Zolotukhin [Tue, 26 Mar 2019 00:39:01 +0000 (17:39 -0700)]
Add quant-passes stubs. (#18151)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18151
ghimport-source-id: 7d12462971bdf3e5e26a3f150f1fcad05bba1a15

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18152 Initial implementation of InsertObserverNodes pass.
* **#18151 Add quant-passes stubs.**

gh-metadata: pytorch pytorch 18149 gh/zolotukhinm@gmail.com/1/head

Differential Revision: D14584224

fbshipit-source-id: b3d0b5ff797160d5ad23f91f732e627b0129086c

5 years agocaffe2 - support flaky operator tests for caffe2 build (#18155)
Duc Ngo [Mon, 25 Mar 2019 23:55:30 +0000 (16:55 -0700)]
caffe2 - support flaky operator tests for caffe2 build (#18155)

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

- Make a python decorator caffe2_flaky for caffe2 operator unit tests.
- The environment variable CAFFE2_RUN_FLAKY_TESTS are now used to mark flaky test mode

During test run,
- If flaky tests mode are on, only flaky tests are run
- If flaky tests mode are off, only non-flaky tests are run

Mark ctc_beam_search_decoder_op_test as flaky

Reviewed By: ezyang, salexspb

Differential Revision: D14468816

fbshipit-source-id: dceb4a48daeb5437ad9cc714bef3343e9761f3a4

5 years agoRemove unused th_scalar_type (#18390)
iurii zdebskyi [Mon, 25 Mar 2019 22:48:11 +0000 (15:48 -0700)]
Remove unused th_scalar_type (#18390)

Summary:
th_scalar_type seems to be unused anywhere so can be removed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18390

Reviewed By: ezyang

Differential Revision: D14591374

Pulled By: izdeby

fbshipit-source-id: 2113aa81229cdfdfb8dc5c951ea6dea3725b8582

5 years agoPorting CPU UpSample functions to ATen (#18020)
Ivan Ogasawara [Mon, 25 Mar 2019 21:31:43 +0000 (14:31 -0700)]
Porting CPU UpSample functions to ATen (#18020)

Summary:
This PR resolves partially #10482
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18020

Differential Revision: D14598029

Pulled By: ezyang

fbshipit-source-id: 513e7c6438ab6d5dc3f43241e7cb724744e9a287

5 years agoFix caffe2 build with BLAS=OpenBLAS (#18422)
nihui [Mon, 25 Mar 2019 18:55:52 +0000 (11:55 -0700)]
Fix caffe2 build with BLAS=OpenBLAS (#18422)

Summary:
g++ complains about failing to find the declaration of cblas_sscal and cblas_dscal BLAS function
let's fix it  :)

fedora 29, gcc 8.3.1, openblas 0.3.5
build with cmake -DBLAS=OpenBLAS ..
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18422

Differential Revision: D14598977

Pulled By: soumith

fbshipit-source-id: bde77bfb359d2ff38226401caeed78c114ef7468

5 years agoAdd addcmul, lerp to fuser, enable scalar->float specialization in symbolic script...
Wanchao Liang [Mon, 25 Mar 2019 18:02:17 +0000 (11:02 -0700)]
Add addcmul, lerp to fuser, enable scalar->float specialization in symbolic script (#18081)

Summary:
This PR did two things:

1. Enable scalar->float specialization in symbolic script, so AD formula that contains scalar in the schema, should write `float` instead.
2. add addcmul, lerp to AD and fuser.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18081

Differential Revision: D14490493

Pulled By: wanchaol

fbshipit-source-id: b3b86d960d5f051b30733bc908b19786111cdaa4

5 years agoAdd ability to query if built with CUDA and MKL-DNN. (#18362)
Edward Yang [Mon, 25 Mar 2019 17:22:54 +0000 (10:22 -0700)]
Add ability to query if built with CUDA and MKL-DNN. (#18362)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18362
ghimport-source-id: 374b7ab97e2d6a894368007133201f510539296f

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18242 Test running a CUDA build on CPU machine.
* **#18362 Add ability to query if built with CUDA and MKL-DNN.**

Fixes #18108.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14584430

fbshipit-source-id: 7605a1ac4e8f2a7c70d52e5a43ad7f03f0457473

5 years agoUpdating submodules
svcscm [Mon, 25 Mar 2019 17:22:22 +0000 (10:22 -0700)]
Updating submodules

Reviewed By: yns88

fbshipit-source-id: b2c5eb7dfa9048e399461c00d1103e945a30a5bc

5 years agoImplement reference counting for shared IPC CUDA tensors (#16854)
Vitaly Fedyunin [Mon, 25 Mar 2019 17:18:29 +0000 (10:18 -0700)]
Implement reference counting for shared IPC CUDA tensors (#16854)

Summary:
This is to fix #16141 and similar issues.

The idea is to track a reference to every shared CUDA Storage and deallocate memory only after a consumer process deallocates received Storage.

ezyang Done with cleanup. Same (insignificantly better) performance as in file-per-share solution, but handles millions of shared tensors easily. Note [ ] documentation in progress.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16854

Differential Revision: D13994490

Pulled By: VitalyFedyunin

fbshipit-source-id: 565148ec3ac4fafb32d37fde0486b325bed6fbd1

5 years agoDon't segfault on trying to get data_ptr of sparse tensor. (#18347)
Gregory Chanan [Mon, 25 Mar 2019 15:53:42 +0000 (08:53 -0700)]
Don't segfault on trying to get data_ptr of sparse tensor. (#18347)

Summary:
Also asserts in storage_initialized that there is a storage.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18347

Differential Revision: D14582028

Pulled By: gchanan

fbshipit-source-id: df3f5d181188f39e361839169fd054539c3b2839

5 years agoAssert tensor isn't sparse in enforce_invariants. (#18338)
Gregory Chanan [Mon, 25 Mar 2019 15:38:11 +0000 (08:38 -0700)]
Assert tensor isn't sparse in enforce_invariants. (#18338)

Summary:
There's no reason we can't check this, but I'm punting on implementing it for now.  But it currently segfaults, so this is an improvements.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18338

Differential Revision: D14580308

Pulled By: gchanan

fbshipit-source-id: 44d4cafeab12e1beeb3453a2d4068d221c2e9c4f

5 years agoOnly look for Caffe2 package when shared (#18421)
Sacha [Mon, 25 Mar 2019 14:21:37 +0000 (07:21 -0700)]
Only look for Caffe2 package when shared (#18421)

Summary:
Previously it would look for the Config even if it was not written.

Fixed #18419
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18421

Differential Revision: D14597139

Pulled By: ezyang

fbshipit-source-id: c212cbf5dc91564c12d9d07e507c8285e11c6bdf

5 years agoAdd more options to the quantization model exporter (#18383)
Summer Deng [Mon, 25 Mar 2019 11:18:09 +0000 (04:18 -0700)]
Add more options to the quantization model exporter (#18383)

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

Add command line options for different quantization schemes.

Reviewed By: amylittleyang

Differential Revision: D14476862

fbshipit-source-id: 37fbf5b4c1c550121eae313f5a71d703a0a87f0f

5 years agoRevert "Specialize optional tensor inputs to graphs in the JIT (#18360)" (#18411)
Thomas Viehmann [Mon, 25 Mar 2019 04:26:45 +0000 (21:26 -0700)]
Revert "Specialize optional tensor inputs to graphs in the JIT (#18360)" (#18411)

Summary:
This reverts commit 7cc7ed1322405ba3c627b9c5661a330f92c4183d.

I think it's better to sort out the issues raised in #18407 firs. I'm sorry for not stopping it earlier.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18411

Differential Revision: D14594937

Pulled By: soumith

fbshipit-source-id: 3c90b7fa7694e2f59e55607acecde4a47af801ea

5 years agoFix deprecated: type() -> scalar_type() (#18406)
Gao, Xiang [Mon, 25 Mar 2019 02:40:08 +0000 (19:40 -0700)]
Fix deprecated: type() -> scalar_type() (#18406)

Summary:
Sorry for not sending these fixes in a single PR. I found this compiler warning when I was working on something else, and I just go to GitHub and modify the file directly for convenience...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18406

Differential Revision: D14594180

Pulled By: soumith

fbshipit-source-id: 92f48513bc62fbe2c67c759d68830a973296e43b

5 years agoFix deprecated: type() -> scalar_type()
Gao, Xiang [Mon, 25 Mar 2019 02:24:08 +0000 (19:24 -0700)]
Fix deprecated: type() -> scalar_type()

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

Differential Revision: D14593890

Pulled By: soumith

fbshipit-source-id: 92b9a8c22008341c0cc3b7a721bef1973c528daf

5 years agoAdded tensor size warning to F.mse_loss() (#18349)
mc-robinson [Mon, 25 Mar 2019 02:17:00 +0000 (19:17 -0700)]
Added tensor size warning to F.mse_loss() (#18349)

Summary:
To address the issue of broadcasting giving the wrong result in `nn.MSELoss()` as mentioned here https://github.com/pytorch/pytorch/issues/16045 . In particular, the issue often arises when computing the loss between tensors with shapes (n, 1) and (n,)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18349

Differential Revision: D14594176

Pulled By: soumith

fbshipit-source-id: f23ae68a4bf42f3554ad7678a314ba2c7532a6db

5 years agoFix For Requires Grad Infinite Loop (#18361)
Elias Ellison [Sun, 24 Mar 2019 21:28:22 +0000 (14:28 -0700)]
Fix For Requires Grad Infinite Loop (#18361)

Summary:
Previously, we would continue to run requires grad on a loop body when the outputs and inputs disagreed. This adds a check so that we don't continue running if the results haven't changed since the last run.

Fix for https://github.com/pytorch/pytorch/issues/18320
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18361

Differential Revision: D14584332

Pulled By: eellison

fbshipit-source-id: 696b225f80a2036318540946428b525985a9e735

5 years agoupdate magma instructions (#18410)
Soumith Chintala [Sun, 24 Mar 2019 20:11:20 +0000 (13:11 -0700)]
update magma instructions (#18410)

Summary:
fixes https://github.com/pytorch/pytorch/issues/18389

cc: stas00
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18410

Differential Revision: D14594198

Pulled By: soumith

fbshipit-source-id: fb46ef77a36c90ad95e47f7066f5d32aa1f1370f

5 years agoRemoved some dead code (#18201)
Iurii Zdebskyi [Sun, 24 Mar 2019 15:17:34 +0000 (08:17 -0700)]
Removed some dead code (#18201)

Summary:
Removed some dead code.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18201

Differential Revision: D14555251

Pulled By: izdeby

fbshipit-source-id: f49640133ef4ae1b0306f7cec6655f23869cc6e7

5 years agoSpecialize optional tensor inputs to graphs in the JIT (#18360)
Thomas Viehmann [Sun, 24 Mar 2019 05:54:36 +0000 (22:54 -0700)]
Specialize optional tensor inputs to graphs in the JIT (#18360)

Summary:
This specializes optional tensor inputs to either a DimensionedTensorType or, when None is passed,
UndefinedTensor (aka AutogradZeroTensorType).
This works because we already have different specs and thus separate plans for the two cases.
It enhances the shape analysis - because now unwrapped optional tensors will have DimensionedTensorType with appropriate shape and required grad etc.
Also, when combined with "if-pruning" (which I understand #18259 works towards), we actually get much nicer concrete graphs, too.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18360

Differential Revision: D14590577

Pulled By: soumith

fbshipit-source-id: cac204a506d1d38b15703cbcc67a6b75fd4979f4

5 years agoMove pyobj_ to TensorImpl (#18225)
Will Feng [Sat, 23 Mar 2019 19:47:15 +0000 (12:47 -0700)]
Move pyobj_ to TensorImpl (#18225)

Summary:
Currently, `THPVariable_Wrap(…)` and `THPVariable_NewWithVar(…)` depend on the existence of `pyobj_` in the autograd metadata of a Variable to convert the Variable to a Python tensor. However, after the Variable/Tensor merge, there will be Variables that don't contain autograd metadata, and to allow the conversion from non-autograd-meta Variable to a Python tensor we need to store the `pyobj_` outside of autograd metadata and in a place where it will always be available.

This PR makes it possible by moving `pyobj_` into TensorImpl, so that `THPVariable_Wrap(…)` and `THPVariable_NewWithVar(…)` can always access a Variable's `pyobj_` and convert the Variable to a Python tensor.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18225

Differential Revision: D14562616

Pulled By: yf225

fbshipit-source-id: 18d4aaace70eee6120abaf9276036d1f8f51b18d

5 years agoFix deprecated scalar type in ATen/native/Distributions.cpp
Xiang Gao [Sat, 23 Mar 2019 17:01:28 +0000 (10:01 -0700)]
Fix deprecated scalar type in ATen/native/Distributions.cpp

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

Differential Revision: D14577543

Pulled By: ezyang

fbshipit-source-id: 36674530b32366c51835e4073d7ba23d455d2fda

5 years agoRevert D14446895: [C2] Implement rotated generate_proposals_op without opencv depende...
Edward Yang [Sat, 23 Mar 2019 16:33:40 +0000 (09:33 -0700)]
Revert D14446895: [C2] Implement rotated generate_proposals_op without opencv dependency (~2x faster)

Differential Revision:
D14446895

Original commit changeset: 847f2443e645

fbshipit-source-id: fc6ab5ee59e027f125f5ab0f7ee51ad7db37d4a4

5 years agoRevert D14584266: [pytorch][PR] Better error message for tensor with grad as constant...
Michael Suo [Sat, 23 Mar 2019 09:47:57 +0000 (02:47 -0700)]
Revert D14584266: [pytorch][PR] Better error message for tensor with grad as constant in tracing

Differential Revision:
D14584266

Original commit changeset: 4e7850dadc78

fbshipit-source-id: 3bb3b5006e469edff984c16e0ff8d5dac2862d88

5 years agoBetter error when module attr is used (#18164)
Elias Ellison [Sat, 23 Mar 2019 03:13:02 +0000 (20:13 -0700)]
Better error when module attr is used (#18164)

Summary:
Adds a suggestion to add to __constants__ when a torch.nn.Module attr is accessed
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18164

Differential Revision: D14580060

Pulled By: eellison

fbshipit-source-id: 0c5adc21d7341a5691d4b45930947cb1ba84c8e8

5 years agoFix incorrect sparse add behavior when the sparse tensor has non-contiguous values...
Will Feng [Sat, 23 Mar 2019 02:25:58 +0000 (19:25 -0700)]
Fix incorrect sparse add behavior when the sparse tensor has non-contiguous values (#18179)

Summary:
Currently, this code gives incorrect result:
```python
import torch
indices=torch.tensor([[7, 1, 3]])
values=torch.tensor([[1., 1., 1.],
               [1., 1., 1.],
               [1., 1., 1.]])
x = torch.sparse_coo_tensor(indices, values, size=(10, 3))
values=torch.tensor(1.).expand(3, 3)
y = torch.sparse_coo_tensor(indices, values, size=(10, 3))
z = x + y

tensor(indices=tensor([[7, 1, 3]]),
       values=tensor([[2., 1., 1.],
                      [1., 1., 1.],
                      [1., 1., 1.]]),
       size=(10, 3), nnz=3, layout=torch.sparse_coo)
```

This PR fixes the bug by adding special handling for sparse tensors with non-contiguous values in the addition function (specifically, by cat'ing the indices and values together).

This PR closes https://github.com/pytorch/pytorch/issues/17950 and https://github.com/pytorch/pytorch/issues/17919.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18179

Reviewed By: ezyang

Differential Revision: D14569591

Pulled By: yf225

fbshipit-source-id: f5a14c4a31337fc95eab64596212066b4fb18b1a

5 years agoImplement rotated generate_proposals_op without opencv dependency (1.8x faster) ...
Jing Huang [Sat, 23 Mar 2019 01:12:27 +0000 (18:12 -0700)]
Implement rotated generate_proposals_op without opencv dependency (1.8x faster) (#18010)

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

[C2] Implement rotated generate_proposals_op without opencv dependency.

Reviewed By: newstzpz

Differential Revision: D14446895

fbshipit-source-id: 847f2443e645f8cae1327dfbaa111c48875ca9be

5 years agoRemove empty file (actual file_check.cpp resides in torch/csrc/jit/testing) (#18303)
Mikhail Zolotukhin [Sat, 23 Mar 2019 00:00:10 +0000 (17:00 -0700)]
Remove empty file (actual file_check.cpp resides in torch/csrc/jit/testing) (#18303)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18303
ghimport-source-id: 66f4402075b123e36c6ffdf806b7c93187a1a58a

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18307 Convert test_recursive_cse to use Filecheck inline annotations.
* #18306 [Filecheck] Add a feature to parse check annotations from string.
* #18305 Add python bindings for parseIR.
* **#18303 Remove empty file (actual file_check.cpp resides in torch/csrc/jit/testing)**

Differential Revision: D14586003

fbshipit-source-id: a13e57bd4302e4d3f06198068d525de25e2aa8b3

5 years agoTurn script_type_parser into a class (#18211)
Michael Suo [Fri, 22 Mar 2019 23:24:36 +0000 (16:24 -0700)]
Turn script_type_parser into a class (#18211)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18211
ghimport-source-id: 73b81e9ec631937b14db1da10991831788a6894b

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18296 [jit] Add namespacing for ScriptClasses
* #18284 [jit] make test module hook use save/load
* **#18211 [jit] Turn script_type_parser into a class**
* #18148 [jit] python interop for script classes

If we are namespacing classes, the type parser will need to carry around
some state about which namespaces to look in. This PR just wraps it in a
class in preparation.

Also, subscriptToType can no longer be static, since parseTypeFromExpr
may give different results depending on the namespaces available, so
it's been made a regular function instead of a static map lookup.

Reviewed By: eellison

Differential Revision: D14581128

fbshipit-source-id: 711315472ccde1920abf9fdb5a871ac27fb86787

5 years agopython interop for script classes (#18148)
Michael Suo [Fri, 22 Mar 2019 23:24:36 +0000 (16:24 -0700)]
python interop for script classes (#18148)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18148
ghimport-source-id: 40a9d745dc9aeba53d098743323fcbd50ca65137

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18148 py interop**

Support for converting classes between the Python–TorchScript boundary. Like other TorchScript values, ScriptClasses are native Python values when used in Python and IValues when used in TorchScript.

Notably, there is a copy across this boundary, which will be surprising to users who will expect standard Python reference semantics. I have some ideas for fixing that, but it's a more involved process.

Reviewed By: jamesr66a

Differential Revision: D14526259

fbshipit-source-id: 5916e3032488a42dc7da756c1826d7c040a21ebd

5 years agoBetter error message for tensor with grad as constant in tracing (#18298)
Elias Ellison [Fri, 22 Mar 2019 22:25:40 +0000 (15:25 -0700)]
Better error message for tensor with grad as constant in tracing (#18298)

Summary:
Fix for https://github.com/pytorch/pytorch/issues/17583

There's an unrelated issue right now causing a segfault when printing tensor so that might have to fixed first for this to land
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18298

Differential Revision: D14584266

Pulled By: eellison

fbshipit-source-id: 4e7850dadc78ef1e98ad40b9d8adc0fef42acf48

5 years agoSupport for basic list comprehensions (#17267)
Nikolay Korovaiko [Fri, 22 Mar 2019 22:22:23 +0000 (15:22 -0700)]
Support for basic list comprehensions (#17267)

Summary:
Supports the following syntax:
```
        torch.jit.script
        def comp(l):
            # type: (List[float]) -> List[float]

            n = [x * 3 for x in l]
            return n
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17267

Differential Revision: D14581119

Pulled By: Krovatkin

fbshipit-source-id: 6fd091a8a9ab607386ac58fda6ad88bf8aea380e

5 years agoMake it possible to trigger XLA/slow tests via commit message. (#18345)
Edward Yang [Fri, 22 Mar 2019 21:58:35 +0000 (14:58 -0700)]
Make it possible to trigger XLA/slow tests via commit message. (#18345)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18345
ghimport-source-id: 9649d76bb194866859d62e6ba2a3a265c96ebba5

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18345 Make it possible to trigger XLA/slow tests via commit message.**

Four variants are supported: `[xla ci] [ci xla] [xla test] [test xla]`; substitute
xla with slow for slow tests.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: D14584557

fbshipit-source-id: fcbfdfb28246823135bb3d3910baae073d16e81d

5 years agoAvoid refcount when looking up dispatch key
Sebastian Messmer [Fri, 22 Mar 2019 21:05:50 +0000 (14:05 -0700)]
Avoid refcount when looking up dispatch key

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

Reviewed By: ezyang

Differential Revision: D14512979

fbshipit-source-id: 45e548974f06184c375c2bb8339e3049a4ebd880