xref: /llvm-project/mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.td (revision 1d7120c69a9baed2ffc74067fda202a4ee35f720)
1d05d4219STres Popp//==-- ShapeToStandard.td - Shape to Standard Patterns -------*- tablegen -*==//
2d05d4219STres Popp//
3d05d4219STres Popp// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4d05d4219STres Popp// See https://llvm.org/LICENSE.txt for license information.
5d05d4219STres Popp// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d05d4219STres Popp//
7d05d4219STres Popp//===----------------------------------------------------------------------===//
8d05d4219STres Popp//
9d05d4219STres Popp// Defines Patterns to lower Shape ops to Std.
10d05d4219STres Popp//
11d05d4219STres Popp//===----------------------------------------------------------------------===//
12d05d4219STres Popp
13d05d4219STres Popp#ifndef MLIR_CONVERSION_SHAPETOSTANDARD_TD
14d05d4219STres Popp#define MLIR_CONVERSION_SHAPETOSTANDARD_TD
15d05d4219STres Popp
16*1d7120c6SRiver Riddleinclude "mlir/IR/PatternBase.td"
17d05d4219STres Poppinclude "mlir/Dialect/Shape/IR/ShapeOps.td"
18d05d4219STres Popp
19d05d4219STres Poppdef BroadcastableStringAttr : NativeCodeCall<[{
20d05d4219STres Popp  $_builder.getStringAttr("required broadcastable shapes")
21d05d4219STres Popp}]>;
22d05d4219STres Popp
233842d4b6STres Poppdef CstrBroadcastableToRequire : Pat<(Shape_CstrBroadcastableOp $shapes),
24d05d4219STres Popp            (Shape_CstrRequireOp
253842d4b6STres Popp              (Shape_IsBroadcastableOp $shapes),
26d05d4219STres Popp              (BroadcastableStringAttr))>;
27d05d4219STres Popp
2873cb58dcSBenjamin Kramerdef EqStringAttr : NativeCodeCall<[{
2973cb58dcSBenjamin Kramer  $_builder.getStringAttr("required equal shapes")
3073cb58dcSBenjamin Kramer}]>;
3173cb58dcSBenjamin Kramer
3273cb58dcSBenjamin Kramerdef CstrEqToRequire : Pat<(Shape_CstrEqOp $shapes),
3373cb58dcSBenjamin Kramer  (Shape_CstrRequireOp (Shape_ShapeEqOp $shapes), (EqStringAttr))>;
3473cb58dcSBenjamin Kramer
35d05d4219STres Popp#endif // MLIR_CONVERSION_SHAPETOSTANDARD_TD
36