Browse Source

!317 Add strerror for open fail.

From: @zhangxiaokun9
Reviewed-by: @xchu42,@ji_chen
Signed-off-by: @ji_chen
tags/v1.1.0
mindspore-ci-bot Gitee 4 years ago
parent
commit
e0f3a07962
2 changed files with 9 additions and 5 deletions
  1. +8
    -4
      ge/common/model_parser/base.cc
  2. +1
    -1
      ge/graph/passes/memcpy_addr_async_pass.cc

+ 8
- 4
ge/common/model_parser/base.cc View File

@@ -39,12 +39,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro
return GE_EXEC_MODEL_PATH_INVALID; return GE_EXEC_MODEL_PATH_INVALID;
} }


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(model_path) == -1, return GE_EXEC_READ_MODEL_FILE_FAILED,
"File size not valid.");
if (GetFileLength(model_path) == -1) {
GELOGE(GE_EXEC_READ_MODEL_FILE_FAILED, "File size not valid, file: %s.", model_path);
return GE_EXEC_READ_MODEL_FILE_FAILED;
}


std::ifstream fs(real_path.c_str(), std::ifstream::binary); std::ifstream fs(real_path.c_str(), std::ifstream::binary);

GE_CHK_BOOL_RET_STATUS(fs.is_open(), GE_EXEC_READ_MODEL_FILE_FAILED, "Open file failed! path:%s", model_path);
if (!fs.is_open()) {
GELOGE(GE_EXEC_READ_MODEL_FILE_FAILED, "Open file: %s failed, error: %s", model_path, strerror(errno));
return GE_EXEC_READ_MODEL_FILE_FAILED;
}


// get length of file: // get length of file:
(void)fs.seekg(0, std::ifstream::end); (void)fs.seekg(0, std::ifstream::end);


+ 1
- 1
ge/graph/passes/memcpy_addr_async_pass.cc View File

@@ -250,7 +250,7 @@ NodePtr MemcpyAddrAsyncPass::CreateMemcpyAddrAsyncNode(const ComputeGraphPtr &gr
} }
} }


NodePtr memcpy_addr_async_node = graph->AddNodeAfter(op_desc, out_data_anchor->GetOwnerNode());
NodePtr memcpy_addr_async_node = graph->AddNode(op_desc);
GE_CHECK_NOTNULL_EXEC(memcpy_addr_async_node, return nullptr); GE_CHECK_NOTNULL_EXEC(memcpy_addr_async_node, return nullptr);


return memcpy_addr_async_node; return memcpy_addr_async_node;


Loading…
Cancel
Save