[HLO] Move `SameOperandsAndResultShape` trait to Unary/BinaryElemenwiseOp classes.
PiperOrigin-RevId: 352404756
This commit is contained in:
parent
c11ea4ef5a
commit
9e07bdf4ea
|
@ -120,7 +120,9 @@ def HLO_CreateTokenOp : HLO_Op<"create_token", [NoSideEffect]> {
|
||||||
|
|
||||||
class HLO_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits,
|
class HLO_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits,
|
||||||
Type TensorType>: HLO_Op<mnemonic,
|
Type TensorType>: HLO_Op<mnemonic,
|
||||||
!listconcat(traits, [InferShapedTypeOpInterface, InferFusibilityOpInterface])> {
|
!listconcat(traits,
|
||||||
|
[InferShapedTypeOpInterface, InferFusibilityOpInterface,
|
||||||
|
SameOperandsAndResultShape])> {
|
||||||
let arguments = (ins TensorType:$operand);
|
let arguments = (ins TensorType:$operand);
|
||||||
let results = (outs TensorType);
|
let results = (outs TensorType);
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
|
@ -146,7 +148,7 @@ class HLO_UnaryElementwiseOp<string mnemonic, list<OpTrait> traits,
|
||||||
|
|
||||||
// Abs supports complex to real, so element type is not guaranteed to match.
|
// Abs supports complex to real, so element type is not guaranteed to match.
|
||||||
def HLO_AbsOp: HLO_UnaryElementwiseOp<"abs",
|
def HLO_AbsOp: HLO_UnaryElementwiseOp<"abs",
|
||||||
[NoSideEffect, SameOperandsAndResultShape,
|
[NoSideEffect,
|
||||||
DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
||||||
TensorOf<[HLO_SInt, AnyFloat, HLO_Complex]>>, BASE_HLO_AbsOp {
|
TensorOf<[HLO_SInt, AnyFloat, HLO_Complex]>>, BASE_HLO_AbsOp {
|
||||||
}
|
}
|
||||||
|
@ -157,10 +159,8 @@ def HLO_CbrtOp: HLO_UnaryElementwiseOp<"cbrt",
|
||||||
def HLO_CeilOp: HLO_UnaryElementwiseOp<"ceil",
|
def HLO_CeilOp: HLO_UnaryElementwiseOp<"ceil",
|
||||||
[NoSideEffect, SameOperandsAndResultType], HLO_FpTensor>, BASE_HLO_CeilOp;
|
[NoSideEffect, SameOperandsAndResultType], HLO_FpTensor>, BASE_HLO_CeilOp;
|
||||||
|
|
||||||
def HLO_ConvertOp : HLO_UnaryElementwiseOp<
|
def HLO_ConvertOp : HLO_UnaryElementwiseOp<"convert",
|
||||||
"convert", [NoSideEffect, SameOperandsAndResultShape], HLO_Tensor>,
|
[NoSideEffect], HLO_Tensor>, BASE_HLO_ConvertOp {
|
||||||
BASE_HLO_ConvertOp {
|
|
||||||
|
|
||||||
let builders = [
|
let builders = [
|
||||||
OpBuilderDAG<(ins "Value":$operand, "Type":$result_element_ty)>];
|
OpBuilderDAG<(ins "Value":$operand, "Type":$result_element_ty)>];
|
||||||
|
|
||||||
|
@ -189,15 +189,14 @@ def HLO_FloorOp: HLO_UnaryElementwiseOp<"floor",
|
||||||
[NoSideEffect, SameOperandsAndResultType], HLO_FpTensor>, BASE_HLO_FloorOp;
|
[NoSideEffect, SameOperandsAndResultType], HLO_FpTensor>, BASE_HLO_FloorOp;
|
||||||
|
|
||||||
def HLO_ImagOp: HLO_UnaryElementwiseOp<"imag",
|
def HLO_ImagOp: HLO_UnaryElementwiseOp<"imag",
|
||||||
[NoSideEffect, SameOperandsAndResultShape,
|
[NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
||||||
DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
|
||||||
HLO_ComplexTensor>, BASE_HLO_ImagOp {
|
HLO_ComplexTensor>, BASE_HLO_ImagOp {
|
||||||
let results = (outs HLO_FpTensor);
|
let results = (outs HLO_FpTensor);
|
||||||
let hasFolder = 1;
|
let hasFolder = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
def HLO_IsFiniteOp: HLO_UnaryElementwiseOp<"is_finite",
|
def HLO_IsFiniteOp: HLO_UnaryElementwiseOp<"is_finite",
|
||||||
[NoSideEffect, SameOperandsAndResultShape], HLO_Tensor>,
|
[NoSideEffect], HLO_Tensor>,
|
||||||
BASE_HLO_IsFiniteOp {
|
BASE_HLO_IsFiniteOp {
|
||||||
let arguments = (ins HLO_FpTensor:$x);
|
let arguments = (ins HLO_FpTensor:$x);
|
||||||
let results = (outs HLO_PredTensor:$y);
|
let results = (outs HLO_PredTensor:$y);
|
||||||
|
@ -231,8 +230,7 @@ def HLO_PopulationCountOp: HLO_UnaryElementwiseOp<"popcnt",
|
||||||
BASE_HLO_PopulationCountOp;
|
BASE_HLO_PopulationCountOp;
|
||||||
|
|
||||||
def HLO_RealOp: HLO_UnaryElementwiseOp<"real",
|
def HLO_RealOp: HLO_UnaryElementwiseOp<"real",
|
||||||
[NoSideEffect, SameOperandsAndResultShape,
|
[NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
||||||
DeclareOpInterfaceMethods<InferTypeOpInterface>],
|
|
||||||
HLO_ComplexTensor>, BASE_HLO_RealOp {
|
HLO_ComplexTensor>, BASE_HLO_RealOp {
|
||||||
let results = (outs HLO_FpTensor);
|
let results = (outs HLO_FpTensor);
|
||||||
let hasFolder = 1;
|
let hasFolder = 1;
|
||||||
|
@ -272,7 +270,9 @@ def HLO_TanhOp: HLO_UnaryElementwiseOp<"tanh",
|
||||||
// See https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations
|
// See https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations
|
||||||
|
|
||||||
class HLO_BinaryElementwiseOp<string mnemonic, list<OpTrait> traits> :
|
class HLO_BinaryElementwiseOp<string mnemonic, list<OpTrait> traits> :
|
||||||
HLO_Op<mnemonic, !listconcat(traits, [InferShapedTypeOpInterface, InferFusibilityOpInterface])> {
|
HLO_Op<mnemonic, !listconcat(traits,
|
||||||
|
[InferShapedTypeOpInterface, InferFusibilityOpInterface,
|
||||||
|
SameOperandsAndResultShape])> {
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
HLO_Tensor:$lhs,
|
HLO_Tensor:$lhs,
|
||||||
HLO_Tensor:$rhs
|
HLO_Tensor:$rhs
|
||||||
|
@ -315,8 +315,7 @@ def HLO_Atan2Op : HLO_BinaryElementwiseOp<"atan2",
|
||||||
[NoSideEffect, SameOperandsAndResultType]>, BASE_HLO_Atan2Op;
|
[NoSideEffect, SameOperandsAndResultType]>, BASE_HLO_Atan2Op;
|
||||||
|
|
||||||
def HLO_ComplexOp: HLO_BinaryElementwiseOp<"complex",
|
def HLO_ComplexOp: HLO_BinaryElementwiseOp<"complex",
|
||||||
[NoSideEffect, SameOperandsAndResultShape,
|
[NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]>,
|
||||||
DeclareOpInterfaceMethods<InferTypeOpInterface>]>,
|
|
||||||
BASE_HLO_ComplexOp {
|
BASE_HLO_ComplexOp {
|
||||||
let arguments = (ins HLO_FpTensor:$lhs, HLO_FpTensor:$rhs);
|
let arguments = (ins HLO_FpTensor:$lhs, HLO_FpTensor:$rhs);
|
||||||
let results = (outs HLO_ComplexTensor);
|
let results = (outs HLO_ComplexTensor);
|
||||||
|
|
Loading…
Reference in New Issue