Commit Graph

2510 Commits (723b8b1d285638b8b0e594345df821a6f1f8c468)
 

Author SHA1 Message Date
James Newling 647f2f5076
Additional tests for view lowering (#2584)
The logic for lowering the aten view op to linalg is fairly complex. 
In this PR I have tried to follow all non-failing paths through the 
lowering and add unit tests where they're missing.

There is 1 logical change to the lowering: redundant tensor.cast ops
(same source and destination type) are folded.
2023-11-20 17:35:25 -08:00
Yuanqiang Liu 7b94189e07
[E2E] add nan case in elementwise comparison e2e tests (#2575) 2023-11-20 11:27:08 +08:00
Stella Laurenzo 5eae0adff1
Breakup python pytorch deps (#2582)
This lifts the core of the jit_ir_importer and ltc out of the pt1
project, making them peers to it. As a side-effect of this layering, now
the "MLIR bits" (dialects, etc) are not commingled with the various
parts of the pt1 project, allowing pt1 and ltc to overlay cleanly onto a
more fundamental "just MLIR" Python core. Prior to this, the Python
namespace was polluted to the point that this could not happen.

That "just MLIR" Python core will be introduced in a followup, which
will create the space to upstream the FX and ONNX pure Python importers.

This primary non-NFC change to the API is:

* `torch_mlir.dialects.torch.importer.jit_ir` ->
`torch_mlir.jit_ir_importer`.

The rest is source code layering so that we can make the pt1 project
optional without losing the other features.

Progress on #2546.
2023-11-19 12:10:19 -08:00
Yuanqiang Liu facbe5d96b
[Torch Dialect] support AtenArangeStartOutOp in ReduceOpVariants like… (#2563)
… AtenBernoulli_FloatOp

It fixing case like: `%2110 = torch.aten.arange.start_out %int1,
%int1517, %int1, %2109 : !torch.int, !torch.int, !torch.int,
!torch.tensor -> !torch.tensor`.
`aten.arange.start_out` doesn't have value semantics also, means`%2110`
is an alias for %2109.
So I decompose it to `aten.arange.start` + `torch.contents.overwrite`.  
The complex decomposition logic is target to handle cases like view and
dtype cast which I add in e2e tests.
2023-11-17 00:51:55 +08:00
James Newling dad1f012f6
Add verification for torch permute op (#2551)
- adds support for an optional verifier to the generated torch op
tablegen (GeneratedTorchOps.td)
- uses the above to add a verifier for the torch permute op. 

Motivation: I hit an unclear error from linalg while developing a
decomposition pass for pixel_shuffle. The error would have been clearer
if the problem had been detected earlier in the invalid aten.permute op.

Testing: new tests added. To run added tests, from the base directory
run

```
 ./build/bin/llvm-lit  test/Dialect/Torch/invalid.mlir
 ```
2023-11-15 11:47:54 -08:00
James Newling e81282ae8f
Support for prims collapse op (lowering to linalg) (#2572)
Steps taken:
1) add generator code to torch_ods_gen.py, run update_torch_ods.sh
2) add (custom) shape and type inference generator code to
abstract_interp_lib_gen.py, run update_abstract_interp_lib.sh
3) Implement lowering to tensor.collapse_dims. Requires the `start` and
`end` values to be constant, else lowering fails
4) Update xfail_sets.py (append to LTC_XFAIL_SET) after running
/tools/e2e_test.sh --filter Collapse --verbose -c XX for all support
backends (XX).

Motivation: 
- Supporting the collapse operation will be useful for lowering of
pixel_shuffle (see Issue #2559)
2023-11-15 08:34:38 -08:00
Stella Laurenzo 6be9789f9f
update PyTorch version to 2.2.0.dev20231115 (#2577)
torch version: 2.2.0.dev20231115
torch commit hash: a5a404865c01f86881f6b3ab0cd9a562d0b420de
torchvision version: 0.17.0.dev20231115

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-15 06:38:54 -08:00
Stella Laurenzo d734f7890c
update PyTorch version to 2.2.0.dev20231114 (#2574)
torch version: 2.2.0.dev20231114
torch commit hash: ec2f8fd2f1ac81996641848d9c7b904fddbbf9cf
torchvision version: 0.17.0.dev20231114

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-14 06:23:05 -08:00
Shehroze Khan dde66e66b0
add bool scalar type to int implicit cast (#2571)
[LTC] Add bool scalar type to int implicit cast
2023-11-14 08:56:12 -05:00
Stella Laurenzo c61f0bd5bb
update PyTorch version to 2.2.0.dev20231113 (#2570)
torch version: 2.2.0.dev20231113
torch commit hash: a45a8bf9e7e1530692f2703f8da430bc2825af7c
torchvision version: 0.17.0.dev20231113

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-13 07:19:30 -08:00
lzw dd759a24f2
Update readme to fit new project structure (#2548)
Co-authored-by: lanzongwei.lan <lanzongwei.lan@bytedance.com>
2023-11-12 21:19:18 -08:00
Stella Laurenzo 1a064cdf1a
update PyTorch version to 2.2.0.dev20231112 (#2569)
torch version: 2.2.0.dev20231112
torch commit hash: 63a5a14da9ef3ebd68ce0cebea4aa84e030a2cf8
torchvision version: 0.17.0.dev20231112

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-12 07:32:55 -08:00
Stella Laurenzo 2a99402796
update PyTorch version to 2.2.0.dev20231111 (#2568)
torch version: 2.2.0.dev20231111
torch commit hash: f40306d6c4b2613c18525a274d98feeda0036473
torchvision version: 0.17.0.dev20231111

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-11 07:00:47 -08:00
Yuanqiang Liu 3ab790c50a
[Torch Dialect] add canonicalize for aten.numel (#2562) 2023-11-11 12:16:53 +08:00
Stella Laurenzo b20daf5710
update PyTorch version to 2.2.0.dev20231110 (#2566)
torch version: 2.2.0.dev20231110
torch commit hash: edbf22fa03bafd1d2849ba41db75a2bea172dbcc
torchvision version: 0.17.0.dev20231110

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-10 06:23:58 -08:00
James Newling 98ee7fe548 Update E2E links 2023-11-09 13:55:37 -06:00
Ramiro Leal-Cavazos d082310bd8 Move Wiki to `docs/`
Currently the docs are split into two places, the `docs/` directory
and the Github Wiki of Torch-MLIR. This commit moves the wiki docs to
`docs/` to consolidate everything into one place. This has the added
benefit that users will get all the documentation when they clone the
repository.

Note: there are 4 files in the wiki, but only one is truly needed
- Torch-ops-E2E-implementation.md: only file needed
- Coding-Style.md: the contents of this file are already in
Torch-ops-E2E-implementation.md
- Weekly-LLVM-Update.md: this is outdated. We no longer have a weekly
schedule for llvm updates
- Home.md: Contains links to talks and resources that are already
present in the documentation in `docs/` or in
Torch-ops-E2E-implementation.md

Co-authored-by: Yi Zhang <cathyzhyi@google.com>
Co-authored-by: Ashay Rane <ashay@users.noreply.github.com>
Co-authored-by: Sean Silva <silvasean@google.com>
Co-authored-by: Daniel Ellis <1346302+dellis23@users.noreply.github.com>
Co-authored-by: Vivek Khandelwal <vivekkhandelwal1424@gmail.com>
2023-11-09 13:55:37 -06:00
Stella Laurenzo a7b5dfb389
update PyTorch version to 2.2.0.dev20231109 (#2564)
torch version: 2.2.0.dev20231109
torch commit hash: 2c3ba6926e38dba05bda34f0af9c092a40cff5b7
torchvision version: 0.17.0.dev20231109

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-09 06:21:48 -08:00
Yuanqiang Liu 60effcee89
[Dtype Function] fix aten.div.Tensor_mode's dtype function (#2555) 2023-11-09 09:46:53 +08:00
saienduri ad18219820
Fix for unused variable failure when trying to bump torch-mlir in IREE (#2560)
Due to blob being an unused variable, we are not able to bump torch-mlir
in iree. With this PR, we remove this unused variable.
2023-11-08 15:55:41 -08:00
Stella Laurenzo f3bfa81857
update PyTorch version to 2.2.0.dev20231106 (#2556)
torch version: 2.2.0.dev20231106
torch commit hash: a04dd794ad694baeb257c12329c3166c6a44ae50
torchvision version: 0.17.0.dev20231106

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-08 07:20:36 -08:00
James Newling b6e551c7b8
Decomposition of aten.pixel_shuffle with static input shape (#2550)
For static tests (that is when the shape is know) for example:

 ```
 @annotate_args([None, ([3, 18, 2, 2], torch.float32, True)])
 ```
 
The e2e passes. But only if the replacement op's return type is set as
undefined (optional shape and type must be explicitly made unset),
otherwise there's a error about the function return type.
 
 For dynamic cases, for example if the above is replaced with 
 
  ```
 @annotate_args([None, ([-1, -1, -1, -1], torch.float32, True)])
 ```

There is a failure to lower to linalg from torch ("view op explicitly
labelled as illegal"). This seems to be because the support for lowering
from torch to linalg with dynamic shapes is limited.
2023-11-08 08:52:44 -05:00
JianzheXiao a42d4c18ff
[Torch Dialect]Support aten.cosine_similarity (#2364)
As title, add support for aten.cosine_similarity, support broadcast
inputA/inputB to the same shape
2023-11-08 15:28:30 +08:00
James Newling 026cb314da
Specify path of e2e_test.sh after directory change (#2557)
Is there a way to disable some of CI for docs-only PR's?
2023-11-07 16:07:02 -08:00
Stella Laurenzo 4b9db995b5
update PyTorch version to 2.2.0.dev20231105 (#2554)
torch version: 2.2.0.dev20231105
torch commit hash: 2d7dd2e800dfd6332656074bfa208e4b25cfe907
torchvision version: 0.17.0.dev20231105

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-05 06:57:01 -08:00
Jiawei Wu d5ee8ee73a
[Torch Dialect] emit aten.reshape_as op and add decomposition pattern. (#2553) 2023-11-05 11:38:36 +08:00
Stella Laurenzo 71ca529a62
update PyTorch version to 2.2.0.dev20231104 (#2552)
torch version: 2.2.0.dev20231104
torch commit hash: a89fef71845d0dbc2c4c4a4c7878f51f4968ab90
torchvision version: 0.17.0.dev20231104

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-04 09:01:26 -07:00
Yuanqiang Liu 0378da0abd
[Torch Dialect] support aten.isinf (#2544)
Also fix linalg lowering from `UEQ` to `OEQ`.  
I will check other comparison's lowering later.
2023-11-04 22:26:01 +08:00
saienduri 88adf384cc
torch-mlir change for dense resource implementation (#2513)
Co-authored-by: Avinash Sharma <avinash@nod-labs.com>
2023-11-03 11:44:07 -07:00
Sambhav Jain 1b9fb1b51d
[Bazel] Mirror project reorganization (#2547)
Updates Bazel build to mirror project reorganization from
https://github.com/llvm/torch-mlir/pull/2542.

GHA:
https://github.com/sjain-stanford/torch-mlir/actions/runs/6744430250/job/18334262852
2023-11-03 08:45:51 -07:00
Stella Laurenzo 3caddd2dd9
update PyTorch version to 2.2.0.dev20231103 (#2549)
torch version: 2.2.0.dev20231103
torch commit hash: fd56aa0daeec624bcff822fef04fe9339770dc33
torchvision version: 0.17.0.dev20231103

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-03 08:25:58 -07:00
Stella Laurenzo 6961f0a247
Re-organize project structure to separate PyTorch dependencies from core project. (#2542)
This is a first step towards the structure we discussed here:
https://gist.github.com/stellaraccident/931b068aaf7fa56f34069426740ebf20

There are two primary goals:

1. Separate the core project (C++ dialects and conversions) from the
hard PyTorch dependencies. We move all such things into projects/pt1 as
a starting point since they are presently entangled with PT1-era APIs.
Additional work can be done to disentangle components from that
(specifically LTC is identified as likely ultimately living in a
`projects/ltc`).
2. Create space for native PyTorch2 Dynamo-based infra to be upstreamed
without needing to co-exist with the original TorchScript path.

Very little changes in this path with respect to build layering or
options. These can be updated in a followup without commingling
directory structure changes.

This also takes steps toward a couple of other layering enhancements:

* Removes the llvm-external-projects/torch-mlir-dialects sub-project,
collapsing it into the main tree.
* Audits and fixes up the core C++ build to account for issues found
while moving things. This is just an opportunistic pass through but
roughly ~halves the number of build actions for the project from the
high 4000's to the low 2000's.

It deviates from the discussed plan by having a `projects/` tree instead
of `compat/`. As I was thinking about it, this will better accommodate
the follow-on code movement.

Once things are roughly in place and the CI passing, followups will
focus on more in-situ fixes and cleanups.
2023-11-02 19:45:55 -07:00
Stella Laurenzo 536e45cb3b
update PyTorch version to 2.2.0.dev20231102 (#2545)
torch version: 2.2.0.dev20231102
torch commit hash: d2c3aa1fded6d1a0165eafe6e08816a85a1190d8
torchvision version: 0.17.0.dev20231102

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-02 08:39:55 -07:00
Zhekun(Josh) Zhang 88d4c475d3
[Torch] Fix mixP case for non value semantic ops (#2540)
NonValueSemantic Ops like Add_, div_, etc. expect result DType to be the
same as the first input. However, current implementation would result in
wrong result type for case like:

```python
a = torch.randn(3, 3).half() # float16
b = torch.randn(3, 3) # float32
a += b # i.e. torch.ops.aten.add_(a, b)
```
torch expects `a` to be float16, but dtype refinement would infer
float32 type, since it's replaced by `aten.add`.
2023-11-02 12:40:08 +08:00
Daniel Garvey 4901773f77
add uncovered cases in view lowering (#2524)
removes unecessary checks from empty strided
2023-11-01 21:56:44 -05:00
Yuanqiang Liu 365655ca29
[Torch Dialect] add canonicalize pattern for aten.floor with integer … (#2534)
…type
2023-11-02 09:51:31 +08:00
saienduri a2e694df40
add e2e support for torch.eye operations (aten.eye, aten.eye.m) (#2478) 2023-11-01 11:23:28 -07:00
Stella Laurenzo e12937c642
update PyTorch version to 2.2.0.dev20231101 (#2538)
torch version: 2.2.0.dev20231101
torch commit hash: e844d7ab047429425f117b1c566038713d2d7784
torchvision version: 0.17.0.dev20231101

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-11-01 08:17:40 -07:00
Daniel Garvey 1d41f7b6fe
Rework AtenEmptyStridedOp checks (#2537)
Now using Value instead of Ints. Trades compile failure for a runtime
assert
2023-10-31 22:56:54 -05:00
xiaolou86 4199feffed
Fix typos in comments (#2539)
Fix typos in comments
2023-10-31 20:10:47 -07:00
JianzheXiao e8706957c0
[Torch Dialect] Add Support for aten.unflatten.int (#2475)
As title, Add support for aten.unflatten.int, support dim to be negative
and one of the sizes' elements to be -1
2023-10-31 15:36:16 +08:00
Stella Laurenzo b88f9ec8f2
update PyTorch version to 2.2.0.dev20231027 (#2536)
torch version: 2.2.0.dev20231027
torch commit hash: 525a926aaa127e59c71ed66915055ac027dba507
torchvision version: 0.17.0.dev20231027

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-27 09:47:45 -07:00
Stella Laurenzo 2e5c624b58
update PyTorch version to 2.2.0.dev20231026 (#2535)
torch version: 2.2.0.dev20231026
torch commit hash: bf9fd89f63f213a5c449dd589ac96cf9c9218885
torchvision version: 0.17.0.dev20231026

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-26 09:45:36 -07:00
Yuanqiang Liu e7282487ea
[Torch Dialect] support aten.glu (#2531) 2023-10-26 10:36:18 +08:00
Stella Laurenzo b0f39ac966
update PyTorch version to 2.2.0.dev20231025 (#2532)
torch version: 2.2.0.dev20231025
torch commit hash: e6efc2915b4ac65c784fbcbbf42ad87b49214417
torchvision version: 0.17.0.dev20231025

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-25 10:11:06 -07:00
Stella Laurenzo e184e45398
update PyTorch version to 2.2.0.dev20231024 (#2530)
torch version: 2.2.0.dev20231024
torch commit hash: a422515e75cad4e785bbdbdff4f4e1c7c406bb24
torchvision version: 0.17.0.dev20231024

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-24 07:50:06 -07:00
Ze Zhang 7cb2db6279
Update dtype check in torch-to-tosa clamp op (#2529)
As titled.

---------

Co-authored-by: Ze Zhang <ze.zhang@getcruise.com>
2023-10-23 17:04:30 -07:00
Stella Laurenzo 6d74e8cccd
update PyTorch version to 2.2.0.dev20231023 (#2528)
torch version: 2.2.0.dev20231023
torch commit hash: 88eb6bbb1ab58d7cdb49349b64c02a04911be8f2
torchvision version: 0.17.0.dev20231023

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-23 09:32:21 -07:00
Stella Laurenzo 0f781ab4bf
update PyTorch version to 2.2.0.dev20231022 (#2526)
torch version: 2.2.0.dev20231022
torch commit hash: f468e74875f6b7f95b7b01ccf3b05c3917e2865d
torchvision version: 0.17.0.dev20231022

Co-authored-by: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
2023-10-22 08:01:12 -07:00
Sarthak Gupta 7633619ed2
[torch] Implement stronger verifiers for non-value semantic ops (#2519)
Attempt to solve https://github.com/llvm/torch-mlir/issues/2490

Changes for Non Value Semantic Ops having the
`IsTrailingUnderscoreInplaceVariant` trait :
- AnyTorchTensorType -> Torch_NonValueTensorType
- AnyTorchOptionalTensorType -> AnyTorchOptionalNonValueTensorType
- AnyTorchListOfOptionalTensorType ->
AnyTorchListOfOptionalNonValueTensorType
- AnyTorchListOfTensorType -> AnyTorchListOfNonValueTensorType

Created three new tensor types for optional and list non value tensors.
2023-10-21 09:09:55 -07:00