Commit Graph

91 Commits (158c9b540846a428652ca090e7ea24335751bc36)

Author SHA1 Message Date
Vivek Khandelwal f9d59eb500 [MLIR][TORCH] Add decomposition for aten.randn_like op
This commit decomposes aten.randn_like op into aten.randn.generator op.

Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
2023-01-18 12:09:27 +05:30
Jiahao Li e2698433db
Fix empty tensor when select -1 (#1787) 2023-01-17 10:14:14 -08:00
Vivek Khandelwal 924503c436 build: manually update PyTorch version
Set PyTorch and TorchVision version to nightly release 2023-01-15.

Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
2023-01-16 13:07:57 +05:30
Jiahao Li 4f94831fed
[LINALG][TOSA][MHLO] Add e2e support for aten bitwise ops (#1753) 2023-01-11 14:40:03 -08:00
Vivek Khandelwal fd236b2c89 [MLIR][TORCH] Add decomposition for prims.var and prims.sqrt op
Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
2023-01-11 17:39:10 +05:30
Ashay Rane 4e4a571104
[TOSA] Add LeakyReLU conversion pass (#1790)
* feat(TorchToTOSA): LeakyReLU legalization

* test(LeakyReLU): Add LIT test and enable e2e test

Co-authored-by: Philipp Braun <philipp.braun@amd.com>
2023-01-10 21:42:07 -08:00
Gleb Kazantaev 8f01072099
Fix OptionalCType class name (#1779)
* Fix OptionalCType class name

* Rmove LTC xfail tests
2023-01-06 17:03:24 -05:00
Jiahao Li 8dc5d985eb
Add e2e support for aten logical or/and/xor/not ops (#1761) 2023-01-03 18:11:25 -08:00
Srirammaswamy a88e3766e8
Add E2E support for LeakyRelu and LeakyReluBackward ops (#1733)
Co-authored-by: srirammaswamy <srirammaswamy@gmail.com>
2023-01-03 08:30:16 -08:00
powderluv b2dbbba5e6
xfail ElementwisePreluModule_basic in dynamo (#1763) 2022-12-31 13:54:25 -08:00
Ashay Rane ac780529b4
Revert e2e support for aten logical or/and/xor/not ops (#1757)
This reverts commit eaab9be207, since it
is causing the post-merge CI tests to fail, causing subsequent PRs to be
blocked.  Specifically, the tests
`ElementwiseAtenLogicalAndOpPromoteBroadcastModule_basic` and
`ElementwiseAtenLogicalXorOpPromoteBroadcastModule_basic` fail because
the oracle does not match the computed result.  This patch reverts the
commit to make the post-merge builds green again.
2022-12-29 21:01:06 -06:00
Shivam Gupta 2f45959f0d
Prelu lowering to linalg (#1712)
Prelu lowering to linalg
2022-12-28 08:51:33 +05:30
Jiahao Li eaab9be207
Add e2e support for aten logical or/and/xor/not ops (#1752) 2022-12-26 10:23:38 +08:00
Jiahao Li 49071f86e6
[MHLO] Evaluate RuntimeAssertOp at compile time (#1732) 2022-12-22 17:12:52 +08:00
Jiahao Li 60a139271d
Add aten.std.correction op and its decomposition (#1731) 2022-12-21 21:02:40 -08:00
Jiahao Li 15b249777b
[Torch][MHLO] Decompose aten.copy op. Lower aten.rsqrt & sigmoid to mhlo. (#1734) 2022-12-22 10:13:59 +08:00
Chi_Liu 9dc09ac8c5
[TOSA] Add aten.gather support for tosa (#1680) 2022-12-21 11:04:07 -08:00
Chi_Liu b2cefc0b64
[TOSA] Add aten.masked_fill.Tensor/Scalar support (#1735) 2022-12-21 08:56:07 -08:00
pranavmulticore 0f6008c802
Added GeluBackward: MHLO support (#1725) 2022-12-21 20:09:43 +08:00
Abhishek Varma 66d7a412cb [RefineTypes] Fix knowledge dtype for `aten.embedding` op
-- The dtype of the result of `aten.embedding` should match that of
   the `weight` operand's (operand[0]) instead of hardcoding to f32.
-- This commit aims to provide a fix for the same.

Signed-off-by: Abhishek Varma <abhishek@nod-labs.com>
2022-12-20 19:56:12 +05:30
Ashay Rane dd1cf578a6
build: fix LTC code after upstream PyTorch change (#1727)
pytorch/pytorch@140a3139 reverted a change from yesterday, causing the
RollPyTorch action to break.  This patch reverts the corresponding
change in the torch-mlir LTC code.

This patch also re-enables tests that were previously marked as XFAIL.
2022-12-16 13:07:38 -06:00
Prashant Kumar 564403e3a1 Add float16 support in the refbackend.
This will require https://reviews.llvm.org/D139121 patch to go through.
2022-12-15 21:19:52 +05:30
Sean Silva af9e8a5e63 [torchdynamo] Move to aot_autograd instead of raw make_fx
As [@ezyang suggested](https://github.com/pytorch/pytorch/issues/90276#issuecomment-1339791275),
use `torch._dynamo.optimizations.training.aot_autograd` instead of raw
`make_fx`. This is more future proof and gives us the backward pass and
functionalization. We don't currently get functionalization because of
https://github.com/pytorch/pytorch/issues/90759

This also incidentally fixes the source location handling, which makes
`lockstep_basic.py` give an accurate source location!
2022-12-15 01:55:50 -08:00
Chi_Liu 163d19cce6
[TOSA] Add aten.add/sub.Scalar/Tensor si64 type support (#1604) 2022-12-12 12:13:07 -08:00
Vivek Khandelwal d4862ec611 [MLIR][TORCH] Add e2e support for aten.var_mean op
Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-12-12 15:46:54 +05:30
Vivek Khandelwal 143a8f378d build: manually update PyTorch version
Set PyTorch and TorchVision version to nightly release 2022-12-11.

Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-12-12 15:46:54 +05:30
Sean Silva 7731211d02 Remove eager_mode
This was an experimental attempt at rolling out own op-by-op executor
with `__torch_dispatch__`, but it proved difficult to make it robust.
Op-by-op execution is very easy to implement robustly now with the
PyTorch 2.0 stack, so we don't need eager_mode.

Downstream users were using eager_mode to implement lockstep numerical
accuracy debuggers. We implemented the same functionality with
TorchDynamo in https://github.com/llvm/torch-mlir/pull/1681 so now there
is not much reason to continue maintaining it.
2022-12-09 03:50:00 -08:00
Sean Silva 29c8823464 [e2e tests] Rename default config from "refbackend" to "linalg"
This more accurately reflects what it is. The previous name was
conflating the use of RefBackend (which `linalg`, `tosa`, and `mhlo`
configs all use) with the use of the linalg backend (e.g. TorchToLinalg).

This conflation was artifically giving the linalg backend a "privileged"
position, which we want to avoid. We still keep it as the default
backend, and it remains the most complete, but at least there's not
artificial boosting.
2022-12-08 01:34:46 -08:00
Sean Silva 88db99946b [torchdynamo] Use decompositions to support a few ops 2022-12-01 11:25:20 -08:00
Ramiro Leal-Cavazos b4b92c990e
Replace LCG algorithm with squares64 algorithm in AtenUniformOp (#1633)
This commit replaces the LCG algorithm that was being used by the
`TorchToLinalg` lowering of `AtenUniformOp` to generate random numbers
with the `squares64` algorithm, for the LCG algorithm was producing
tensors that were highly correlated with one another.

Squares64 algorithm: https://arxiv.org/abs/2004.06278

Closes https://github.com/llvm/torch-mlir/issues/1608
2022-12-01 08:30:10 -08:00
Abhishek Varma c27c1791f1 [MLIR][TORCH] Add e2e support for `aten.amax` op
-- This commit adds e2e support for `atend.amax` op.

Signed-off-by: Abhishek Varma <abhishek@nod-labs.com>
2022-11-30 17:54:37 +05:30
Ramiro Leal-Cavazos a8cbfff95b
Reduce memory usage of e2e tests by reducing input sizes (#1653)
There are a few e2e tests that take several very large tensors as
input, which leads to the e2e test suite leaking too much
memory. Running things locally resulted in a total memory usage of
12.5 GB when running the suite sequentially on the refbackend.

Many of the tests that take large tensors don't actually need
such large tensors to pass, and some that take several large tensors
as input are just doing the same thing multiple times. This commit
reduces the size of some of the tensors and removes repetitive parts
of tests to reduce the memory usage to a total of 3 GB.
2022-11-29 10:03:36 -08:00
Vivek Khandelwal 4d49c44967 build: manually update PyTorch version
Set PyTorch and TorchVision version to nightly release 2022-11-22.
Add failing tests to the xfail set.

Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-11-29 20:33:27 +05:30
Sean Silva f4d4743f08 Fix eager mode XFAIL's 2022-11-29 01:46:29 -08:00
Sean Silva ecb09c2fc3 [torchdynamo] Fix output size computation for upsample_nearest2d 2022-11-29 01:46:29 -08:00
Sean Silva 883b986eda [torchdynamo] Annotate the XFAIL's with more info 2022-11-29 01:46:29 -08:00
Sean Silva a24c7039f7 [torchdynamo] Update XFAIL sets with upstream bug numbers. 2022-11-25 08:45:23 -08:00
Vivek Khandelwal b3f68dfef3 Update xfail_sets.py 2022-11-25 12:41:56 +05:30
Vivek Khandelwal d9cbf01d1e Revert "build: update llvm tag to 147fe9de"
This reverts commit e45ad313d4.
2022-11-25 12:41:56 +05:30
Sean Silva 28957adaac [torchdynamo] Initial TorchDynamo support
This adds a basic e2e Config for TorchDynamo using
Linalg-on-Tensors/RefBackend.
But TorchDynamo is pretty orthogonal to
various other pieces, so it should compose nicely with variations like:
- Switching out all the backends (Linalg-on-Tensors, TOSA, MHLO)
- PyTorch functionalization and decompositions
- Taking the example inputs and compiling with all dynamic or all static
  shapes without duplicating tests.

This adds it to the CI, but there are still a lot of XFAIL's.

This also adds a helper `from torch_mlir.dynamo import
make_simple_dynamo_backend` which simplifies some of the steps for
making a Torch-MLIR-based TorchDynamo backend. We include "simple" in
the name because we are going to be exploring various things next from
the long-term roadmap.

The next steps are:
- Burn down all the XFAIL's.
- Start working on the pieces from the [long-term roadmap](https://github.com/llvm/torch-mlir/blob/main/docs/long_term_roadmap.md).
  - Add functionalization/decompositions into the TorchDynamo flow and
    remove reliance on the current Torch-MLIR "frontend".
  - Write a pure-Python direct FX->MLIR importer.
  - Hook up the new PyTorch symbolic shape stuff.
  - Explore PrimTorch decompositions for simplifying backends.
2022-11-24 04:10:25 -08:00
Vivek Khandelwal e45ad313d4 build: update llvm tag to 147fe9de
Summary of changes:
- Update call to `hasNoEffect` utility
- `KDynamicSize` value changed to
  `std::numeric_limits<int64_t>::min()` from `-1`
- Update tags
  llvm: 147fe9de29dc13c14835127b35280c4d95c8e8ba
  mhlo: 1944b5fa6062ec4c065d726c9c5d64f1487ee8c5

Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-11-24 12:44:43 +05:30
Tanyo Kwok 14f1260ac4
Add more mhlo basic converters (#1628)
* Add more mhlo basic converters

* remove unused pinnedMemory constraints

* refine naming
2022-11-24 14:28:34 +08:00
Maksim Levental bfcfd60d55
[MLIR][TORCH] Refix differentiable view (#1639)
* `BatchMlpLayerModule_basic` passes

* Fix https://github.com/llvm/torch-mlir/issues/1618 by stripping `requires_grad` from results of view ops.
2022-11-23 15:35:39 -06:00
Tanyo Kwok 4aad5ccf39
fix #1626 return type mismatch (#1634) 2022-11-23 15:02:41 +08:00
Vivek Khandelwal 68f568b704 [MLIR][TORCH] Add E2E support for prims.convert_element_type op
Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-11-22 09:36:36 +05:30
Sean Silva 22307a1427 Clean up some parts of the test suite
The purpose of the test suite is to accelerate the development of the
compiler. However, we had various tests there that were not expected to
work, had no in-progress work being tested by the test, and nobody was
actively working on them. Having such tests in our test suite just adds
clutter and slows down development on the compiler.
2022-11-21 06:14:31 -08:00
Tanyo Kwok a9fb0c5459
fix mhlo e2e ci crashes (#1620)
* fix mhlo e2e ci crashes

* add passed tests

* calc dynamic positive dim
2022-11-21 21:50:35 +08:00
Abhishek Varma 1d949f3ac2 [MLIR][TORCH] Fix aten.upsample_nearest2d op
-- aten.upsample_nearest2d.vec op is not present
   owing to https://github.com/pytorch/pytorch/pull/85638
-- So this commit adds a lowering on aten.upsample_nearest2d.

Signed-off-by: Abhishek Varma <abhishek@nod-labs.com>
2022-11-18 13:41:47 +05:30
Vivek Khandelwal 5f7177da35 [MLIR][TORCH] Add decomposition for aten.var_mean.correction op
Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-11-17 13:00:09 +05:30
George Petterson 92f385bd9f [MLIR][TORCH] Add E2E support aten.convolution_backward op
This commit adds the decomposition for the `aten.convolution_backward`
and `aten.convolution_backward_overrideable` op.
2022-11-15 07:38:26 +05:30