Skip to content

Commit

Permalink
benchdnn: graph: fix fpmath mode setting when cml is specified with a…
Browse files Browse the repository at this point in the history
…pply_to_int
  • Loading branch information
wzt1997 authored and TaoLv committed Nov 22, 2024
1 parent d11367c commit 3f8230a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions tests/benchdnn/graph/deserialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ struct deserialized_graph {
std::string get_string() const;

// Return the fpmath mode attribute
const std::pair<std::string, bool> get_fpmath_mode() const {
return std::make_pair(
fpmath_mode_, str2bool(fpmath_mode_apply_to_int_.c_str()));
const std::pair<std::string, std::string> get_fpmath_mode() const {
return std::make_pair(fpmath_mode_, fpmath_mode_apply_to_int_);
}

void set_fpmath_mode(const graph_fpmath_mode_t &fpmath_mode) {
Expand Down
5 changes: 3 additions & 2 deletions tests/benchdnn/graph/flex_rewrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,9 @@ void flex_rewrite::graph_attrs_rewrite(deserialized_graph &dgraph) {

for (auto &aop : dgraph.ops_) {
// save the graph-level config for ops
aop.fpmath_mode_ = fpmath_mode_.mode_;
aop.fpmath_mode_apply_to_int_ = bool2str(fpmath_mode_.apply_to_int_);
const auto &mode = dgraph.get_fpmath_mode();
aop.fpmath_mode_ = mode.first;
aop.fpmath_mode_apply_to_int_ = mode.second;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/benchdnn/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct prb_t {

const auto &fpmath = dg.get_fpmath_mode();
fpmath_mode.mode_ = fpmath.first;
fpmath_mode.apply_to_int_ = fpmath.second;
fpmath_mode.apply_to_int_ = str2bool(fpmath.second.c_str());
}

deserialized_graph dg;
Expand Down
8 changes: 4 additions & 4 deletions tests/benchdnn/graph/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool parse_graph_fpmath_mode(
fpmath_mode_vec.pop_back();

size_t start_pos = 0;
auto subs = get_substr(mode, start_pos, ':');
auto mode_subs = get_substr(mode, start_pos, ':');
if (start_pos != std::string::npos && start_pos >= mode.size()) {
BENCHDNN_PRINT(0, "%s \'%s\'\n",
"Error: dangling symbol at the end of input",
Expand All @@ -172,17 +172,17 @@ bool parse_graph_fpmath_mode(

bool apply_to_int = false;
if (start_pos != std::string::npos) {
subs = get_substr(mode, start_pos, '\0');
auto bool_subs = get_substr(mode, start_pos, '\0');
if (start_pos != std::string::npos) {
BENCHDNN_PRINT(0, "%s \'%s\'\n",
"Error: dangling symbol at the end of input",
mode.c_str());
SAFE_V(FAIL);
}
apply_to_int = str2bool(subs.c_str());
apply_to_int = str2bool(bool_subs.c_str());
}
fpmath_mode_vec.emplace_back(
mode, apply_to_int, /* override_json_value = */ true);
mode_subs, apply_to_int, /* override_json_value = */ true);
}
}
return true;
Expand Down

0 comments on commit 3f8230a

Please sign in to comment.