Skip to content

Commit

Permalink
benchdnn: graph: styling
Browse files Browse the repository at this point in the history
  • Loading branch information
dzarukin committed Jan 15, 2025
1 parent 381134e commit 17bec50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions tests/benchdnn/graph/input_displacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,19 @@ int partition_data_displacer_t::displace_input_data(
const auto &user_set
= is_div ? pow2_div_vals : (is_mul ? pow2_mul_vals : dummy);
fill_cfg_t fill_cfg(user_set, "Mul/Div displacer");
SAFE(gen_pow2_filling(mem_replace, mem.md_, fill_cfg, res), WARN);
SAFE(gen_fixed_set_filling(mem_replace, mem.md_, fill_cfg, res), WARN);
} else {
assert(!"unexepcted filling type");
assert(!"unexpected filling type");
}

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

// do the reverse job
auto *parent_op = &dg_->get_op_by_out_lt(tensor.id_);
bool backward_path_launched = false;
while (filling_type == filling_type_t::quantization && !parent_op->empty()
&& op_ids_set_.find(parent_op->id_) != op_ids_set_.end()) {
backward_path_launched = true;
// generate the reverse op based on OP kind
// make a copy of deserialized_op to avoid impact on graph execution
// Currently, we support the following OPs' reverse execution:
Expand Down Expand Up @@ -270,7 +272,9 @@ int partition_data_displacer_t::displace_input_data(
parent_op = &dg_->get_op_by_out_lt(tensor.id_);
}

BENCHDNN_PRINT(3, "%s\n", "[DISPLACE]: Backward path ended.");
if (backward_path_launched) {
BENCHDNN_PRINT(3, "%s\n", "[DISPLACE]: Backward path ended.");
}

bool mds_are_equal = dnnl_memory_desc_equal(mem_replace.md_, mem.md_) == 1;
bool mds_are_int8 = is_integral_dt(mem_replace.dt())
Expand Down Expand Up @@ -361,7 +365,7 @@ int partition_data_displacer_t::gen_quantize_filling(
return OK;
}

int partition_data_displacer_t::gen_pow2_filling(dnn_mem_t &mem,
int partition_data_displacer_t::gen_fixed_set_filling(dnn_mem_t &mem,
const_dnnl_memory_desc_t md, const fill_cfg_t &fill_cfg,
res_t *res) const {

Expand Down
6 changes: 4 additions & 2 deletions tests/benchdnn/graph/input_displacer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace graph {
enum class filling_type_t {
undef = 0,
quantization,
// Floating-point power-of-2 values for precise disivision/multiplication.
pow2,
};

Expand Down Expand Up @@ -55,8 +56,9 @@ class partition_data_displacer_t {

int gen_quantize_filling(const ::graph::deserialized_op &main_op, int arg,
dnn_mem_t &mem, const ::std::string &dt, res_t *res);
// Generates floating-point power-of-2 values in the target memory.
int gen_pow2_filling(dnn_mem_t &mem, const_dnnl_memory_desc_t lt,
// Generates values in the target memory based on predefined set of values
// from `fill_cfg`.
int gen_fixed_set_filling(dnn_mem_t &mem, const_dnnl_memory_desc_t md,
const fill_cfg_t &fill_cfg, res_t *res) const;
};

Expand Down
4 changes: 2 additions & 2 deletions tests/benchdnn/utils/fill.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2023-2024 Intel Corporation
* Copyright 2023-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,7 +65,7 @@ std::string fill_cfg_t::print_verbose() const {
std::stringstream ss;

ss << "[FILL_CFG]";
if (!name_.empty()) ss << " name:" << name_;
if (!name_.empty()) ss << " name:\'" << name_ << "\';";

// Predefined set is mutually excluded with a range setting.
if (!predefined_set_.empty()) {
Expand Down

0 comments on commit 17bec50

Please sign in to comment.