Commit Graph

1719 Commits

Author SHA1 Message Date
Edward Yang
4d72538f80 Give Tensor a trivial (for now) metaclass _TensorMeta (#56147)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56147

This is support of #55686, you can see the broader context of the metaclass in
a more complete PR #56017.  The short story is that in the future I want to
give Tensor a non-trivial metaclass, so to derisk the change first I give it a
trivial metaclass to shake out any bugs that might be caused by it.  The
metaclass shouldn't have any performance impact on Tensor as it only gets
invoked upon subclass creation.

By the way, it was totally not documented how to create metaclasses in the Python
C API, and it took a good bit of trial error to figure it out (and the answer is
now immortalized in https://stackoverflow.com/q/67077317/23845 -- the things
that I got wrong in earlier versions of the PR included setting tp_basicsize
incorrectly, incorrectly setting Py_TPFLAGS_HAVE_GC on the metaclass--you want
to leave it unset so that it inherits, and determining that tp_init is what
actually gets called when you construct a class, not tp_call as another
not-to-be-named StackOverflow question suggests).

Aside: Ordinarily, adding a metaclass to a class is a user visible change, as
it means that it is no longer valid to mixin another class with a different
metaclass. However, because _C._TensorBase is a C extension object, it will
typically conflict with most other metaclasses, so this is not BC breaking.

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

Test Plan: Imported from OSS

Reviewed By: H-Huang

Differential Revision: D28028747

Pulled By: ezyang

fbshipit-source-id: c1e35a986aeb3db540c73d188f53dce951eeed33
2021-04-28 09:24:21 -07:00
Heitor Schueroff
57e37080cd Added OpInfo for torch.einsum (#56276)
Summary:
Adds OpInfo testing for torch.einsum.

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

Reviewed By: mruberry

Differential Revision: D27967095

Pulled By: heitorschueroff

fbshipit-source-id: 60524273d2ca885e7eeb932db3e7fd697ae5ca8e
2021-04-27 07:39:38 -07:00
Sam Estep
e3900d2ba5 Add lint for unqualified noqa (#56272)
Summary:
As this diff shows, currently there are a couple hundred instances of raw `noqa` in the codebase, which just ignore all errors on a given line. That isn't great, so this PR changes all existing instances of that antipattern to qualify the `noqa` with respect to a specific error code, and adds a lint to prevent more of this from happening in the future.

Interestingly, some of the examples the `noqa` lint catches are genuine attempts to qualify the `noqa` with a specific error code, such as these two:
```
test/jit/test_misc.py:27:            print(f"{hello + ' ' + test}, I'm a {test}") # noqa E999
test/jit/test_misc.py:28:            print(f"format blank") # noqa F541
```
However, those are still wrong because they are [missing a colon](https://flake8.pycqa.org/en/3.9.1/user/violations.html#in-line-ignoring-errors), which actually causes the error code to be completely ignored:

- If you change them to anything else, the warnings will still be suppressed.
- If you add the necessary colons then it is revealed that `E261` was also being suppressed, unintentionally:
  ```
  test/jit/test_misc.py:27:57: E261 at least two spaces before inline comment
  test/jit/test_misc.py:28:35: E261 at least two spaces before inline comment
  ```

I did try using [flake8-noqa](https://pypi.org/project/flake8-noqa/) instead of a custom `git grep` lint, but it didn't seem to work. This PR is definitely missing some of the functionality that flake8-noqa is supposed to provide, though, so if someone can figure out how to use it, we should do that instead.

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

Test Plan:
CI should pass on the tip of this PR, and we know that the lint works because the following CI run (before this PR was finished) failed:

- https://github.com/pytorch/pytorch/runs/2365189927

Reviewed By: janeyx99

Differential Revision: D27830127

Pulled By: samestep

fbshipit-source-id: d6dcf4f945ebd18cd76c46a07f3b408296864fcb
2021-04-19 13:16:18 -07:00
Zhengxu Chen
8176ab6ca0 [JIT] Put explicit error message on class attribute accesses. (#55723)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55723

Resolving https://github.com/pytorch/pytorch/issues/51139

Test Plan:
python test/test_jit.py TestClassType.test_unresolved_attributes

Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27691960

fbshipit-source-id: 1d078a4ab25af1a73109ca6ef0333a67a634bff6
2021-04-16 15:47:10 -07:00
Tugsbayasgalan Manlaibaatar
1360980659 Remove duplicate test due to rebasing mistake (#56287)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56287

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27828430

Pulled By: tugsbayasgalan

fbshipit-source-id: a5d846871ce78399409113fd5dbf2c43a4e46296
2021-04-16 13:57:13 -07:00
Tugsbayasgalan Manlaibaatar
b405e2ce12 Implicit conversion from null tensor to NoneType (#55823)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55823

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27717324

Pulled By: tugsbayasgalan

fbshipit-source-id: a071b90bcea9e8f2b5da633a8dadd11772fb5101
2021-04-16 00:05:52 -07:00
nikithamalgi
14d529a368 Add support for refinement for torch.jit.Future (#56148)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56148

Fixes issue: #55787

Test Plan: Imported from OSS

Reviewed By: navahgar

Differential Revision: D27796830

Pulled By: nikithamalgifb

fbshipit-source-id: b7a60218010793a54eb52d6b7602d333dc5a1c9e
2021-04-15 14:08:58 -07:00
James Reed
71a5314591 Fix ScriptMethod dispatch on __torch_function__ (#56103)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56103

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D27784142

Pulled By: jamesr66a

fbshipit-source-id: 555dcb7c3a98b8fb9e9ca9b499cafad54e819aa7
2021-04-15 08:46:43 -07:00
nikithamalgi
d7d7556f17 Move tensor implicit conversions to test_builtins.py (#55532)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55532

Test Plan: Imported from OSS

Reviewed By: mruberry

Differential Revision: D27729682

Pulled By: nikithamalgifb

fbshipit-source-id: d2517ee68b83e59cde87b8fb7d5bf7203f02cbc6
2021-04-13 07:13:20 -07:00
nikithamalgi
8fc16da649 [Hackathon]Move tests for slice to test_slice.py (#55524)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55524

Test Plan: Imported from OSS

Reviewed By: driazati

Differential Revision: D27686738

Pulled By: nikithamalgifb

fbshipit-source-id: f1896d739c3a3a7ece987f6eea4072477626231b
2021-04-12 21:02:19 -07:00
nikithamalgi
5cd73df8f8 [Hackathon]Move complex tests to test_complex.py (#55514)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55514

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D27679881

Pulled By: nikithamalgifb

fbshipit-source-id: 8a4f4ab8f375187b72ede6feaea37ab546da6d3e
2021-04-12 20:35:36 -07:00
James Reed
68e0796466 [JIT][write path] Make NoneType annotation_str emit NoneType instead of None (#54746)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54746

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27350331

Pulled By: jamesr66a

fbshipit-source-id: 3f44d6589c29f39378432d0b6b281d96bb4829e7
2021-04-12 17:36:45 -07:00
James Reed
a3c06e69aa [JIT][write path] Fix TupleType.annotation_str to conform to typing module syntax for empty tuple type (#54745)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54745

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27350332

Pulled By: jamesr66a

fbshipit-source-id: 62af3b2b53561bb8e4adbdc0aec54520e08a5bf7
2021-04-12 17:29:33 -07:00
Sameer Deshmukh
5fb1142702 Add CSR (compressed sparse row) layout for sparse tensors (#50937)
Summary:
Implement compressed sparse row format. Derived from the GCS implementation at https://github.com/pytorch/pytorch/pull/44190

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

Reviewed By: mrshenli

Differential Revision: D27439865

Pulled By: ezyang

fbshipit-source-id: 3ba3dcb9679505b980ff6a5f513e913bbae2fb1d
2021-04-12 10:09:12 -07:00
Yukio Siraichi
93bf0ae6fc Remove legacy constructor calls from pytorch codebase. (#54142)
Summary:
Follow up from https://github.com/pytorch/pytorch/issues/53889
Related to https://github.com/pytorch/pytorch/issues/47112

Removing every occurrence of the legacy constructor call present in PyTorch at:
- _docs_
- _benchmarks_
- _test_
- _caffe2_
- _CONTRIBUTING.md_

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

Reviewed By: ngimel

Differential Revision: D27699450

Pulled By: mruberry

fbshipit-source-id: 530aa3f5746cc8bc1407d5d51b2bbd8075e30546
2021-04-11 15:45:17 -07:00
Yanan Cao
fa29a647db [JIT] Allow unpacking tuple and assign their values to SELECT-type expressions (#55268)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/51176

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

Reviewed By: pbelevich, izdeby

Differential Revision: D27551950

Pulled By: gmagogsfm

fbshipit-source-id: 35324b728649bb1e6c5410a1004d2f6964f98304
2021-04-11 14:21:48 -07:00
Tugsbayasgalan Manlaibaatar
b80c6f863f Disambiguate error message for working with not fully refined tuple types (#55745)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55745

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27698691

Pulled By: tugsbayasgalan

fbshipit-source-id: 7855042d37290f19d53adfc0b4da606430501663
2021-04-11 02:30:05 -07:00
Tugsbayasgalan Manlaibaatar
076961e8b5 Add tuple add operator (#52292)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52292

Test Plan: Imported from OSS

Reviewed By: Lilyjjo

Differential Revision: D26792416

Pulled By: tugsbayasgalan

fbshipit-source-id: 882325b171c1ff53ec40243d3f9334049c03fe57
2021-04-09 10:24:48 -07:00
nikithamalgi
c998f3573c [Hackathon]Move tests related to containers in typing to test_typing.py (#55504)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55504

Test Plan: Imported from OSS

Reviewed By: navahgar, pbelevich

Differential Revision: D27666760

Pulled By: nikithamalgifb

fbshipit-source-id: c1a7904f33855efa4f60f8f54c029a95a5fd529c
2021-04-08 18:40:37 -07:00
Rong Rong (AI Infra)
55db156229 remove test_jit_py3.py entirely (#55560)
Summary:
1. move module related stuff to test_module_container
2. created test_types for types and annotation
3. created test_misc for the rest

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

Reviewed By: VitalyFedyunin

Differential Revision: D27650911

Pulled By: walterddr

fbshipit-source-id: d895a7da9e9c3d25a662a37faf4daabc276b9c1a
2021-04-08 14:28:54 -07:00
Nikitha Malgi
432df40d83 [Hackathon] Move python builtins to test_python_builtins.py (#55479)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55479

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D27642098

Pulled By: nikithamalgifb

fbshipit-source-id: 8d92a7d0f6db63f3cc3f439cb75a8d809af9106d
2021-04-08 08:06:54 -07:00
Rong Rong (AI Infra)
2dd7dafb62 [Hackathon][take2] jit py3 move list dict tuple to jit/ (#55515)
Summary:
moved to jit/test_list_dict.py

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

Reviewed By: mrshenli

Differential Revision: D27627615

Pulled By: walterddr

fbshipit-source-id: 6b17a4d6535ae2d6d848532a4df2278d3aaefa7b
2021-04-07 14:25:04 -07:00
Tugsbayasgalan Manlaibaatar
10abbb812a Support tensor subclasses in Torchscript (#54817)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54817

Test Plan:
python test case

Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D27407723

fbshipit-source-id: 459b9067f07908026f94620c1cfa3e00e8b50a4e
2021-04-07 12:10:27 -07:00
James Reed
3db2333d09 [JIT] Make NoneType annotation_str emit NoneType instead of None (#54642)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54642

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27314174

Pulled By: jamesr66a

fbshipit-source-id: 153e9aa4ab781fa1d49d9d55a2e487bf7b04f0d7
2021-03-26 11:32:20 -07:00
James Reed
1e9ad6e5cd [JIT] Fix TupleType.annotation_str to conform to typing module syntax for empty tuple type (#54641)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54641

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27314173

Pulled By: jamesr66a

fbshipit-source-id: 13c6e6b571672adc443429f59f3b30aae356c03d
2021-03-26 11:30:17 -07:00
anjali411
f9ca0d87a7 Teach Python TS frontend to parse complex literals (#52881)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52881

**This PR adds:**
1. logic to parse complex constants (complex literals of the form `bj`)
2. logic to parse complex lists
3. support for complex constructors: `complex(tensor/int/float/bool, tensor/int/float/bool)`
4. Limited operator support
     - `add`, `sub`, `mul`, `torch.tensor`, `torch.as_tensor`

**Follow-up work:**
1. Add complex support for unary and other registered ops.
2. support complex constructor with string as input (this is supported in Python eager mode).
3. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.
4. onnx doesn't support complex tensors, so we should error out with a clear and descriptive error message.

Test Plan: Imported from OSS

Reviewed By: bdhirsh

Differential Revision: D27245059

Pulled By: anjali411

fbshipit-source-id: af043b5159ae99a9cc8691b5a8401503fa8d6f05
2021-03-24 08:12:17 -07:00
Elias Ellison
9be4c75fa0 [JIT] Add Reinplacing to MKLDNN Subgraphs (#53908)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53908

This adds reinplacing to MKLDNN Subgraphs so that we replace `aten::add` with `aten::add_`. Normally you would have to prove device and dtype, but we know that already, and because we have explicit broadcast nodes for other reasons we dont have to prove that the output shape of add is the same as inputs.

Ive tested correctness on resnet, I'm going to do more extensive testing as well. When I benchmarked the "unsafe" version (always inplace) I saw average speedups of ~16% for both Single threaded and Multithreaded. I dont think the "safe" version will be far beyond; when I looked at resnet for example every `add` and `relu` were reinplaced.

Theres some question of reusing other alias / liveness / inplacing passes in SR. I thought about it, however I didnt want to add a cross-dependency between very different parts of the code base with a bunch of different assumptions. The logic here is also covering a simpler case and does not add much complexity IMO.

Test Plan: Imported from OSS

Reviewed By: Krovatkin

Differential Revision: D27132969

Pulled By: eellison

fbshipit-source-id: 121a38daaedf01363f6b66a814beaaa72a0ab0dc
2021-03-22 19:21:03 -07:00
Yanan Cao
f48a9712b7 Rewrite functional.tensordot to be TorchScript-able (#53672)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/53487

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

Reviewed By: VitalyFedyunin

Differential Revision: D26934392

Pulled By: gmagogsfm

fbshipit-source-id: f842af340e4be723bf90b903793b0221af158ca7
2021-03-20 23:03:30 -07:00
Edward Yang
c2f41b6b84 Add meta device to generic device testing framework, skip NotImplementedError (#53682)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53682

With this, under the meta device, 101 tests passed and 16953 skipped.
It ain't much, but it's a start.

Some various bits and bobs:
- NotImplementedError suppression at test level is implemented
  in the same way as CUDA memory leak check, i.e., by wrapping
  test methods and monkeypatching them back in.
- I had to reimplement assertRaises/assertRaisesRegex from scratch to
  ignore NotImplementedError when _ignore_not_implemented_error is True.
  The implementation relies on a small amount of private API that hasn't
  changed since 2010
- expectedAlertNondeterministic doesn't really work so I skipped them
  all; there's probably a way to do it better

I tested this using `pytest --disable-warnings --tb=native -k meta --sw
test/*.py` and a pile of extra patches to make collection actually work
(lol).

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

Test Plan: Imported from OSS

Reviewed By: mruberry

Differential Revision: D26955539

Pulled By: ezyang

fbshipit-source-id: ac21c8734562497fdcca3b614a28010bc4c03d74
2021-03-14 20:41:19 -07:00
Philip Meier
b0afe945a7 Fix pylint error torch.tensor is not callable (#53424)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53424

Fixes https://github.com/pytorch/pytorch/issues/24807 and supersedes the stale https://github.com/pytorch/pytorch/issues/25093 (Cc Microsheep). If you now run the reproduction

```python
import torch

if __name__ == "__main__":
    t = torch.tensor([1, 2, 3], dtype=torch.float64)
```

with `pylint==2.6.0`, you get the following output

```
test_pylint.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test_pylint.py:4:8: E1101: Module 'torch' has no 'tensor' member; maybe 'Tensor'? (no-
member)
test_pylint.py:4:38: E1101: Module 'torch' has no 'float64' member (no-member)
```

Now `pylint` doesn't recognize `torch.tensor` at all, but it is promoted in the stub. Given that it also doesn't recognize `torch.float64`, I think fixing this is out of scope of this PR.

 ---

## TL;DR

This BC-breaking only for users that rely on unintended behavior. Since `torch/__init__.py` loaded `torch/tensor.py` it was populated in `sys.modules`. `torch/__init__.py` then overwrote `torch.tensor` with the actual function. With this `import torch.tensor as tensor` does not fail, but returns the function rather than the module. Users that rely on this import need to change it to `from torch import tensor`.

Reviewed By: zou3519

Differential Revision: D26223815

Pulled By: bdhirsh

fbshipit-source-id: 125b9ff3d276e84a645cd7521e8d6160b1ca1c21
2021-03-09 11:32:53 -08:00
Yanan Cao
bf88a4dad5 Support parsing Ellipsis in JIT frontend (#53576)
Summary:
De-sugars `Ellipsis` into dots (`...`)

Fixes https://github.com/pytorch/pytorch/issues/53517

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

Reviewed By: pbelevich

Differential Revision: D26904361

Pulled By: gmagogsfm

fbshipit-source-id: 5b23e049a075a9a99e37dcb47a9410b6f82a6fb7
2021-03-09 00:06:21 -08:00
mattip
54a2498919 Modify tests to use assertWarnsOnceRegex instead of maybeWarnsRegex (#52387)
Summary:
Related to https://github.com/pytorch/pytorch/issues/50006

Follow on for https://github.com/pytorch/pytorch/issues/48560 to ensure TORCH_WARN_ONCE warnings are caught. Most of this is straight-forward find-and-replace, but I did find one place where the TORCH_WARN_ONCE warning was not wrapped into a python warning.

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

Reviewed By: albanD

Differential Revision: D26773387

Pulled By: mruberry

fbshipit-source-id: 5be7efbc8ab4a32ec8437c9c45f3b6c3c328f5dd
2021-03-08 03:32:14 -08:00
Joel Schlosser
6557ea0509 Context manager for hiding source ranges (#53188)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/52456

## Background

Provides a context manager `_hide_source_ranges()` that disables printing graph source ranges by default. It can be overridden on a per-graph basis if desired.

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

Test Plan:
```
python test/test_jit.py TestJit.test_hide_source_ranges_context_manager
```

```python
import torch

torch.jit.script
def foo(x):
    return torch.add(x, x)

print(foo.graph)
with torch.jit._hide_source_ranges():
    print(foo.graph)

    # Override context manager
    print(foo.graph.str(print_source_ranges=True))

print(foo.graph)
```

```
graph(%x.1 : Tensor):
  %3 : int = prim::Constant[value=1]()
  %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11
  return (%4)

graph(%x.1 : Tensor):
  %3 : int = prim::Constant[value=1]()
  %4 : Tensor = aten::add(%x.1, %x.1, %3)
  return (%4)

graph(%x.1 : Tensor):
  %3 : int = prim::Constant[value=1]()
  %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11
  return (%4)

graph(%x.1 : Tensor):
  %3 : int = prim::Constant[value=1]()
  %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11
  return (%4)
```

Reviewed By: walterddr, zhangguanheng66

Differential Revision: D26817070

Pulled By: jbschlosser

fbshipit-source-id: e9d123452c616b0a9dda9e134ef6c2886f229d9b
2021-03-04 09:11:08 -08:00
nikithamalgi
c5b0c2fa8b Support torch.complex (#53227)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53227

========
Adds Support for Torch.complex in JIT

Test:
====
python test/test_jit.py -k test_torch_complex

Test Plan: Imported from OSS

Reviewed By: zdevito, bhosmer

Differential Revision: D26808285

Pulled By: nikithamalgifb

fbshipit-source-id: c6918b2baac814e78613a264d90941b8c6102237
2021-03-04 00:03:00 -08:00
Nikitha Malgi
7a60b7dc3e Add support to compare devices (#53045)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53045

Test Plan:
=====
python test/test_jit.py -k test_device_not_equal

Reviewed By: pbelevich

Differential Revision: D26737964

Pulled By: nikithamalgifb

fbshipit-source-id: 2205aa1f214a86282602168c364dca1363d2f7dd
2021-03-01 21:04:43 -08:00
nikithamalgi
c423733967 Add support for builtin sum (#52188)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/18627
Adds torch.sum support for JIT

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

Test Plan:
python test/test_jit.py -k test_list_sum
python test/test_jit.py -k test_torch_sum

Reviewed By: pbelevich, anjali411

Differential Revision: D26670022

Pulled By: nikithamalgifb

fbshipit-source-id: eb58f0a3a64dab4b9fa1f4eb854e9854fa9bda55
2021-02-25 21:09:34 -08:00
Tugsbayasgalan Manlaibaatar
e658d7c37b Ignore user annotated ignored attributes (#52367)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52367

This fixes https://github.com/pytorch/pytorch/issues/52217

Test Plan: Imported from OSS

Reviewed By: navahgar, gmagogsfm

Differential Revision: D26574411

Pulled By: tugsbayasgalan

fbshipit-source-id: 7eac097f5b97cfe65854bceca14d41c156cd6e0a
2021-02-23 10:40:44 -08:00
Nikolay Korovaiko
847d1d4d53 add debug_flush_compilation_cache to Method (#52317)
Summary:
Forgot to add `debug_flush_compilation_cache ` to `Method` as well.

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

Reviewed By: bdhirsh

Differential Revision: D26583313

Pulled By: Krovatkin

fbshipit-source-id: 1b3e503950cc3314796aff53b3b8038d16767870
2021-02-22 12:31:09 -08:00
nikithamalgi
e677b71056 Add support for pow (#52374)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/18627
Adds pow support for JIT

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

Test Plan: python test/test_jit.py -k test_torch_pow

Reviewed By: heitorschueroff

Differential Revision: D26555070

Pulled By: nikithamalgifb

fbshipit-source-id: 0d325f09cf893e4ae50277a95a6b7ad67d94f342
2021-02-21 19:55:58 -08:00
nikithamalgi
d819a21692 Support any (#52360)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/18627
Adds torch.any support for JIT

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

Test Plan:
python test/test_jit.py -k test_torch_any
python test/test_jit.py -k test_any

Reviewed By: tugsbayasgalan

Differential Revision: D26550626

Pulled By: nikithamalgifb

fbshipit-source-id: 36c2ae15e3bfb7b32bbf442818c879b0d2120cf1
2021-02-21 15:49:57 -08:00
Yuxin Wu
a62b0deae0 [pytorch] make is_tracing scriptable (#49853)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49853

fix https://github.com/pytorch/pytorch/issues/47379

Test Plan: buck test mode/dev-nosan //caffe2/test:jit -- 'test_script_is_tracing'

Reviewed By: SplitInfinity

Differential Revision: D25704315

fbshipit-source-id: 33c09c5bc1f1b62ef254f58e18ab1e951dbd1790
2021-02-20 02:53:28 -08:00
Richard Zou
b71215a909 Revert D26515596: [pytorch][PR] Add support for pow
Test Plan: revert-hammer

Differential Revision:
D26515596 (83feaebfc3)

Original commit changeset: 0c25a8eba8ed

fbshipit-source-id: 1a206f0b2923d922911fdaa5448a4e3a844ac5c4
2021-02-19 07:29:37 -08:00
nikithamalgi
83feaebfc3 Add support for pow (#52374)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/18627
Adds pow support for JIT

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

Test Plan: python test/test_jit.py -k test_torch_pow

Reviewed By: Lilyjjo

Differential Revision: D26515596

Pulled By: nikithamalgifb

fbshipit-source-id: 0c25a8eba8ed93291c5e447e863edac2a35b61fb
2021-02-18 23:03:28 -08:00
Nikolay Korovaiko
0019a20a2b [WIP] Add a _flush_compilation_cache for testing (#52001)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52001

Reviewed By: eellison

Differential Revision: D26371876

Pulled By: Krovatkin

fbshipit-source-id: db773d7124916bad31e80bdd7bb9b4170060977b
2021-02-16 10:49:38 -08:00
Ansley Ussery
1657d59641 Walk Python AST to check for unsupported attribute type annotations (#51805)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51805

Test Plan: Imported from OSS

Reviewed By: suo

Differential Revision: D26418589

Pulled By: ansley

fbshipit-source-id: c13e9096dcfa242d158ebf1ae4f86ef6c46ff0ec
2021-02-12 18:18:01 -08:00
Yanan Cao
705fa7e964 [Usability] Capture argument names for traced functions and modules (#51775)
Summary:
Previously `torch.jit.trace` relies on AutoGrad hooks to infer name of tensors in computation, including those of function/method arguments. This often doesn't work out because:

- These names often do not exist
- Tracer uses argument name of first tensor operation on each tensor as inferred argument names. These tensor operations have programmatically-generated names like `argument_1`

This PR extracts argument names directly from Python functions and pass them down to tracer, which then assigns them to correct graph inputs. This way, we always have the correct argument names captured in IR.

This is useful for both debugging and supporting using `InterfaceType` to represent traced modules.

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

Reviewed By: izdeby

Differential Revision: D26273105

Pulled By: gmagogsfm

fbshipit-source-id: 934a385041137dc3731bb6fa8657b11532fed9e5
2021-02-10 18:28:08 -08:00
Mike Ruberry
594a66d778 Warn about floor_divide performing incorrect rounding (#50281) (#50281)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50281

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

Test Plan: Imported from OSS

Reviewed By: ngimel

Pulled By: mruberry

Differential Revision: D26257855

fbshipit-source-id: e5d497cf07b0c746838ed081c5d0e82fb4cb701b
2021-02-10 03:13:34 -08:00
nikithamalgi
9c0caf0384 Adding support for comparing two bool varibales (#51844)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51844

Fixes issue #48174

=========

Adds support to compare two bool variables

Test:
======
python test/test_jit.py -k test_compare_two_bool_inputs

Test Plan: Imported from OSS

Reviewed By: navahgar

Differential Revision: D26353694

Pulled By: nikithamalgifb

fbshipit-source-id: 41af5ba3e4075ed7a21595b10e388a7302aa1fce
2021-02-10 02:13:25 -08:00
nikithamalgi
141f615161 Support torch.type (#51904)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51904

Fixes issue: #25433

=========
Makes tensor.type(dtype) scriptable

Test:
======
python test/test_jit.py -v TestJit.test_script_tensor_type

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D26331503

Pulled By: nikithamalgifb

fbshipit-source-id: d9188999fee601a8402fdc4d9052dee4e0d529d5
2021-02-09 11:39:57 -08:00
Chester Liu
58eb23378f Clean up usage of torch._six partially (#49785)
Summary:
See https://github.com/pytorch/pytorch/issues/42919

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

Reviewed By: mruberry

Differential Revision: D25963833

Pulled By: bugra

fbshipit-source-id: 11c90d6b8d3f206c9d0a4d8621b773beb10c6ba2
2021-02-08 13:58:34 -08:00