• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2    Copyright 2022 The StableHLO Authors.
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8     http://www.apache.org/licenses/LICENSE-2.0
9 
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 ==============================================================================*/
16 
17 #ifndef STABLEHLO_DIALECT_CHLO_OPS_H
18 #define STABLEHLO_DIALECT_CHLO_OPS_H
19 
20 #include "dialect/Base.h"
21 #include "llvm/ADT/APFloat.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "mlir/Dialect/Quant/QuantTypes.h"
24 #include "mlir/IR/Attributes.h"
25 #include "mlir/IR/Builders.h"
26 #include "mlir/IR/BuiltinTypes.h"
27 #include "mlir/IR/Dialect.h"
28 #include "mlir/IR/DialectImplementation.h"
29 #include "mlir/IR/Location.h"
30 #include "mlir/IR/MLIRContext.h"
31 #include "mlir/IR/OpDefinition.h"
32 #include "mlir/IR/Operation.h"
33 #include "mlir/IR/TypeUtilities.h"
34 #include "mlir/IR/Types.h"
35 #include "mlir/IR/Value.h"
36 #include "mlir/Interfaces/ControlFlowInterfaces.h"
37 #include "mlir/Interfaces/InferTypeOpInterface.h"
38 #include "mlir/Interfaces/SideEffectInterfaces.h"
39 
40 // Include order matters
41 #include "dialect/ChloEnums.h.inc"
42 #define GET_ATTRDEF_CLASSES
43 #include "dialect/ChloAttrs.h.inc"
44 
45 namespace mlir {
46 namespace chlo {
47 
48 class ChloDialect : public Dialect {
49  public:
50   explicit ChloDialect(MLIRContext* context);
getDialectNamespace()51   static StringRef getDialectNamespace() { return "chlo"; }
52 
53   Operation* materializeConstant(OpBuilder& builder, Attribute value, Type type,
54                                  Location loc) override;
55 
56   Attribute parseAttribute(DialectAsmParser& parser, Type type) const override;
57 
58   void printAttribute(Attribute attr, DialectAsmPrinter& os) const override;
59 };
60 
61 }  // namespace chlo
62 }  // namespace mlir
63 
64 namespace mlir {
65 namespace chlo {
66 namespace OpTrait {
67 
68 template <typename ConcreteType>
69 class Broadcasting
70     : public mlir::OpTrait::TraitBase<ConcreteType, Broadcasting> {};
71 
72 }  // namespace OpTrait
73 }  // namespace chlo
74 }  // namespace mlir
75 
76 #define GET_OP_CLASSES
77 #include "dialect/ChloOps.h.inc"
78 
79 #endif  // STABLEHLO_DIALECT_CHLO_OPS_H
80