Browse Source

!1781 fix cmetric

From: @wangxiaotian22
Reviewed-by: 
Signed-off-by:
tags/v1.5.1
mindspore-ci-bot Gitee 3 years ago
parent
commit
adbe333018
11 changed files with 115 additions and 64 deletions
  1. +26
    -56
      ge/common/util.cc
  2. +2
    -2
      ge/graph/load/model_manager/davinci_model.cc
  3. +1
    -1
      ge/graph/preprocess/insert_op/ge_aipp_op.cc
  4. +2
    -1
      ge/hybrid/node_executor/hccl/hccl_node_executor.cc
  5. +1
    -1
      ge/ir_build/option_utils.cc
  6. +1
    -2
      ge/offline/main.cc
  7. +7
    -0
      tests/depends/mmpa/src/mmpa_stub.cc
  8. +1
    -0
      tests/ut/ge/CMakeLists.txt
  9. +63
    -0
      tests/ut/ge/common/util_unittest.cc
  10. +3
    -0
      tests/ut/ge/graph/load/davinci_model_unittest.cc
  11. +8
    -1
      tests/ut/ge/graph_ir/ge_ir_build_unittest.cc

+ 26
- 56
ge/common/util.cc View File

@@ -340,15 +340,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char
return res; return res;
} }


void PathValidErrReport(const std::string &file_path, const std::string &atc_param, const std::string &reason) {
if (!atc_param.empty()) {
REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({atc_param, file_path, reason}));
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] invalid, reason:%s", file_path.c_str(), reason.c_str());
}
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const std::string &file_path, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const std::string &file_path,
const std::string &atc_param) { const std::string &atc_param) {
// The specified path is empty // The specified path is empty
std::map<std::string, std::string> args_map; std::map<std::string, std::string> args_map;
if (file_path.empty()) { if (file_path.empty()) {
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
if (!atc_param.empty()) {
REPORT_INPUT_ERROR("E10004", std::vector<std::string>({"parameter"}), std::vector<std::string>({atc_param}));
} else { } else {
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid");
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid.");
} }
GELOGW("Input parameter %s is empty.", file_path.c_str()); GELOGW("Input parameter %s is empty.", file_path.c_str());
return false; return false;
@@ -356,13 +365,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const
std::string real_path = RealPath(file_path.c_str()); std::string real_path = RealPath(file_path.c_str());
// Unable to get absolute path (does not exist or does not have permission to access) // Unable to get absolute path (does not exist or does not have permission to access)
if (real_path.empty()) { if (real_path.empty()) {
if (atc_param != "") {
std::string reason = "realpath error, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno));
}
std::string reason = "realpath error, errmsg:" + std::string(strerror(errno));
PathValidErrReport(file_path, atc_param, reason);
GELOGW("Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno)); GELOGW("Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -378,23 +382,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(real_path, mode), !ValidateStr(real_path, mode),
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, real_path, kPathValidReason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] has invalid char, %s", file_path.c_str(), kPathValidReason);
}
PathValidErrReport(file_path, atc_param, kPathValidReason);
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason);


// The absolute path points to a file that is not readable // The absolute path points to a file that is not readable
if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) { if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) {
if (atc_param != "") {
std::string reason = "cat not access, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] can't acccess, errmsg:%s", file_path.c_str(), strerror(errno));
}
PathValidErrReport(file_path, atc_param, "cat not access, errmsg:" + std::string(strerror(errno)));
GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -406,10 +399,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
const std::string &atc_param) { const std::string &atc_param) {
// The specified path is empty // The specified path is empty
if (file_path.empty()) { if (file_path.empty()) {
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
if (!atc_param.empty()) {
REPORT_INPUT_ERROR("E10004", std::vector<std::string>({"parameter"}), std::vector<std::string>({atc_param}));
} else { } else {
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid");
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid.");
} }
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param}); ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
GELOGW("Input parameter's value is empty."); GELOGW("Input parameter's value is empty.");
@@ -417,17 +410,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
} }


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH, GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH,
if (atc_param != "") {
std::string reason = "len is too long, it must be less than " +
std::to_string(MMPA_MAX_PATH);
ErrorManager::GetInstance().ATCReportErrMessage(
"E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] len is too long, it must be less than %d",
file_path.c_str(), MMPA_MAX_PATH);
}
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(),
std::string reason = "len is too long, it must be less than " +
std::to_string(MMPA_MAX_PATH);
PathValidErrReport(file_path, atc_param, reason);
return false, "Path[%s] len is too long, it must be less than %d", file_path.c_str(),
MMPA_MAX_PATH); MMPA_MAX_PATH);


