| 1 | // Tencent is pleased to support the open source community by making ncnn available. |
| 2 | // |
| 3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. |
| 4 | // |
| 5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except |
| 6 | // in compliance with the License. You may obtain a copy of the License at |
| 7 | // |
| 8 | // https://opensource.org/licenses/BSD-3-Clause |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software distributed |
| 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 13 | // specific language governing permissions and limitations under the License. |
| 14 | |
| 15 | #ifndef TF_DIALECT_H |
| 16 | #define TF_DIALECT_H |
| 17 | |
| 18 | #include <mlir/Dialect/Traits.h> |
| 19 | #include <mlir/IR/BuiltinOps.h> |
| 20 | #include <mlir/IR/Dialect.h> |
| 21 | #include <mlir/IR/OpImplementation.h> |
| 22 | #include <mlir/Interfaces/ControlFlowInterfaces.h> |
| 23 | #include <mlir/Interfaces/DerivedAttributeOpInterface.h> |
| 24 | #include <mlir/Interfaces/InferTypeOpInterface.h> |
| 25 | #include <mlir/Interfaces/LoopLikeInterface.h> |
| 26 | #include <mlir/Interfaces/SideEffectInterfaces.h> |
| 27 | |
| 28 | #include "tf_traits.h" |
| 29 | |
| 30 | namespace mlir { |
| 31 | |
| 32 | namespace TF { |
| 33 | |
| 34 | class TensorFlowDialect : public mlir::Dialect |
| 35 | { |
| 36 | public: |
| 37 | TensorFlowDialect(mlir::MLIRContext* context); |
| 38 | |
| 39 | static StringRef getDialectNamespace() |
| 40 | { |
| 41 | return "tf"; |
| 42 | } |
| 43 | |
| 44 | Attribute parseAttribute(DialectAsmParser& parser, Type type) const override; |
| 45 | |
| 46 | // Parse a type registered to this dialect. |
| 47 | Type parseType(DialectAsmParser& parser) const override; |
| 48 | |
| 49 | // Parses resource type with potential subtypes. |
| 50 | Type ParseResourceType(DialectAsmParser& parser) const; |
| 51 | |
| 52 | // Parse and print variant type. It may have subtypes inferred using shape |
| 53 | // inference. |
| 54 | Type ParseVariantType(DialectAsmParser& parser) const; |
| 55 | |
| 56 | // Registered hook to materialize a constant operation from a given attribute |
| 57 | // value with the desired resultant type. |
| 58 | Operation* materializeConstant(OpBuilder& builder, Attribute value, Type type, Location loc) override; |
| 59 | }; |
| 60 | |
| 61 | } // namespace TF |
| 62 | |
| 63 | } // namespace mlir |
| 64 | |
| 65 | #define GET_OP_CLASSES |
| 66 | #include "tf_all_ops.h.inc" |
| 67 | |
| 68 | #endif // TF_DIALECT_H |