text
stringlengths
0
2.2M
for_(const auto &i_post_ops : s.post_ops)
for_(const auto &i_scratchpad_mode : s.scratchpad_mode)
for (auto i_runtime_dim_mask : s.runtime_dim_mask) {
dt_conf_t iconf = dt2cfg(i_sdt);
dt_conf_t oconf = dt2cfg(i_ddt);
attr_t attr;
attr.insert(i_oscale);
attr.insert(i_zero_points);
attr.insert(i_post_ops);
attr.insert(i_scratchpad_mode);
handle_legacy_attr(attr, s.attr);
if (attr.oscale.policy == policy_t::PER_OC) {
fprintf(stderr,
"ERROR: reorder driver: `per_oc` policy is not supported "
"due to potential ambiguity. Please use one of `per_dim_0` "
"or `per_dim_1` policies.\n"),
fflush(stderr);
SAFE_V(FAIL);
}
if (i_cross_engine != NONE && is_cpu()) {
fprintf(stderr,
"ERROR: reorder driver: `cpu` engine does not support "
"anything but `--cross-engine=none`.\n"),
fflush(stderr);
SAFE_V(FAIL);
}
std::vector<float> attr_scale = {attr.oscale.scale};
auto &scale = attr.oscale.scale == 0 ? s.def_scale : attr_scale;
for (const auto &i_scale : scale) {
const prb_t prb(s.prb_dims, i_stag, i_dtag, iconf, oconf, attr,
i_oflag, i_cross_engine, i_runtime_dim_mask, i_scale);
std::stringstream ss;
ss << prb;
const std::string cpp_pstr = ss.str();
const char *pstr = cpp_pstr.c_str();
BENCHDNN_PRINT(1, "run: %s\n", pstr);
res_t res {};
int status = doit(&prb, &res);
bool want_perf_report = false;
parse_result(res, want_perf_report, status, pstr);
if (want_perf_report && is_bench_mode(PERF)) {
perf_report_t pr(&prb, s.perf_template);
pr.report(&res, pstr);
}
benchdnn_stat.tests++;
}
}
}
static const std::string help_oflag
= "FLAG:MASK[+...] (Default: not specified)\n Specifies `extra` "
"field of destination memory descriptor.\n `FLAG` values are "
"`s8s8_comp` and `zp_comp`.\n `MASK` is an non-negative integer "
"specifying dimension to apply compensation.\n";
static const std::string help_runtime_dim_mask
= "UINT (Default: `0`)\n Specifies a bit-mask that indicates "
"whether a dimension is `DNNL_RUNTIME_DIM_VAL` if `1` on a "
"correspondent dimension.\n";
static const std::string help_def_scales
= "FLOAT\n Output scales, used to improve testing coverage.\n If "
"`--attr-oscale` is specified, does not have an effect.\n";
static const std::string help_cross_engine
= "KIND (Default: `none`)\n Specifies `KIND` of cross-engine "
"used for benchmarking.\n `KIND` values are `none`, `cpu2gpu` or "
"`gpu2cpu`.\n";
int bench(int argc, char **argv) {
driver_name = "reorder";
using namespace parser;
static settings_t s;
static const settings_t def {};
for (; argc > 0; --argc, ++argv) {
const bool parsed_options = parse_bench_settings(argv[0])
|| parse_batch(bench, argv[0])
|| parse_dt(s.sdt, def.sdt, argv[0], "sdt")
|| parse_dt(s.ddt, def.ddt, argv[0], "ddt")
|| parse_tag(s.stag, def.stag, argv[0], "stag")
|| parse_tag(s.dtag, def.dtag, argv[0], "dtag")
|| parse_multivector_option(s.oflag, def.oflag, str2flag,
argv[0], "oflag", help_oflag, ',', '+')
|| parse_vector_option(s.runtime_dim_mask, def.runtime_dim_mask,
atoi, argv[0], "runtime-dim-mask",
help_runtime_dim_mask)
|| parse_vector_option(s.def_scale, def.def_scale, atof,
argv[0], "def-scales", help_def_scales)
|| parse_vector_option(s.cross_engine, def.cross_engine,
str2cross_engine, argv[0], "cross-engine",
help_cross_engine)
|| parse_attr(s.attr, argv[0])