• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- Shape.h - MLIR Shape dialect -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the shape dialect that is used to describe and solve shape
10 // relations of MLIR operations using ShapedType.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_SHAPE_IR_SHAPE_H
15 #define MLIR_SHAPE_IR_SHAPE_H
16 
17 #include "mlir/IR/BuiltinOps.h"
18 #include "mlir/IR/Dialect.h"
19 #include "mlir/IR/OpDefinition.h"
20 #include "mlir/IR/OpImplementation.h"
21 #include "mlir/IR/SymbolTable.h"
22 #include "mlir/Interfaces/ControlFlowInterfaces.h"
23 #include "mlir/Interfaces/InferTypeOpInterface.h"
24 #include "mlir/Interfaces/SideEffectInterfaces.h"
25 
26 namespace mlir {
27 class PatternRewriter;
28 
29 namespace shape {
30 
31 /// Alias type for extent tensors.
32 RankedTensorType getExtentTensorType(MLIRContext *ctx);
33 
34 /// The component type corresponding to shape, element type and attribute.
35 class ComponentType : public Type::TypeBase<ComponentType, Type, TypeStorage> {
36 public:
37   using Base::Base;
38 };
39 
40 /// The element type of the shaped type.
41 class ElementType : public Type::TypeBase<ElementType, Type, TypeStorage> {
42 public:
43   using Base::Base;
44 };
45 
46 /// The shape descriptor type represents rank and dimension sizes.
47 class ShapeType : public Type::TypeBase<ShapeType, Type, TypeStorage> {
48 public:
49   using Base::Base;
50 };
51 
52 /// The type of a single dimension.
53 class SizeType : public Type::TypeBase<SizeType, Type, TypeStorage> {
54 public:
55   using Base::Base;
56 };
57 
58 /// The ValueShape represents a (potentially unknown) runtime value and shape.
59 class ValueShapeType
60     : public Type::TypeBase<ValueShapeType, Type, TypeStorage> {
61 public:
62   using Base::Base;
63 };
64 
65 /// The Witness represents a runtime constraint, to be used as shape related
66 /// preconditions on code execution.
67 class WitnessType : public Type::TypeBase<WitnessType, Type, TypeStorage> {
68 public:
69   using Base::Base;
70 };
71 
72 } // namespace shape
73 } // namespace mlir
74 
75 #define GET_OP_CLASSES
76 #include "mlir/Dialect/Shape/IR/ShapeOps.h.inc"
77 
78 #include "mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc"
79 
80 #endif // MLIR_SHAPE_IR_SHAPE_H
81