• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2021 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 #include "src/common/log_adapter.h"
17 #include "nnacl/arithmetic_self_parameter.h"
18 #include "src/common/ops/populate/populate_register.h"
19 using mindspore::schema::PrimitiveType_Abs;
20 using mindspore::schema::PrimitiveType_Ceil;
21 using mindspore::schema::PrimitiveType_Cos;
22 using mindspore::schema::PrimitiveType_Floor;
23 using mindspore::schema::PrimitiveType_Log;
24 using mindspore::schema::PrimitiveType_LogGrad;
25 using mindspore::schema::PrimitiveType_LogicalNot;
26 using mindspore::schema::PrimitiveType_Neg;
27 using mindspore::schema::PrimitiveType_NegGrad;
28 using mindspore::schema::PrimitiveType_Reciprocal;
29 using mindspore::schema::PrimitiveType_Round;
30 using mindspore::schema::PrimitiveType_Rsqrt;
31 using mindspore::schema::PrimitiveType_Sin;
32 using mindspore::schema::PrimitiveType_Sqrt;
33 using mindspore::schema::PrimitiveType_Square;
34 
35 namespace mindspore {
36 namespace lite {
PopulateArithmeticSelf(const void * prim)37 OpParameter *PopulateArithmeticSelf(const void *prim) {
38   MS_CHECK_TRUE_RET(prim != nullptr, nullptr);
39   auto *primitive = static_cast<const schema::Primitive *>(prim);
40 
41   auto *param = reinterpret_cast<ArithmeticSelfParameter *>(malloc(sizeof(ArithmeticSelfParameter)));
42   if (param == nullptr) {
43     MS_LOG(ERROR) << "malloc ArithmeticSelfParameter failed.";
44     return nullptr;
45   }
46   memset(param, 0, sizeof(ArithmeticSelfParameter));
47 
48   param->op_parameter_.type_ = primitive->value_type();
49   return reinterpret_cast<OpParameter *>(param);
50 }
51 
52 REG_POPULATE(PrimitiveType_Abs, PopulateArithmeticSelf, SCHEMA_CUR)
53 REG_POPULATE(PrimitiveType_Cos, PopulateArithmeticSelf, SCHEMA_CUR)
54 REG_POPULATE(PrimitiveType_Sin, PopulateArithmeticSelf, SCHEMA_CUR)
55 REG_POPULATE(PrimitiveType_Log, PopulateArithmeticSelf, SCHEMA_CUR)
56 REG_POPULATE(PrimitiveType_Neg, PopulateArithmeticSelf, SCHEMA_CUR)
57 REG_POPULATE(PrimitiveType_NegGrad, PopulateArithmeticSelf, SCHEMA_CUR)
58 REG_POPULATE(PrimitiveType_LogGrad, PopulateArithmeticSelf, SCHEMA_CUR)
59 REG_POPULATE(PrimitiveType_Sqrt, PopulateArithmeticSelf, SCHEMA_CUR)
60 REG_POPULATE(PrimitiveType_Square, PopulateArithmeticSelf, SCHEMA_CUR)
61 REG_POPULATE(PrimitiveType_Rsqrt, PopulateArithmeticSelf, SCHEMA_CUR)
62 REG_POPULATE(PrimitiveType_LogicalNot, PopulateArithmeticSelf, SCHEMA_CUR)
63 REG_POPULATE(PrimitiveType_Floor, PopulateArithmeticSelf, SCHEMA_CUR)
64 REG_POPULATE(PrimitiveType_Ceil, PopulateArithmeticSelf, SCHEMA_CUR)
65 REG_POPULATE(PrimitiveType_Round, PopulateArithmeticSelf, SCHEMA_CUR)
66 REG_POPULATE(PrimitiveType_Reciprocal, PopulateArithmeticSelf, SCHEMA_CUR)
67 }  // namespace lite
68 }  // namespace mindspore
69