// A regular matching expression to verify the validity of the input file path // A regular matching expression to verify the validity of the input file path
@@ -441,12 +427,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(file_path, mode), !ValidateStr(file_path, mode),
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, kPathValidReason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] has invalid char, %s", file_path.c_str(), kPathValidReason);
}
PathValidErrReport(file_path, atc_param, kPathValidReason);
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason);


std::string real_path = RealPath(file_path.c_str()); std::string real_path = RealPath(file_path.c_str());
@@ -454,13 +435,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
if (!real_path.empty()) { if (!real_path.empty()) {
// File is not readable or writable // File is not readable or writable
if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) { if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) {
if (atc_param != "") {
std::string reason = "cat not access, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] can't acccess, errmsg:%s", file_path.c_str(), strerror(errno));
}
PathValidErrReport(file_path, atc_param, "cat not access, errmsg:" + std::string(strerror(errno)));
GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -479,12 +454,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
std::string prefix_path = std::string(file_path).substr(0, static_cast<size_t>(path_split_pos)); std::string prefix_path = std::string(file_path).substr(0, static_cast<size_t>(path_split_pos));
// Determine whether the specified path is valid by creating the path // Determine whether the specified path is valid by creating the path
if (CreateDirectory(prefix_path) != 0) { if (CreateDirectory(prefix_path) != 0) {
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, "Can not create directory"});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] Can not create directory", file_path.c_str());
}
PathValidErrReport(file_path, atc_param, "Can not create directory");
GELOGW("Can not create directory[%s].", file_path.c_str()); GELOGW("Can not create directory[%s].", file_path.c_str());
return false; return false;
} }


+ 2
- 2
ge/graph/load/model_manager/davinci_model.cc View File

@@ -3466,11 +3466,11 @@ bool DavinciModel::CheckUserAndModelSize(const int64_t &size, const int64_t &op_
} }
// The input and model input size can not be exactly equal because user input is not definite. // The input and model input size can not be exactly equal because user input is not definite.
if ((size + kDataMemAlignSizeCompare) < op_size) { if ((size + kDataMemAlignSizeCompare) < op_size) {
REPORT_INNER_ERROR("E19999", "%s size:%ld from user add align:%u < input_op_size:%ld in model, model_id:%u, "
REPORT_INNER_ERROR("E19999", "%s size:%ld from user add align:%u < op_size:%ld in model, model_id:%u, "
"check invalid", "check invalid",
input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_); input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_);
GELOGE(ACL_ERROR_GE_PARAM_INVALID, GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"[Check][Param] %s size:%ld from user add align:%u < input_op_size:%ld in model, model_id:%u",
"[Check][Param] %s size:%ld from user add align:%u < op_size:%ld in model, model_id:%u",
input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_); input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_);
return false; return false;
} }


+ 1
- 1
ge/graph/preprocess/insert_op/ge_aipp_op.cc View File

