• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-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/grad/group_conv2d_grad_input.h"
18 #include "mindapi/base/shared_ptr.h"
19 #include "mindapi/ir/value.h"
20 #include "mindapi/src/helper.h"
21 #include "ops/op_name.h"
22 #include "ops/primitive_c.h"
23 #include "utils/log_adapter.h"
24 
25 namespace mindspore {
26 namespace ops {
27 MIND_API_OPERATOR_IMPL(GroupConv2DGradInput, BaseOperator);
Init(const int64_t & in_channel,const int64_t & out_channel,const std::vector<int64_t> & kernel_size,const PadMode & pad_mode,const std::vector<int64_t> & pad_list,const std::vector<int64_t> & stride,const std::vector<int64_t> & dilation,const int64_t & group,const std::vector<int64_t> & input_shape,const Format & format,const ActivationType & activation_type,const bool has_bias)28 void GroupConv2DGradInput::Init(const int64_t &in_channel, const int64_t &out_channel,
29                                 const std::vector<int64_t> &kernel_size, const PadMode &pad_mode,
30                                 const std::vector<int64_t> &pad_list, const std::vector<int64_t> &stride,
31                                 const std::vector<int64_t> &dilation, const int64_t &group,
32                                 const std::vector<int64_t> &input_shape, const Format &format,
33                                 const ActivationType &activation_type, const bool has_bias) {
34   set_in_channel(in_channel);
35   set_out_channel(out_channel);
36   set_kernel_size(kernel_size);
37   set_pad_mode(pad_mode);
38   set_pad_list(pad_list);
39   set_stride(stride);
40   set_dilation(dilation);
41   set_group(group);
42   set_input_shape(input_shape);
43   set_format(format);
44   set_activation_type(activation_type);
45   set_has_bias(has_bias);
46 }
47 
set_in_channel(const int64_t & in_channel)48 void GroupConv2DGradInput::set_in_channel(const int64_t &in_channel) {
49   (void)this->AddAttr(kInChannel, api::MakeValue(in_channel));
50 }
51 
get_in_channel() const52 int64_t GroupConv2DGradInput::get_in_channel() const {
53   auto value_ptr = GetAttr(kInChannel);
54   MS_EXCEPTION_IF_NULL(value_ptr);
55   return GetValue<int64_t>(value_ptr);
56 }
57 
set_out_channel(const int64_t & out_channel)58 void GroupConv2DGradInput::set_out_channel(const int64_t &out_channel) {
59   (void)this->AddAttr(kOutChannel, api::MakeValue(out_channel));
60 }
61 
get_out_channel() const62 int64_t GroupConv2DGradInput::get_out_channel() const {
63   auto value_ptr = GetAttr(kOutChannel);
64   MS_EXCEPTION_IF_NULL(value_ptr);
65   return GetValue<int64_t>(value_ptr);
66 }
67 
set_kernel_size(const std::vector<int64_t> & kernel_size)68 void GroupConv2DGradInput::set_kernel_size(const std::vector<int64_t> &kernel_size) {
69   (void)this->AddAttr(kKernelSize, api::MakeValue(kernel_size));
70 }
71 
get_kernel_size() const72 std::vector<int64_t> GroupConv2DGradInput::get_kernel_size() const {
73   auto value_ptr = GetAttr(kKernelSize);
74   MS_EXCEPTION_IF_NULL(value_ptr);
75   return GetValue<std::vector<int64_t>>(value_ptr);
76 }
77 
set_pad_mode(const PadMode & pad_mode)78 void GroupConv2DGradInput::set_pad_mode(const PadMode &pad_mode) {
79   int64_t swi = pad_mode;
80   (void)this->AddAttr(kPadMode, api::MakeValue(swi));
81 }
82 
get_pad_mode() const83 PadMode GroupConv2DGradInput::get_pad_mode() const {
84   auto value_ptr = GetAttr(kPadMode);
85   MS_EXCEPTION_IF_NULL(value_ptr);
86   return PadMode(GetValue<int64_t>(value_ptr));
87 }
88 
set_pad_list(const std::vector<int64_t> & pad_list)89 void GroupConv2DGradInput::set_pad_list(const std::vector<int64_t> &pad_list) {
90   (void)this->AddAttr(kPadList, api::MakeValue(pad_list));
91 }
92 
get_pad_list() const93 std::vector<int64_t> GroupConv2DGradInput::get_pad_list() const {
94   auto value_ptr = GetAttr(kPadList);
95   MS_EXCEPTION_IF_NULL(value_ptr);
96   return GetValue<std::vector<int64_t>>(value_ptr);
97 }
98 
set_stride(const std::vector<int64_t> & stride)99 void GroupConv2DGradInput::set_stride(const std::vector<int64_t> &stride) {
100   (void)this->AddAttr(kStride, api::MakeValue(stride));
101 }
102 
get_stride() const103 std::vector<int64_t> GroupConv2DGradInput::get_stride() const {
104   auto value_ptr = GetAttr(kStride);
105   MS_EXCEPTION_IF_NULL(value_ptr);
106   return GetValue<std::vector<int64_t>>(value_ptr);
107 }
108 
set_dilation(const std::vector<int64_t> & dilation)109 void GroupConv2DGradInput::set_dilation(const std::vector<int64_t> &dilation) {
110   (void)this->AddAttr(kDilation, api::MakeValue(dilation));
111 }
112 
get_dilation() const113 std::vector<int64_t> GroupConv2DGradInput::get_dilation() const {
114   auto value_ptr = GetAttr(kDilation);
115   MS_EXCEPTION_IF_NULL(value_ptr);
116   return GetValue<std::vector<int64_t>>(value_ptr);
117 }
118 
set_group(const int64_t & group)119 void GroupConv2DGradInput::set_group(const int64_t &group) { (void)this->AddAttr(kGroup, api::MakeValue(group)); }
120 
get_group() const121 int64_t GroupConv2DGradInput::get_group() const {
122   auto value_ptr = GetAttr(kGroup);
123   MS_EXCEPTION_IF_NULL(value_ptr);
124   return GetValue<int64_t>(value_ptr);
125 }
126 
set_input_shape(const std::vector<int64_t> & input_shape)127 void GroupConv2DGradInput::set_input_shape(const std::vector<int64_t> &input_shape) {
128   (void)this->AddAttr(kInputShape, api::MakeValue(input_shape));
129 }
130 
get_input_shape() const131 std::vector<int64_t> GroupConv2DGradInput::get_input_shape() const {
132   auto value_ptr = GetAttr(kInputShape);
133   MS_EXCEPTION_IF_NULL(value_ptr);
134   return GetValue<std::vector<int64_t>>(value_ptr);
135 }
136 
set_format(const Format & format)137 void GroupConv2DGradInput::set_format(const Format &format) {
138   int64_t swi = format;
139   (void)this->AddAttr(kFormat, api::MakeValue(swi));
140 }
141 
get_format() const142 Format GroupConv2DGradInput::get_format() const {
143   auto value_ptr = GetAttr(kFormat);
144   MS_EXCEPTION_IF_NULL(value_ptr);
145   return Format(GetValue<int64_t>(value_ptr));
146 }
147 
set_activation_type(const ActivationType & activation_type)148 void GroupConv2DGradInput::set_activation_type(const ActivationType &activation_type) {
149   int64_t swi = activation_type;
150   (void)this->AddAttr(kActivationType, api::MakeValue(swi));
151 }
152 
get_activation_type() const153 ActivationType GroupConv2DGradInput::get_activation_type() const {
154   auto value_ptr = GetAttr(kActivationType);
155   MS_EXCEPTION_IF_NULL(value_ptr);
156   return ActivationType(GetValue<int64_t>(value_ptr));
157 }
158 
set_has_bias(const bool has_bias)159 void GroupConv2DGradInput::set_has_bias(const bool has_bias) {
160   (void)this->AddAttr(kHasBias, api::MakeValue(has_bias));
161 }
162 
get_has_bias() const163 bool GroupConv2DGradInput::get_has_bias() const {
164   auto value_ptr = GetAttr(kHasBias);
165   MS_EXCEPTION_IF_NULL(value_ptr);
166   return GetValue<bool>(value_ptr);
167 }
168 REGISTER_PRIMITIVE_C(kNameGroupConv2DGradInput, GroupConv2DGradInput);
169 }  // namespace ops
170 }  // namespace mindspore
171