Commit Graph

24358 Commits

Author SHA1 Message Date
Joseph Spisak
9fd1a7697f
Create CODE_OF_CONDUCT.md 2020-02-28 13:20:00 -08:00
Michael Carilli
a726827ec8 Formatting changes for gradient scaling (#33832)
Summary:
hard to get right locally...I can build the docs but never quite match what it looks like live.  the bullet point indentation was just an oversight.

Removing `Returns:` formatting tabs because they take up a lot of space when rendered and add no clarity.  Some functions in Pytorch [do use them](https://pytorch.org/docs/master/torch.html#torch.eye), but [many don't bother](https://pytorch.org/docs/master/torch.html#torch.is_tensor), so apparently some people shared my feelings (Not using them is in line with existing practice).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33832

Differential Revision: D20135581

Pulled By: ngimel

fbshipit-source-id: bc788a7e57b142f95c4fa5baf3fe01f94c45abd8
2020-02-28 11:40:48 -08:00
Igor Sugak
5dde8cd483 [caffe2] fix no matching function min/max Clang errors (#33563)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33563

When NVCC or Clang are driving CUDA compilation many math functions are declared by default, with a small difference: Clang marks them as `__device__` only, while NVCC uses both `__host__` and `__device__`. This makes every un-elaborated `min` or `max` function call from a `__host__` function generate a syntax error when Clang is used.

Fix the errors by using `std::min` and `std::max` from `<algorithm>`, since C++14 they are `constexpr` and can be used in the `__device__` code [1].

1. https://llvm.org/docs/CompileCudaWithLLVM.html#algorithm

Test Plan:
```lang=bash
buck build mode/opt -c fbcode.cuda_use_clang=true //fblearner/flow/projects/dper:workflow
buck build mode/opt //fblearner/flow/projects/dper:workflow
```
Execute tests on devgpu:
```
buck test mode/dev-nosan -j 8 //caffe2/caffe2/python/operator_test/... //caffe2/test:cuda
```

Reviewed By: ngimel

Differential Revision: D20005795

fbshipit-source-id: 98a3f35e8a96c15d3ad3d2066396591f5cca1696
2020-02-28 11:33:24 -08:00
Mingfei Ma
c6d301220a Fix torch.cat() performance regression on single core CPU (#33534)
Summary:
This PR addresses the performance regression on `torch.cat()` on CPU with single thread.
Previous optimization https://github.com/pytorch/pytorch/issues/30806 introduced regression for several cases on pytorch operator benchmark.
See https://github.com/pytorch/pytorch/issues/33334 for detail.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33534

Differential Revision: D20129963

Pulled By: VitalyFedyunin

fbshipit-source-id: 3fa6cd266978e5b54fa37105555502b77352df3e
2020-02-28 11:22:08 -08:00
svcscm
890242254b Updating submodules
Summary:
GitHub commits:

6f4df6e0cd
6b7df86da1
f873713ad6
2b3b76cc4d
b990727d33

Test Plan: n/a

Reviewed By: wittgenst

fbshipit-source-id: bf7b1639ee23e1e823bc2217f56c87dc7befaf7f
2020-02-28 10:42:20 -08:00
Gregory Chanan
04dc0e6973 Split Distribution.cu into smaller files to reduce compilation time. (#33892)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33892

Test Plan: Imported from OSS

Differential Revision: D20148925

Pulled By: gchanan

fbshipit-source-id: 955e6ff22ee5fb24000b9f2ee58a243e76edf993
2020-02-28 09:21:51 -08:00
anjali411
dece155335 Modified assertEqual to handle complex tensors (#33773)
Summary:
- Modified assertEqual to handle complex tensors
- added a test in test_torch.py to test torch.zeros
- added dispatch for complex for index_kernel, index_put_kernel
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33773

Differential Revision: D20135553

Pulled By: anjali411

fbshipit-source-id: f716604535c0447ecffa335b0fc843431397c988
2020-02-28 08:43:28 -08:00
anjali411
09046713cc removed .data from test_autograd.py (#33886)
Summary:
issue: https://github.com/pytorch/pytorch/issues/33630
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33886

Differential Revision: D20160292

Pulled By: anjali411

fbshipit-source-id: 14a42d8148bd60db2dd8ec39f83f99c061ae19c1
2020-02-28 08:24:07 -08:00
Jerry Zhang
f5f1e5e7f6 [quant][graphmode][refactor] Factor out getInvokedMethod (#33649)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33649

Test Plan:
.

Imported from OSS

Differential Revision: D20123589

fbshipit-source-id: 0853d757434fb85c6d86666ff9fc991f8c4cb4bc
2020-02-27 23:48:09 -08:00
Jerry Zhang
7f1112820a [quant][graphmode][refactor] Move check for weight outside of insertObserverFor (#33276)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33276

att

Test Plan:
.

Imported from OSS

Differential Revision: D20123593

fbshipit-source-id: 45dc8488ddf02225ba2c20374c9385edd77a4912
2020-02-27 23:48:04 -08:00
Jerry Zhang
7c13f576ea [quant][graphmode][refactor] Checks for bias and weight (#33273)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33273

- Move the check for bias to valueNeedsToBeQuantized
- Move TORCH_CHECK inside the functions for checking if a value is bias or weight

Test Plan:
.

Imported from OSS

Differential Revision: D20123595

fbshipit-source-id: 4b805d57dcaf41a6436506d021dd5f6518bc88fd
2020-02-27 23:47:59 -08:00
Jerry Zhang
97541a5106 [quant][graphmode][refactor] Move values_to_skip check inside valueNeedsToBeQuantized (#33275)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33275

att

Test Plan:
.

Imported from OSS

Differential Revision: D20123592

fbshipit-source-id: 2b56ea8bab27eb9ea2bf792c83e48a7af8917e1a
2020-02-27 23:46:29 -08:00
Wanchao Liang
64aab3260a [jit] allow RRef local creation with IValue objects (#33263)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33263

This PR allow PyRRef local creation to inspect the pyobject, if it
founds that we could turn it to an IValue, turn to an IValue first,
otherwise hold it as a PyObjectType

Test Plan:
Imported from OSS

https://fb.quip.com/aGxRAh2lCg05

Differential Revision: D19871243

Pulled By: wanchaol

fbshipit-source-id: ae5be3c52fb1e6db33c64e64ef64bc8b9ea63a9a
2020-02-27 22:49:53 -08:00
Igor Sugak
1507573a52 [caffe2] fix no return statement in constexpr function Clang error in TypeIndex.h (#33576)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33576

`throw` statement at the end of `constexpr` is ill-formed according to Clang. It happens when Clang is driving CUDA compilation and compiles for device the effected code. Due to its compilation model it requires host code to be well-formed even when compiling for device.

Fix the error by guarding the entire definition of `type_index_impl` with `__CUDA_ARCH__` check.

Test Plan:
```lang=bash
buck build mode/opt -c fbcode.cuda_use_clang=true //fblearner/flow/projects/dper:workflow
buck build mode/opt //fblearner/flow/projects/dper:workflow
```
Execute tests on devgpu:
```
buck test mode/dev-nosan -j 8 //caffe2/caffe2/python/operator_test/... //caffe2/test:cuda
```

Reviewed By: smessmer

Differential Revision: D20008881

fbshipit-source-id: b0dc9abf0dc308b8b8637b54646a0411baf7fef3
2020-02-27 22:29:58 -08:00
peter
c18cb1eb52 Improve dll loading logic on Windows (#33856)
Summary:
The way it works on the Anaconda distribution of Python 3.8 is a bit different. Loading DLLs explicitly  (e.g. `ctype.CDLL`) relies on paths appended by `os.add_dll_directory`. But if you try to load DLLs implicitly (e.g. `from torch._C import *`), it will rely on `PATH`.

Fixes https://github.com/pytorch/vision/issues/1916.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33856

Differential Revision: D20150080

Pulled By: soumith

fbshipit-source-id: cdbe76c138ea259ef7414c6634d4f7e0b1871af3
2020-02-27 21:58:35 -08:00
Meghan Lele
cb8d9f99aa [JIT] Implement Tensor.tolist() (#33472)
Summary:
**Summary**
This commit adds an implementation of `Tensor.tolist()` to the JIT interpreter.

**Testing**
This commit adds several unit tests that test that this function works correctly for
0D, 1D, 2D and 3D tensors of type `float`, `int` and `bool`.

```
(base) meghanl-mbp:pytorch meghanl$ python test/test_jit.py TestList.test_to_list -v
Fail to import hypothesis in common_utils, tests are not derandomized
test_to_list (jit.test_list_dict.TestList)
Unit tests for Tensor.tolist() function. ... ok

----------------------------------------------------------------------
Ran 1 test in 0.329s

OK
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33472

Differential Revision: D20109738

Pulled By: SplitInfinity

fbshipit-source-id: a6e3fee5e3201d5e1f0c4ca45048488ae2bf5e33
2020-02-27 21:45:46 -08:00
Wanchao Liang
5029ff001b [Revert] manual revert of D19918320 (#33920)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33920

revert D19918320

Test Plan: revert diff

Reviewed By: zhaojuanmao

Differential Revision: D20151299

fbshipit-source-id: c346554ae9074991331479e434e54b0cc513f1a4
2020-02-27 21:22:36 -08:00
Michael Suo
8f84deddd1 [jit] fix up refs in overview.md (#33919)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33919

Test Plan: Imported from OSS

Differential Revision: D20154953

Pulled By: suo

fbshipit-source-id: 2ef83cce8da88212bed7edc813c9b233267ea81b
2020-02-27 19:22:51 -08:00
Michael Suo
d6485b411b [jit] add top-level readme to csrc/jit (#33916)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33916

Test Plan: Imported from OSS

Differential Revision: D20150771

Pulled By: suo

fbshipit-source-id: c7550954ddd6a294ce833348bf9fa058503e9bd7
2020-02-27 19:21:05 -08:00
Michael Suo
bd7e9c490a [jit] stop printing crap in test_jit (#33917)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33917

Test Plan: Imported from OSS

Differential Revision: D20150750

Pulled By: suo

fbshipit-source-id: 9a35298a8856d423fb6b9043174853cccf968706
2020-02-27 19:06:43 -08:00
lixinyu
d66c320b10 disable leaky_relu_ backward calculation with negative slope (#33639)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33639

Test Plan: Imported from OSS

Differential Revision: D20045735

Pulled By: glaringlee

fbshipit-source-id: b3becf30a8fe9ee178792bd88f6ee10102504ed5
2020-02-27 18:54:57 -08:00
Jerry Zhang
997b5b5797 [quant][graphmode][refactor] Simplify signature for insertObserverFor (#33274)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33274

att

Test Plan:
.

Imported from OSS

Differential Revision: D20123588

fbshipit-source-id: e656d96e0b6004bfcca5df2ab222184d4e1dd6ad
2020-02-27 17:24:41 -08:00
Michael Suo
db4a24e008 [jit] remove some unused/redundant files (#33806)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33806

as title

Test Plan: Imported from OSS

Differential Revision: D20122117

Pulled By: suo

fbshipit-source-id: 209d29ed2c873181140c9fb5cdc305c200ce4008
2020-02-27 17:16:12 -08:00
Vitaly Fedyunin
877ab3afe3 Better handing of Autograd+Fork errors. (#33885)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33885

Fixes: #32835
Fixes: #5834

Can not combine with CUDA's implementation as each of them requires individual `std::once_flag` as well as different `forked_autograd_child` functions. CUDA version relays to python module, autograd uses TORCH_CHECK to report error to python and cpp.

Test Plan: Imported from OSS

Differential Revision: D20144024

Pulled By: VitalyFedyunin

fbshipit-source-id: e7cf30568fff5110e9df7fe5b23f18ed992fa17f
2020-02-27 16:07:29 -08:00
Simón Sepúlveda Osses
746e5218e7 Mistake in MSELoss documentation (#33836)
Summary:
Replaced `sum` with `mean` in [line 392](https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/loss.py#L392)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33836

Differential Revision: D20142053

Pulled By: ailzhang

fbshipit-source-id: 2bfe19944ffc5534902dd9087023e70ddf5746c3
2020-02-27 15:34:46 -08:00
Ailing Zhang
48fd410e44 Try fix XLAPreAutograd with *_like functions. (#33848)
Summary:
In *_like functions we call
`globalLegacyTypeDispatch().initForDispatchKeySet(c10::detail::multi_dispatch_key_set(self, options));` -> `dispatchKeyToBackend` and thus this change.
`self` has both `XLAPreAutograd` and `XLATensorId` in key set.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33848

Differential Revision: D20135898

Pulled By: ailzhang

fbshipit-source-id: a8585f39f3fa77b53718f20d3144f4f2f3cb8e53
2020-02-27 15:28:40 -08:00
Gregory Chanan
87e97ced20 Split UnaryOpsKernel into smaller files for faster compilation. (#33888)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33888

Test Plan: Imported from OSS

Differential Revision: D20143653

Pulled By: gchanan

fbshipit-source-id: de708030e93e96091e0c01a89b4342872d0657dd
2020-02-27 15:13:01 -08:00
Eli Uriegas
aff1da5aac .circleci: Remove trailing slash, fix conda upload (#33903)
Summary:
Conda registers a suffixed slash as a new user so it was failing to
upload the anaconda packages.

In the future this should be handled through a single variable that can
be used for both but until then this will have to do.

Bug was introduced in https://github.com/pytorch/pytorch/issues/33842

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33903

Differential Revision: D20148679

Pulled By: seemethere

fbshipit-source-id: 27c95f5d906ce84aa34bf5d76fd6f1ef5df08fb9
2020-02-27 14:56:02 -08:00
Jongsoo Park
a7fe200f5f [caffe2] simplify caffe2 code with fbgemm handling block size 1 emb (#33774)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33774

Simplify caffe2 code using D19246900

Test Plan: CI

Reviewed By: jianyuh

Differential Revision: D20102410

fbshipit-source-id: 8de4d9cfac66898db0718ac6477339fd5e5428e3
2020-02-27 14:45:28 -08:00
Jack Cao
524dad13a8 Add device to the test tensor. Default device type is CPU, in pytorch… (#33635)
Summary:
…/xla this will result in a failure since it is comparing a XLA tensor with a CPU tensor.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33635

Differential Revision: D20043517

Pulled By: ailzhang

fbshipit-source-id: d84038ea675e4d4a9c02e7a8b0924bdb12f40501
2020-02-27 14:40:07 -08:00
HearyShen
edd5c009f7 fix docs mistakes in lr_scheduler.MultiplicativeLR (#33805)
Summary:
This PR is referenced to an issue: [The docs of `MultiplicativeLR` use `LambdaLR` as example](https://github.com/pytorch/pytorch/issues/33752#issue-570374087)

https://github.com/pytorch/pytorch/issues/33752
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33805

Differential Revision: D20121314

Pulled By: mruberry

fbshipit-source-id: 5afa63bbe83d35ce4e55705b8cbd96326a907651
2020-02-27 14:11:57 -08:00
Gregory Chanan
d97560999b Split BinaryCompareKernel.cu into a file-per-kernel to speed up compilation. (#33871)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33871

Test Plan: Imported from OSS

Differential Revision: D20140862

Pulled By: gchanan

fbshipit-source-id: a4fde38c1c7c5905e3855fa490ea2e87bb24c703
2020-02-27 13:48:36 -08:00
Meghan Lele
5eacdfb21f Revert D20127441: [pytorch][PR] [JIT] Introduce a fake Tensor creation node for IR unit tests
Test Plan: revert-hammer

Differential Revision:
D20127441

Original commit changeset: 56da4f23ac46

fbshipit-source-id: 7d4602e5011bec6f6871eab16af05a3198694e5d
2020-02-27 13:48:31 -08:00
Gregory Chanan
c4d611a0f5 Split BinaryMiscOpsKernels into more files for faster build times. (#33873)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33873

Test Plan: Imported from OSS

Differential Revision: D20140974

Pulled By: gchanan

fbshipit-source-id: 88b982881e8034f3b03cdb6911ae4239d2bb1596
2020-02-27 13:47:06 -08:00
Brian Vaughan
910acafc79 Revert D20124224: [jit] stop printing crap in test_jit
Test Plan: revert-hammer

Differential Revision:
D20124224

Original commit changeset: 9241d21fdf94

fbshipit-source-id: 0680f9db922f9a33a4e859eedd142b87a51bbede
2020-02-27 13:40:34 -08:00
svcscm
53630f7681 Updating submodules
Summary:
GitHub commits:

ae68f84fcd
6cb0beaf0e
401fb54029
fe8777e593
44fcf005eb
72ee067b90
01a3c124d4
c94f8f43b9
a09b292a28
472e40a902
967d4bc051

Test Plan: n/a

Reviewed By: wittgenst

fbshipit-source-id: e8e43b1cbc365fd7f5b068d625c4020240358690
2020-02-27 13:35:14 -08:00
Brian Vaughan
243af17d65 Revert D20103905: [jit] Fix flipped PackedSequence outputs in script
Test Plan: revert-hammer

Differential Revision:
D20103905

Original commit changeset: 84081213ed21

fbshipit-source-id: 2b260654fac87e52fbaf8035018e4ea484928af1
2020-02-27 13:29:35 -08:00
Brian Vaughan
a7cf5c859f Revert D20136865: fix lint
Test Plan: revert-hammer

Differential Revision:
D20136865

Original commit changeset: 4bf7ac324a0a

fbshipit-source-id: 94cc83cda180f744cec174d269f1b82babff0e5c
2020-02-27 13:21:44 -08:00
iurii zdebskyi
908eee5583 remove .data from test/distributed/ (#33874)
Summary:
`.data` calls are unsafe and should not be used.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33874

Differential Revision: D20141059

Pulled By: izdeby

fbshipit-source-id: 8e11afc74f0cb04f5b18b458068fb813a6d51708
2020-02-27 13:14:29 -08:00
Meghan Lele
390d4d6df3 [JIT] Introduce a fake Tensor creation node for IR unit tests (#33595)
Summary:
**Summary**
There is often a need to create a Tensor when writing IR by hand for JIT
optimisation pass unit tests. The only options for this today are real
Tensor creation functions like `aten::ones`. Any test that uses these functions
must also use the same default arguments as the Python/C++ API, which means
that all of the tests have to be updated when the API is updated. This commit
introduces a new primitive, `prim::MakeTestTensor` with schema `() -> Tensor` that
should be used in unit tests instead of real Tensor creation functions. This new
primitive has no public-facing API, so the maintenance burden is much lower.

**Testing**
This commit updates the alias analysis and DCE tests to use `prim::MakeTestTensor` instead of
`aten::rand`, `aten::ones`, and `aten::zeros`.

```
$ ./bin/test_jit
CUDA not available. Disabling CUDA and MultiCUDA tests
Note: Google Test filter = *-*_CUDA:*_MultiCUDA
[==========] Running 75 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 75 tests from JitTest
[ RUN      ] JitTest.ADFormulas
[       OK ] JitTest.ADFormulas (82 ms)
[ RUN      ] JitTest.Attributes
[       OK ] JitTest.Attributes (0 ms)
...
...
...
[ RUN      ] JitTest.LiteInterpreterPrim
[       OK ] JitTest.LiteInterpreterPrim (0 ms)
[ RUN      ] JitTest.LiteInterpreterLoadOrigJit
[       OK ] JitTest.LiteInterpreterLoadOrigJit (2 ms)
[----------] 75 tests from JitTest (150 ms total)

[----------] Global test environment tear-down
[==========] 75 tests from 1 test case ran. (150 ms total)
[  PASSED  ] 75 tests.
```

**Fixes**
This pull request fixes https://github.com/pytorch/pytorch/issues/33500.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33595

Differential Revision: D20127441

Pulled By: SplitInfinity

fbshipit-source-id: 56da4f23ac46335227254f606c6481718108f378
2020-02-27 13:10:20 -08:00
Michael Suo
dbe850af5b [jit] do the code reorg (#33851)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33851

Rationale and context described in #33828.

Script to reproduce the move:
https://gist.github.com/suo/16cbefaaeb67ca5a7c6caffd49b7f6e9
ghstack-source-id: 99079645

Test Plan: Make sure CI passes

Reviewed By: jamesr66a

Differential Revision: D20133869

fbshipit-source-id: 390e9241a9c85366d9005c492ac31f10aa96488e
2020-02-27 13:02:51 -08:00
Jerry Zhang
afbd04449e [quant][graphmode] Swap dequantize after inline for ops that doesn't require observation (#33173)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33173

How to deal with ops that’s defined for both floating point and quantized Tensor?

Category of ops: the ones that doesn’t require observers, which means the quantization parameters(scale/zero_point) of the output of this op can be inferred from the quantization parameters of inputs.
For example:
avg_pool, max_pool, flatten, transpose, upsample

Another related topic to previous one is how do we deal with things like adaptive_avg_pool2d that does not require to be observed and it works with quantized tensor as well? If we insert quant/dequant for them, even the quant fusion becomes a numerically changing operation because the scale/zero_point for input and output are different.

Proposal

We can swap the operator with dequantize whenever we see it. For example, for pattern
Let’s say aten::general_op is defined for both floating point and quantized

%r = aten::conv(...)
%q = quantize(%r)
%dq = dequantize(%q)
%f = aten::general_op(%dq)
...

We detect that all inputs of aten::general_op is produced by dequantize, we’ll first delete all the dequantize for the inputs and then insert dequantize for each use of the output of the aten::general_op, note that this should work generally for all the case we might encounter.

After transformation we’ll have:

%r = aten::conv(...)
%q = quantize(%r)
%x = aten::general_op(%q)
%f = dequantize(%x)
...

1. Multiple inputs
    1. We need to make sure all inputs of the aten::general_op are produced by dequantize before we do this transformation
2. Input used by multiple operators
    1. We already did this by inserting dequantize for each use of the value
3. Output used by multiple operators
    1. We’ll reuse the code that inserts dequantize(might need some refactor)

Note that current concat does not belong to this category right now since it does not inherit quantization parameters from inputs.

Test Plan:
python test/test_jit.py

Imported from OSS

Differential Revision: D20123590

fbshipit-source-id: de2febe1f37e4079457a23acaeccbc6d9c9e1f8a
2020-02-27 12:42:29 -08:00
Lu Fang
6647a44e8c Automatic update of fbcode/onnx to 9fdae4c68960a2d44cd1cc871c74a6a9d469fa1f (#33858)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33858

Previous import was 04a29addfd5b912812addb8dea5f8763fbfaad01

Included changes:
- **[9fdae4c6](https://github.com/onnx/onnx/commit/9fdae4c6)**: Copy sizes in some optimizers to remain shape information (#2574) <daquexian>
- **[c978d102](https://github.com/onnx/onnx/commit/c978d102)**: Implement CELU node as a Function (#2575) <Jeremy Cochoy>
- **[c677aef4](https://github.com/onnx/onnx/commit/c677aef4)**: Fix CI build break (#2603) <Changming Sun>
- **[d343755d](https://github.com/onnx/onnx/commit/d343755d)**: Allow function body to rely on other operator sets (#2597) <Ke Zhang>

Test Plan: ci

Reviewed By: hl475

Differential Revision: D20135343

fbshipit-source-id: d719c4ba2ae26892a5fa921691c84eba64b59291
2020-02-27 12:40:39 -08:00
Gregory Chanan
bd77abffe3 Kill some unused (TH)Storage-based APIs. (#33815)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33815

Test Plan: Imported from OSS

Differential Revision: D20119333

Pulled By: gchanan

fbshipit-source-id: 15042ca0fabdc88b53d662b6dd964968f64997f4
2020-02-27 12:23:25 -08:00
JeongUkJae
b10761d890 fix type stub errors (#33762)
Summary:
I've been using pytorch with type hintings, and I found errors that can be easily fixed. So I'm creating this PR to fix type bugs.

I expected below code should be type-checked without any errors.

```python
import torch
from torch.nn import Linear
from torch.autograd import Variable
from torch.optim import AdamW
from torch.utils import hooks

# nn.Module should have training attribute
module = Linear(10, 20)
module.training

# torch should have dtype bfloat16
tensor2 = torch.tensor([1,2,3], dtype=torch.bfloat16)

# torch.Tensor.cuda should accept int or str value
torch.randn(5).cuda(1)
torch.tensor(5).cuda('cuda:0')

# optimizer should have default attribute
module = Linear(10, 20)
print(AdamW(module.weight).default)

# torch.Tensor should have these boolean attributes
torch.tensor([1]).is_sparse
torch.tensor([1]).is_quantized
torch.tensor([1]).is_mkldnn

# Size class should tuple of int
a, b = torch.tensor([[1,2,3]]).size()

# check modules can be accessed
torch.nn.parallel
torch.autograd.profiler
torch.multiprocessing
torch.sparse
torch.onnx
torch.jit
torch.hub
torch.random
torch.distributions
torch.quantization
torch.__config__
torch.__future__

torch.ops
torch.classes

# Variable class's constructor should return Tensor
def fn_to_test_variable(t: torch.Tensor):
    return None

v = Variable(torch.tensor(1))
fn_to_test_variable(v)

# check RemovableHandle attributes can be accessed
handle = hooks.RemovableHandle({})
handle.id
handle.next_id

# check torch function hints
torch.is_grad_enabled()
```

But current master branch raises errors. (I checked with pyright)

```
$ pyright test.py
Searching for source files
Found 1 source file
test.py
  12:45 - error: 'bfloat16' is not a known member of module
  15:21 - error: Argument of type 'Literal[1]' cannot be assigned to parameter 'device' of type 'Optional[device]'
  'int' is incompatible with 'device'
  Cannot assign to 'None'
  16:22 - error: Argument of type 'Literal['cuda:0']' cannot be assigned to parameter 'device' of type 'Optional[device]'
  'str' is incompatible with 'device'
  Cannot assign to 'None'
  23:19 - error: Cannot access member 'is_sparse' for type 'Tensor'
  Member 'is_sparse' is unknown
  24:19 - error: Cannot access member 'is_quantized' for type 'Tensor'
  Member 'is_quantized' is unknown
  25:19 - error: Cannot access member 'is_mkldnn' for type 'Tensor'
  Member 'is_mkldnn' is unknown
  32:7 - error: 'autograd' is not a known member of module
  33:7 - error: 'multiprocessing' is not a known member of module
  34:7 - error: 'sparse' is not a known member of module
  35:7 - error: 'onnx' is not a known member of module
  36:7 - error: 'jit' is not a known member of module
  37:7 - error: 'hub' is not a known member of module
  38:7 - error: 'random' is not a known member of module
  39:7 - error: 'distributions' is not a known member of module
  40:7 - error: 'quantization' is not a known member of module
  41:7 - error: '__config__' is not a known member of module
  42:7 - error: '__future__' is not a known member of module
  44:7 - error: 'ops' is not a known member of module
  45:7 - error: 'classes' is not a known member of module
  60:7 - error: 'is_grad_enabled' is not a known member of module
20 errors, 0 warnings
Completed in 1.436sec
```

and below list is not checked as errors, but I think these are errors too.

* `nn.Module.training` is not boolean
* return type of `torch.Tensor.size()` is `Tuple[Unknown]`.

 ---

related issues.

https://github.com/pytorch/pytorch/issues/23731, https://github.com/pytorch/pytorch/issues/32824, https://github.com/pytorch/pytorch/issues/31753
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33762

Differential Revision: D20118884

Pulled By: albanD

fbshipit-source-id: 41557d66674a11b8e7503a48476d4cdd0f278eab
2020-02-27 06:58:53 -08:00
Pavel Belevich
095de1e872 Migrate random_ from the TH to Aten (CPU and CUDA) (#33663)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33663

Test Plan: Imported from OSS

Differential Revision: D20056350

Pulled By: pbelevich

fbshipit-source-id: f9859b79ffdec70c48d6ee3ec70fd6fad593a9f5
2020-02-27 05:05:42 -08:00
Michael Suo
f5952cf7cb fix lint (#33861)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33861

Test Plan: Imported from OSS

Differential Revision: D20136865

Pulled By: suo

fbshipit-source-id: 4bf7ac324a0abce9b45121ac5ab438448a6f3149
2020-02-27 00:33:51 -08:00
Shihao Xu
9733711394 [JIT] Support calling Tensor.element_size() in TorchScript (#33808)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33808

# Problem

https://github.com/pytorch/pytorch/issues/33620
ghstack-source-id: 99073701

Test Plan:
```
buck test mode/dev-nosan //caffe2/test:jit -- test_numel

buck test mode/dev-nosan //caffe2/test:jit -- test_element_size

buck build mode/dev-nosan //caffe2/test:jit \
&& buck-out/gen/caffe2/test/jit\#binary.par -r test_numel

buck build mode/dev-nosan //caffe2/test:jit \
&& buck-out/gen/caffe2/test/jit\#binary.par -r test_element_size
```

Compile error

P126667043

Generated code,
```
buck-out/dev/gen/caffe2/generate-code=register_aten_ops_0.cpp/register_aten_ops_0.cpp

buck-out/dev/gen/caffe2/generate-code=register_aten_ops_2.cpp/register_aten_ops_2.cpp
```
P126667064

Differential Revision: D7050644

fbshipit-source-id: 20dbdb9c500b6d7683c23e3049d43ed0ca06d831
2020-02-26 22:30:44 -08:00
Hong Xu
00f685d2d8 Add Scalar::type() (#33603)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33603

This function returns ScalarType based on its value. This is helpful
to avoid code generated in aten_op.h has returned Scalars depending on
arg self to determine its type.

Test Plan: Imported from OSS

Differential Revision: D20100218

Pulled By: ezyang

fbshipit-source-id: 337729a7559e6abb3a16b2a563a2b92aa96c7016
2020-02-26 22:25:18 -08:00
Edward Yang
d41c8d0461 Correctly preserve "not set anywhere" TensorOptions when merging. (#33510)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33510

Previously, we would fill in TensorOption with defaults whenever an
item was missing from both the left and right side of the merge.  This
is morally incorrect: if we don't have an item on the left or right,
we should keep the entry empty (so the downstream user can apply
the appropriate defaulting rule).

I don't think this caused any bugs, but I noticed this error when
working on a later patch in my diff stack.

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

Test Plan: Imported from OSS

Differential Revision: D20001775

Pulled By: ezyang

fbshipit-source-id: 88139fc268b488cd1834043584a0d73f46c8ecaa
2020-02-26 21:46:39 -08:00