• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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 
17 #ifndef MINDSPORE_CCSRC_FRONTEND_OPERATOR_COMPOSITE_DO_SIGNATURE_H_
18 #define MINDSPORE_CCSRC_FRONTEND_OPERATOR_COMPOSITE_DO_SIGNATURE_H_
19 
20 #include <vector>
21 #include <string>
22 #include <unordered_map>
23 #include <utility>
24 #include <map>
25 #include <set>
26 #include <memory>
27 
28 #include "pipeline/jit/static_analysis/static_analysis.h"
29 #include "utils/misc.h"
30 #include "utils/any.h"
31 #include "ir/dtype.h"
32 #include "ir/meta_func_graph.h"
33 #include "utils/ms_utils.h"
34 
35 namespace mindspore {
36 // namespace to support composite operators definition
37 namespace prim {
38 class DoSignatureMetaFuncGraph : public MetaFuncGraph {
39  public:
DoSignatureMetaFuncGraph(const std::string & name,const ValuePtr & function)40   explicit DoSignatureMetaFuncGraph(const std::string &name, const ValuePtr &function)
41       : MetaFuncGraph("S-" + name), function_(function) {}
42 
43   ~DoSignatureMetaFuncGraph() override = default;
44 
45   MS_DECLARE_PARENT(DoSignatureMetaFuncGraph, MetaFuncGraph)
46 
47   FuncGraphPtr GenerateFuncGraph(const abstract::AbstractBasePtrList &args_spec_list) override;
function()48   const ValuePtr function() const { return function_; }
49 
50   friend bool operator==(const DoSignatureMetaFuncGraph &lhs, const DoSignatureMetaFuncGraph &rhs) {
51     return &lhs == &rhs;
52   }
53 
54  private:
55   ValuePtr function_;
56 };
57 using RWSignaturePtr = std::shared_ptr<DoSignatureMetaFuncGraph>;
58 
59 extern const std::map<TypeId, size_t> type_map;
60 
61 // shared with pynative
62 void RaiseExceptionForConvertRefDtype(const std::string &func_name, const std::string &ref_type,
63                                       const std::string &target_type);
64 void RaiseExceptionForCheckParameter(const std::string &func_name, size_t i, const std::string &source_type);
65 
66 AnfNodePtr GenerateCNode(const FuncGraphPtr &func_graph, const std::string &func_name, const ValuePtr &function,
67                          const AbstractBasePtrList &args_spec_list, const AnfNodePtrList &old_node_inputs);
68 }  // namespace prim
69 }  // namespace mindspore
70 
71 #endif  // MINDSPORE_CCSRC_FRONTEND_OPERATOR_COMPOSITE_DO_SIGNATURE_H_
72