forked from OSchip/llvm-project
Add Expm1 op to the math dialect.
Differential Revision: https://reviews.llvm.org/D96704
This commit is contained in:
parent
d01ea0edaa
commit
9f581815ae
|
@ -244,6 +244,40 @@ def Exp2Op : FloatUnaryOp<"exp2"> {
|
|||
}];
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ExpM1Op
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def ExpM1Op : FloatUnaryOp<"expm1"> {
|
||||
let summary = "base-e exponential of the specified value minus 1";
|
||||
let description = [{
|
||||
Syntax:
|
||||
|
||||
```
|
||||
operation ::= ssa-id `=` `math.expm1` ssa-use `:` type
|
||||
```
|
||||
|
||||
expm1(x) := exp(x) - 1
|
||||
|
||||
The `expm1` operation takes one operand and returns one result of the same
|
||||
type. This type may be a float scalar type, a vector whose element type is
|
||||
float, or a tensor of floats. It has no standard attributes.
|
||||
|
||||
Example:
|
||||
|
||||
```mlir
|
||||
// Scalar natural exponential minus 1.
|
||||
%a = math.expm1 %b : f64
|
||||
|
||||
// SIMD vector element-wise natural exponential minus 1.
|
||||
%f = math.expm1 %g : vector<4xf32>
|
||||
|
||||
// Tensor element-wise natural exponential minus 1.
|
||||
%x = math.expm1 %y : tensor<4x?xf8>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LogOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -74,6 +74,18 @@ func @exp2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
|
|||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @expm1(
|
||||
// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
|
||||
func @expm1(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
|
||||
// CHECK: %{{.*}} = math.expm1 %[[F]] : f32
|
||||
%0 = math.expm1 %f : f32
|
||||
// CHECK: %{{.*}} = math.expm1 %[[V]] : vector<4xf32>
|
||||
%1 = math.expm1 %v : vector<4xf32>
|
||||
// CHECK: %{{.*}} = math.expm1 %[[T]] : tensor<4x4x?xf32>
|
||||
%2 = math.expm1 %t : tensor<4x4x?xf32>
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @log(
|
||||
// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)
|
||||
func @log(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {
|
||||
|
|
Loading…
Reference in New Issue