!22081 [ME]Code clean of master

Merge pull request !22081 from chenfei_mindspore/code_clean_of_master
This commit is contained in:
i-robot 2021-08-28 06:09:50 +00:00 committed by Gitee
commit 0ad0d9144e
6 changed files with 28 additions and 21 deletions

View File

@ -425,9 +425,11 @@ bool E2eDump::isDatasetGraph(const session::KernelGraph *graph) {
}
bool E2eDump::DumpDirExists(const std::string &dump_path) {
DIR *dir = opendir(dump_path.c_str());
if (dir) {
if (dir != nullptr) {
MS_LOG(INFO) << "Dump dir " << dump_path << " exists";
closedir(dir);
if (closedir(dir) == -1) {
MS_LOG(WARNING) << "Dump dir " << dump_path << " close failed!";
}
return true;
}
return false;
@ -446,12 +448,15 @@ bool E2eDump::MoveDumpFiles(const std::string &first_dir, const std::string &sec
std::string old_file_path = first_dir + "/" + file_name;
std::string new_file_path = second_dir + "/" + file_name;
if (rename(old_file_path.c_str(), new_file_path.c_str()) != 0) {
closedir(d_handle);
if (closedir(d_handle) == -1) {
MS_LOG(WARNING) << "Dump dir " << first_dir << " close failed!";
}
return false;
}
}
closedir(d_handle);
if (closedir(d_handle) == -1) {
MS_LOG(WARNING) << "Dump dir " << first_dir << " close failed!";
}
return true;
}
@ -469,11 +474,15 @@ bool E2eDump::DeleteDirContents(const std::string &dir_path) {
int res = remove(file_path.c_str());
if (res != 0) {
// Could not remove the file
closedir(d_handle);
if (closedir(d_handle) == -1) {
MS_LOG(WARNING) << "Dump dir " << dir_path << " close failed!";
}
return false;
}
}
closedir(d_handle);
if (closedir(d_handle) == -1) {
MS_LOG(WARNING) << "Dump dir " << dir_path << " close failed!";
}
return true;
}
} // namespace mindspore

View File

@ -126,7 +126,7 @@ class SymbolResolver {
SymbolPtr symbol() { return symbol_; }
py::object &result() { return result_; }
const py::object &result() { return result_; }
AnfNodePtr resolved_node() { return resolved_node_; }

View File

@ -113,7 +113,7 @@ class FlagRegister {
return !result->empty();
}
bool ParseValue(const std::string &s, bool *result) {
bool ParseValue(const std::string &s, bool *result) const {
*result = (s.empty() || s == "true" || s == "on" || s == "1");
return *result || s == "false" || s == "off" || s == "0";
}

View File

@ -25,7 +25,7 @@
#include "pybind_api/ir/base_ref_py.h"
namespace mindspore {
py::function GetBpropFunctionByObj(py::object obj) {
py::function GetBpropFunctionByObj(const py::object &obj) {
static const std::string get_bprop_fn = "get_bprop_fn";
static const std::string ad_module = "mindspore.ops._grad";
static const std::string ad_experimental_module = "mindspore.ops._grad_experimental";
@ -36,12 +36,12 @@ py::function GetBpropFunctionByObj(py::object obj) {
return fn;
}
py::function GetBpropFunction(std::string name) {
py::function GetBpropFunction(const std::string &name) {
auto fn = GetBpropFunctionByObj(py::str(name));
return fn;
}
py::function GetComputeFunction(std::string name) {
py::function GetComputeFunction(const std::string &name) {
static const std::string module = "mindspore._extends.builtin_operations";
py::module mod = py::module::import(common::SafeCStr(module));
if (!py::hasattr(mod, common::SafeCStr(name))) {

View File

@ -25,11 +25,11 @@
namespace py = pybind11;
namespace mindspore {
py::function GetBpropFunctionByObj(py::object obj);
py::function GetBpropFunctionByObj(const py::object &obj);
py::function GetBpropFunction(std::string name);
py::function GetBpropFunction(const std::string &name);
py::function GetComputeFunction(std::string name);
py::function GetComputeFunction(const std::string &name);
BaseRef RunComputeFunction(const PrimitivePtr &prim, const VectorRef &args);

View File

@ -180,11 +180,10 @@ def test_if_after_if_02():
control_flow_if_after_if(IfAfterIfNet2, x, y)
@pytest.mark.level1
@pytest.mark.level0
@pytest.mark.platform_x86_gpu_training
# Now in ascend result is not correct
# @pytest.mark.platform_arm_ascend_training
# @pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.env_onecard
def test_if_after_if_03():
x = Tensor(2, mstype.int32)
@ -192,8 +191,7 @@ def test_if_after_if_03():
control_flow_if_after_if(IfAfterIfNet3, x, y)
@pytest.mark.skip(reason="Result is not correct in multigraph sink.")
@pytest.mark.level1
@pytest.mark.level0
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.env_onecard