AndOp lowering from XLA to StandardOps

This includes moving the patterns out of the xla_hlo namespace. This is
due to mlir::hlo_xla::AndOp hiding the mlir::AndOp.

PiperOrigin-RevId: 280754069
Change-Id: Ia4ab671b084ac1710875adaf8e6f4a46245313fc
This commit is contained in:
A. Unique TensorFlower 2019-11-15 15:56:52 -08:00 committed by TensorFlower Gardener
parent e70d095050
commit 9a24946408
2 changed files with 9 additions and 2 deletions

View File

@ -31,9 +31,11 @@ using mlir::OwningRewritePatternList;
using mlir::PassRegistration;
namespace mlir {
namespace xla_hlo {
namespace {
#include "tensorflow/compiler/mlir/xla/transforms/generated_legalize_to_standard.inc"
} // end anonymous namespace
namespace xla_hlo {
namespace {
struct CompareIConvert : public RewritePattern {
explicit CompareIConvert(MLIRContext *context)
@ -131,7 +133,7 @@ mlir::xla_hlo::createLegalizeToStdPass() {
void mlir::xla_hlo::PopulateXlaToStdPatterns(OwningRewritePatternList *patterns,
mlir::MLIRContext *ctx) {
mlir::xla_hlo::populateWithGenerated(ctx, patterns);
mlir::populateWithGenerated(ctx, patterns);
patterns
->insert<mlir::xla_hlo::CompareFConvert, mlir::xla_hlo::CompareIConvert>(
ctx);

View File

@ -28,6 +28,11 @@ def IsSameSizePred : CPred<
"== $1->getType().cast<ShapedType>().getShape()">;
def IsSameSizeConstraint : Constraint<IsSameSizePred, "inputs are same size">;
def : Pat<(HLO_AndOp HLO_PredTensor:$l, HLO_PredTensor:$r,
IsNullAttr:$broadcast_dimensions),
(AndOp $l, $r),
[(IsSameSizeConstraint $l, $r)]>;
def : Pat<(HLO_AddOp HLO_FpTensor:$l, HLO_FpTensor:$r,
IsNullAttr:$broadcast_dimensions),
(AddFOp $l, $r),