Commit Graph

11 Commits

Author SHA1 Message Date
Edward Z. Yang
597e2a11a3 indexing_dtype_strength_reduction more aggressive free_symbols tests (#103470)
ValueRanges can't handle symbolic bounds. Be a bit more careful about detecting if you try to pass in expressions with free symbols, and fall back to "don't know" range if this occurs.

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

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103470
Approved by: https://github.com/eellison
2023-06-13 16:00:41 +00:00
XiaobingSuper
49cd184f89 inductor: improve the index range check for index_expr vec check (#102263)
Fix https://github.com/pytorch/pytorch/issues/102065.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/102263
Approved by: https://github.com/lezcano, https://github.com/peterbell10, https://github.com/jgong5
2023-06-01 03:07:14 +00:00
Sergii Dymchenko
477f3f555f Simplify by using yield from (#97831)
The issues were found by SIM104 flake8-simplify in a local run.

I'll take a look on adding the check to the CI separately.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/97831
Approved by: https://github.com/Skylion007
2023-03-29 19:15:24 +00:00
Edward Z. Yang
50bc25baa0 Move ValueRanges into its own module (#94528)
I am going to use it in ShapeEnv shortly.

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

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94528
Approved by: https://github.com/eellison
2023-02-11 02:54:49 +00:00
Jason Ansel
24ae50bcc7 Add config option to reduce warnings in inductor (#94413)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94413
Approved by: https://github.com/ezyang
2023-02-10 15:44:15 +00:00
Aaron Gokaslan
8fce9a09cd [BE]: pyupgrade Python to 3.8 - imports and object inheritance only (#94308)
Apply parts of pyupgrade to torch (starting with the safest changes).
This PR only does two things: removes the need to inherit from object and removes unused future imports.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94308
Approved by: https://github.com/ezyang, https://github.com/albanD
2023-02-07 21:10:56 +00:00
Jason Ansel
24b501903c Minor sympy usage fix in fbcode (#93171)
Summary: To supports older versions of sympy.

Test Plan:
```
buck2 run @//mode/opt @//mode/inplace -c python.package_style=inplace -c fbcode.enable_gpu_sections=true //caffe2/benchmarks/dynamo:torchbench -- -dcuda --performance --inductor --only hf_T5
```

Differential Revision: D42812188

Pull Request resolved: https://github.com/pytorch/pytorch/pull/93171
Approved by: https://github.com/eellison
2023-01-30 23:34:22 +00:00
Horace He
19c9b09449 Replace IndexingDiv with FloorDiv in Inductor (#92878)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92878
Approved by: https://github.com/ezyang
2023-01-24 15:06:22 +00:00
lezcano
353e9f883f Add name attribute to ValueRangeAnalysis (#92121)
This is expected when used within InterpreterShim.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/92121
Approved by: https://github.com/eellison
2023-01-14 12:07:52 +00:00
lezcano
fd0030fe74 Fix indexing_dtype_strength_reduction (#91601)
Many of the previous inductive cases were wrong (e.g. `abs`, `sq`, `div` and `truediv`).
We rewrite it using the mathematical terms that allow to prove the relevant upper
and lower bounds.

Note that the inductive step can be seen as a not-too-difficult optimisation problem
with constraints, hence the naming of the functions.

For many of the other functions, we also simplify the formulas, which will be useful
when this code is generalised to work with symbolic shapes.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/91601
Approved by: https://github.com/jansel, https://github.com/eellison
2023-01-10 23:39:30 +00:00
Elias Ellison
8b3d31cfc5 Add A ValueRange Analysis Pass to convert int64 indexing to int32 (#91028)
Builds up sympy expressions computing the lower and upper bound of ranges, and then finds `op.to_dtype(x, torch.int64)` nodes whose dominated values can all be computed in a lower precision. I haven't gotten all the way to work with dynamic shapes but it should be a fairly small change. There's still additional work to get torchinductor to work with large tensors (see https://github.com/pytorch/torchdynamo/issues/1819) because we would need to add explicit dtype annotations to int64 which we're not doing right now.

Fix for https://github.com/pytorch/torchdynamo/issues/1293.

Performance Before OpBench aten.upsample_bilinear2d.vec float32:
(25th %, 50th %, 75th %)
Before
[0.7521964636710751, 0.8645357996607477, 2.8746003906598494]
After:
[0.9511363478204263, 1.0295566597806718, 3.2662165264101755]
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91028
Approved by: https://github.com/jansel
2022-12-22 20:04:26 +00:00