@@ -114,7 +114,7 @@ Status GetDataDimN(const ge::NodePtr &data_node, ge::Format format, int64_t &bat
std::vector<std::string>({ std::vector<std::string>({
data_node->GetName() + " format", data_node->GetName() + " format",
TypeUtils::FormatToSerialString(format), TypeUtils::FormatToSerialString(format),
"only format " + TypeUtils::FormatToSerialString(FORMAT_NCHW) + " and "+
"only format " + TypeUtils::FormatToSerialString(FORMAT_NCHW) + " and " +
TypeUtils::FormatToSerialString(FORMAT_NHWC) + TypeUtils::FormatToSerialString(FORMAT_NHWC) +
" supported which dynamic aipp is linked"})); " supported which dynamic aipp is linked"}));
GELOGE(PARAM_INVALID, "[Check][Param] Not support data format:%s, node:%s", GELOGE(PARAM_INVALID, "[Check][Param] Not support data format:%s, node:%s",


+ 2
- 1
ge/hybrid/node_executor/hccl/hccl_node_executor.cc View File

@@ -24,6 +24,7 @@
#include "external/graph/types.h" #include "external/graph/types.h"
#include "hybrid/executor/hybrid_execution_context.h" #include "hybrid/executor/hybrid_execution_context.h"
#include "hccl/hcom.h" #include "hccl/hcom.h"
#include "runtime/event.h"


namespace ge { namespace ge {
namespace { namespace {
@@ -325,7 +326,7 @@ Status RdmaNodeTask::ExecuteAsync(TaskContext &context, std::function<void()> do


rtEvent_t evt = nullptr; rtEvent_t evt = nullptr;
if (context.GetExecutionContext()->hccl_stream != nullptr) { if (context.GetExecutionContext()->hccl_stream != nullptr) {
GE_CHK_RT_RET(rtEventCreateWithFlag(&evt, 0x01));
GE_CHK_RT_RET(rtEventCreateWithFlag(&evt, RT_EVENT_WITH_FLAG));
GE_CHK_RT_RET(rtStreamWaitEvent(context.GetExecutionContext()->hccl_stream, evt)); GE_CHK_RT_RET(rtStreamWaitEvent(context.GetExecutionContext()->hccl_stream, evt));
} }
TaskContext *p_ctx = &context; TaskContext *p_ctx = &context;


+ 1
- 1
ge/ir_build/option_utils.cc View File

@@ -204,7 +204,7 @@ bool CheckDynamicImagesizeInputShapeValid(map<string, vector<int64_t>> shape_map
if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) { if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) {
GELOGE(ge::PARAM_INVALID, GELOGE(ge::PARAM_INVALID,
"[Check][DynamicImagesizeInputShape] input_format [%s] invalid, can not support now.", input_format.c_str()); "[Check][DynamicImagesizeInputShape] input_format [%s] invalid, can not support now.", input_format.c_str());
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter","value","reason"}),
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"input_format", input_format, "this format is not support"})); std::vector<std::string>({"input_format", input_format, "this format is not support"}));
return false; return false;
} }


+ 1
- 2
ge/offline/main.cc View File

@@ -953,8 +953,7 @@ domi::Status GenerateModel(std::map<string, string> &options, std::string output
ge::Model load_model = ge::Model("loadmodel", "version2"); ge::Model load_model = ge::Model("loadmodel", "version2");
auto ret1 = load_model.LoadFromFile(FLAGS_model); auto ret1 = load_model.LoadFromFile(FLAGS_model);
if (ret1 != ge::GRAPH_SUCCESS) { if (ret1 != ge::GRAPH_SUCCESS) {
REPORT_INPUT_ERROR("E10041", std::vector<std::string>({"file"}), std::vector<std::string>({FLAGS_model}));
REPORT_CALL_ERROR("E19999", "load from model file:%s failed", FLAGS_model.c_str());
REPORT_INPUT_ERROR("E10041", std::vector<std::string>({"parameter"}), std::vector<std::string>({FLAGS_model}));
DOMI_LOGE("Load model from %s failed, please check model file or " DOMI_LOGE("Load model from %s failed, please check model file or "
"input parameter[--framework] is correct", FLAGS_model.c_str()); "input parameter[--framework] is correct", FLAGS_model.c_str());
(void)ge_generator.Finalize(); (void)ge_generator.Finalize();


+ 7
- 0
tests/depends/mmpa/src/mmpa_stub.cc View File

@@ -220,6 +220,13 @@ VOID mmScandirFree(mmDirent **entryList, INT32 count)


INT32 mmAccess2(const CHAR *pathName, INT32 mode) INT32 mmAccess2(const CHAR *pathName, INT32 mode)
{ {
if (pathName == NULL) {
return EN_INVALID_PARAM;
}
INT32 ret = access(pathName, mode);
if (ret != EN_OK) {
return EN_ERROR;
}
return 0; return 0;
} }




+ 1
- 0
tests/ut/ge/CMakeLists.txt View File

@@ -764,6 +764,7 @@ set(MULTI_PARTS_TEST_FILES
"graph_ir/ge_ir_build_unittest.cc" "graph_ir/ge_ir_build_unittest.cc"
"graph/transop_util_unittest.cc" "graph/transop_util_unittest.cc"
"common/datatype_transfer_unittest.cc" "common/datatype_transfer_unittest.cc"
"common/util_unittest.cc"
"common/dump_manager_unittest.cc" "common/dump_manager_unittest.cc"
"common/dump_op_unittest.cc" "common/dump_op_unittest.cc"
"common/dump_exception_unittest.cc" "common/dump_exception_unittest.cc"


+ 63
- 0
tests/ut/ge/common/util_unittest.cc View File

@@ -0,0 +1,63 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <gtest/gtest.h>

#include "common/util.h"

namespace ge {
namespace formats {
class UtestUtilTransfer : public testing::Test {
protected:
void SetUp() {}
void TearDown() {}
};


INT32 mmAccess2(const CHAR *pathName, INT32 mode)
{
return -1;
}

TEST_F(UtestUtilTransfer, CheckOutputPathValid) {
EXPECT_EQ(CheckOutputPathValid("", ""), false);
EXPECT_EQ(CheckOutputPathValid("", "model"), false);

char max_file_path[14097] = {0};
memset(max_file_path, 1, 14097);
EXPECT_EQ(CheckOutputPathValid(max_file_path, "model"), false);

EXPECT_EQ(CheckOutputPathValid("$#%", ""), false);

// system("touch test_util");
// system("chmod 555 test_util");
// EXPECT_EQ(CheckOutputPathValid("./test_util", ""), false);
// system("rm -r test_util");
}

TEST_F(UtestUtilTransfer, CheckInputPathValid) {
EXPECT_EQ(CheckInputPathValid("", ""), false);
EXPECT_EQ(CheckInputPathValid("", "model"), false);

EXPECT_EQ(CheckInputPathValid("$#%", ""), false);

EXPECT_EQ(CheckInputPathValid("./test_util", ""), false);

}

}
}


+ 3
- 0
tests/ut/ge/graph/load/davinci_model_unittest.cc View File

@@ -1035,6 +1035,9 @@ TEST_F(UtestDavinciModel, NnExecute) {
ProfilingManager::Instance().device_id_.emplace_back(0); ProfilingManager::Instance().device_id_.emplace_back(0);
model.task_list_.resize(1); model.task_list_.resize(1);
EXPECT_EQ(model.NnExecute(stream, false, input_data, output_data), SUCCESS); EXPECT_EQ(model.NnExecute(stream, false, input_data, output_data), SUCCESS);

input_data.blobs[0].length = 128;
EXPECT_NE(model.NnExecute(stream, false, input_data, output_data), SUCCESS);
} }
TEST_F(UtestDavinciModel, update_io_addr_success) { TEST_F(UtestDavinciModel, update_io_addr_success) {
DavinciModel model(0, nullptr); DavinciModel model(0, nullptr);


+ 8
- 1
tests/ut/ge/graph_ir/ge_ir_build_unittest.cc View File

@@ -368,7 +368,14 @@ TEST(UtestIrBuild, check_modify_mixlist_param) {
{"ge.exec.modify_mixlist", "/modify.json"} {"ge.exec.modify_mixlist", "/modify.json"}
}; };
ModelBufferData model; ModelBufferData model;
auto ret = aclgrphBuildModel(graph, build_options, model); auto ret = aclgrphBuildModel(graph, build_options, model);
EXPECT_EQ(ret, GRAPH_PARAM_INVALID); EXPECT_EQ(ret, GRAPH_PARAM_INVALID);
}

TEST(UtestIrCommon, check_dynamic_imagesize_input_shape_valid_format_empty) {
std::map<std::string, std::vector<int64_t>> shape_map;
std::string dynamic_image_size = "";
bool ret = CheckDynamicImagesizeInputShapeValid(shape_map, "123", dynamic_image_size);
EXPECT_EQ(ret, false);
} }

Loading…
Cancel
Save