Skip to content

Commit

Permalink
benchdnn: graph: change default value of --expected-n-partitions to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoLv committed Jan 2, 2025
1 parent 32aa319 commit 263bd0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
5 changes: 3 additions & 2 deletions tests/benchdnn/doc/driver_graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ where *graph-knobs* are:
Multiple attributes value changes may be specified using the `*`
delimeter. Multiple ops modification may be specified using the `+`
delimeter. By default, the option value is empty, meaning values are taken from original graph.
- `--expected-n-partitions=INT` -- Specify the number of expected partitions
- `--expected-n-partitions=INT` -- Specify the number of expected partitions
returned from the graph. `INT` is a non-negative integer value. When `INT`
value is `0` (the default), the check is skipped.
value is `0`, the check is skipped. By default, the value is `1` which means
the graph should be fused as one partition.
- `--dt={undef [default], f32, bf16, f16}` -- Specify the data types in the
input JSON file. Currently, you can define data types for pure floating-point
input graph only. For example, you can specify `--dt=f16` for an `f32` graph
Expand Down
25 changes: 11 additions & 14 deletions tests/benchdnn/graph/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ std::string case_to_str(const std::string &json_file,
s << " ";
}

if (expected_n_partitions != 0) {
if (expected_n_partitions != 1) {
s << "--expected-n-partitions=" << std::to_string(expected_n_partitions)
<< " ";
}
Expand Down Expand Up @@ -475,19 +475,6 @@ int doit(const prb_t *prb, res_t *res) {
if (aop.kind_ == "End") { end_opid_v.emplace_back(aop.id_); }
}

if (prb->expected_n_partition != 0) {
// If the expected partition num is specified by user with command line
// knob
if (partitions.size() != prb->expected_n_partition) {
BENCHDNN_PRINT(0,
"Error: the expected number of partitions (%zu) doesn't "
"coincide with the actual number of partitions returned "
"(%zu).\n ",
prb->expected_n_partition, partitions.size());
return res->state = FAILED, FAIL;
}
}

if (partitions.empty()) {
BENCHDNN_PRINT(0, "%s\n", "Error: partitions are empty");
return res->state = FAILED, FAIL;
Expand Down Expand Up @@ -557,6 +544,16 @@ int doit(const prb_t *prb, res_t *res) {
return FAIL;
}

if (prb->expected_n_partition != 0
&& partitions.size() != prb->expected_n_partition) {
BENCHDNN_PRINT(0,
"Error: the expected number of partitions (%zu) doesn't "
"coincide with the actual number of partitions returned "
"(%zu).\n ",
prb->expected_n_partition, partitions.size());
return res->state = FAILED, FAIL;
}

if (res->state == SKIPPED || res->state == UNIMPLEMENTED) return OK;

const auto &eng = get_graph_engine();
Expand Down
7 changes: 4 additions & 3 deletions tests/benchdnn/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ struct settings_t : public base_settings_t {
std::string json_file;
std::vector<std::map<size_t, std::string>> in_shapes_vec {{{0, "default"}}};
std::vector<std::map<size_t, std::string>> op_attrs_vec {{{0, "default"}}};
// `0` means not specified by user with command line knob, will skip
// the partition num check.
std::vector<size_t> expected_n_partition_vec {0};
// By default, we expect the graph should be fused as a single partition.
// The user can specify `--expected-n-partitions=0` to skip the partition
// number check.
std::vector<size_t> expected_n_partition_vec {1};
std::vector<graph_fpmath_mode_t> fpmath_mode_vec {graph_fpmath_mode_t {}};
std::vector<dnnl_data_type_t> dt {dnnl_data_type_undef};

Expand Down

0 comments on commit 263bd0f

Please sign in to comment.