[KernelGen] Lower tf.Erf and tf.Erfc ops to CHLO.

This does not include the lowerings from CHLO to LMHLO.

PiperOrigin-RevId: 344091604
This commit is contained in:
Lucy Fox 2020-11-24 10:55:01 -08:00 committed by TensorFlow MLIR Team
parent 9f20ef0581
commit 85f92a1651
2 changed files with 29 additions and 2 deletions

View File

@ -417,6 +417,32 @@ def HLOClient_ConstantLikeOp : HLOClient_Op<"constant_like",
let hasCanonicalizer = 1; let hasCanonicalizer = 1;
} }
def HLOClient_ErfOp : HLOClient_UnaryElementwiseOp<"erf",
[NoSideEffect, SameOperandsAndResultShape],
HLO_FpTensor> {
let summary = "Erfc operator";
let description = [{
Computes the Gauss error function of `x` element-wise.
erf(x) = erf_impl(x) if |x| < 1
= 1 - erfc_impl(x) otherwise
}];
}
def HLOClient_ErfcOp : HLOClient_UnaryElementwiseOp<"erfc",
[NoSideEffect, SameOperandsAndResultShape],
HLO_FpTensor> {
let summary = "Erfc operator";
let description = [{
Computes an approximation of the error function complement (1 - erf(x)).
erfc(x) = erfc_impl(x) if |x| > 1
= 1 - erf_impl(x) otherwise
}];
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Broadcasting compare op // Broadcasting compare op
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -50,7 +50,8 @@ namespace {
// TODO(herhut): Generate these out of op definitions. // TODO(herhut): Generate these out of op definitions.
#define MAP_CHLO_OPERATION_CWISE_UNARY(fn, sep) \ #define MAP_CHLO_OPERATION_CWISE_UNARY(fn, sep) \
fn(AcosOp) sep fn(AtanOp) sep fn(SinhOp) sep fn(TanOp) fn(AcosOp) sep fn(AtanOp) sep fn(ErfOp) sep fn(ErfcOp) sep fn(SinhOp) \
sep fn(TanOp)
template <typename OpTy> template <typename OpTy>
inline void AddLegalOpOnRankedTensor(ConversionTarget *target) { inline void AddLegalOpOnRankedTensor(ConversionTarget *target) {