[MLIR][HLO] Remove duplicate `PopulateTransformUnrankedHloPatterns`
PiperOrigin-RevId: 359046173
This commit is contained in:
parent
2df1bb3d6b
commit
ac0552f127
|
@ -105,7 +105,7 @@ def TestInferShapedTypeMethodsPass : Pass<"mhlo-test-infer-shaped-type-methods",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def TransformUnrankedHloPass : Pass<"transform-unranked-hlo", "FuncOp"> {
|
def TransformUnrankedHloPass : Pass<"mhlo-transform-unranked-hlo", "FuncOp"> {
|
||||||
let summary = "Realize element-wise operations on ranked tensors where possible.";
|
let summary = "Realize element-wise operations on ranked tensors where possible.";
|
||||||
let constructor = "createTransformUnrankedHloPass()";
|
let constructor = "createTransformUnrankedHloPass()";
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ template <typename T>
|
||||||
class OperationPass;
|
class OperationPass;
|
||||||
class Pass;
|
class Pass;
|
||||||
|
|
||||||
|
namespace mhlo {
|
||||||
|
|
||||||
// Transforms unranked HLO operations to ranked ones where possible.
|
// Transforms unranked HLO operations to ranked ones where possible.
|
||||||
std::unique_ptr<FunctionPass> createTransformUnrankedHloPass();
|
std::unique_ptr<FunctionPass> createTransformUnrankedHloPass();
|
||||||
|
|
||||||
namespace mhlo {
|
|
||||||
|
|
||||||
/// Lowers HLO control flow ops to the Standard dialect.
|
/// Lowers HLO control flow ops to the Standard dialect.
|
||||||
std::unique_ptr<OperationPass<FuncOp>> createLegalizeControlFlowPass();
|
std::unique_ptr<OperationPass<FuncOp>> createLegalizeControlFlowPass();
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,6 @@ limitations under the License.
|
||||||
namespace mlir {
|
namespace mlir {
|
||||||
class OwningRewritePatternList;
|
class OwningRewritePatternList;
|
||||||
|
|
||||||
// Populates a collection of rewrite patterns to realize element-wise operations
|
|
||||||
// on ranked tensors where possible.
|
|
||||||
void PopulateTransformUnrankedHloPatterns(MLIRContext *context,
|
|
||||||
OwningRewritePatternList *patterns);
|
|
||||||
|
|
||||||
namespace mhlo {
|
namespace mhlo {
|
||||||
|
|
||||||
// Collection of rewrite patterns for lowering a general dot product.
|
// Collection of rewrite patterns for lowering a general dot product.
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct ConvertConstantLikeOp : public OpConversionPattern<ConstantLikeOp> {
|
||||||
ConversionPatternRewriter &rewriter) const override {
|
ConversionPatternRewriter &rewriter) const override {
|
||||||
auto result_ty = op.getType().cast<ShapedType>();
|
auto result_ty = op.getType().cast<ShapedType>();
|
||||||
|
|
||||||
// Unranked uses are not supported. Consider `transform-unranked-hlo`.
|
// Unranked uses are not supported. Consider `mhlo-transform-unranked-hlo`.
|
||||||
if (!result_ty.hasRank()) return failure();
|
if (!result_ty.hasRank()) return failure();
|
||||||
|
|
||||||
// Lower to MHLO constant if statically shaped.
|
// Lower to MHLO constant if statically shaped.
|
||||||
|
|
|
@ -526,7 +526,7 @@ struct TransformUnrankedHloPass
|
||||||
|
|
||||||
// Populate rewrite patterns.
|
// Populate rewrite patterns.
|
||||||
OwningRewritePatternList patterns;
|
OwningRewritePatternList patterns;
|
||||||
PopulateTransformUnrankedHloPatterns(&ctx, &patterns);
|
mhlo::PopulateTransformUnrankedHloPatterns(&ctx, &patterns);
|
||||||
|
|
||||||
// Apply transformation.
|
// Apply transformation.
|
||||||
if (failed(
|
if (failed(
|
||||||
|
@ -537,6 +537,8 @@ struct TransformUnrankedHloPass
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace mhlo {
|
||||||
|
|
||||||
void PopulateTransformUnrankedHloPatterns(MLIRContext *context,
|
void PopulateTransformUnrankedHloPatterns(MLIRContext *context,
|
||||||
OwningRewritePatternList *patterns) {
|
OwningRewritePatternList *patterns) {
|
||||||
#define MAP_HLO(op) ElementwiseOpConversion<mhlo::op>
|
#define MAP_HLO(op) ElementwiseOpConversion<mhlo::op>
|
||||||
|
@ -565,4 +567,5 @@ std::unique_ptr<FunctionPass> createTransformUnrankedHloPass() {
|
||||||
return std::make_unique<TransformUnrankedHloPass>();
|
return std::make_unique<TransformUnrankedHloPass>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace mhlo
|
||||||
} // namespace mlir
|
} // namespace mlir
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// RUN: mlir-hlo-opt --transform-unranked-hlo --cse --split-input-file %s | FileCheck %s
|
// RUN: mlir-hlo-opt --mhlo-transform-unranked-hlo --cse --split-input-file %s | FileCheck %s
|
||||||
|
|
||||||
// Check the validity of expected IR.
|
// Check the validity of expected IR.
|
||||||
// CHECK-LABEL: @sqr_transform_result
|
// CHECK-LABEL: @sqr_transform_result
|
||||||
|
|
Loading…
Reference in New Issue