[mlir] Add support for lowering tanh to LLVMIR.
authorHanhan Wang <hanchung@google.com>
Mon, 15 Jun 2020 17:26:32 +0000 (10:26 -0700)
committerHanhan Wang <hanchung@google.com>
Thu, 18 Jun 2020 17:42:13 +0000 (10:42 -0700)
commit9cb10296ecaa2d7131744375e8b14200674fa1e5
treefc0839cb3095305ffea90ad5c7e29d17de0894a6
parentc835b5cc1df6833febff3ffd887518e26beae397
[mlir] Add support for lowering tanh to LLVMIR.

Summary:
Fixed build of D81618

Add a pattern for expanding tanh op into exp form.
A `tanh` is expanded into:
   1) 1-exp^{-2x} / 1+exp^{-2x}, if x => 0
   2) exp^{2x}-1 / exp^{2x}+1  , if x < 0.

Differential Revision: https://reviews.llvm.org/D82040
mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h
mlir/lib/Dialect/StandardOps/Transforms/CMakeLists.txt
mlir/lib/Dialect/StandardOps/Transforms/ExpandTanh.cpp [new file with mode: 0644]
mlir/test/Dialect/Standard/expand-tanh.mlir [new file with mode: 0644]
mlir/test/lib/Transforms/CMakeLists.txt
mlir/test/lib/Transforms/TestExpandTanh.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp