已合并
按照cleancode规范消除池化类算子的告警 #2877
小王!创建于 3月18日
按照cleancode规范消除池化类算子的告警 #2877
已合并
从已删除 :remove-compile-warnning-9.0.0合入到cann/ops-nn9.0.0
共 17 个文件变更+29-30
| @@ -70,7 +70,6 @@ uint64_t AdaptiveMaxPool3DTilingSimt::GetTilingKey() const | |||
| 70 | }else { | 70 | }else { |
| 71 | return GET_TPL_TILING_KEY(TPL_MODE_2, TPL_INT64_UINT64, TPL_MULTI_MODE_0, TPL_DATA_FORMAT_MODE_0); | 71 | return GET_TPL_TILING_KEY(TPL_MODE_2, TPL_INT64_UINT64, TPL_MULTI_MODE_0, TPL_DATA_FORMAT_MODE_0); |
| 72 | } | 72 | } |
| 73 | - | ||
| 74 | } | 73 | } |
| 75 | 74 | ||
| 76 | ge::graphStatus AdaptiveMaxPool3DTilingSimt::PostTiling() | 75 | ge::graphStatus AdaptiveMaxPool3DTilingSimt::PostTiling() |
| @@ -173,7 +173,7 @@ ge::graphStatus AdaptivePool3dBaseTiling::GetPlatformInfo() | |||
| 173 | { | 173 | { |
| 174 | auto platformPtr = context_->GetPlatformInfo(); | 174 | auto platformPtr = context_->GetPlatformInfo(); |
| 175 | if (platformPtr == nullptr) { | 175 | if (platformPtr == nullptr) { |
| 176 | - auto compileInfoPtr = reinterpret_cast<const AdaptivePool3dCompileInfo*>(context_->GetCompileInfo()); | 176 | + auto compileInfoPtr = static_cast<const AdaptivePool3dCompileInfo*>(context_->GetCompileInfo()); |
| 177 | OP_CHECK_IF( | 177 | OP_CHECK_IF( |
| 178 | compileInfoPtr == nullptr, OP_LOGE(context_->GetNodeName(), "compile info is null"), | 178 | compileInfoPtr == nullptr, OP_LOGE(context_->GetNodeName(), "compile info is null"), |
| 179 | return ge::GRAPH_FAILED); | 179 | return ge::GRAPH_FAILED); |
| @@ -28,9 +28,9 @@ | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | -using namespace std; | ||
| 32 | 31 | ||
| 33 | namespace optiling { | 32 | namespace optiling { |
| 33 | +using namespace std; | ||
| 34 | using Ops::NN::Optiling::TilingBaseClass; | 34 | using Ops::NN::Optiling::TilingBaseClass; |
| 35 | constexpr int64_t MAX_INT32 = 2147483647; | 35 | constexpr int64_t MAX_INT32 = 2147483647; |
| 36 | constexpr uint64_t MAX_UINT32 = 4294967295; | 36 | constexpr uint64_t MAX_UINT32 = 4294967295; |
| @@ -94,16 +94,17 @@ ge::graphStatus InferShape4AvgPoolV2Grad(gert::InferShapeContext* context) | |||
| 94 | 94 | ||
| 95 | auto padding_mode = attrs->GetAttrPointer<char>(ATTR_PADDING_MODE_POS); | 95 | auto padding_mode = attrs->GetAttrPointer<char>(ATTR_PADDING_MODE_POS); |
| 96 | OP_CHECK_NULL_WITH_CONTEXT(context, padding_mode); | 96 | OP_CHECK_NULL_WITH_CONTEXT(context, padding_mode); |
| 97 | - OP_CHECK_IF( | 97 | + OP_CHECK_IF(strcmp(padding_mode, "SAME") != 0 && strcmp(padding_mode, "VALID") != 0 && |
| 98 | - !strcmp(padding_mode, "SAME") && !strcmp(padding_mode, "VALID") && !strcmp(padding_mode, "CALCULATED"), | 98 | + strcmp(padding_mode, "CALCULATED") != 0, OP_LOGE(context->GetNodeName(), |
| 99 | - OP_LOGE(context->GetNodeName(),"attr padding_mode(%s) only support SAME、 VALID and CALCULATED", padding_mode), return GRAPH_FAILED); | 99 | + "attr padding_mode(%s) only support SAME, VALID and CALCULATED", padding_mode), |
| 100 | + return GRAPH_FAILED); | ||
| 100 | 101 | ||
| 101 | auto ksize = attrs->GetAttrPointer<gert::ContinuousVector>(ATTR_KERNEL_POS); | 102 | auto ksize = attrs->GetAttrPointer<gert::ContinuousVector>(ATTR_KERNEL_POS); |
| 102 | OP_CHECK_NULL_WITH_CONTEXT(context, ksize); | 103 | OP_CHECK_NULL_WITH_CONTEXT(context, ksize); |
| 103 | OP_CHECK_IF( | 104 | OP_CHECK_IF( |
| 104 | ksize->GetSize() != ATTR_LIST_SHAPE_SIZE, | 105 | ksize->GetSize() != ATTR_LIST_SHAPE_SIZE, |
| 105 | OP_LOGE(context->GetNodeName(), "Length of ksize %lu must be 4!", ksize->GetSize()), return GRAPH_FAILED); | 106 | OP_LOGE(context->GetNodeName(), "Length of ksize %lu must be 4!", ksize->GetSize()), return GRAPH_FAILED); |
| 106 | - auto ksize_data = reinterpret_cast<const int64_t*>(ksize->GetData()); | 107 | + auto ksize_data = static_cast<const int64_t*>(ksize->GetData()); |
| 107 | 108 | ||
| 108 | if (dataFormatStr == "NCHW") { | 109 | if (dataFormatStr == "NCHW") { |
| 109 | OP_CHECK_IF(ksize_data[IDX_ZERO] != ONE, | 110 | OP_CHECK_IF(ksize_data[IDX_ZERO] != ONE, |
| @@ -126,7 +127,7 @@ ge::graphStatus InferShape4AvgPoolV2Grad(gert::InferShapeContext* context) | |||
| 126 | OP_CHECK_IF( | 127 | OP_CHECK_IF( |
| 127 | strides->GetSize() != ATTR_LIST_SHAPE_SIZE, | 128 | strides->GetSize() != ATTR_LIST_SHAPE_SIZE, |
| 128 | OP_LOGE(context->GetNodeName(), "Length of strides %lu must be 4!", strides->GetSize()), return GRAPH_FAILED); | 129 | OP_LOGE(context->GetNodeName(), "Length of strides %lu must be 4!", strides->GetSize()), return GRAPH_FAILED); |
| 129 | - auto strides_data = reinterpret_cast<const int64_t*>(strides->GetData()); | 130 | + auto strides_data = static_cast<const int64_t*>(strides->GetData()); |
| 130 | 131 | ||
| 131 | if (dataFormatStr == "NCHW") { | 132 | if (dataFormatStr == "NCHW") { |
| 132 | OP_CHECK_IF(strides_data[IDX_ZERO] != ONE, | 133 | OP_CHECK_IF(strides_data[IDX_ZERO] != ONE, |
| @@ -20,9 +20,8 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | -using namespace std; | ||
| 24 | - | ||
| 25 | namespace optiling { | 23 | namespace optiling { |
| 24 | +using namespace std; | ||
| 26 | 25 | ||
| 27 | BEGIN_TILING_DATA_DEF(MaxPoolGradWithArgmaxV3TilingData) | 26 | BEGIN_TILING_DATA_DEF(MaxPoolGradWithArgmaxV3TilingData) |
| 28 | TILING_DATA_FIELD_DEF(uint64_t, nc); | 27 | TILING_DATA_FIELD_DEF(uint64_t, nc); |
| @@ -46,7 +46,7 @@ ge::graphStatus MaxPoolWithArgmaxV3BaseTiling::GetPlatformInfo() | |||
| 46 | { | 46 | { |
| 47 | auto platformPtr = context_->GetPlatformInfo(); | 47 | auto platformPtr = context_->GetPlatformInfo(); |
| 48 | if (platformPtr == nullptr) { | 48 | if (platformPtr == nullptr) { |
| 49 | - auto compileInfoPtr = reinterpret_cast<const MaxPoolWithArgmaxV3CompileInfo*>(context_->GetCompileInfo()); | 49 | + auto compileInfoPtr = static_cast<const MaxPoolWithArgmaxV3CompileInfo*>(context_->GetCompileInfo()); |
| 50 | OP_CHECK_IF( | 50 | OP_CHECK_IF( |
| 51 | compileInfoPtr == nullptr, CUBE_INNER_ERR_REPORT(context_, "compile info is null"), | 51 | compileInfoPtr == nullptr, CUBE_INNER_ERR_REPORT(context_, "compile info is null"), |
| 52 | return ge::GRAPH_FAILED); | 52 | return ge::GRAPH_FAILED); |
| @@ -446,7 +446,7 @@ ge::graphStatus GetAvgPool3DPlatformInfo(gert::TilingContext* context, uint64_t& | |||
| 446 | { | 446 | { |
| 447 | auto platformPtr = context->GetPlatformInfo(); | 447 | auto platformPtr = context->GetPlatformInfo(); |
| 448 | if (platformPtr == nullptr) { | 448 | if (platformPtr == nullptr) { |
| 449 | - auto compileInfoPtr = reinterpret_cast<const optiling::avgPool3DTilingCompileInfo::CubeCompileInfo *>(context->GetCompileInfo()); | 449 | + auto compileInfoPtr = static_cast<const optiling::avgPool3DTilingCompileInfo::CubeCompileInfo *>(context->GetCompileInfo()); |
| 450 | OP_TILING_CHECK(compileInfoPtr == nullptr, CUBE_INNER_ERR_REPORT(context, "compile info is null"), | 450 | OP_TILING_CHECK(compileInfoPtr == nullptr, CUBE_INNER_ERR_REPORT(context, "compile info is null"), |
| 451 | return ge::GRAPH_FAILED); | 451 | return ge::GRAPH_FAILED); |
| 452 | coreNum = compileInfoPtr->core_num; | 452 | coreNum = compileInfoPtr->core_num; |
| @@ -102,7 +102,7 @@ public: | |||
| 102 | const char *op_type = context->GetNodeType(); | 102 | const char *op_type = context->GetNodeType(); |
| 103 | fe::PlatFormInfos *platformInfoPtr = context->GetPlatformInfo(); | 103 | fe::PlatFormInfos *platformInfoPtr = context->GetPlatformInfo(); |
| 104 | if (platformInfoPtr == nullptr) { | 104 | if (platformInfoPtr == nullptr) { |
| 105 | - auto compileInfoPtr = reinterpret_cast<const Ops::NN::Optiling::CompileInfoCommon *>(context->GetCompileInfo()); | 105 | + auto compileInfoPtr = static_cast<const Ops::NN::Optiling::CompileInfoCommon *>(context->GetCompileInfo()); |
| 106 | OPS_ERR_IF(compileInfoPtr == nullptr, OPS_REPORT_VECTOR_INNER_ERR(op_type, "compileInfoPtr is null."), | 106 | OPS_ERR_IF(compileInfoPtr == nullptr, OPS_REPORT_VECTOR_INNER_ERR(op_type, "compileInfoPtr is null."), |
| 107 | return ge::GRAPH_FAILED); | 107 | return ge::GRAPH_FAILED); |
| 108 | soc_version = compileInfoPtr->socVersion; | 108 | soc_version = compileInfoPtr->socVersion; |
| @@ -138,7 +138,7 @@ public: | |||
| 138 | const char *op_type = context->GetNodeType(); | 138 | const char *op_type = context->GetNodeType(); |
| 139 | auto platformInfoPtr = context->GetPlatformInfo(); | 139 | auto platformInfoPtr = context->GetPlatformInfo(); |
| 140 | if (platformInfoPtr == nullptr) { | 140 | if (platformInfoPtr == nullptr) { |
| 141 | - auto compileInfoPtr = reinterpret_cast<const Ops::NN::Optiling::CompileInfoCommon *>(context->GetCompileInfo()); | 141 | + auto compileInfoPtr = static_cast<const Ops::NN::Optiling::CompileInfoCommon *>(context->GetCompileInfo()); |
| 142 | OPS_ERR_IF(compileInfoPtr == nullptr, OPS_REPORT_VECTOR_INNER_ERR(op_type, "compileInfoPtr is null."), | 142 | OPS_ERR_IF(compileInfoPtr == nullptr, OPS_REPORT_VECTOR_INNER_ERR(op_type, "compileInfoPtr is null."), |
| 143 | return ge::GRAPH_FAILED); | 143 | return ge::GRAPH_FAILED); |
| 144 | soc_version = compileInfoPtr->socVersion; | 144 | soc_version = compileInfoPtr->socVersion; |
pooling/avg_pool_v2_grad/op_host/avg_pool_v2_grad_infershape.cppOP_CHECK_IF(strcmp(padding_mode, "SAME") != 0 && strcmp(padding_mode, "VALID") != 0 && strcmp(padding_mode, "CALCULATED") != 0, OP_LOGE(context->GetNodeName(), "attr padding_mode(%s) only support SAME, VALID and CALCULATED", padding_mode), return GRAPH_FAILED);将逻辑运算符 '&&' 改为 '||'。正确的逻辑是:如果 padding_mode 不等于 "SAME" 且不等于 "VALID" 且不等于 "CALCULATED",则报错。修改为:OP_CHECK_IF(strcmp(padding_mode, "SAME") != 0 || strcmp(padding_mode, "VALID") != 0 || strcmp(padding_mode, "CALCULATED") != 0, ...)。或者更清晰地写为:if (strcmp(padding_mode, "SAME") != 0 && strcmp(padding_mode, "VALID") != 0 && strcmp(padding_mode, "CALCULATED") != 0) { 报错 }。此评论由代码审查工具自动生成