forked from mindspore-Ecosystem/mindspore
!22329 Code clean of r1.3
Merge pull request !22329 from chenfei_mindspore/code_clean_of_r1.3
This commit is contained in:
commit
b61ce3adf8
|
@ -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,16 @@ 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 +475,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
|
||||
|
|
|
@ -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_; }
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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))) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue