fix codex warning

This commit is contained in:
zengzitao 2021-08-23 16:30:41 +08:00
parent 8cbd80adcc
commit e1264cb709
4 changed files with 15 additions and 15 deletions

View File

@ -52,7 +52,7 @@ std::set<int64_t> GetUniqReduceAxes(const AnfNodePtr &node, bool is_ascend = fal
auto axis_vec = GetReduceAxis(node);
if (axis_vec.empty()) {
for (size_t i = 0; i < src_shape_vec.size(); ++i) {
axis_vec.emplace_back(SizeToLong(i));
(void)axis_vec.emplace_back(SizeToLong(i));
}
} else {
(void)std::transform(axis_vec.begin(), axis_vec.end(), axis_vec.begin(), [&src_shape_vec](int64_t axis) -> int64_t {

View File

@ -557,7 +557,7 @@ std::tuple<std::vector<bool>, std::vector<ParallelInfo>> ParallelOpFusion::Searc
std::vector<size_t> indices;
for (size_t i = 0; i < cs.size(); ++i) {
if (cs[i]) {
origin_indices.insert({cs[i], i});
origin_indices.emplace(cs[i], i);
indices.push_back(i);
}
}

View File

@ -32,11 +32,11 @@ std::vector<std::string> GetTokens(const std::string &str, const std::string &de
std::vector<std::string> tokens;
std::vector<char> c_str(str.begin(), str.end());
c_str.push_back('\0');
char *saveptr;
char *saveptr = nullptr;
char *pch = strtok_r(&c_str[0], delim.c_str(), &saveptr);
while (pch != NULL) {
while (pch != nullptr) {
tokens.emplace_back(pch);
pch = strtok_r(NULL, delim.c_str(), &saveptr);
pch = strtok_r(nullptr, delim.c_str(), &saveptr);
}
return tokens;
}
@ -44,19 +44,19 @@ std::vector<std::string> GetTokens(const std::string &str, const std::string &de
// Parse flag string to key-value pair.
// Flag format: "--key=value", bool flag's value can be implicit, the "--key" means "--key=true"
std::pair<std::string, std::string> ParseFlag(const std::string &flag) {
auto i = flag.find("--");
// check the string starts with "--".
constexpr size_t expected_size = 2;
if (i != 0 || flag.size() == expected_size) {
auto i = flag.find("--");
constexpr size_t leading_size = 2;
if (flag.size() <= leading_size || i != 0) {
return std::pair<std::string, std::string>();
}
i += expected_size;
i += leading_size;
auto j = flag.find('=', i + 1); // the key should not be empty, "--=" is invalid
if (j == std::string::npos) {
if (j >= flag.size()) {
// no value, treated as bool flag.
return std::make_pair(flag.substr(i), "");
} else if (j + 1 != flag.size() && flag.find('=', j + 1) == std::string::npos) {
} else if (j + 1 < flag.size() && flag.find('=', j + 1) == std::string::npos) {
// normal "--key=value" format
return std::make_pair(flag.substr(i, j - i), flag.substr(j + 1));
}

View File

@ -65,19 +65,19 @@ class GraphKernelFlags {
*
* Experimental feature, enabled by default when opt_level=3
*/
bool enable_stitch_fusion;
bool enable_stitch_fusion{false};
/**
* Enable recompute fusion in graph kernel fusion strategy, enabled when op_level>=2.
*/
bool enable_recompute_fusion;
bool enable_recompute_fusion{true};
/**
* Enable parallel fusion in graph kernel fusion strategy.
*
* Experimental feature, enabled by default when opt_level=3
*/
bool enable_parallel_fusion;
bool enable_parallel_fusion{false};
/**
* Optimization level, value from 0 to 3.
@ -88,7 +88,7 @@ class GraphKernelFlags {
* The default value is OptLevel_2 when the context "enable_graph_kernel" is set,
* but if it's also changed in "graph_kernel_flags", then the "graph_kernel_flags" will prevail.
*/
unsigned int opt_level; // defaults 0 or 2
unsigned int opt_level{0}; // defaults 0 or 2
/**
* auto_tune, unsupported now.