| @@ -125,7 +125,7 @@ inline const PrimitivePtr kPrimSequenceMask = std::make_shared<Primitive>("Seque | |||
| // NN | |||
| inline const PrimitivePtr kPrimFlatten = std::make_shared<Primitive>("Flatten"); | |||
| inline const PrimitivePtr kPrimSoftmax = std::make_shared<Primitive>("Softmax"); | |||
| inline const PrimitivePtr kPrimSoftMax = std::make_shared<Primitive>("SoftMax"); | |||
| inline const PrimitivePtr kPrimLogSoftmax = std::make_shared<Primitive>("LogSoftmax"); | |||
| inline const PrimitivePtr kPrimLogSoftmaxGrad = std::make_shared<Primitive>("LogSoftmaxGrad"); | |||
| inline const PrimitivePtr kPrimTanh = std::make_shared<Primitive>("Tanh"); | |||
| @@ -0,0 +1,19 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/abs.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAbs, Abs); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ABS_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ABS_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAbs = "Abs"; | |||
| class Abs : public PrimitiveC { | |||
| public: | |||
| Abs() : PrimitiveC(kNameAbs) { InitIOName({"input_x"}, {"output"}); } | |||
| ~Abs() = default; | |||
| MS_DECLARE_PARENT(Abs, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ABS_H_ | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/adam.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void Adam::set_use_locking(const bool &use_locking) { this->AddAttr(kUseLocking, MakeValue(use_locking)); } | |||
| bool Adam::get_use_locking() const { | |||
| auto value_ptr = GetAttr(kUseLocking); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| void Adam::set_use_nesteroy(const bool &use_nesteroy) { this->AddAttr(kUseNesteroy, MakeValue(use_nesteroy)); } | |||
| bool Adam::get_use_nesteroy() const { | |||
| auto value_ptr = GetAttr(kUseNesteroy); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| void Adam::Init(const bool &use_locking, const bool &use_nesteroy) { | |||
| this->set_use_locking(use_locking); | |||
| this->set_use_nesteroy(use_nesteroy); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameAdam, Adam); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ADAM_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ADAM_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAdam = "Adam"; | |||
| class Adam : public PrimitiveC { | |||
| public: | |||
| Adam() : PrimitiveC(kNameAdam) {} | |||
| ~Adam() = default; | |||
| MS_DECLARE_PARENT(Adam, PrimitiveC); | |||
| void Init(const bool &use_locking = false, const bool &use_nesteroy = false); | |||
| void set_use_locking(const bool &use_locking); | |||
| void set_use_nesteroy(const bool &use_nesteroy); | |||
| bool get_use_locking() const; | |||
| bool get_use_nesteroy() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ADAM_H_ | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -15,19 +15,18 @@ | |||
| */ | |||
| #include "c_ops/add.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| namespace { | |||
| abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) { | |||
| MS_EXCEPTION_IF_NULL(primitive); | |||
| auto add_prim = primitive->cast<PrimTensorAddPtr>(); | |||
| auto add_prim = primitive->cast<PrimAddPtr>(); | |||
| MS_EXCEPTION_IF_NULL(add_prim); | |||
| auto op_name = add_prim->name(); | |||
| return BroadCastInferShape(op_name, input_args); | |||
| @@ -43,12 +42,13 @@ TypePtr InferType(const PrimitivePtr &prim, const std::vector<AbstractBasePtr> & | |||
| auto infer_type = CheckAndConvertUtils::CheckTensorTypeSame(types, common_valid_types, prim->name()); | |||
| return TypeIdToType(infer_type); | |||
| } | |||
| } // namespace | |||
| AbstractBasePtr TensorAddInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args) { | |||
| AbstractBasePtr AddInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args) { | |||
| return std::make_shared<abstract::AbstractTensor>(InferType(primitive, input_args), | |||
| InferShape(primitive, input_args)->shape()); | |||
| } | |||
| REGISTER_PRIMITIVE_EVAL_IMPL(TensorAdd, prim::kPrimTensorAdd, TensorAddInfer); | |||
| REGISTER_PRIMITIVE_C(kNameTensorAdd, TensorAdd); | |||
| REGISTER_PRIMITIVE_EVAL_IMPL(Add, prim::kPrimTensorAdd, AddInfer); | |||
| REGISTER_PRIMITIVE_C(kNameAdd, Add); | |||
| } // namespace mindspore | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -25,18 +25,18 @@ | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameTensorAdd = "TensorAdd"; | |||
| class TensorAdd : public PrimitiveC { | |||
| constexpr auto kNameAdd = "Add"; | |||
| class Add : public PrimitiveC { | |||
| public: | |||
| TensorAdd() : PrimitiveC(kNameTensorAdd) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~TensorAdd() = default; | |||
| MS_DECLARE_PARENT(TensorAdd, PrimitiveC); | |||
| Add() : PrimitiveC(kNameAdd) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~Add() = default; | |||
| MS_DECLARE_PARENT(Add, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| AbstractBasePtr TensorAddInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimTensorAddPtr = std::shared_ptr<TensorAdd>; | |||
| AbstractBasePtr AddInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimAddPtr = std::shared_ptr<Add>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ADD_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/add_fold.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAddFold, AddFold); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ADDFOLD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ADDFOLD_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAddFold = "AddFold"; | |||
| class AddFold : public PrimitiveC { | |||
| public: | |||
| AddFold() : PrimitiveC(kNameAddFold) {} | |||
| ~AddFold() = default; | |||
| MS_DECLARE_PARENT(AddFold, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ADDFOLD_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/addn.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAddN, AddN); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ADDN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ADDN_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAddN = "AddN"; | |||
| class AddN : public PrimitiveC { | |||
| public: | |||
| AddN() : PrimitiveC(kNameAddN) { InitIOName({"inputs"}, {"sum"}); } | |||
| ~AddN() = default; | |||
| MS_DECLARE_PARENT(AddN, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ADDN_H_ | |||
| @@ -0,0 +1,51 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/apply_momentum.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void ApplyMomentum::Init(bool use_nesterov, bool use_locking, float gradient_scale) { | |||
| this->set_use_nesterov(use_nesterov); | |||
| this->set_use_locking(use_locking); | |||
| this->set_gradient_scale(gradient_scale); | |||
| } | |||
| void ApplyMomentum::set_use_nesterov(bool use_nesterov) { this->AddAttr(kUseNesterov, MakeValue(use_nesterov)); } | |||
| void ApplyMomentum::set_use_locking(bool use_locking) { this->AddAttr(kUseLocking, MakeValue(use_locking)); } | |||
| void ApplyMomentum::set_gradient_scale(float gradient_scale) { | |||
| this->AddAttr(kGradientScale, MakeValue(gradient_scale)); | |||
| } | |||
| bool ApplyMomentum::get_use_nesterov() const { | |||
| auto value_ptr = GetAttr(kUseNesterov); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| bool ApplyMomentum::get_use_locking() const { | |||
| auto value_ptr = GetAttr(kUseLocking); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| float ApplyMomentum::get_gradient_scale() { | |||
| auto value_ptr = GetAttr(kGradientScale); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameApplyMomentum, ApplyMomentum); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_APPLYMOMENTUM_H_ | |||
| #define MINDSPORE_CORE_C_OPS_APPLYMOMENTUM_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameApplyMomentum = "ApplyMomentum"; | |||
| class ApplyMomentum : public PrimitiveC { | |||
| public: | |||
| ApplyMomentum() : PrimitiveC(kNameApplyMomentum) { | |||
| InitIOName({"variable", "accumulation", "learning_rate", "gradient", "momentum"}, {"output"}); | |||
| } | |||
| ~ApplyMomentum() = default; | |||
| MS_DECLARE_PARENT(ApplyMomentum, PrimitiveC); | |||
| void Init(bool use_nesterov, bool use_locking, float gradient_scale); | |||
| void set_use_nesterov(bool use_nesterov); | |||
| void set_use_locking(bool use_locking); | |||
| void set_gradient_scale(float gradient_scale); | |||
| bool get_use_nesterov() const; | |||
| bool get_use_locking() const; | |||
| float get_gradient_scale(); | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_APPLYMOMENTUM_H_ | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/arg_min.h" | |||
| namespace mindspore { | |||
| void ArgMin::Init(bool keep_dims, int64_t axis) { | |||
| set_axis(axis); | |||
| set_keep_dims(keep_dims); | |||
| } | |||
| void ArgMin::set_axis(int64_t axis) { this->AddAttr(kAxis, MakeValue(axis)); } | |||
| void ArgMin::set_keep_dims(bool keep_dims) { this->AddAttr(kOutputType, MakeValue(keep_dims)); } | |||
| int64_t ArgMin::get_axis() { | |||
| auto value_ptr = GetAttr(kAxis); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| bool ArgMin::get_keep_dims() { | |||
| auto value_ptr = GetAttr(kKeepDims); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameArgMin, ArgMin); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,45 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ARGMIN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ARGMIN_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameArgMin = "ArgMin"; | |||
| class ArgMin : public PrimitiveC { | |||
| public: | |||
| ArgMin() : PrimitiveC(kNameArgMin) { InitIOName({"x"}, {"output"}); } | |||
| ~ArgMin() = default; | |||
| MS_DECLARE_PARENT(ArgMin, PrimitiveC); | |||
| void Init(bool keep_dims, int64_t axis = -1); | |||
| void set_axis(int64_t axis); | |||
| void set_keep_dims(bool keep_dims); | |||
| int64_t get_axis(); | |||
| bool get_keep_dims(); | |||
| }; | |||
| AbstractBasePtr ArgMinInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimArgMin = std::shared_ptr<ArgMin>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ARGMIN_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/asin.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAsin, Asin); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ASIN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ASIN_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAsin = "Asin"; | |||
| class Asin : public PrimitiveC { | |||
| public: | |||
| Asin() : PrimitiveC(kNameAsin) {} | |||
| ~Asin() = default; | |||
| MS_DECLARE_PARENT(Asin, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ASIN_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/assign.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAssign, Assign); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ASSIGN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ASSIGN_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAssign = "Assign"; | |||
| class Assign : public PrimitiveC { | |||
| public: | |||
| Assign() : PrimitiveC(kNameAssign) { InitIOName({"ref", "value"}, {"output"}); } | |||
| ~Assign() = default; | |||
| MS_DECLARE_PARENT(Assign, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ASSIGN_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/assign_add.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAssignAdd, AssignAdd); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ASSIGNADD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ASSIGNADD_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAssignAdd = "AssignAdd"; | |||
| class AssignAdd : public PrimitiveC { | |||
| public: | |||
| AssignAdd() : PrimitiveC(kNameAssignAdd) { InitIOName({"ref", "value"}, {"output"}); } | |||
| ~AssignAdd() = default; | |||
| MS_DECLARE_PARENT(AssignAdd, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ASSIGNADD_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/atan.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameAtan, Atan); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_ATAN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_ATAN_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAtan = "Atan"; | |||
| class Atan : public PrimitiveC { | |||
| public: | |||
| Atan() : PrimitiveC(kNameAtan) {} | |||
| ~Atan() = default; | |||
| MS_DECLARE_PARENT(Atan, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_ATAN_H_ | |||
| @@ -0,0 +1,54 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/audio_spectrogram.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void AudioSpectrogram::set_window_size(const int64_t &window_size) { | |||
| this->AddAttr(kWindowSize, MakeValue(window_size)); | |||
| } | |||
| int64_t AudioSpectrogram::get_window_size() const { | |||
| auto value_ptr = GetAttr(kWindowSize); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void AudioSpectrogram::set_stride(const int64_t &stride) { this->AddAttr(kStride, MakeValue(stride)); } | |||
| int64_t AudioSpectrogram::get_stride() const { | |||
| auto value_ptr = GetAttr(kStride); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void AudioSpectrogram::set_mag_square(const bool &mag_square) { this->AddAttr(kMagSquare, MakeValue(mag_square)); } | |||
| bool AudioSpectrogram::get_mag_square() const { | |||
| auto value_ptr = GetAttr(kMagSquare); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| void AudioSpectrogram::Init(const int64_t &window_size, const int64_t &stride, const bool &mag_square) { | |||
| this->set_window_size(window_size); | |||
| this->set_stride(stride); | |||
| this->set_mag_square(mag_square); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameAudioSpectrogram, AudioSpectrogram); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,44 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_AUDIOSPECTROGRAM_H_ | |||
| #define MINDSPORE_CORE_C_OPS_AUDIOSPECTROGRAM_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameAudioSpectrogram = "AudioSpectrogram"; | |||
| class AudioSpectrogram : public PrimitiveC { | |||
| public: | |||
| AudioSpectrogram() : PrimitiveC(kNameAudioSpectrogram) {} | |||
| ~AudioSpectrogram() = default; | |||
| MS_DECLARE_PARENT(AudioSpectrogram, PrimitiveC); | |||
| void Init(const int64_t &window_size, const int64_t &stride, const bool &mag_square); | |||
| void set_window_size(const int64_t &window_size); | |||
| void set_stride(const int64_t &stride); | |||
| void set_mag_square(const bool &mag_square); | |||
| int64_t get_window_size() const; | |||
| int64_t get_stride() const; | |||
| bool get_mag_square() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_AUDIOSPECTROGRAM_H_ | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -13,6 +13,7 @@ | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/avg_pool.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| @@ -24,36 +25,73 @@ | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void AvgPool::set_padding(const std::string &pad) { this->AddAttr("padding", MakeValue(pad)); } | |||
| void AvgPool::set_padding(const std::string &padding) { | |||
| CheckAndConvertUtils::CheckString(kPadding, padding, {kValid, kSame}, this->name()); | |||
| this->AddAttr(kPadding, MakeValue(padding)); | |||
| } | |||
| std::string AvgPool::get_padding() const { | |||
| auto value_ptr = GetAttr("padding"); | |||
| auto value_ptr = GetAttr(kPadding); | |||
| return GetValue<std::string>(value_ptr); | |||
| } | |||
| void AvgPool::set_kernel_size(const std::vector<int64_t> &kernel_size) { | |||
| this->AddAttr("k_size", MakeValue(kernel_size)); | |||
| this->AddAttr(kKernelSize, MakeValue(CheckAndConvertUtils::CheckPositiveVector(kKernelSize, kernel_size, this->name(), | |||
| false, true))); | |||
| } | |||
| std::vector<int64_t> AvgPool::get_kernel_size() const { | |||
| auto value_ptr = GetAttr("k_size"); | |||
| auto value_ptr = GetAttr(kKernelSize); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| void AvgPool::set_strides(const std::vector<int64_t> &strides) { this->AddAttr("strides", MakeValue(strides)); } | |||
| void AvgPool::set_strides(const std::vector<int64_t> &strides) { | |||
| this->AddAttr(kStride, | |||
| MakeValue(CheckAndConvertUtils::CheckPositiveVector(kStride, strides, this->name(), false, true))); | |||
| } | |||
| std::vector<int64_t> AvgPool::get_strides() const { | |||
| auto value_ptr = GetAttr("strides"); | |||
| auto value_ptr = GetAttr(kStride); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| void AvgPool::set_format(const Format &format) { | |||
| int64_t f = format; | |||
| this->AddAttr(kFormat, MakeValue(f)); | |||
| } | |||
| Format AvgPool::get_format() const { | |||
| auto value_ptr = GetAttr(kFormat); | |||
| return Format(GetValue<int64_t>(value_ptr)); | |||
| } | |||
| void AvgPool::set_pad(const std::vector<int64_t> &pad) { this->AddAttr(kPad, MakeValue(pad)); } | |||
| std::vector<int64_t> AvgPool::get_pad() const { | |||
| auto value_ptr = GetAttr(kPad); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| void AvgPool::set_round_mode(const int64_t &round_mode) { | |||
| CheckAndConvertUtils::CheckInRange(kRoundMode, round_mode, kIncludeBoth, {0, 1}, this->name()); | |||
| this->AddAttr(kRoundMode, MakeValue(round_mode)); | |||
| } | |||
| int64_t AvgPool::get_round_mode() const { | |||
| auto value_ptr = GetAttr(kRoundMode); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void AvgPool::Init(const std::vector<int64_t> &kernel_size, const std::vector<int64_t> &stride, | |||
| const std::string &padding) { | |||
| auto prim_name = this->name(); | |||
| this->AddAttr("data_format", MakeValue("NCHW")); | |||
| this->set_padding(CheckAndConvertUtils::CheckString("padding", padding, {"valid", "same"}, prim_name)); | |||
| this->set_kernel_size(CheckAndConvertUtils::CheckPositiveVector("k_size", kernel_size, prim_name, false, true)); | |||
| this->set_strides(CheckAndConvertUtils::CheckPositiveVector("strides", stride, this->name(), false, true)); | |||
| const std::string &padding, const Format &format, const std::vector<int64_t> &pad, | |||
| const int64_t &round_mode) { | |||
| this->set_padding(padding); | |||
| this->set_kernel_size(kernel_size); | |||
| this->set_strides(stride); | |||
| this->set_format(format); | |||
| this->set_pad(pad); | |||
| this->set_round_mode(round_mode); | |||
| } | |||
| namespace { | |||
| abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) { | |||
| MS_EXCEPTION_IF_NULL(primitive); | |||
| auto pool_prim = primitive->cast<PrimAvgPoolPtr>(); | |||
| @@ -83,7 +121,7 @@ abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<A | |||
| out_w = ceil(in_w / stride_w); | |||
| } | |||
| std::vector<int64_t> out_shape = {batch, channel, out_h, out_w}; | |||
| if (std::any_of(out_shape.begin(), out_shape.end(), [](int a) { return a <= 0; })) { | |||
| if (std::any_of(out_shape.begin(), out_shape.end(), [](int64_t a) { return a <= 0; })) { | |||
| MS_LOG(EXCEPTION) << "Kernel size is not valid."; | |||
| } | |||
| return std::make_shared<abstract::Shape>(out_shape); | |||
| @@ -95,6 +133,7 @@ TypePtr InferType(const PrimitivePtr &prim, const std::vector<AbstractBasePtr> & | |||
| } | |||
| return input_args[0]->BuildType(); | |||
| } | |||
| } // namespace | |||
| AbstractBasePtr AvgPoolInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args) { | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -33,13 +33,21 @@ class AvgPool : public PrimitiveC { | |||
| ~AvgPool() = default; | |||
| MS_DECLARE_PARENT(AvgPool, PrimitiveC); | |||
| void Init(const std::vector<int64_t> &kernel_size = {1}, const std::vector<int64_t> &stride = {1}, | |||
| const std::string &padding = "valid"); | |||
| void set_padding(const std::string &pad); | |||
| const std::string &padding = "valid", const Format &format = NCHW, | |||
| const std::vector<int64_t> &pad = {0, 0, 0, 0}, const int64_t &round_mode = 0); | |||
| void set_padding(const std::string &padding); | |||
| void set_kernel_size(const std::vector<int64_t> &kernel_size); | |||
| void set_strides(const std::vector<int64_t> &strides); | |||
| void set_format(const Format &format); | |||
| void set_pad(const std::vector<int64_t> &pad); | |||
| void set_round_mode(const int64_t &round_mode); | |||
| std::vector<int64_t> get_kernel_size() const; | |||
| std::vector<int64_t> get_strides() const; | |||
| std::string get_padding() const; | |||
| Format get_format() const; | |||
| std::vector<int64_t> get_pad() const; | |||
| int64_t get_round_mode() const; | |||
| }; | |||
| AbstractBasePtr AvgPoolInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| @@ -0,0 +1,59 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/batch_norm.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void BatchNorm::Init(bool is_training, float epsilon, const Format &format) { | |||
| set_is_training(is_training); | |||
| set_epsilon(epsilon); | |||
| set_format(format); | |||
| } | |||
| void BatchNorm::set_is_training(bool is_training) { this->AddAttr(kIsTraining, MakeValue(is_training)); } | |||
| void BatchNorm::set_epsilon(float epsilon) { | |||
| CheckAndConvertUtils::CheckInRange(kEpsilon, epsilon, kIncludeBoth, {0.0, 1.0}, this->name()); | |||
| this->AddAttr(kEpsilon, MakeValue(epsilon)); | |||
| } | |||
| void BatchNorm::set_format(const Format &format) { | |||
| int64_t f = format; | |||
| this->AddAttr(kFormat, MakeValue(f)); | |||
| } | |||
| bool BatchNorm::get_is_trainging() { | |||
| auto value_ptr = GetAttr(kIsTraining); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| float BatchNorm::get_epsilon() { | |||
| auto value_ptr = GetAttr(kEpsilon); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| Format BatchNorm::get_format() const { | |||
| auto value_ptr = GetAttr(kFormat); | |||
| return Format(GetValue<int64_t>(value_ptr)); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameBatchNorm, BatchNorm); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,52 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BATCH_NORMAL_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BATCH_NORMAL_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <memory> | |||
| #include <string> | |||
| #include "c_ops/op_utils.h" | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBatchNorm = "BatchNorm"; | |||
| class BatchNorm : public PrimitiveC { | |||
| public: | |||
| BatchNorm() : PrimitiveC(kNameBatchNorm) { | |||
| InitIOName({"x", "scale", "offset", "mean", "variance"}, | |||
| {"y", "batch_mean", "batch_variance", "reserve_space_1", "reserve_space_2"}); | |||
| } | |||
| ~BatchNorm() = default; | |||
| MS_DECLARE_PARENT(BatchNorm, PrimitiveC); | |||
| void Init(bool is_training = false, float epsilon = 1e-5, const Format &format = NCHW); | |||
| void set_is_training(bool is_training); | |||
| void set_epsilon(float epsilon); | |||
| void set_format(const Format &format); | |||
| bool get_is_trainging(); | |||
| float get_epsilon(); | |||
| Format get_format() const; | |||
| }; | |||
| AbstractBasePtr BatchNormInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimBatchNormPtr = std::shared_ptr<BatchNorm>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BatchNorm_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/batch_norm_fold.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameBatchNormFold, BatchNormFold); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,37 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BATCHNORMFOLD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BATCHNORMFOLD_H_ | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBatchNormFold = "BatchNormFold"; | |||
| class BatchNormFold : public PrimitiveC { | |||
| public: | |||
| BatchNormFold() : PrimitiveC(kNameBatchNormFold) {} | |||
| ~BatchNormFold() = default; | |||
| MS_DECLARE_PARENT(BatchNormFold, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| using PrimBatchNormFoldPtr = std::shared_ptr<BatchNormFold>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BATCHNORMFOLD_H_ | |||
| @@ -0,0 +1,33 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/bias_add.h" | |||
| #include <memory> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void BiasAdd::set_format(const Format &format) { | |||
| int64_t f = format; | |||
| this->AddAttr(kFormat, MakeValue(f)); | |||
| } | |||
| Format BiasAdd::get_format() const { | |||
| auto value_ptr = GetAttr(kFormat); | |||
| return Format(GetValue<int64_t>(value_ptr)); | |||
| } | |||
| void BiasAdd::Init(const Format &format) { this->set_format(format); } | |||
| REGISTER_PRIMITIVE_C(kNameBiasAdd, BiasAdd); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BIASADD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BIASADD_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBiasAdd = "BiasAdd"; | |||
| class BiasAdd : public PrimitiveC { | |||
| public: | |||
| BiasAdd() : PrimitiveC(kNameBiasAdd) { InitIOName({"x", "b"}, {"output"}); } | |||
| ~BiasAdd() = default; | |||
| MS_DECLARE_PARENT(BiasAdd, PrimitiveC); | |||
| void Init(const Format &format = NCHW); | |||
| void set_format(const Format &format); | |||
| Format get_format() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BIASADD_H_ | |||
| @@ -0,0 +1,37 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/bias_grad.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void BiasGrad::set_axis(const std::vector<int64_t> &axis) { this->AddAttr(kAxis, MakeValue(axis)); } | |||
| std::vector<int64_t> BiasGrad::get_axis() const { | |||
| auto value_ptr = GetAttr(kAxis); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| void BiasGrad::Init(const std::vector<int64_t> &axis) { this->set_axis(axis); } | |||
| REGISTER_PRIMITIVE_C(kNameBiasGrad, BiasGrad); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BIASGRAD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BIASGRAD_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBiasGrad = "BiasGrad"; | |||
| class BiasGrad : public PrimitiveC { | |||
| public: | |||
| BiasGrad() : PrimitiveC(kNameBiasGrad) {} | |||
| ~BiasGrad() = default; | |||
| MS_DECLARE_PARENT(BiasGrad, PrimitiveC); | |||
| void Init(const std::vector<int64_t> &axis); | |||
| void set_axis(const std::vector<int64_t> &axis); | |||
| std::vector<int64_t> get_axis() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BIASGRAD_H_ | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/binary_cross_entropy.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void BinaryCrossEntropy::set_reduction(const std::string &reduction) { | |||
| CheckAndConvertUtils::CheckString(kReduction, reduction, {"none", "mean", "sum"}, this->name()); | |||
| this->AddAttr(kReduction, MakeValue(reduction)); | |||
| } | |||
| std::string BinaryCrossEntropy::get_reduction() const { | |||
| auto value_ptr = GetAttr(kReduction); | |||
| return GetValue<std::string>(value_ptr); | |||
| } | |||
| void BinaryCrossEntropy::Init(const std::string &reduction) { this->set_reduction(reduction); } | |||
| REGISTER_PRIMITIVE_C(kNameBinaryCrossEntropy, BinaryCrossEntropy); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| #include <string> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBinaryCrossEntropy = "BinaryCrossEntropy"; | |||
| class BinaryCrossEntropy : public PrimitiveC { | |||
| public: | |||
| BinaryCrossEntropy() : PrimitiveC(kNameBinaryCrossEntropy) {} | |||
| ~BinaryCrossEntropy() = default; | |||
| MS_DECLARE_PARENT(BinaryCrossEntropy, PrimitiveC); | |||
| void Init(const std::string &reduction = "mean"); | |||
| void set_reduction(const std::string &reduction); | |||
| std::string get_reduction() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| @@ -0,0 +1,31 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/binary_cross_entropy_grad.h" | |||
| namespace mindspore { | |||
| void BinaryCrossEntropyGrad::Init(const std::string &reduction) { set_reduction(reduction); } | |||
| void BinaryCrossEntropyGrad::set_reduction(const std::string &reduction) { | |||
| CheckAndConvertUtils::CheckString(kReduction, reduction, {"none", "mean", "sum"}, name()); | |||
| this->AddAttr(kReduction, MakeValue(reduction)); | |||
| } | |||
| std::string BinaryCrossEntropyGrad::get_reduction() const { | |||
| auto value_ptr = GetAttr(kReduction); | |||
| return GetValue<std::string>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameBinaryCrossEntropyGrad, BinaryCrossEntropyGrad); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,43 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBinaryCrossEntropyGrad = "BinaryCrossEntropyGrad"; | |||
| class BinaryCrossEntropyGrad : public PrimitiveC { | |||
| public: | |||
| BinaryCrossEntropyGrad() : PrimitiveC(kNameBinaryCrossEntropyGrad) {} | |||
| ~BinaryCrossEntropyGrad() = default; | |||
| MS_DECLARE_PARENT(BinaryCrossEntropyGrad, PrimitiveC); | |||
| void Init(const std::string &reduction = "mean"); | |||
| void set_reduction(const std::string &reduction); | |||
| std::string get_reduction() const; | |||
| }; | |||
| AbstractBasePtr BinaryCrossEntropyGradInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimBinaryCrossEntropyGrad = std::shared_ptr<BinaryCrossEntropyGrad>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BINARY_CROSS_ENTROPY_GRAD_H_ | |||
| @@ -0,0 +1,50 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/black_box.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void BlackBox::Init(const std::string &id, int64_t size, const std::vector<int64_t> &address) { | |||
| this->set_id(id); | |||
| this->set_size(size); | |||
| this->set_address(address); | |||
| } | |||
| void BlackBox::set_id(const std::string &id) { this->AddAttr(kId, MakeValue(id)); } | |||
| std::string BlackBox::get_id() const { | |||
| auto value_ptr = this->GetAttr(kId); | |||
| return GetValue<std::string>(value_ptr); | |||
| } | |||
| void BlackBox::set_size(int64_t size) { this->AddAttr(kSize, MakeValue(size)); } | |||
| int64_t BlackBox::get_size() const { | |||
| auto value_ptr = this->GetAttr(kSize); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void BlackBox::set_address(const std::vector<int64_t> &address) { this->AddAttr(kAddress, MakeValue(address)); } | |||
| std::vector<int64_t> BlackBox::get_address() const { | |||
| auto value_ptr = this->GetAttr(kAddress); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameBlackBox, BlackBox); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,45 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BLACKBOX_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BLACKBOX_H_ | |||
| #include <string> | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBlackBox = "BlackBox"; | |||
| class BlackBox : public PrimitiveC { | |||
| public: | |||
| BlackBox() : PrimitiveC(kNameBlackBox) {} | |||
| ~BlackBox() = default; | |||
| MS_DECLARE_PARENT(BlackBox, PrimitiveC); | |||
| void Init(const std::string &id, int64_t size, const std::vector<int64_t> &address); | |||
| void set_id(const std::string &id); | |||
| void set_size(int64_t size); | |||
| void set_address(const std::vector<int64_t> &address); | |||
| std::string get_id() const; | |||
| int64_t get_size() const; | |||
| std::vector<int64_t> get_address() const; | |||
| }; | |||
| using PrimBlackBoxPtr = std::shared_ptr<BlackBox>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BLACKBOX_H_ | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/broadcast.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void Broadcast::Init(int64_t root_rank, const std::string &group) { | |||
| this->set_root_rank(root_rank); | |||
| this->set_group(group); | |||
| } | |||
| void Broadcast::set_root_rank(int64_t root_rank) { this->AddAttr(kKeepProb, MakeValue(root_rank)); } | |||
| void Broadcast::set_group(const std::string &group) { | |||
| CheckAndConvertUtils::CheckString(kGroup, group, {"hccl_world_group", "hccl_world_group"}, this->name()); | |||
| this->AddAttr(kGroup, MakeValue(group)); | |||
| } | |||
| int64_t Broadcast::get_root_rank() { | |||
| auto value_ptr = this->GetAttr(kRootRank); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| std::string Broadcast::get_group() const { | |||
| auto value_ptr = this->GetAttr(kGroup); | |||
| return GetValue<std::string>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameBroadcast, Broadcast); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| #include <string> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBroadcast = "Broadcast"; | |||
| class Broadcast : public PrimitiveC { | |||
| public: | |||
| Broadcast() : PrimitiveC(kNameBroadcast) {} | |||
| ~Broadcast() = default; | |||
| MS_DECLARE_PARENT(Broadcast, PrimitiveC); | |||
| void Init(int64_t root_rank, const std::string &group = "hccl_world_group"); | |||
| void set_root_rank(int64_t root_rank); | |||
| void set_group(const std::string &group); | |||
| int64_t get_root_rank(); | |||
| std::string get_group() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| @@ -0,0 +1,33 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/broadcast_to.h" | |||
| namespace mindspore { | |||
| void BroadcastTo::Init(const std::vector<int64_t> &shape) { set_shape(shape); } | |||
| void BroadcastTo::set_shape(const std::vector<int64_t> &shape) { | |||
| CheckAndConvertUtils::CheckInteger(kShapeSize, shape.size(), kGreaterThan, 0, name()); | |||
| CheckAndConvertUtils::CheckPositiveVector(kShape, shape, name(), false, true); | |||
| AddAttr(kShape, MakeValue(shape)); | |||
| } | |||
| std::vector<int64_t> BroadcastTo::get_shape() const { | |||
| auto value_ptr = GetAttr(kShape); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameBroadcastTo, BroadcastTo); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,46 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| #define MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/op_utils.h" | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameBroadcastTo = "BroadcastTo"; | |||
| class BroadcastTo : public PrimitiveC { | |||
| public: | |||
| BroadcastTo() : PrimitiveC(kNameBroadcastTo) {} | |||
| ~BroadcastTo() = default; | |||
| MS_DECLARE_PARENT(BroadcastTo, PrimitiveC); | |||
| void Init(const std::vector<int64_t> &shape); | |||
| void set_shape(const std::vector<int64_t> &shape); | |||
| std::vector<int64_t> get_shape() const; | |||
| }; | |||
| AbstractBasePtr BroadcastToInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimBroadcastToPtr = std::shared_ptr<BroadcastTo>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_BROADCAST_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/cast.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameCast, Cast); | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CAST_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CAST_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCast = "Cast"; | |||
| class Cast : public PrimitiveC { | |||
| public: | |||
| Cast() : PrimitiveC(kNameCast) { InitIOName({"x", "dst_type"}, {"output"}); } | |||
| ~Cast() = default; | |||
| MS_DECLARE_PARENT(Cast, PrimitiveC); | |||
| }; | |||
| AbstractBasePtr CastInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimCast = std::shared_ptr<Cast>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CAST_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/ceil.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameCeil, Ceil); | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CEIL_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CEIL_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCeil = "Ceil"; | |||
| class Ceil : public PrimitiveC { | |||
| public: | |||
| Ceil() : PrimitiveC(kNameCeil) { InitIOName({"x"}, {"y"}); } | |||
| ~Ceil() = default; | |||
| MS_DECLARE_PARENT(Ceil, PrimitiveC); | |||
| }; | |||
| AbstractBasePtr CeilInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimCeil = std::shared_ptr<Ceil>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CEIL_H_ | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/clip.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| #include "c_ops/op_utils.h" | |||
| namespace mindspore { | |||
| void Clip::Init(const float max, const float min) { | |||
| this->set_max(max); | |||
| this->set_min(min); | |||
| } | |||
| void Clip::set_max(const float max) { this->AddAttr(kMax, MakeValue(max)); } | |||
| float Clip::get_max() const { | |||
| auto value_ptr = this->GetAttr(kMax); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| void Clip::set_min(const float min) { this->AddAttr(kMin, MakeValue(min)); } | |||
| float Clip::get_min() const { | |||
| auto value_ptr = this->GetAttr(kMin); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameClip, Clip); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,41 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CLIP_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CLIP_H_ | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameClip = "Clip"; | |||
| class Clip : public PrimitiveC { | |||
| public: | |||
| Clip() : PrimitiveC(kNameClip) {} | |||
| ~Clip() = default; | |||
| MS_DECLARE_PARENT(Clip, PrimitiveC); | |||
| void Init(const float max, const float min); | |||
| void set_max(const float max); | |||
| void set_min(const float min); | |||
| float get_max() const; | |||
| float get_min() const; | |||
| }; | |||
| using PrimClipPtr = std::shared_ptr<Clip>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CLIP_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/concat.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void Concat::Init(int64_t axis) { this->set_axis(axis); } | |||
| int64_t Concat::get_axis() const { | |||
| auto value_ptr = this->GetAttr(kAxis); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void Concat::set_axis(int64_t axis) { | |||
| this->AddAttr(kAxis, MakeValue(CheckAndConvertUtils::CheckInteger(kAxis, axis, kGreaterEqual, 0, this->name()))); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameConcat, Concat); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CONCAT_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CONCAT_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameConcat = "Concat"; | |||
| class Concat : public PrimitiveC { | |||
| public: | |||
| Concat() : PrimitiveC(kNameConcat) {} | |||
| ~Concat() = default; | |||
| MS_DECLARE_PARENT(Concat, PrimitiveC); | |||
| void Init(int64_t axis = 0); | |||
| void set_axis(int64_t axis); | |||
| int64_t get_axis() const; | |||
| }; | |||
| AbstractBasePtr ConcatInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimConcatPtr = std::shared_ptr<Concat>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CONCAT_H_ | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/constant_of_shape.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void ConstantOfShape::Init(int64_t data_type, const std::vector<float> &value) { | |||
| this->set_data_type(data_type); | |||
| this->set_value(value); | |||
| } | |||
| void ConstantOfShape::set_data_type(int64_t data_type) { this->AddAttr(kDataType, MakeValue(data_type)); } | |||
| int64_t ConstantOfShape::get_data_type() const { | |||
| auto value_ptr = this->GetAttr(kDataType); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void ConstantOfShape::set_value(const std::vector<float> &value) { this->AddAttr(kValue, MakeValue(value)); } | |||
| std::vector<float> ConstantOfShape::get_value() const { | |||
| auto value_ptr = this->GetAttr(kValue); | |||
| return GetValue<std::vector<float>>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameConstantOfShape, ConstantOfShape); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CONSTANTOFSHAPE_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CONSTANTOFSHAPE_H_ | |||
| #include <memory> | |||
| #include <vector> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameConstantOfShape = "ConstantOfShape"; | |||
| class ConstantOfShape : public PrimitiveC { | |||
| public: | |||
| ConstantOfShape() : PrimitiveC(kNameConstantOfShape) {} | |||
| ~ConstantOfShape() = default; | |||
| MS_DECLARE_PARENT(ConstantOfShape, PrimitiveC); | |||
| void Init(int64_t data_type, const std::vector<float> &value); | |||
| void set_data_type(int64_t data_type); | |||
| void set_value(const std::vector<float> &value); | |||
| int64_t get_data_type() const; | |||
| std::vector<float> get_value() const; | |||
| }; | |||
| using PrimConstantOfShapePtr = std::shared_ptr<ConstantOfShape>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CONSTANTOFSHAPE_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/control_depend.h" | |||
| namespace mindspore { | |||
| void ControlDepend::Init(int64_t depend_mode) { this->set_depend_mode(depend_mode); } | |||
| void ControlDepend::set_depend_mode(int64_t depend_mode) { | |||
| CheckAndConvertUtils::CheckInRange(kDependMode, depend_mode, kIncludeBoth, {0, 1}, name()); | |||
| AddAttr(kDependMode, MakeValue(depend_mode)); | |||
| } | |||
| int64_t ControlDepend::get_depend_mode() { | |||
| auto value_ptr = GetAttr(kDependMode); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameControlDepend, ControlDepend); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CONTROL_DEPEND_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CONTROL_DEPEND_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameControlDepend = "ControlDepend"; | |||
| class ControlDepend : public PrimitiveC { | |||
| public: | |||
| ControlDepend() : PrimitiveC(kNameControlDepend) {} | |||
| ~ControlDepend() = default; | |||
| MS_DECLARE_PARENT(ControlDepend, PrimitiveC); | |||
| void Init(int64_t depend_mode); | |||
| void set_depend_mode(int64_t depend_mode); | |||
| int64_t get_depend_mode(); | |||
| }; | |||
| AbstractBasePtr ControlDependInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimControlDepend = std::shared_ptr<ControlDepend>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CONTROl_DEPEND_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/cos.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameCos, Cos); | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_COS_H_ | |||
| #define MINDSPORE_CORE_C_OPS_COS_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCos = "Cos"; | |||
| class Cos : public PrimitiveC { | |||
| public: | |||
| Cos() : PrimitiveC(kNameCos) {} | |||
| ~Cos() = default; | |||
| MS_DECLARE_PARENT(Cos, PrimitiveC); | |||
| void Init(float alpha = 0.0); | |||
| }; | |||
| AbstractBasePtr CosInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimCos = std::shared_ptr<Cos>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_COS_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/custom.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| #include "c_ops/op_utils.h" | |||
| namespace mindspore { | |||
| void Custom::Init(const std::vector<int64_t> &custom) { this->set_custom(custom); } | |||
| void Custom::set_custom(const std::vector<int64_t> &custom) { this->AddAttr(kCustom, MakeValue(custom)); } | |||
| std::vector<int64_t> Custom::get_custom() const { | |||
| auto value_ptr = this->GetAttr(kCustom); | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameCustom, Custom); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,41 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CUSTOM_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CUSTOM_H_ | |||
| #include <memory> | |||
| #include <vector> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCustom = "Custom"; | |||
| class Custom : public PrimitiveC { | |||
| public: | |||
| Custom() : PrimitiveC(kNameCustom) {} | |||
| ~Custom() = default; | |||
| MS_DECLARE_PARENT(Custom, PrimitiveC); | |||
| void Init(const std::vector<int64_t> &custom); | |||
| void set_custom(const std::vector<int64_t> &custom); | |||
| std::vector<int64_t> get_custom() const; | |||
| }; | |||
| using PrimCustomPtr = std::shared_ptr<Custom>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CUSTOM_H_ | |||
| @@ -0,0 +1,23 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/custom_normalize.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameCustomNormalize, CustomNormalize); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,37 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CUSTOMNORMALIZE_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CUSTOMNORMALIZE_H_ | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCustomNormalize = "CustomNormalize"; | |||
| class CustomNormalize : public PrimitiveC { | |||
| public: | |||
| CustomNormalize() : PrimitiveC(kNameCustomNormalize) {} | |||
| ~CustomNormalize() = default; | |||
| MS_DECLARE_PARENT(CustomNormalize, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| using PrimCustomNormalizePtr = std::shared_ptr<CustomNormalize>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CUSTOMNORMALIZE_H_ | |||
| @@ -0,0 +1,44 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/custom_predict.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void CustomPredict::Init(int64_t outputNum, float weight_threshold) { | |||
| this->set_outputNum(outputNum); | |||
| this->set_weight_threshold(weight_threshold); | |||
| } | |||
| void CustomPredict::set_outputNum(int64_t outputNum) { this->AddAttr(kOutputNum, MakeValue(outputNum)); } | |||
| int64_t CustomPredict::get_outputNum() const { | |||
| auto value_ptr = this->GetAttr(kOutputNum); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void CustomPredict::set_weight_threshold(float weight_threshold) { | |||
| this->AddAttr(kWeightThreshold, MakeValue(weight_threshold)); | |||
| } | |||
| float CustomPredict::get_weight_threshold() const { | |||
| auto value_ptr = this->GetAttr(kWeightThreshold); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameCustomPredict, CustomPredict); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,42 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_CUSTOMPREDICT_H_ | |||
| #define MINDSPORE_CORE_C_OPS_CUSTOMPREDICT_H_ | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameCustomPredict = "CustomPredict"; | |||
| class CustomPredict : public PrimitiveC { | |||
| public: | |||
| CustomPredict() : PrimitiveC(kNameCustomPredict) {} | |||
| ~CustomPredict() = default; | |||
| MS_DECLARE_PARENT(CustomPredict, PrimitiveC); | |||
| void Init(int64_t outputNum, float weight_threshold); | |||
| void set_outputNum(int64_t outputNum); | |||
| void set_weight_threshold(float weight_threshold); | |||
| int64_t get_outputNum() const; | |||
| float get_weight_threshold() const; | |||
| }; | |||
| using PrimCustomPredictPtr = std::shared_ptr<CustomPredict>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_CUSTOMPREDICT_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/depend.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameDepend, Depend); | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_DEPEND_H_ | |||
| #define MINDSPORE_CORE_C_OPS_DEPEND_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameDepend = "Depend"; | |||
| class Depend : public PrimitiveC { | |||
| public: | |||
| Depend() : PrimitiveC(kNameDepend) {} | |||
| ~Depend() = default; | |||
| MS_DECLARE_PARENT(Depend, PrimitiveC); | |||
| void Init(); | |||
| }; | |||
| AbstractBasePtr DependInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimDepend = std::shared_ptr<Depend>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_DEPEND_H_ | |||
| @@ -0,0 +1,51 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/depth_to_space.h" | |||
| #include <string> | |||
| #include <algorithm> | |||
| #include <memory> | |||
| #include <set> | |||
| #include <vector> | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void DepthToSpace::set_block_size(const int64_t &block_size) { | |||
| CheckAndConvertUtils::Check(kBlockSize, block_size, kGreaterEqual, "", 2, this->name()); | |||
| this->AddAttr(kBlockSize, MakeValue(block_size)); | |||
| } | |||
| int64_t DepthToSpace::get_block_size() const { | |||
| auto value_ptr = GetAttr(kBlockSize); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void DepthToSpace::set_format(const Format &format) { | |||
| int64_t f = format; | |||
| this->AddAttr(kFormat, MakeValue(f)); | |||
| } | |||
| Format DepthToSpace::get_format() const { | |||
| auto value_ptr = GetAttr(kFormat); | |||
| return Format(GetValue<int64_t>(value_ptr)); | |||
| } | |||
| void DepthToSpace::Init(const int64_t &block_size, const Format &format) { | |||
| this->set_block_size(block_size); | |||
| this->set_format(format); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameDepthToSpace, DepthToSpace); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,43 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_DEPTH_TO_SPACE_H_ | |||
| #define MINDSPORE_CORE_C_OPS_DEPTH_TO_SPACE_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameDepthToSpace = "DepthToSpace"; | |||
| class DepthToSpace : public PrimitiveC { | |||
| public: | |||
| DepthToSpace() : PrimitiveC(kNameDepthToSpace) { InitIOName({"x"}, {"y"}); } | |||
| ~DepthToSpace() = default; | |||
| MS_DECLARE_PARENT(DepthToSpace, PrimitiveC); | |||
| void Init(const int64_t &block_size, const Format &format = NCHW); | |||
| void set_block_size(const int64_t &block_size); | |||
| int64_t get_block_size() const; | |||
| void set_format(const Format &format); | |||
| Format get_format() const; | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_DEPTH_TO_SPACE_H_ | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -24,11 +24,11 @@ | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void DepthWiseConv2D::Init(int channel_multiplier, const std::vector<int64_t> &kernel_size, int mode, | |||
| void DepthWiseConv2D::Init(int64_t channel_multiplier, const std::vector<int64_t> &kernel_size, int64_t mode, | |||
| const std::string &pad_mode, const std::vector<int64_t> &pad, | |||
| const std::vector<int64_t> &stride, const std::vector<int64_t> &dilation, int group) { | |||
| const std::vector<int64_t> &stride, const std::vector<int64_t> &dilation, int64_t group) { | |||
| auto prim_name = this->name(); | |||
| this->AddAttr("data_format", MakeValue("NCHW")); | |||
| this->set_format(NCHW); | |||
| this->AddAttr("offset_a", MakeValue(0)); | |||
| this->set_mode(CheckAndConvertUtils::CheckInteger("mode", mode, kEqual, 3, prim_name)); | |||
| @@ -88,18 +88,18 @@ std::vector<int64_t> DepthWiseConv2D::get_pads() const { | |||
| return GetValue<std::vector<int64_t>>(value_ptr); | |||
| } | |||
| int DepthWiseConv2D::get_mode() const { | |||
| int64_t DepthWiseConv2D::get_mode() const { | |||
| auto value_ptr = this->GetAttr(kMode); | |||
| return GetValue<int>(value_ptr); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| int DepthWiseConv2D::get_group() const { | |||
| int64_t DepthWiseConv2D::get_group() const { | |||
| auto value_ptr = this->GetAttr(kGroup); | |||
| return GetValue<int>(value_ptr); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| int DepthWiseConv2D::get_output_channel() const { | |||
| auto value_ptr = this->GetAttr(kOutputChannel); | |||
| return GetValue<int>(value_ptr); | |||
| int64_t DepthWiseConv2D::get_out_channel() const { | |||
| auto value_ptr = this->GetAttr(kOutChannel); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| void DepthWiseConv2D::set_kernel_size(const std::vector<int64_t> &kernel_size) { | |||
| @@ -112,11 +112,20 @@ void DepthWiseConv2D::set_dilation(const std::vector<int64_t> &dilation) { | |||
| } | |||
| void DepthWiseConv2D::set_pad_mode(const std::string &pad_mode) { this->AddAttr(kPadMode, MakeValue(pad_mode)); } | |||
| void DepthWiseConv2D::set_pad(const std::vector<int64_t> &pad) { this->AddAttr(kPad, MakeValue(pad)); } | |||
| void DepthWiseConv2D::set_mode(int mode) { this->AddAttr(kMode, MakeValue(mode)); } | |||
| void DepthWiseConv2D::set_group(int group) { this->AddAttr(kGroup, MakeValue(group)); } | |||
| void DepthWiseConv2D::set_out_channel(int output_channel) { this->AddAttr(kOutputChannel, MakeValue(output_channel)); } | |||
| void DepthWiseConv2D::set_mode(int64_t mode) { this->AddAttr(kMode, MakeValue(mode)); } | |||
| void DepthWiseConv2D::set_group(int64_t group) { this->AddAttr(kGroup, MakeValue(group)); } | |||
| void DepthWiseConv2D::set_out_channel(int64_t out_channel) { this->AddAttr(kOutChannel, MakeValue(out_channel)); } | |||
| void DepthWiseConv2D::set_pads(const std::vector<int64_t> &pad_list) { this->AddAttr(kPads, MakeValue(pad_list)); } | |||
| void DepthWiseConv2D::set_format(const Format &format) { | |||
| int64_t f = format; | |||
| this->AddAttr(kFormat, MakeValue(f)); | |||
| } | |||
| Format DepthWiseConv2D::get_format() const { | |||
| auto value_ptr = GetAttr(kFormat); | |||
| return Format(GetValue<int64_t>(value_ptr)); | |||
| } | |||
| abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) { | |||
| MS_EXCEPTION_IF_NULL(primitive); | |||
| auto conv_prim = primitive->cast<PrimDepthWiseConv2DPtr>(); | |||
| @@ -129,7 +138,7 @@ abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<A | |||
| CheckAndConvertUtils::CheckInteger("weight_rank", w_shape.size(), kEqual, 4, prim_name); | |||
| CheckAndConvertUtils::CheckInteger("x_rank", x_shape.size(), kEqual, 4, prim_name); | |||
| CheckAndConvertUtils::Check("x_shape[1]", x_shape[1], kEqual, "w_shape[1]", w_shape[1], conv_prim->name()); | |||
| auto out_channel = conv_prim->get_output_channel(); | |||
| auto out_channel = conv_prim->get_out_channel(); | |||
| std::vector<int64_t> temp_w; | |||
| std::copy(w_shape.begin() + 2, w_shape.end(), std::back_inserter(temp_w)); | |||
| @@ -148,8 +157,8 @@ abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<A | |||
| auto stride_w = stride[3]; | |||
| auto dilation_h = dilation[2]; | |||
| auto dilation_w = dilation[3]; | |||
| int h_out = -1; | |||
| int w_out = -1; | |||
| int64_t h_out = -1; | |||
| int64_t w_out = -1; | |||
| std::vector<int64_t> pad_list(4, 0); | |||
| auto pad_mode = conv_prim->get_pad_mode(); | |||
| if (pad_mode == "valid") { | |||
| @@ -1,5 +1,5 @@ | |||
| /** | |||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| @@ -31,28 +31,30 @@ class DepthWiseConv2D : public PrimitiveC { | |||
| DepthWiseConv2D() : PrimitiveC(kNameDepthWiseConv2D) { InitIOName({"x", "w"}, {"output"}); } | |||
| ~DepthWiseConv2D() = default; | |||
| MS_DECLARE_PARENT(DepthWiseConv2D, PrimitiveC); | |||
| void Init(int out_channel, const std::vector<int64_t> &kernel_size, int mode = 1, | |||
| void Init(int64_t out_channel, const std::vector<int64_t> &kernel_size, int64_t mode = 1, | |||
| const std::string &pad_mode = "valid", const std::vector<int64_t> &pad = {0, 0, 0, 0}, | |||
| const std::vector<int64_t> &stride = {1, 1, 1, 1}, const std::vector<int64_t> &dilation = {1, 1, 1, 1}, | |||
| int group = 1); | |||
| int64_t group = 1); | |||
| std::vector<int64_t> get_kernel_size() const; | |||
| std::vector<int64_t> get_stride() const; | |||
| std::vector<int64_t> get_dilation() const; | |||
| std::string get_pad_mode() const; | |||
| std::vector<int64_t> get_pad() const; | |||
| std::vector<int64_t> get_pads() const; | |||
| int get_mode() const; | |||
| int get_group() const; | |||
| int get_output_channel() const; | |||
| int64_t get_mode() const; | |||
| int64_t get_group() const; | |||
| int64_t get_out_channel() const; | |||
| void set_kernel_size(const std::vector<int64_t> &kernel_size); | |||
| void set_stride(const std::vector<int64_t> &stride); | |||
| void set_dilation(const std::vector<int64_t> &dilation); | |||
| void set_pad_mode(const std::string &pad_mode); | |||
| void set_pad(const std::vector<int64_t> &pad); | |||
| void set_mode(int mode); | |||
| void set_group(int group); | |||
| void set_out_channel(int output_channel); | |||
| void set_mode(int64_t mode); | |||
| void set_group(int64_t group); | |||
| void set_out_channel(int64_t out_channel); | |||
| void set_pads(const std::vector<int64_t> &pad_list); | |||
| void set_format(const Format &format); | |||
| Format get_format() const; | |||
| }; | |||
| AbstractBasePtr DepthWiseConv2DInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/div.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameDiv, Div); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_DIV_H_ | |||
| #define MINDSPORE_CORE_C_OPS_DIV_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameDiv = "Div"; | |||
| class Div : public PrimitiveC { | |||
| public: | |||
| Div() : PrimitiveC(kNameDiv) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~Div() = default; | |||
| MS_DECLARE_PARENT(Div, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_DIV_H_ | |||
| @@ -0,0 +1,32 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/dropout.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| void Dropout::Init(float keep_prob) { this->set_keep_prob(keep_prob); } | |||
| void Dropout::set_keep_prob(float keep_prob) { | |||
| CheckAndConvertUtils::CheckInRange(kKeepProb, keep_prob, kIncludeRight, {0.0, 1.0}, this->name()); | |||
| this->AddAttr(kKeepProb, MakeValue(keep_prob)); | |||
| } | |||
| float Dropout::get_keep_prob() { | |||
| auto value_ptr = this->GetAttr(kKeepProb); | |||
| return GetValue<float>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameDropout, Dropout); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,35 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_DROPOUT_H_ | |||
| #define MINDSPORE_CORE_C_OPS_DROPOUT_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameDropout = "Dropout"; | |||
| class Dropout : public PrimitiveC { | |||
| public: | |||
| Dropout() : PrimitiveC(kNameDropout) {} | |||
| ~Dropout() = default; | |||
| MS_DECLARE_PARENT(Dropout, PrimitiveC); | |||
| void Init(float keep_prob = 0.5); | |||
| void set_keep_prob(float keep_prob); | |||
| float get_keep_prob(); | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_DROPOUT_H_ | |||
| @@ -0,0 +1,33 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/embedding_lookup.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void EmbeddingLookup::set_setattr_flag(const bool &setattr_flag) { | |||
| this->AddAttr(kSetattrFlag, MakeValue(setattr_flag)); | |||
| } | |||
| bool EmbeddingLookup::get_setattr_flag() const { | |||
| auto value_ptr = GetAttr(kSetattrFlag); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameEmbeddingLookup, EmbeddingLookup); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_EMBEDDINGLOOKUP_H_ | |||
| #define MINDSPORE_CORE_C_OPS_EMBEDDINGLOOKUP_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameEmbeddingLookup = "EmbeddingLookup"; | |||
| class EmbeddingLookup : public PrimitiveC { | |||
| public: | |||
| EmbeddingLookup() : PrimitiveC(kNameEmbeddingLookup) { InitIOName({"params", "indices"}, {"offset"}); } | |||
| ~EmbeddingLookup() = default; | |||
| MS_DECLARE_PARENT(EmbeddingLookup, PrimitiveC); | |||
| void set_setattr_flag(const bool &setattr_flag = true); | |||
| bool get_setattr_flag() const; | |||
| // void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_EMBEDDINGLOOKUP_H_ | |||
| @@ -0,0 +1,20 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/equal.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameEqual, Equal); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_EQUAL_H_ | |||
| #define MINDSPORE_CORE_C_OPS_EQUAL_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameEqual = "Equal"; | |||
| class Equal : public PrimitiveC { | |||
| public: | |||
| Equal() : PrimitiveC(kNameEqual) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~Equal() = default; | |||
| MS_DECLARE_PARENT(Equal, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_EQUAL_H_ | |||
| @@ -0,0 +1,20 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/exp.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameExp, Exp); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_EXP_H_ | |||
| #define MINDSPORE_CORE_C_OPS_EXP_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameExp = "Exp"; | |||
| class Exp : public PrimitiveC { | |||
| public: | |||
| Exp() : PrimitiveC(kNameExp) { InitIOName({"x"}, {"y"}); } | |||
| ~Exp() = default; | |||
| MS_DECLARE_PARENT(Exp, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_EXP_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/expand_dims.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameExpandDims, ExpandDims); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_EXPANDDIMS_H_ | |||
| #define MINDSPORE_CORE_C_OPS_EXPANDDIMS_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameExpandDims = "ExpandDims"; | |||
| class ExpandDims : public PrimitiveC { | |||
| public: | |||
| ExpandDims() : PrimitiveC(kNameExpandDims) { InitIOName({"x", "axis"}, {"output"}); } | |||
| ~ExpandDims() = default; | |||
| MS_DECLARE_PARENT(ExpandDims, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_EXPANDDIMS_H_ | |||
| @@ -0,0 +1,44 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/fake_quant_with_min_max_vars.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "utils/check_convert_utils.h" | |||
| #include "abstract/primitive_infer_map.h" | |||
| namespace mindspore { | |||
| void FakeQuantWithMinMaxVars::Init(const bool &narrow_range, int64_t num_bits) { | |||
| this->set_narrow_range(narrow_range); | |||
| this->set_num_bits(num_bits); | |||
| } | |||
| void FakeQuantWithMinMaxVars::set_narrow_range(const bool &narrow_range) { | |||
| this->AddAttr(kNarrowRange, MakeValue(narrow_range)); | |||
| } | |||
| bool FakeQuantWithMinMaxVars::get_narrow_range() const { | |||
| auto value_ptr = this->GetAttr(kNarrowRange); | |||
| return GetValue<bool>(value_ptr); | |||
| } | |||
| void FakeQuantWithMinMaxVars::set_num_bits(int64_t num_bits) { this->AddAttr(kNumBits, MakeValue(num_bits)); } | |||
| int64_t FakeQuantWithMinMaxVars::get_num_bits() const { | |||
| auto value_ptr = this->GetAttr(kNumBits); | |||
| return GetValue<int64_t>(value_ptr); | |||
| } | |||
| REGISTER_PRIMITIVE_C(kNameFakeQuantWithMinMaxVars, FakeQuantWithMinMaxVars); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,41 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FAKEQUANTWITHMINMAXVARS_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FAKEQUANTWITHMINMAXVARS_H_ | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFakeQuantWithMinMaxVars = "FakeQuantWithMinMaxVars"; | |||
| class FakeQuantWithMinMaxVars : public PrimitiveC { | |||
| public: | |||
| FakeQuantWithMinMaxVars() : PrimitiveC(kNameFakeQuantWithMinMaxVars) {} | |||
| ~FakeQuantWithMinMaxVars() = default; | |||
| MS_DECLARE_PARENT(FakeQuantWithMinMaxVars, PrimitiveC); | |||
| void Init(const bool &narrow_range, int64_t num_bits); | |||
| void set_narrow_range(const bool &narrow_range); | |||
| void set_num_bits(int64_t num_bits); | |||
| bool get_narrow_range() const; | |||
| int64_t get_num_bits() const; | |||
| }; | |||
| using PrimFakeQuantWithMinMaxVarsPtr = std::shared_ptr<FakeQuantWithMinMaxVars>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FAKEQUANTWITHMINMAXVARS_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/fft_imag.h" | |||
| #include <memory> | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFftImag, FftImag); | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FFTIMAG_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FFTIMAG_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFftImag = "FftImag"; | |||
| class FftImag : public PrimitiveC { | |||
| public: | |||
| FftImag() : PrimitiveC(kNameFftImag) {} | |||
| ~FftImag() = default; | |||
| MS_DECLARE_PARENT(FftImag, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FFTIMAG_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/fill.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFill, Fill); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FILL_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FILL_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFill = "Fill"; | |||
| class Fill : public PrimitiveC { | |||
| public: | |||
| Fill() : PrimitiveC(kNameFill) {} | |||
| ~Fill() = default; | |||
| MS_DECLARE_PARENT(Fill, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FILL_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/flatten.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFlatten, Flatten); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FLATTEN_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FLATTEN_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFlatten = "Flatten"; | |||
| class Flatten : public PrimitiveC { | |||
| public: | |||
| Flatten() : PrimitiveC(kNameFlatten) {} | |||
| ~Flatten() = default; | |||
| MS_DECLARE_PARENT(Flatten, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FLATTEN_H_ | |||
| @@ -0,0 +1,21 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/flatten_grad.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFlattenGrad, FlattenGrad); | |||
| } | |||
| @@ -0,0 +1,40 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FLATTEN_GRAD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FLATTEN_GRAD_H_ | |||
| #include <vector> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "c_ops/op_utils.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFlattenGrad = "FlattenGrad"; | |||
| class FlattenGrad : public PrimitiveC { | |||
| public: | |||
| FlattenGrad() : PrimitiveC(kNameFlattenGrad) { InitIOName({"x", "shape"}, {"output"}); } | |||
| ~FlattenGrad() = default; | |||
| MS_DECLARE_PARENT(FlattenGrad, PrimitiveC); | |||
| }; | |||
| AbstractBasePtr FlattenGradInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, | |||
| const std::vector<AbstractBasePtr> &input_args); | |||
| using PrimFlattenGrad = std::shared_ptr<FlattenGrad>; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FlattenGrad_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/floor.h" | |||
| #include <memory> | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFloor, Floor); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,38 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FLOOR_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FLOOR_H_ | |||
| #include <map> | |||
| #include <vector> | |||
| #include <string> | |||
| #include <memory> | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFloor = "Floor"; | |||
| class Floor : public PrimitiveC { | |||
| public: | |||
| Floor() : PrimitiveC(kNameFloor) { InitIOName({"x"}, {"y"}); } | |||
| ~Floor() = default; | |||
| MS_DECLARE_PARENT(Floor, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FLOOR_H_ | |||
| @@ -0,0 +1,20 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/floor_div.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFloorDiv, FloorDiv); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FLOORDIV_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FLOORDIV_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFloorDiv = "FloorDiv"; | |||
| class FloorDiv : public PrimitiveC { | |||
| public: | |||
| FloorDiv() : PrimitiveC(kNameFloorDiv) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~FloorDiv() = default; | |||
| MS_DECLARE_PARENT(FloorDiv, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FLOORDIV_H_ | |||
| @@ -0,0 +1,20 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/floor_mod.h" | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameFloorMod, FloorMod); | |||
| } // namespace mindspore | |||
| @@ -0,0 +1,34 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CORE_C_OPS_FLOORMOD_H_ | |||
| #define MINDSPORE_CORE_C_OPS_FLOORMOD_H_ | |||
| #include "c_ops/primitive_c.h" | |||
| #include "abstract/abstract_value.h" | |||
| #include "utils/check_convert_utils.h" | |||
| namespace mindspore { | |||
| constexpr auto kNameFloorMod = "FloorMod"; | |||
| class FloorMod : public PrimitiveC { | |||
| public: | |||
| FloorMod() : PrimitiveC(kNameFloorMod) { InitIOName({"x", "y"}, {"output"}); } | |||
| ~FloorMod() = default; | |||
| MS_DECLARE_PARENT(FloorMod, PrimitiveC); | |||
| void Init() {} | |||
| }; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_C_OPS_FLOORMOD_H_ | |||
| @@ -0,0 +1,22 @@ | |||
| /** | |||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| * Unless required by applicable law or agreed to in writing, software | |||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #include "c_ops/gather.h" | |||
| #include <memory> | |||
| namespace mindspore { | |||
| REGISTER_PRIMITIVE_C(kNameGather, Gather); | |||
| } // namespace mindspore | |||