• 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_PARALLEL_OPS_INFO_ELEMENTARY_FUNCTION_INFO_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_ELEMENTARY_FUNCTION_INFO_H_
19 
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 #include <memory>
24 #include "ir/value.h"
25 #include "frontend/parallel/auto_parallel/operator_costmodel.h"
26 #include "frontend/parallel/ops_info/activation_info.h"
27 #include "frontend/parallel/strategy.h"
28 
29 namespace mindspore {
30 namespace parallel {
31 class ExpInfo : public ActivationOther {
32  public:
ExpInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)33   ExpInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
34       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ExpCost>()) {}
35   ~ExpInfo() override = default;
36 };
37 
38 class LogInfo : public ActivationOther {
39  public:
LogInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)40   LogInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
41       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<LogCost>()) {}
42   ~LogInfo() override = default;
43 };
44 
45 class CosInfo : public ActivationOther {
46  public:
CosInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)47   CosInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
48       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<CosCost>()) {}
49   ~CosInfo() override = default;
50 };
51 
52 class ACosInfo : public ActivationOther {
53  public:
ACosInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)54   ACosInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
55            const PrimitiveAttrs &attrs)
56       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ACosCost>()) {}
57   ~ACosInfo() override = default;
58 };
59 
60 class LogicalNotInfo : public ActivationOther {
61  public:
LogicalNotInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)62   LogicalNotInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
63                  const PrimitiveAttrs &attrs)
64       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<LogicalNotCost>()) {}
65   ~LogicalNotInfo() override = default;
66 };
67 
68 class AbsInfo : public ActivationOther {
69  public:
AbsInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)70   AbsInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
71       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AbsCost>()) {}
72   ~AbsInfo() override = default;
73 };
74 
75 class SignInfo : public ActivationOther {
76  public:
SignInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)77   SignInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
78            const PrimitiveAttrs &attrs)
79       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<SignCost>()) {}
80   ~SignInfo() override = default;
81 };
82 
83 class FloorInfo : public ActivationOther {
84  public:
FloorInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)85   FloorInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
86             const PrimitiveAttrs &attrs)
87       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<FloorCost>()) {}
88   ~FloorInfo() override = default;
89 };
90 
91 class RoundInfo : public ActivationOther {
92  public:
RoundInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)93   RoundInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
94             const PrimitiveAttrs &attrs)
95       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<RoundCost>()) {}
96   ~RoundInfo() override = default;
97 };
98 
99 class ReciprocalInfo : public ActivationOther {
100  public:
ReciprocalInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)101   ReciprocalInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
102                  const PrimitiveAttrs &attrs)
103       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ReciprocalCost>()) {}
104   ~ReciprocalInfo() override = default;
105 };
106 
107 class InvInfo : public ActivationOther {
108  public:
InvInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)109   InvInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
110       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<InvCost>()) {}
111   ~InvInfo() override = default;
112 };
113 
114 class RsqrtInfo : public ActivationOther {
115  public:
RsqrtInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)116   RsqrtInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
117             const PrimitiveAttrs &attrs)
118       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<RsqrtCost>()) {}
119   ~RsqrtInfo() override = default;
120 };
121 
122 class TanInfo : public ActivationOther {
123  public:
TanInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)124   TanInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
125       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<TanCost>()) {}
126   ~TanInfo() override = default;
127 };
128 
129 class SinInfo : public ActivationOther {
130  public:
SinInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)131   SinInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
132       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<SinCost>()) {}
133   ~SinInfo() override = default;
134 };
135 
136 class SinhInfo : public ActivationOther {
137  public:
SinhInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)138   SinhInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
139            const PrimitiveAttrs &attrs)
140       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<SinhCost>()) {}
141   ~SinhInfo() override = default;
142 };
143 
144 class Log1pInfo : public ActivationOther {
145  public:
Log1pInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)146   Log1pInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
147             const PrimitiveAttrs &attrs)
148       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<Log1pCost>()) {}
149   ~Log1pInfo() override = default;
150 };
151 
152 class Expm1Info : public ActivationOther {
153  public:
Expm1Info(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)154   Expm1Info(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
155             const PrimitiveAttrs &attrs)
156       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<Expm1Cost>()) {}
157   ~Expm1Info() override = default;
158 };
159 
160 class CoshInfo : public ActivationOther {
161  public:
CoshInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)162   CoshInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
163            const PrimitiveAttrs &attrs)
164       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<CoshCost>()) {}
165   ~CoshInfo() override = default;
166 };
167 
168 class CeilInfo : public ActivationOther {
169  public:
CeilInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)170   CeilInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
171            const PrimitiveAttrs &attrs)
172       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<CeilCost>()) {}
173   ~CeilInfo() override = default;
174 };
175 
176 class AtanhInfo : public ActivationOther {
177  public:
AtanhInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)178   AtanhInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
179             const PrimitiveAttrs &attrs)
180       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AtanhCost>()) {}
181   ~AtanhInfo() override = default;
182 };
183 
184 class AtanInfo : public ActivationOther {
185  public:
AtanInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)186   AtanInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
187            const PrimitiveAttrs &attrs)
188       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AtanCost>()) {}
189   ~AtanInfo() override = default;
190 };
191 
192 class AsinInfo : public ActivationOther {
193  public:
AsinInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)194   AsinInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
195            const PrimitiveAttrs &attrs)
196       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AsinCost>()) {}
197   ~AsinInfo() override = default;
198 };
199 
200 class AsinhInfo : public ActivationOther {
201  public:
AsinhInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)202   AsinhInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
203             const PrimitiveAttrs &attrs)
204       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AsinhCost>()) {}
205   ~AsinhInfo() override = default;
206 };
207 
208 class AcoshInfo : public ActivationOther {
209  public:
AcoshInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)210   AcoshInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
211             const PrimitiveAttrs &attrs)
212       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<AcoshCost>()) {}
213   ~AcoshInfo() override = default;
214 };
215 
216 class ErfInfo : public ActivationOther {
217  public:
ErfInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)218   ErfInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, const PrimitiveAttrs &attrs)
219       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ErfCost>()) {}
220   ~ErfInfo() override = default;
221 };
222 
223 class ErfcInfo : public ActivationOther {
224  public:
ErfcInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)225   ErfcInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
226            const PrimitiveAttrs &attrs)
227       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ErfcCost>()) {}
228   ~ErfcInfo() override = default;
229 };
230 
231 class ZerosLikeInfo : public ActivationOther {
232  public:
ZerosLikeInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)233   ZerosLikeInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
234                 const PrimitiveAttrs &attrs)
235       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<ZerosLikeCost>()) {}
236   ~ZerosLikeInfo() override = default;
237 };
238 
239 class OnesLikeInfo : public ActivationOther {
240  public:
OnesLikeInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)241   OnesLikeInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
242                const PrimitiveAttrs &attrs)
243       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<OnesLikeCost>()) {}
244   ~OnesLikeInfo() override = default;
245 };
246 
247 class BesselI0eInfo : public ActivationOther {
248  public:
BesselI0eInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)249   BesselI0eInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
250                 const PrimitiveAttrs &attrs)
251       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<BesselI0eCost>()) {}
252   ~BesselI0eInfo() override = default;
253 };
254 
255 class BesselI1eInfo : public ActivationOther {
256  public:
BesselI1eInfo(const std::string & name,const Shapes & inputs_shape,const Shapes & outputs_shape,const PrimitiveAttrs & attrs)257   BesselI1eInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape,
258                 const PrimitiveAttrs &attrs)
259       : ActivationOther(name, inputs_shape, outputs_shape, attrs, std::make_shared<BesselI1eCost>()) {}
260   ~BesselI1eInfo() override = default;
261 };
262 }  // namespace parallel
263 }  // namespace mindspore
264 
265 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_OPS_INFO_ELEMENTARY_FUNCTION_INFO_H_
266