[ptensor] Add elementwise unary ops
- Dominant language
- MLIR
- Stars
- 156
- Forks
- 45
- Avg merge
- 4h 14m
- Merged PRs (30d)
- 22
Description
* Generally follow the implementation of elementwise binary ops
* [ ] New struct `EWUnaryOpId` in PTensorOps.h (see below)
* [ ] New PTensor Operations in PTensorOps.td as defined in [Operation Details->Elementwise Operations in the RFC](https://github.com/intel/mlir-extensions/tree/refactor/docs/rfcs/20220804-ptensor#operation-details).
* [ ] New conversion patterns in PTensorToLinalg.cpp (new classes and adding patterns to `RewritePatternSet` in `ConvertPTensorToLinalgPass`
* See [array-API spec](https://data-apis.org/array-api/latest/API_specification/elementwise_functions.html) for the expected behavior of the operations:
* [ ] ABS
* [ ] ACOS
* [ ] ACOSH
* [ ] ASIN
* [ ] ASINH
* [ ] ATAN
* [ ] ATANH
* [ ] BITWISE_INVERT
* [ ] CEIL
* [ ] COS
* [ ] COSH
* [ ] EXP
* [ ] EXPM1
* [ ] FLOOR
* [ ] ISFINITE
* [ ] ISINF
* [ ] ISNAN
* [ ] LOGICAL_NOT
* [ ] LOG
* [ ] LOG1P
* [ ] LOG2
* [ ] LOG10
* [ ] NEGATIVE
* [ ] POSITIVE
* [ ] ROUND
* [ ] SIGN
* [ ] SIN
* [ ] SINH
* [ ] SQUARE
* [ ] SQRT
* [ ] TAN
* [ ] TANH
* [ ] TRUNC
* [ ] ERF
Reference implementations can be found in the TOSA dialect and/or on main (numba_dpcomp/numba_dpcomp/mlir/numpy/funcs.py [Python]).
It is ok to let initial implementations operate on default PTensorTypes only, e.g. ignore device and distribution attributes of input tensors.
```C++
enum EWUnaryOpId : int {
ABS,
ACOS,
ACOSH,
ASIN,
ASINH,
ATAN,
ATANH,
BITWISE_INVERT,
CEIL,
COS,
COSH,
EXP,
EXPM1,
FLOOR,
ISFINITE,
ISINF,
ISNAN,
LOGICAL_NOT,
LOG,
LOG1P,
LOG2,
LOG10,
NEGATIVE,
POSITIVE,
ROUND,
SIGN,
SIN,
SINH,
SQUARE,
SQRT,
TAN,
TANH,
TRUNC,
ERF,
EWUNARYOP_LAST
};
```
Contributor guide
Assessment
This issue has not been assessed yet.