PyTorch MergeBot
462b727d1e
Revert "Add decomposition for permute_copy ( #130944 )"
...
This reverts commit ab9a7eadd3 .
Reverted https://github.com/pytorch/pytorch/pull/130944 on behalf of https://github.com/jeanschmidt due to Broke internal signal executorch.backends.xnnpack.test.ops.permute.TestPermute, more details on D62737086. @eellison could you please help get this PR merged to main? ([comment](https://github.com/pytorch/pytorch/pull/130944#issuecomment-2355846394 ))
2024-09-17 13:42:55 +00:00
PyTorch MergeBot
2c4ae81494
Revert "Add decomposition for squeeze_copy ( #130941 )"
...
This reverts commit c33b0580e6 .
Reverted https://github.com/pytorch/pytorch/pull/130941 on behalf of https://github.com/jeanschmidt due to Need to revert in order to be able to revert https://github.com/pytorch/pytorch/pull/130944 , after fixing any merge conflicts, feel free to merge it back ([comment](https://github.com/pytorch/pytorch/pull/130941#issuecomment-2355831480 ))
2024-09-17 13:39:07 +00:00
Tom Ritchford
c33b0580e6
Add decomposition for squeeze_copy ( #130941 )
...
* Extracted from #128416
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130941
Approved by: https://github.com/amjames , https://github.com/eellison
2024-09-16 15:46:57 +00:00
Tom Ritchford
ab9a7eadd3
Add decomposition for permute_copy ( #130944 )
...
* Extracted from #129476
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130944
Approved by: https://github.com/amjames , https://github.com/eellison
2024-09-15 19:35:14 +00:00
Tom Ritchford
e05ea2b179
Add decomposition for transpose_copy ( #130943 )
...
* Extracted from #128416
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130943
Approved by: https://github.com/amjames , https://github.com/eellison
2024-09-11 19:45:22 +00:00
Pian Pawakapan
177e4f4218
remove _check call on item() for torch.istft ( #135234 )
...
Fixes #135014
Pull Request resolved: https://github.com/pytorch/pytorch/pull/135234
Approved by: https://github.com/tugsbayasgalan
2024-09-06 17:31:25 +00:00
Tobias Ringwald
758d787901
Added complex support for torch.logsumexp ( #133187 )
...
Added complex support for `torch.logsumexp`. Implemented complex backward pass for `torch.logsumexp`.
Fixes #133047
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133187
Approved by: https://github.com/amjames , https://github.com/lezcano
2024-09-03 17:28:36 +00:00
Spencer Gibson
3e42f21eee
Bucketize fix to include number and tensor inputs ( #133652 )
...
Fixes #132222
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133652
Approved by: https://github.com/ezyang
2024-08-28 13:35:41 +00:00
cyy
b567ca0f51
Remove unused imported names in python files ( #134438 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134438
Approved by: https://github.com/zou3519
2024-08-27 20:44:04 +00:00
Bob Ren
94f92fbd88
Use integer divison in arange length calculation when start/end/step are integral ( #134296 )
...
Fixes #133338
Test Plan:
```
TORCH_LOGS=dynamic python
import torch
torch._dynamo.config.capture_scalar_outputs = True
@torch.compile()
def f(x):
y = x.item()
torch._check_is_size(y)
r = torch.arange(y, dtype=torch.float32)
torch._check(r.size(0) == y)
return r
f(torch.tensor([300]))
```
Before and after diff. Verify the following line
```
I0813 11:05:44.890000 652898 torch/fx/experimental/symbolic_shapes.py:5198] [0/0] runtime_assert Eq(CeilToInt(IntTrueDiv(u0, 1)), u0) [guard added] at aa.py:10 in f (_dynamo/utils.py:2092 in run_node), for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="Eq(CeilToInt(IntTrueDiv(u0, 1)), u0)"
```
no longer shows in the logs. Also verify CI passes.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134296
Approved by: https://github.com/aorenste
2024-08-24 21:09:28 +00:00
Lucy Qiu
6f738d6434
Remove early exit in constant_pad_nd for export ( #132679 )
...
Summary:
Remove the early exit for padding when padding = [0, 0, 0, 0].
This prevents export from specializing when all padding=0, allowing export when all padding >= 0. Specialization will still happen for negative padding.
This change will be used to export image preprocess for multimodal models, where images of dynamic shape are padded. As images are of dynamic shape, we can't be sure if padding will be required or not. Padding is guaranteed to be non-negative.
Preprocess code: https://github.com/pytorch/torchtune/pull/1242
Note: the alternative is to wrap padding in a custom op, which isn't ideal given the custom op will contain the same impl as constant_pad_nd.
Test Plan: ci
Differential Revision: D60687727
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132679
Approved by: https://github.com/ezyang
2024-08-20 00:07:41 +00:00
Edward Z. Yang
fc32732596
Don't attempt to compute hints for unbacked expressions ( #132060 )
...
This breaks the inference we made that if you cat an N-D tensor with a 1-D tensor of size (u0,), the u0 must be zero, but no one really wanted that anyway...
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132060
Approved by: https://github.com/Skylion007
2024-08-02 16:39:14 +00:00
PyTorch MergeBot
1197550876
Revert "Don't attempt to compute hints for unbacked expressions ( #132060 )"
...
This reverts commit d342dc0179 .
Reverted https://github.com/pytorch/pytorch/pull/132060 on behalf of https://github.com/ezyang due to test_correct_module_names ([comment](https://github.com/pytorch/pytorch/pull/132407#issuecomment-2265754857 ))
2024-08-02 16:32:43 +00:00
Edward Z. Yang
d342dc0179
Don't attempt to compute hints for unbacked expressions ( #132060 )
...
This breaks the inference we made that if you cat an N-D tensor with a 1-D tensor of size (u0,), the u0 must be zero, but no one really wanted that anyway...
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132060
Approved by: https://github.com/Skylion007
ghstack dependencies: #131649 , #132407
2024-08-02 12:09:37 +00:00
Xuehai Pan
e7eeee473c
[BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ ( #129765 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129765
Approved by: https://github.com/ezyang
2024-07-31 10:42:50 +00:00
Tom Ritchford
bdf5a6dca9
Add decomposition for unsqueeze_copy ( #130942 )
...
* Extracted from #128416
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130942
Approved by: https://github.com/peterbell10
2024-07-29 21:13:37 +00:00
Tom Ritchford
962f248437
Add decomposition for expand_copy ( #130940 )
...
* Extracted from #129476
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130940
Approved by: https://github.com/peterbell10
2024-07-29 16:23:56 +00:00
PyTorch MergeBot
2c4023d65f
Revert "[BE] typing for decorators - _refs/nn/functional ( #131581 )"
...
This reverts commit dbf7c318b2 .
Reverted https://github.com/pytorch/pytorch/pull/131581 on behalf of https://github.com/clee2000 due to breaking lint internally D60265575 ([comment](https://github.com/pytorch/pytorch/pull/131572#issuecomment-2254328359 ))
2024-07-28 03:29:31 +00:00
Aaron Orenstein
dbf7c318b2
[BE] typing for decorators - _refs/nn/functional ( #131581 )
...
See #131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131581
Approved by: https://github.com/oulgen , https://github.com/zou3519
ghstack dependencies: #131568 , #131569 , #131570 , #131571 , #131572 , #131573 , #131574 , #131575 , #131576 , #131577 , #131578 , #131579 , #131580
2024-07-26 05:00:03 +00:00
Aaron Orenstein
4a5a87168e
[BE] typing for decorators - _prims_common/wrappers ( #131567 )
...
See #131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131567
Approved by: https://github.com/oulgen , https://github.com/zou3519
2024-07-25 14:35:13 +00:00
Patryk Merchelski
e8956c9fe6
Allow cpu scalar to be moved to HPU in masked_fill_decomposition ( #127871 )
...
Extension of the condition allowing the cpu scalar to be moved to specific devices.
This fixes an HPU specific error:
`torch._dynamo.exc.BackendCompilerFailed: backend='aot_hpu_training_backend' raised:
RuntimeError: Expected `value` to be on same device as `a`While executing %masked_fill : [num_users=1] = call_method[target=masked_fill](args = (%matmul, %expand_as, %tensor), kwargs = {})`
On the HPU in eager mode the problem doesn't occur because the pytorch's implementation is not used then.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127871
Approved by: https://github.com/jgong5 , https://github.com/ezyang
2024-07-25 13:04:55 +00:00
Aaron Orenstein
44fdf24967
[BE] typing for decorators - jit/_decompositions ( #131566 )
...
See #131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131566
Approved by: https://github.com/oulgen , https://github.com/zou3519
2024-07-24 20:28:28 +00:00
Aaron Orenstein
5a0068cc69
[BE] mypy: disallow untyped decorators ( #131428 )
...
Untyped decorators strip the types from their decorated function so even if the underlying function is fully typed then callers to it don't get any benefit from type annotations.
Step 1 - Enable the error and override in all the offending files.
#131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131428
Approved by: https://github.com/justinchuby , https://github.com/oulgen
2024-07-23 21:50:55 +00:00
Tom Ritchford
16247987a1
Add decomposition for t_copy ( #130939 )
...
* Extracted from #128416
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130939
Approved by: https://github.com/peterbell10
2024-07-23 08:29:19 +00:00
Tom Ritchford
500cbb5b90
Add decomposition for view_copy ( #130938 )
...
* Extracted from #128416
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130938
Approved by: https://github.com/peterbell10
ghstack dependencies: #130937
2024-07-21 20:39:24 +00:00
Tom Ritchford
f628813066
Fix out_wrapper, _make_copy_from_view to handle all signatures ( #130937 )
...
* See #128416 and #129476
* Simplify xskip lists in test/functorch/test_ops.py
* Add supports_out=True to OpInfos for copy ops
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130937
Approved by: https://github.com/peterbell10
2024-07-21 20:39:24 +00:00
Isuru Fernando
bb4251213b
Add decomposition for channel_shuffle ( #118775 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118775
Approved by: https://github.com/peterbell10
2024-07-20 01:24:41 +00:00
Xuehai Pan
4d7bf72d93
[BE][Easy] fix ruff rule needless-bool (SIM103) ( #130206 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130206
Approved by: https://github.com/malfet
2024-07-14 08:17:52 +00:00
PyTorch MergeBot
d97d962082
Revert "Add decompositions for copy variants of view ops ( #128416 )"
...
This reverts commit 68751799b8 .
Reverted https://github.com/pytorch/pytorch/pull/128416 on behalf of https://github.com/izaitsevfb due to breaks test_qs8_permute_copy test in executorch ([comment](https://github.com/pytorch/pytorch/pull/128416#issuecomment-2224023423 ))
2024-07-11 22:09:23 +00:00
PyTorch MergeBot
a2f630a9a4
Revert "Decompose expand_copy and permute_copy ( #129476 )"
...
This reverts commit 7d4cb21098 .
Reverted https://github.com/pytorch/pytorch/pull/129476 on behalf of https://github.com/izaitsevfb due to depends on #128416 which needs to be reverted ([comment](https://github.com/pytorch/pytorch/pull/129476#issuecomment-2224019720 ))
2024-07-11 22:06:15 +00:00
Xuehai Pan
973037be6a
[BE][Easy] apply autofix for ruff rules unnecessary-collection-call (C408): list() / tuple() / dict() ( #130199 )
...
This PR changes the empty collection factory call to Python literals:
- `list()` -> `[]`
- `tuple()` -> `()`
- `dict()` -> `{}`
The Python literals are more performant and safer. For example, the bytecode for building an empty dictionary:
```bash
$ python3 -m dis - <<EOS
import collections
d1 = {}
d2 = dict()
dict = collections.OrderedDict
d3 = dict()
EOS
```
```text
0 0 RESUME 0
1 2 LOAD_CONST 0 (0)
4 LOAD_CONST 1 (None)
6 IMPORT_NAME 0 (collections)
8 STORE_NAME 0 (collections)
3 10 BUILD_MAP 0
12 STORE_NAME 1 (d1)
4 14 PUSH_NULL
16 LOAD_NAME 2 (dict)
18 CALL 0
26 STORE_NAME 3 (d2)
6 28 LOAD_NAME 0 (collections)
30 LOAD_ATTR 8 (OrderedDict)
50 STORE_NAME 2 (dict)
7 52 PUSH_NULL
54 LOAD_NAME 2 (dict)
56 CALL 0
64 STORE_NAME 5 (d3)
66 RETURN_CONST 1 (None)
```
The dict literal `{}` only has one bytecode `BUILD_MAP`, while the factory call `dict()` has three `PUSH_NULL + LOAD_NAME + CALL`. Also, the factory call is not safe if users override the `dict` name in `locals` or `globals` (see the example of replacing with `OrderedDict` above).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130199
Approved by: https://github.com/malfet
2024-07-11 17:30:28 +00:00
Tom Ritchford
7d4cb21098
Decompose expand_copy and permute_copy ( #129476 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129476
Approved by: https://github.com/amjames , https://github.com/lezcano
2024-07-10 17:12:01 +00:00
Tom Ritchford
68751799b8
Add decompositions for copy variants of view ops ( #128416 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128416
Approved by: https://github.com/amjames , https://github.com/lezcano
2024-07-10 01:39:09 +00:00
awayzjj
ccc4ee7793
check boolean alpha and beta of Fake tensor impl for Tensor.addr ( #129839 )
...
Fixes https://github.com/pytorch/pytorch/issues/127043
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129839
Approved by: https://github.com/lezcano
2024-07-02 09:20:49 +00:00
Isuru Fernando
e096faaf30
Fix rot90 decomposition for no rotation ( #129097 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129097
Approved by: https://github.com/peterbell10
ghstack dependencies: #129096
2024-06-24 22:19:42 +00:00
eellison
8cd9b10456
Fix exp decomp numerics ( #129154 )
...
Our previous implementation would sometimes generate `inf` because we did not do the same numerics tricks as in eager:
See comment / [link](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/core/TransformationHelper.h#L123-L144 ) :
```
# curand_uniform has (0,1] bounds. log(1) is 0 and exponential excludes 0.
# we need log to be not 0, and not underflow when converted to half
# fast __logf approximation can underflow, so set log to -epsilon/2 for 1 or close to 1 args
```
Fix for https://github.com/pytorch/pytorch/issues/127749 .
Added a test for non-inf, but it would be great to have more robust decomp distribution tests.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129154
Approved by: https://github.com/bdhirsh , https://github.com/zou3519
2024-06-21 03:21:30 +00:00
Ambareesh Shyam Sundar
0f81473d7b
Update fake tensor error checks for bool tensor subtraction ( #128492 )
...
Fixes #127003
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128492
Approved by: https://github.com/soulitzer
2024-06-17 13:41:15 +00:00
Tom Ritchford
edb45dce85
Add OpInfo entry for as_strided_copy ( #127231 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127231
Approved by: https://github.com/lezcano
2024-06-13 13:58:47 +00:00
Tom Ritchford
2386045e4f
Add OpInfo entry for alias_copy ( #127232 ) ( #128142 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128142
Approved by: https://github.com/lezcano
2024-06-12 09:39:58 +00:00
PyTorch MergeBot
3b73f5de3a
Revert "Add OpInfo entry for alias_copy ( #127232 ) ( #128142 )"
...
This reverts commit 04da6aeb61 .
Reverted https://github.com/pytorch/pytorch/pull/128142 on behalf of https://github.com/DanilBaibak due to The changes broke the test_output_match_alias_copy_cpu_complex64 test. ([comment](https://github.com/pytorch/pytorch/pull/128142#issuecomment-2158793878 ))
2024-06-10 16:17:16 +00:00
Tom Ritchford
04da6aeb61
Add OpInfo entry for alias_copy ( #127232 ) ( #128142 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128142
Approved by: https://github.com/lezcano
2024-06-10 15:01:53 +00:00
Aaron Orenstein
afe15d2d2f
Flip default value for mypy disallow_untyped_defs [3/11] ( #127840 )
...
See #127836 for details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127840
Approved by: https://github.com/oulgen
2024-06-08 18:28:01 +00:00
Shaz Qadeer
cbb7e3053f
View specialization ( #127641 )
...
This PR adds specialization shortcuts for converting n-d to 1-d and 1-d to 2-d views.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127641
Approved by: https://github.com/ezyang
2024-06-08 05:52:52 +00:00
PyTorch MergeBot
0ef5229569
Revert "Change lerp decomp to use aten.as_strided_copy instead of prims.copy_strided ( #128030 )"
...
This reverts commit fdf1666b20 .
Reverted https://github.com/pytorch/pytorch/pull/128030 on behalf of https://github.com/nWEIdia due to breaking cuda12.1 test_cuda, see HUD https://hud.pytorch.org/hud/pytorch/pytorch/main/1?per_page=50&name_filter=inductor ([comment](https://github.com/pytorch/pytorch/pull/128030#issuecomment-2155764546 ))
2024-06-08 02:34:06 +00:00
angelayi
fdf1666b20
Change lerp decomp to use aten.as_strided_copy instead of prims.copy_strided ( #128030 )
...
aten.lerp decomposition causes prims::copy_strided to appear in the graph, which is not core aten.
Internal ref: https://fb.workplace.com/groups/pytorch.edge.users/permalink/1525644288305859/
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128030
Approved by: https://github.com/Skylion007 , https://github.com/zou3519
2024-06-07 20:12:52 +00:00
PyTorch MergeBot
c58d3af3b4
Revert "Add OpInfo entry for alias_copy ( #127232 )"
...
This reverts commit 457df212e1 .
Reverted https://github.com/pytorch/pytorch/pull/127232 on behalf of https://github.com/clee2000 due to broke [onnx](https://github.com/pytorch/pytorch/actions/runs/9397057801/job/25880181144 ) and [mps](https://github.com/pytorch/pytorch/actions/runs/9397057805/job/25879818705 ) tests, [hud link](457df212e1 ) , base is 15 days old, the onnx test xfailed on the pr but the xfail was removed so if you rebase itll surface, mps build failed so no mps tests were run on the pr ([comment](https://github.com/pytorch/pytorch/pull/127232#issuecomment-2152848758 ))
2024-06-06 15:44:47 +00:00
Tom Ritchford
457df212e1
Add OpInfo entry for alias_copy ( #127232 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127232
Approved by: https://github.com/lezcano
2024-06-06 07:46:26 +00:00
Edward Z. Yang
c73c9457aa
Add guard_size_oblivious to vector_norm ( #126772 )
...
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/126772
Approved by: https://github.com/lezcano , https://github.com/Skylion007
ghstack dependencies: #126771
2024-05-21 19:53:21 +00:00
Matthew Hoffman
81277baa0c
Remove removed ruff rule TRY200 ( #126256 )
...
My TOML linter is complaining that "TRY200" is not acceptable for the `tool.ruff.lint` schema.
From the ruff docs: https://docs.astral.sh/ruff/rules/reraise-no-cause/
> This rule has been removed and its documentation is only available for historical reasons.
>
> This rule is identical to [B904](https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/ ) which should be used instead.
and we are currently explicitly ignoring B904.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/126256
Approved by: https://github.com/Skylion007
2024-05-17 16:31:05 +00:00
Guilherme Leobas
402170b22f
Early return in _recursive_build if obj is a Tensor ( #125639 )
...
Fix issue #125551
Pull Request resolved: https://github.com/pytorch/pytorch/pull/125639
Approved by: https://github.com/ezyang
2024-05-17 15:53:37 +00:00