[Mlir-commits] [mlir] b40d073 - [mlir][shape] Extract ShapeBase.td
Sean Silva
llvmlistbot at llvm.org
Tue May 5 13:40:31 PDT 2020
Author: Sean Silva
Date: 2020-05-05T13:39:19-07:00
New Revision: b40d073e53389b33a003ac03ec8f32c30b8d7763
URL: https://github.com/llvm/llvm-project/commit/b40d073e53389b33a003ac03ec8f32c30b8d7763
DIFF: https://github.com/llvm/llvm-project/commit/b40d073e53389b33a003ac03ec8f32c30b8d7763.diff
LOG: [mlir][shape] Extract ShapeBase.td
Added:
mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
Modified:
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
new file mode 100644
index 000000000000..9443b7870072
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td
@@ -0,0 +1,99 @@
+#ifndef SHAPE_BASE_TD
+#define SHAPE_BASE_TD
+
+include "mlir/IR/OpBase.td"
+
+// TODO(jpienaar): Move to base.
+def AnyShaped: ShapedContainerType<[AnyType], IsShapedTypePred, "shaped">;
+
+//===----------------------------------------------------------------------===//
+// Shape Inference dialect definitions
+//===----------------------------------------------------------------------===//
+
+def ShapeDialect : Dialect {
+ let name = "shape";
+
+ let summary = "Types and operations for shape dialect";
+ let description = [{
+ This dialect contains operations for shape inference.
+
+ Note: Unless explicitly stated, all functions that return a shape and take
+ shapes as input, return the invalid shape if one of its operands is an
+ invalid shape. This avoids flagging multiple errors for one verification
+ failure. The dialect itself does not specify how errors should be combined
+ (there are multiple
diff erent options, from always choosing first operand,
+ concatting etc. on how to combine them).
+ }];
+
+ let cppNamespace = "shape";
+
+ let hasConstantMaterializer = 1;
+}
+
+def Shape_ComponentType : DialectType<ShapeDialect,
+ CPred<"$_self.isa<::mlir::shape::ComponentType>()">, "component type">,
+ BuildableType<"$_builder.getType<::mlir::shape::ComponentType>()"> {
+ let typeDescription = [{
+ `shape.element_type` represents the element type of the ShapedType. It may
+ be unknown, error or regular element type supported by ShapedType.
+ }];
+}
+
+def Shape_ElementType : DialectType<ShapeDialect,
+ CPred<"$_self.isa<::mlir::shape::ElementType>()">, "element type">,
+ BuildableType<"$_builder.getType<::mlir::shape::ElementType>()"> {
+ let typeDescription = [{
+ `shape.element_type` represents the element type of the ShapedType. It may
+ be unknown, error or regular element type supported by ShapedType.
+ }];
+}
+
+def Shape_ShapeType : DialectType<ShapeDialect,
+ CPred<"$_self.isa<::mlir::shape::ShapeType>()">, "shape">,
+ BuildableType<"$_builder.getType<::mlir::shape::ShapeType>()"> {
+ let typeDescription = [{
+ `shape.type` represents either an unranked shape, a ranked shape with
+ possibly unknown dimensions or an invalid shape. The rank is of type
+ `shape.size` and, if rank is known, the extent is a 1D tensor of type
+ `shape.size`.
+
+ Shape is printed:
+ * `[*]` if it is an unranked shape
+ * `[?, 2]` if a rank 2 tensor with one unknown dimension
+ * `[3, 4]` is a rank 2 static tensor
+ * `[]` is a scalar
+ * `[1]` is a rank 1 tensor with 1 element
+ * `[invalid]` for an invalid shape
+ }];
+}
+
+def Shape_SizeType : DialectType<ShapeDialect,
+ CPred<"$_self.isa<::mlir::shape::SizeType>()">, "size">,
+ BuildableType<"$_builder.getType<::mlir::shape::SizeType>()"> {
+ let typeDescription = [{
+ `shape.size` represents a non-negative integer with support for being
+ unknown and invalid.
+
+ Operations on `shape.size` types are specialized to handle unknown/dynamic
+ value. So, for example, `<unknown> + x == <unknown>` for all non-error `x :
+ !shape.size` (e.g., an unknown value does not become known due to addition).
+ }];
+}
+
+def Shape_ValueShapeType : DialectType<ShapeDialect,
+ CPred<"$_self.isa<::mlir::shape::ValueShapeType>()">, "value shape">,
+ BuildableType<"::mlir::shape::ValueShapeType::get($_builder.getContext())">
+{
+ let typeDescription = [{
+ `shape.value_shape` represents the value produced by an operation (this
+ corresponds to `Value` in the compiler) and a shape. Conceptually this is a
+ tuple of a value (potentially unknown) and `shape.type`. The value and shape
+ can either or both be unknown. If both the `value` and `shape` are known,
+ then the shape of `value` is conformant with `shape`.
+ }];
+}
+
+def Shape_ShapeOrSizeType: AnyTypeOf<[Shape_SizeType, Shape_ShapeType],
+ "shape or size">;
+
+#endif // SHAPE_BASE_TD
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index 4b8ec1d7ed91..6b64bb78bb85 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -13,103 +13,10 @@
#ifndef SHAPE_OPS
#define SHAPE_OPS
-include "mlir/IR/OpBase.td"
+include "mlir/Dialect/Shape/IR/ShapeBase.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffects.td"
-// TODO(jpienaar): Move to base.
-def AnyShaped: ShapedContainerType<[AnyType], IsShapedTypePred, "shaped">;
-
-//===----------------------------------------------------------------------===//
-// Shape Inference dialect definitions
-//===----------------------------------------------------------------------===//
-
-def ShapeDialect : Dialect {
- let name = "shape";
-
- let summary = "Types and operations for shape dialect";
- let description = [{
- This dialect contains operations for shape inference.
-
- Note: Unless explicitly stated, all functions that return a shape and take
- shapes as input, return the invalid shape if one of its operands is an
- invalid shape. This avoids flagging multiple errors for one verification
- failure. The dialect itself does not specify how errors should be combined
- (there are multiple
diff erent options, from always choosing first operand,
- concatting etc. on how to combine them).
- }];
-
- let cppNamespace = "shape";
-
- let hasConstantMaterializer = 1;
-}
-
-def Shape_ComponentType : DialectType<ShapeDialect,
- CPred<"$_self.isa<::mlir::shape::ComponentType>()">, "component type">,
- BuildableType<"$_builder.getType<::mlir::shape::ComponentType>()"> {
- let typeDescription = [{
- `shape.element_type` represents the element type of the ShapedType. It may
- be unknown, error or regular element type supported by ShapedType.
- }];
-}
-
-def Shape_ElementType : DialectType<ShapeDialect,
- CPred<"$_self.isa<::mlir::shape::ElementType>()">, "element type">,
- BuildableType<"$_builder.getType<::mlir::shape::ElementType>()"> {
- let typeDescription = [{
- `shape.element_type` represents the element type of the ShapedType. It may
- be unknown, error or regular element type supported by ShapedType.
- }];
-}
-
-def Shape_ShapeType : DialectType<ShapeDialect,
- CPred<"$_self.isa<::mlir::shape::ShapeType>()">, "shape">,
- BuildableType<"$_builder.getType<::mlir::shape::ShapeType>()"> {
- let typeDescription = [{
- `shape.type` represents either an unranked shape, a ranked shape with
- possibly unknown dimensions or an invalid shape. The rank is of type
- `shape.size` and, if rank is known, the extent is a 1D tensor of type
- `shape.size`.
-
- Shape is printed:
- * `[*]` if it is an unranked shape
- * `[?, 2]` if a rank 2 tensor with one unknown dimension
- * `[3, 4]` is a rank 2 static tensor
- * `[]` is a scalar
- * `[1]` is a rank 1 tensor with 1 element
- * `[invalid]` for an invalid shape
- }];
-}
-
-def Shape_SizeType : DialectType<ShapeDialect,
- CPred<"$_self.isa<::mlir::shape::SizeType>()">, "size">,
- BuildableType<"$_builder.getType<::mlir::shape::SizeType>()"> {
- let typeDescription = [{
- `shape.size` represents a non-negative integer with support for being
- unknown and invalid.
-
- Operations on `shape.size` types are specialized to handle unknown/dynamic
- value. So, for example, `<unknown> + x == <unknown>` for all non-error `x :
- !shape.size` (e.g., an unknown value does not become known due to addition).
- }];
-}
-
-def Shape_ValueShapeType : DialectType<ShapeDialect,
- CPred<"$_self.isa<::mlir::shape::ValueShapeType>()">, "value shape">,
- BuildableType<"::mlir::shape::ValueShapeType::get($_builder.getContext())">
-{
- let typeDescription = [{
- `shape.value_shape` represents the value produced by an operation (this
- corresponds to `Value` in the compiler) and a shape. Conceptually this is a
- tuple of a value (potentially unknown) and `shape.type`. The value and shape
- can either or both be unknown. If both the `value` and `shape` are known,
- then the shape of `value` is conformant with `shape`.
- }];
-}
-
-def Shape_ShapeOrSizeType: AnyTypeOf<[Shape_SizeType, Shape_ShapeType],
- "shape or size">;
-
//===----------------------------------------------------------------------===//
// Shape op definitions
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list