• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ops/roi_pooling.h"
17 #include "mindapi/base/shared_ptr.h"
18 #include "mindapi/ir/value.h"
19 #include "mindapi/src/helper.h"
20 #include "ops/op_name.h"
21 #include "ops/primitive_c.h"
22 #include "utils/log_adapter.h"
23 
24 namespace mindspore {
25 namespace ops {
26 MIND_API_OPERATOR_IMPL(ROIPooling, BaseOperator);
set_pooled_h(const int64_t pooled_h)27 void ROIPooling::set_pooled_h(const int64_t pooled_h) { (void)this->AddAttr(kPooledH, api::MakeValue(pooled_h)); }
28 
get_pooled_h() const29 int64_t ROIPooling::get_pooled_h() const { return GetValue<int64_t>(GetAttr(kPooledH)); }
30 
set_pooled_w(const int64_t pooled_w)31 void ROIPooling::set_pooled_w(const int64_t pooled_w) { (void)this->AddAttr(kPooledW, api::MakeValue(pooled_w)); }
32 
get_pooled_w() const33 int64_t ROIPooling::get_pooled_w() const {
34   auto value_ptr = GetAttr(kPooledW);
35   return GetValue<int64_t>(value_ptr);
36 }
37 
set_scale(const float scale)38 void ROIPooling::set_scale(const float scale) { (void)this->AddAttr(kScale, api::MakeValue(scale)); }
39 
get_scale() const40 float ROIPooling::get_scale() const {
41   auto value_ptr = GetAttr(kScale);
42   return GetValue<float>(value_ptr);
43 }
44 
Init(const int64_t pooled_h,const int64_t pooled_w,const float scale)45 void ROIPooling::Init(const int64_t pooled_h, const int64_t pooled_w, const float scale) {
46   this->set_pooled_h(pooled_h);
47   this->set_pooled_w(pooled_w);
48   this->set_scale(scale);
49 }
50 
51 REGISTER_PRIMITIVE_C(kNameROIPooling, ROIPooling);
52 }  // namespace ops
53 }  // namespace mindspore
54