Skip to content

Commit d1c3b36

Browse files
tensorflower-gardenerTensorFlow MLIR Team
authored andcommitted
[XLA] Add asinh as a native HLO opcode.
This change promotes `asinh` from a composite operation to a native HLO opcode (`kAsinh`). This allows for direct lowering to device-specific intrinsics which should be more performant. Support is added for GPU. PiperOrigin-RevId: 820245338
1 parent b3d4ff8 commit d1c3b36

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

mhlo/IR/hlo_ops.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AddOp)
359359
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AcosOp)
360360
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AcoshOp)
361361
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AsinOp)
362+
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AsinhOp)
362363
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AndOp)
363364
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(Atan2Op)
364365
INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(AtanhOp)
@@ -5131,6 +5132,7 @@ UNARY_FOLDER_FLOAT(RoundOp, Round)
51315132
UNARY_FOLDER_UPCAST_TO_F64(AcosOp, std::acos, AnyValue)
51325133
UNARY_FOLDER_UPCAST_TO_F64(AcoshOp, std::acosh, AnyValue)
51335134
UNARY_FOLDER_UPCAST_TO_F64(AsinOp, std::asin, AnyValue)
5135+
UNARY_FOLDER_UPCAST_TO_F64(AsinhOp, std::asinh, AnyValue)
51345136
UNARY_FOLDER_UPCAST_TO_F64(AtanhOp, std::atanh, AnyValue)
51355137
UNARY_FOLDER_UPCAST_TO_F64(CoshOp, std::cosh, AnyValue)
51365138
UNARY_FOLDER_UPCAST_TO_F64(CosineOp, std::cos, AnyValue)

mhlo/IR/hlo_ops.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,22 @@ def MHLO_AsinOp : MHLO_UnaryElementwiseOp<"asin",
266266
let hasFolder = 1;
267267
}
268268

269+
def MHLO_AsinhOp : MHLO_UnaryElementwiseOp<"asinh",
270+
[HLO_CompatibleOperandsAndResultType], HLO_AnyFpOrComplexTensor> {
271+
let summary = "Asinh operation";
272+
273+
let description = [{
274+
Performs element-wise asinh operation on `operand` tensor and produces a
275+
`result` tensor.
276+
277+
Example:
278+
```mlir
279+
%result = mhlo.asinh %operand : tensor<2x2xf32>
280+
```
281+
}];
282+
let hasFolder = 1;
283+
}
284+
269285
def MHLO_CbrtOp: MHLO_UnaryElementwiseOp<"cbrt",
270286
[Pure, HLO_CompatibleOperandsAndResultType], MHLO_FpComplexOrQuantizedIntTensor> {
271287
let summary = "Cbrt operation";

mhlo/transforms/map_mhlo_to_scalar_op.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ struct MhloToScalarOp<mhlo::AsinOp> {
6161
using FOp = ::mlir::math::AsinOp;
6262
};
6363
template <>
64+
struct MhloToScalarOp<mhlo::AsinhOp> {
65+
using FOp = ::mlir::math::AsinhOp;
66+
};
67+
template <>
6468
struct MhloToScalarOp<mhlo::AddOp> {
6569
using FOp = ::mlir::arith::AddFOp;
6670
using IOp = ::mlir::arith::AddIOp;

0 commit comments

Comments
 (0)