From cc4244d55f98b03603cf54eb4abac7e128e3c99a Mon Sep 17 00:00:00 2001 From: Frederik Gossen Date: Wed, 20 Jan 2021 18:52:55 +0100 Subject: [PATCH] [MLIR][Standard] Add log1p operation to std Differential Revision: https://reviews.llvm.org/D95041 --- .../mlir/Dialect/StandardOps/IR/Ops.td | 29 +++++++++++++++++++ mlir/test/IR/core-ops.mlir | 3 ++ 2 files changed, 32 insertions(+) diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index 8db6129dbb88..770e68f6da83 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -1942,10 +1942,39 @@ def LogOp : FloatUnaryOp<"log"> { let summary = "base-e logarithm of the specified value"; } +//===----------------------------------------------------------------------===// +// Log10Op +//===----------------------------------------------------------------------===// + def Log10Op : FloatUnaryOp<"log10"> { let summary = "base-10 logarithm of the specified value"; } +//===----------------------------------------------------------------------===// +// Log1pOp +//===----------------------------------------------------------------------===// + +def Log1pOp : FloatUnaryOp<"log1p"> { + let summary = "Computes the natural logarithm of one plus the given value"; + + let description = [{ + Computes the base-e logarithm of one plus the given value. It takes one + operand and returns one result of the same type. + + log1p(x) := log(1 + x) + + Example: + + ```mlir + %y = log1p %x : f64 + ``` + }]; +} + +//===----------------------------------------------------------------------===// +// Log2Op +//===----------------------------------------------------------------------===// + def Log2Op : FloatUnaryOp<"log2"> { let summary = "base-2 logarithm of the specified value"; } diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir index 0e86050870ff..b5266fb2e580 100644 --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -596,6 +596,9 @@ func @standard_instrs(tensor<4x4x?xf32>, f32, i32, index, i64, f16) { // CHECK: %{{[0-9]+}} = ceildivi_signed %cst_4, %cst_4 : tensor<42xi32> %174 = ceildivi_signed %tci32, %tci32 : tensor<42 x i32> + // CHECK: %{{[0-9]+}} = log1p %arg1 : f32 + %175 = log1p %f : f32 + return }