1 /**
2 * Copyright 2020 Huawei Technologies Co., Ltd
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <vector>
18
19 #include "ops/proposal.h"
20 #include "ops/op_utils.h"
21 #include "utils/check_convert_utils.h"
22 #include "abstract/primitive_infer_map.h"
23
24 namespace mindspore {
25 namespace ops {
set_feat_stride(const float feat_stride)26 void Proposal::set_feat_stride(const float feat_stride) { (void)this->AddAttr(kFeatStride, MakeValue(feat_stride)); }
27
get_feat_stride() const28 float Proposal::get_feat_stride() const {
29 auto value_ptr = GetAttr(kFeatStride);
30 return GetValue<float>(value_ptr);
31 }
32
set_base_size(const float base_size)33 void Proposal::set_base_size(const float base_size) { (void)this->AddAttr(kBaseSize, MakeValue(base_size)); }
34
get_base_size() const35 float Proposal::get_base_size() const {
36 auto value_ptr = GetAttr(kBaseSize);
37 return GetValue<float>(value_ptr);
38 }
39
set_min_size(const float min_size)40 void Proposal::set_min_size(const float min_size) { (void)this->AddAttr(kMinSize, MakeValue(min_size)); }
41
get_min_size() const42 float Proposal::get_min_size() const {
43 auto value_ptr = GetAttr(kMinSize);
44 return GetValue<float>(value_ptr);
45 }
46
set_ratio(const std::vector<float> & ratio)47 void Proposal::set_ratio(const std::vector<float> &ratio) { (void)this->AddAttr(kRatio, MakeValue(ratio)); }
48
get_ratio() const49 std::vector<float> Proposal::get_ratio() const {
50 auto value_ptr = GetAttr(kRatio);
51 return GetValue<std::vector<float>>(value_ptr);
52 }
53
set_scale(const std::vector<float> & scale)54 void Proposal::set_scale(const std::vector<float> &scale) { (void)this->AddAttr(kScale, MakeValue(scale)); }
55
get_scale() const56 std::vector<float> Proposal::get_scale() const {
57 auto value_ptr = GetAttr(kScale);
58 return GetValue<std::vector<float>>(value_ptr);
59 }
60
set_pre_nms_topn(const int64_t pre_nms_topn)61 void Proposal::set_pre_nms_topn(const int64_t pre_nms_topn) {
62 (void)this->AddAttr(kPreNmsTopn, MakeValue(pre_nms_topn));
63 }
64
get_pre_nms_topn() const65 int64_t Proposal::get_pre_nms_topn() const {
66 auto value_ptr = GetAttr(kPreNmsTopn);
67 return GetValue<int64_t>(value_ptr);
68 }
69
set_post_nms_topn(const int64_t post_nms_topn)70 void Proposal::set_post_nms_topn(const int64_t post_nms_topn) {
71 (void)this->AddAttr(kPostNmsTopn, MakeValue(post_nms_topn));
72 }
73
get_post_nms_topn() const74 int64_t Proposal::get_post_nms_topn() const {
75 auto value_ptr = GetAttr(kPostNmsTopn);
76 return GetValue<int64_t>(value_ptr);
77 }
78
set_nms_thresh(const float nms_thresh)79 void Proposal::set_nms_thresh(const float nms_thresh) { (void)this->AddAttr(kNmsThresh, MakeValue(nms_thresh)); }
80
get_nms_thresh() const81 float Proposal::get_nms_thresh() const {
82 auto value_ptr = GetAttr(kNmsThresh);
83 return GetValue<float>(value_ptr);
84 }
85
Init(const float feat_stride,const float base_size,const float min_size,const std::vector<float> & ratio,const std::vector<float> & scale,const int64_t pre_nms_topn,const int64_t post_nms_topn,const float nms_thresh)86 void Proposal::Init(const float feat_stride, const float base_size, const float min_size,
87 const std::vector<float> &ratio, const std::vector<float> &scale, const int64_t pre_nms_topn,
88 const int64_t post_nms_topn, const float nms_thresh) {
89 this->set_feat_stride(feat_stride);
90 this->set_base_size(base_size);
91 this->set_min_size(min_size);
92 this->set_ratio(ratio);
93 this->set_scale(scale);
94 this->set_pre_nms_topn(pre_nms_topn);
95 this->set_post_nms_topn(post_nms_topn);
96 this->set_nms_thresh(nms_thresh);
97 }
98 REGISTER_PRIMITIVE_C(kNameProposal, Proposal);
99 } // namespace ops
100 } // namespace mindspore
101