• 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_NODE_H_
17 #define MINDSPORE_CCSRC_BACKEND_COMMON_GRAPH_KERNEL_EXPANDER_BASE_NODE_H_
18 
19 #include <memory>
20 #include <vector>
21 #include <string>
22 #include "abstract/dshape.h"
23 #include "ir/value.h"
24 
25 namespace mindspore::graphkernel::expander {
26 using abstract::BaseShapePtr;
27 class Node {
28  public:
29   Node() = default;
30   virtual ~Node() = default;
31 
32   virtual BaseShapePtr GetShapePtr() = 0;
33   virtual ShapeVector GetShape() = 0;
34   virtual TypePtr GetDtype() = 0;
35   virtual std::string GetFormat() = 0;
36   // virtual std::vector<std::string> GetFormats() = 0;
37   virtual ValuePtr GetValue() = 0;
38 
39   // Get the real object of Node.
40   virtual const void *obj() = 0;
41   template <typename T>
as()42   const T &as() {
43     return *(static_cast<const T *>(obj()));
44   }
45 };
46 using NodePtr = std::shared_ptr<Node>;
47 using NodePtrList = std::vector<NodePtr>;
48 using NodePtrDict = HashMap<std::string, NodePtr>;
49 }  // namespace mindspore::graphkernel::expander
50 #endif  // MINDSPORE_CCSRC_BACKEND_COMMON_GRAPH_KERNEL_EXPANDER_BASE_NODE_H_
51