Skip to content

Commit

Permalink
修改has_parameter用法
Browse files Browse the repository at this point in the history
  • Loading branch information
zjhellofss committed Apr 10, 2024
1 parent ce3b881 commit 0db79c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions source/layer/details/base_convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("dilation")) {
if (!op->has_parameter("dilation")) {
LOG(ERROR) << "Can not find the dilation parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -249,7 +249,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
const uint32_t dilation_h = dilation_param->value.at(0);
const uint32_t dilation_w = dilation_param->value.at(1);

if (op->has_parameter("in_channels")) {
if (!op->has_parameter("in_channels")) {
LOG(ERROR) << "Can not find the in channel parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -259,7 +259,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("out_channels")) {
if (!op->has_parameter("out_channels")) {
LOG(ERROR) << "Can not find the out channel parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -270,7 +270,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("padding")) {
if (!op->has_parameter("padding")) {
LOG(ERROR) << "Can not find the padding parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -281,7 +281,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("bias")) {
if (!op->has_parameter("bias")) {
LOG(ERROR) << "Can not find the bias parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -291,7 +291,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("stride")) {
if (!op->has_parameter("stride")) {
LOG(ERROR) << "Can not find the stride parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -301,7 +301,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
return StatusCode::kParseParameterError;
}

if (op->has_parameter("kernel_size")) {
if (!op->has_parameter("kernel_size")) {
LOG(ERROR) << "Can not find the kernel parameter";
return StatusCode::kParseParameterError;
}
Expand All @@ -312,7 +312,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
}

if (op->type == "nn.Conv2d") {
if (op->has_parameter("padding_mode")) {
if (!op->has_parameter("padding_mode")) {
auto padding_mode =
std::dynamic_pointer_cast<RuntimeParameterString>(params.at("padding_mode"));
if (padding_mode == nullptr) {
Expand All @@ -331,7 +331,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
}
}

if (op->has_parameter("groups")) {
if (!op->has_parameter("groups")) {
LOG(ERROR) << "Can not find the groups parameter";
return StatusCode::kParseParameterError;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
uint32_t output_padding_h = 0;
uint32_t output_padding_w = 0;
if (op->type == "nn.ConvTranspose2d") {
if (op->has_parameter("output_padding")) {
if (!op->has_parameter("output_padding")) {
auto output_padding_arr =
std::dynamic_pointer_cast<RuntimeParameterIntArray>(params.at("output_padding"));
if (!output_padding_arr) {
Expand Down Expand Up @@ -406,7 +406,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
// load weights
const std::map<std::string, std::shared_ptr<RuntimeAttribute>>& attrs = op->attribute;
if (use_bias->value) {
if (op->has_attribute("bias")) {
if (!op->has_attribute("bias")) {
LOG(ERROR) << "Can not find the bias attribute";
return StatusCode::kParseWeightError;
}
Expand All @@ -421,7 +421,7 @@ StatusCode BaseConvolutionLayer::CreateInstance(const std::shared_ptr<RuntimeOpe
conv_layer->set_bias(bias_values);
}

if (op->has_attribute("weight")) {
if (!op->has_attribute("weight")) {
LOG(ERROR) << "Can not find the weight attribute";
return StatusCode::kParseWeightError;
}
Expand Down
6 changes: 3 additions & 3 deletions source/layer/details/linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ StatusCode LinearLayer::CreateInstance(const std::shared_ptr<RuntimeOperator>& o
return StatusCode::kParseParameterError;
}

if (op->has_parameter("bias")) {
if (!op->has_parameter("bias")) {
LOG(ERROR) << "Can not find the use bias parameter in the parameter list.";
return StatusCode::kParseParameterError;
}
Expand All @@ -160,13 +160,13 @@ StatusCode LinearLayer::CreateInstance(const std::shared_ptr<RuntimeOperator>& o
return StatusCode::kParseWeightError;
}

if (op->has_attribute("weight")) {
if (!op->has_attribute("weight")) {
LOG(ERROR) << "Can not find the weight parameter in the parameter list.";
return StatusCode::kParseWeightError;
}

if (use_bias_param->value) {
if (op->has_attribute("bias")) {
if (!op->has_attribute("bias")) {
LOG(ERROR) << "Can not find the bias parameter in the parameter list.";
return StatusCode::kParseWeightError;
}
Expand Down

0 comments on commit 0db79c3

Please sign in to comment.