summaryrefslogtreecommitdiff
path: root/mlir/test/python/dialects/shape.py
AgeCommit message (Collapse)Author
2023-05-26[NFC][Py Reformat] Reformat python files in mlir subdirTobias Hieta
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black`. If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black. If you run into any problems, post to discourse about it and we will try to help. RFC Thread below: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential Revision: https://reviews.llvm.org/D150782
2022-12-28[mlir][py] Add StrAttr convenience builder.Jacques Pienaar
2022-12-21Revert "Revert "[mlir][py] Enable building ops with raw inputs""Jacques Pienaar
Fix Python 3.6.9 issue encountered due to type checking here. Will add back in follow up. This reverts commit 1f47fee2948ef48781084afe0426171d000d7997.
2022-12-21Revert "[mlir][py] Enable building ops with raw inputs"Jacques Pienaar
Reverting to fix build bot. This reverts commit 3781b7905d8d808e5d4e97d597263f8ac48541b8.
2022-12-21[mlir][py] Enable building ops with raw inputsJacques Pienaar
For cases where we can automatically construct the Attribute allow for more user-friendly input. This is consistent with C++ builder generation as well choice of which single builder to generate here (most specialized/user-friendly). Registration of attribute builders from more pythonic input is all Python side. The downside is that * extra checking to see if user provided a custom builder in op builders, * the ODS attribute name is load bearing upside is that * easily change these/register dialect specific ones in downstream projects, * adding support/changing to different convenience builders are all along with the rest of the convenience functions in Python (and no additional changes to tablegen file or recompilation needed); Allow for both building with Attributes as well as raw inputs. This change should therefore be backwards compatible as well as allow for avoiding recreating Attribute where already available. Differential Revision: https://reviews.llvm.org/D139568
2022-10-20[mlir][nfc] Clean-up usage of kDynamicSize.Aliia Khasanova
This patch prepares MLIR code base to change the value of kDynamicSize. https://discourse.llvm.org/t/rfc-unify-kdynamicsize-and-kdynamicstrideoroffset/64534/4 Differential Revision: https://reviews.llvm.org/D136327
2022-05-09[mlir] Fix build & test of mlir python bindings on WindowsStella Stamenova
There are a couple of issues with the python bindings on Windows: - `create_symlink` requires special permissions on Windows - using `copy_if_different` instead allows the build to complete and then be usable - the path to the `python_executable` is likely to contain spaces if python is installed in Program Files. llvm's python substitution adds extra quotes in order to account for this case, but mlir's own python substitution does not - the location of the shared libraries is different on windows - if the type is not specified for numpy arrays, they appear to be treated as strings I've implemented the smallest possible changes for each of these in the patch, but I would actually prefer a slightly more comprehensive fix for the python_executable and the shared libraries. For the python substitution, I think it makes sense to leverage the existing %python instead of adding %PYTHON and instead add a new variable for the case when preloading is needed. This would also make it clearer which tests are which and should be skipped on platforms where the preloading won't work. For the shared libraries, I think it would make sense to pass the correct path and extension (possibly even the names) to the python script since these are known by lit and don't have to be hardcoded in the test at all. Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D125122
2022-03-16[mlir] Move the Builtin FuncOp to the Func dialectRiver Riddle
This commit moves FuncOp out of the builtin dialect, and into the Func dialect. This move has been planned in some capacity from the moment we made FuncOp an operation (years ago). This commit handles the functional aspects of the move, but various aspects are left untouched to ease migration: func::FuncOp is re-exported into mlir to reduce the actual API churn, the assembly format still accepts the unqualified `func`. These temporary measures will remain for a little while to simplify migration before being removed. Differential Revision: https://reviews.llvm.org/D121266
2021-11-28[mlir][python] Normalize asm-printing IR behavior.Stella Laurenzo
While working on an integration, I found a lot of inconsistencies on IR printing and verification. It turns out that we were: * Only doing "soft fail" verification on IR printing of Operation, not of a Module. * Failed verification was interacting badly with binary=True IR printing (causing a TypeError trying to pass an `str` to a `bytes` based handle). * For systematic integrations, it is often desirable to control verification yourself so that you can explicitly handle errors. This patch: * Trues up the "soft fail" semantics by having `Module.__str__` delegate to `Operation.__str__` vs having a shortcut implementation. * Fixes soft fail in the presence of binary=True (and adds an additional happy path test case to make sure the binary functionality works). * Adds an `assume_verified` boolean flag to the `print`/`get_asm` methods which disables internal verification, presupposing that the caller has taken care of it. It turns out that we had a number of tests which were generating illegal IR but it wasn't being caught because they were doing a print on the `Module` vs operation. All except two were trivially fixed: * linalg/ops.py : Had two tests for direct constructing a Matmul incorrectly. Fixing them made them just like the next two tests so just deleted (no need to test the verifier only at this level). * linalg/opdsl/emit_structured_generic.py : Hand coded conv and pooling tests appear to be using illegal shaped inputs/outputs, causing a verification failure. I just used the `assume_verified=` flag to restore the original behavior and left a TODO. Will get someone who owns that to fix it properly in a followup (would also be nice to break this file up into multiple test modules as it is hard to tell exactly what is failing). Notes to downstreams: * If, like some of our tests, you get verification failures after this patch, it is likely that your IR was always invalid and you will need to fix the root cause. To temporarily revert to prior (broken) behavior, replace calls like `print(module)` with `print(module.operation.get_asm(assume_verified=True))`. Differential Revision: https://reviews.llvm.org/D114680
2021-10-25[mlir][python] Infer result types in generated constructors whenever possibleAlex Zinenko
In several cases, operation result types can be unambiguously inferred from operands and attributes at operation construction time. Stop requiring the user to provide these types as arguments in the ODS-generated constructors in Python bindings. In particular, handle the SameOperandAndResultTypes and FirstAttrDerivedResultType traits as well as InferTypeOpInterface using the recently added interface support. This is a significant usability improvement for IR construction, similar to what C++ ODS provides. Depends On D111656 Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D111811
2021-05-13[mlir] Add python test for shape dialectJacques Pienaar
Add basic test for shape.const_shape op as start. Differential Revision: https://reviews.llvm.org/D102341