HomePhabricator

[mlir] Add support for lowering tanh to LLVMIR.

Authored by hanchung on Jun 15 2020, 10:26 AM.

Description

[mlir] Add support for lowering tanh to LLVMIR.

Summary:
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/D81618