1 /**
2 * Copyright 2021 Huawei Technologies Co., Ltd
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "ops/split_with_overlap.h"
18 #include "ops/op_utils.h"
19 namespace mindspore {
20 namespace ops {
Init(int64_t number_split,const std::vector<int64_t> & ratio,const std::vector<int64_t> & extend_top,const std::vector<int64_t> & extend_bottom,int64_t split_dim,int64_t stride,int64_t pad_top,bool trans_format)21 void SplitWithOverlap::Init(int64_t number_split, const std::vector<int64_t> &ratio,
22 const std::vector<int64_t> &extend_top, const std::vector<int64_t> &extend_bottom,
23 int64_t split_dim, int64_t stride, int64_t pad_top, bool trans_format) {
24 this->set_number_split(number_split);
25 this->set_ratio(ratio);
26 this->set_extend_top(extend_top);
27 this->set_extend_bottom(extend_bottom);
28 this->set_split_dim(split_dim);
29 this->set_split_stride(stride);
30 this->set_pad_top(pad_top);
31 this->set_trans_format(trans_format);
32 }
33
set_ratio(const std::vector<int64_t> & ratio)34 void SplitWithOverlap::set_ratio(const std::vector<int64_t> &ratio) { (void)this->AddAttr(kRatio, MakeValue(ratio)); }
35
set_extend_top(const std::vector<int64_t> & extend_top)36 void SplitWithOverlap::set_extend_top(const std::vector<int64_t> &extend_top) {
37 (void)this->AddAttr(kExtendTop, MakeValue(extend_top));
38 }
39
set_extend_bottom(const std::vector<int64_t> & extend_bottom)40 void SplitWithOverlap::set_extend_bottom(const std::vector<int64_t> &extend_bottom) {
41 (void)this->AddAttr(kExtendBottom, MakeValue(extend_bottom));
42 }
43
set_number_split(int64_t number_split)44 void SplitWithOverlap::set_number_split(int64_t number_split) {
45 (void)this->AddAttr(kNumberSplit, MakeValue(number_split));
46 }
47
set_split_dim(int64_t split_dim)48 void SplitWithOverlap::set_split_dim(int64_t split_dim) { (void)this->AddAttr(kSplitDim, MakeValue(split_dim)); }
49
set_split_stride(int64_t stride)50 void SplitWithOverlap::set_split_stride(int64_t stride) { (void)this->AddAttr(kSplitStride, MakeValue(stride)); }
51
set_pad_top(int64_t pad_top)52 void SplitWithOverlap::set_pad_top(int64_t pad_top) { (void)this->AddAttr(kPadTop, MakeValue(pad_top)); }
53
set_trans_format(bool trans_format)54 void SplitWithOverlap::set_trans_format(bool trans_format) {
55 (void)this->AddAttr(kTransFormat, MakeValue(trans_format));
56 }
57
get_ratio() const58 std::vector<int64_t> SplitWithOverlap::get_ratio() const {
59 auto value_ptr = GetAttr(kRatio);
60 return GetValue<std::vector<int64_t>>(value_ptr);
61 }
62
get_extend_top() const63 std::vector<int64_t> SplitWithOverlap::get_extend_top() const {
64 auto value_ptr = GetAttr(kExtendTop);
65 return GetValue<std::vector<int64_t>>(value_ptr);
66 }
67
get_extend_bottom() const68 std::vector<int64_t> SplitWithOverlap::get_extend_bottom() const {
69 auto value_ptr = GetAttr(kExtendBottom);
70 return GetValue<std::vector<int64_t>>(value_ptr);
71 }
72
get_number_split() const73 int64_t SplitWithOverlap::get_number_split() const {
74 auto value_ptr = GetAttr(kNumberSplit);
75 return GetValue<int64_t>(value_ptr);
76 }
77
get_split_dim() const78 int64_t SplitWithOverlap::get_split_dim() const {
79 auto value_ptr = GetAttr(kSplitDim);
80 return GetValue<int64_t>(value_ptr);
81 }
82
get_split_stride() const83 int64_t SplitWithOverlap::get_split_stride() const {
84 auto value_ptr = GetAttr(kSplitStride);
85 return GetValue<int64_t>(value_ptr);
86 }
87
get_pad_top() const88 int64_t SplitWithOverlap::get_pad_top() const {
89 auto value_ptr = GetAttr(kPadTop);
90 return GetValue<int64_t>(value_ptr);
91 }
92
get_trans_format() const93 bool SplitWithOverlap::get_trans_format() const {
94 auto value_ptr = GetAttr(kTransFormat);
95 return GetValue<bool>(value_ptr);
96 }
97
98 REGISTER_PRIMITIVE_C(kNameSplitWithOverlap, SplitWithOverlap);
99 } // namespace ops
100 } // namespace mindspore
101