• 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_CORE_SYMBOLIC_SHAPE_SYMBOL_ENGINE_H_
17 #define MINDSPORE_CORE_SYMBOLIC_SHAPE_SYMBOL_ENGINE_H_
18 #include <memory>
19 #include <string>
20 #include <unordered_map>
21 #include "base/base.h"
22 #include "ir/anf.h"
23 #include "ir/func_graph.h"
24 #include "abstract/abstract_value.h"
25 
26 namespace mindspore {
27 namespace symshape {
28 class MS_CORE_API SymbolEngine : public Base {
29  public:
SymbolEngine(const FuncGraphPtr & fg)30   explicit SymbolEngine(const FuncGraphPtr &fg) : func_graph_(fg) {}
31   ~SymbolEngine() = default;
32   MS_DECLARE_PARENT(SymbolEngine, Base)
33 
34   virtual bool Infer(const AbstractBasePtrList &inputs) = 0;
35   virtual bool IsDependValue(const AnfNodePtr &node) = 0;
36   virtual bool IsDependShape(const AnfNodePtr &node) = 0;
37   virtual bool SupportInfer() = 0;
38   virtual void QuerySymbolExpr(const AnfNodePtr &node,
39                                std::unordered_map<std::string, std::string> *symbol_expr_map) = 0;
func_graph()40   FuncGraphPtr func_graph() const { return func_graph_.lock(); }
41 
42  protected:
43   FuncGraphWeakPtr func_graph_;
44 };
45 }  // namespace symshape
46 using SymbolEnginePtr = std::shared_ptr<symshape::SymbolEngine>;
47 }  // namespace mindspore
48 #endif  // MINDSPORE_CORE_SYMBOLIC_SHAPE_SYMBOL_ENGINE_H_
49