Add chlo.acos and legalization
Add client HLO op for arc cosine and legalize TF op to it & legalization from it to HLO. PiperOrigin-RevId: 324053167
This commit is contained in:
		
							parent
							
								
									cce4bddf4b
								
							
						
					
					
						commit
						d83d437588
					
				|  | @ -17,6 +17,7 @@ limitations under the License. | ||||||
| #define TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_DIALECT_MHLO_IR_CHLO_OPS_H_ | #define TENSORFLOW_COMPILER_MLIR_HLO_INCLUDE_MLIR_HLO_DIALECT_MHLO_IR_CHLO_OPS_H_ | ||||||
| 
 | 
 | ||||||
| #include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||||
|  | #include "mlir-hlo/Dialect/mhlo/IR/infer_fusibility_op_interface.h" | ||||||
| #include "mlir/IR/Dialect.h" | #include "mlir/IR/Dialect.h" | ||||||
| #include "mlir/IR/DialectImplementation.h" | #include "mlir/IR/DialectImplementation.h" | ||||||
| #include "mlir/IR/MLIRContext.h" | #include "mlir/IR/MLIRContext.h" | ||||||
|  |  | ||||||
|  | @ -33,6 +33,7 @@ include "mlir/IR/OpBase.td" | ||||||
| include "mlir/Interfaces/InferTypeOpInterface.td" | include "mlir/Interfaces/InferTypeOpInterface.td" | ||||||
| include "mlir/Interfaces/SideEffectInterfaces.td" | include "mlir/Interfaces/SideEffectInterfaces.td" | ||||||
| include "mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td" | include "mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td" | ||||||
|  | include "mlir-hlo/Dialect/mhlo/IR/infer_fusibility_op_interface.td" | ||||||
| 
 | 
 | ||||||
| def HLOClient_Dialect : Dialect { | def HLOClient_Dialect : Dialect { | ||||||
|   let name = "chlo"; |   let name = "chlo"; | ||||||
|  | @ -338,6 +339,31 @@ def HLOClient_BroadcastComplexOp : HLOClient_BroadcastBinaryElementwiseOp< | ||||||
|   let results = (outs HLO_ComplexTensor); |   let results = (outs HLO_ComplexTensor); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //===----------------------------------------------------------------------===// | ||||||
|  | // Unary op | ||||||
|  | //===----------------------------------------------------------------------===// | ||||||
|  | 
 | ||||||
|  | class HLOClient_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits, | ||||||
|  |     Type TensorType>: HLOClient_Op<mnemonic, | ||||||
|  |       !listconcat(traits, [InferFusibilityOpInterface])> { | ||||||
|  |   let arguments = (ins TensorType:$operand); | ||||||
|  |   let results = (outs TensorType); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | def HLOClient_AcosOp: HLOClient_UnaryElementwiseOp<"acos", | ||||||
|  |     [NoSideEffect, SameOperandsAndResultType], HLO_FpOrComplexTensor> { | ||||||
|  |   let summary = "Acos operator"; | ||||||
|  | 
 | ||||||
|  |   let description = [{ | ||||||
|  |     Returns `Acos(operand)` element-wise. | ||||||
|  | 
 | ||||||
|  |     $$ | ||||||
|  |     \acos(x) = 2 * \atan(\sqrt(1 - x^2) / (1 + x)) if x != -1 | ||||||
|  |              = pi                                  if x == -1 | ||||||
|  |     $$ | ||||||
|  |   }]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| //===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||||
| // Broadcasting compare op | // Broadcasting compare op | ||||||
| //===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue