From 2ea947051523106c076021c12ca923d47aabe9cf Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Tue, 11 May 2021 11:53:40 -0700 Subject: [PATCH] Remove BASE_HLO_ConvOp to remove coupling between MHLO and LMHLO conv ops PiperOrigin-RevId: 373201247 --- include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.td | 16 +++++++++++++++- include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td | 15 --------------- include/mlir-hlo/Dialect/mhlo/IR/lhlo_ops.td | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.td b/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.td index 1ec7013..29ef9da 100644 --- a/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.td +++ b/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.td @@ -1383,7 +1383,13 @@ def HLO_CollectivePermuteOp: HLO_Op<"collective_permute", let results = (outs HLO_Tensor); } -def HLO_ConvOp : HLO_Op<"convolution", [NoSideEffect]>, BASE_HLO_ConvOp { +def HLO_ConvOp : HLO_Op<"convolution", [NoSideEffect]> { + let summary = "Convolution operator"; + let description = [{ + Computes a convolution of the kind used in neural networks. + + See https://www.tensorflow.org/xla/operation_semantics#conv_convolution. + }]; let arguments = !con( (ins HLO_Tensor:$lhs, @@ -1392,6 +1398,14 @@ def HLO_ConvOp : HLO_Op<"convolution", [NoSideEffect]>, BASE_HLO_ConvOp { let results = (outs HLO_Tensor); let hasCustomHLOConverter = 1; + + code extraClassDeclaration = [{ + bool hasWindowReversal() { + auto reversal = window_reversalAttr(); + return reversal && llvm::any_of(reversal.getBoolValues(), + [](bool v) { return v; }); + } + }]; } def HLO_CopyOp: HLO_Op<"copy", [NoSideEffect, SameOperandsAndResultType]> { diff --git a/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td b/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td index 096161f..e7f68c5 100644 --- a/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td +++ b/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops_base.td @@ -150,21 +150,6 @@ def ConvolutionAttributes { } class BASE_HLO_ConvOp { - string summary = "Convolution operator"; - - string description = [{ - Computes a convolution of the kind used in neural networks. - - See https://www.tensorflow.org/xla/operation_semantics#conv_convolution. - }]; - - code extraClassDeclaration = [{ - bool hasWindowReversal() { - auto reversal = window_reversalAttr(); - return reversal && llvm::any_of(reversal.getBoolValues(), - [](bool v) { return v; }); - } - }]; } #endif // HLO_OPS_BASE diff --git a/include/mlir-hlo/Dialect/mhlo/IR/lhlo_ops.td b/include/mlir-hlo/Dialect/mhlo/IR/lhlo_ops.td index 344aaf6..c99977c 100644 --- a/include/mlir-hlo/Dialect/mhlo/IR/lhlo_ops.td +++ b/include/mlir-hlo/Dialect/mhlo/IR/lhlo_ops.td @@ -844,13 +844,27 @@ def LHLO_ConcatenateOp : LHLO_Op<"concatenate", []> { ); } -def LHLO_ConvOp : LHLO_Op<"convolution", []>, BASE_HLO_ConvOp { +def LHLO_ConvOp : LHLO_Op<"convolution", []> { + let summary = "Convolution operator"; + let description = [{ + Computes a convolution of the kind used in neural networks. + + See https://www.tensorflow.org/xla/operation_semantics#conv_convolution. + }]; let arguments = !con( (ins Arg:$lhs, Arg:$rhs, Arg:$output), ConvolutionAttributes.attributes); + + code extraClassDeclaration = [{ + bool hasWindowReversal() { + auto reversal = window_reversalAttr(); + return reversal && llvm::any_of(reversal.getBoolValues(), + [](bool v) { return v; }); + } + }]; } def LHLO_CopyOp: LHLO_Op<"copy", [CopyOpInterface]> {