• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 Huawei Technologies Co., Ltd
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 #ifndef MINDSPORE_CCSRC_BACKEND_COMMON_GRAPH_KERNEL_EXPANDER_BASE_EMITTER_H_
17 #define MINDSPORE_CCSRC_BACKEND_COMMON_GRAPH_KERNEL_EXPANDER_BASE_EMITTER_H_
18 #include <memory>
19 #include "ir/value.h"
20 #include "ir/tensor.h"
21 #include "backend/common/graph_kernel/expander/base/meta_op.h"
22 #include "backend/common/graph_kernel/expander/base/node.h"
23 
24 namespace mindspore::graphkernel::expander {
25 class Emitter {
26  public:
27   Emitter() = default;
28   virtual ~Emitter() = default;
29 
30   /// \brief emit an operator node
Emit(MetaOp op,const NodePtrList & args,const NodePtrDict & kargs)31   inline NodePtr Emit(MetaOp op, const NodePtrList &args, const NodePtrDict &kargs) { return EmitOp(op, args, kargs); }
32   /// \brief emit an operator node
Emit(MetaOp op,const NodePtrList & args)33   inline NodePtr Emit(MetaOp op, const NodePtrList &args) {
34     static const NodePtrDict kargs{};
35     return EmitOp(op, args, kargs);
36   }
37   /// \brief emit a value node
38   virtual NodePtr EmitValue(const ValuePtr &value) = 0;
39 
40  protected:
41   virtual NodePtr EmitOp(MetaOp op, const NodePtrList &args, const NodePtrDict &kargs) = 0;
42 };
43 using EmitterPtr = std::shared_ptr<Emitter>;
44 }  // namespace mindspore::graphkernel::expander
45 #endif  // MINDSPORE_CCSRC_BACKEND_COMMON_GRAPH_KERNEL_EXPANDER_BASE_EMITTER_H_
46