Skip to content

Commit

Permalink
Revised adding unique_id to entry points to have a temporal number as…
Browse files Browse the repository at this point in the history
… unique id
  • Loading branch information
yeonbok committed Feb 21, 2022
1 parent 729ef84 commit aba5ccf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ using namespace cldnn;

void compile_graph::run(program& p) {
OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "CLDNN::pass::CompileGraph");
size_t order_idx = 0;
for (auto& node : p.get_processing_order()) {
node->set_unique_id(std::to_string(order_idx++));
node->set_unique_id();
if (!node->is_type<data>()) {
node->get_output_layout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void post_input_reorder::run(program& p) {
input_layout.size,
input_layout.data_padding);
auto& reorder = add_reorder(p, input, node, current_layout);
reorder.set_unique_id(node->get_unique_id() + "_input_reorder");
reorder.set_unique_id();
reorder.get_output_layout(false);
node->set_output_layout(previous_layout, false);
reorder.set_selected_impl(reorder.type()->choose_impl(reorder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void remove_redundant_reorders::run(program& p) {
if (!update_implementations)
return;

node.set_unique_id(node.get_unique_id() + "_reorder");
node.set_unique_id();
auto new_impl = node.type()->choose_impl(node);
node.set_selected_impl(std::move(new_impl));
};
Expand Down
22 changes: 12 additions & 10 deletions src/plugins/intel_gpu/src/graph/include/program_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <memory>
#include <list>
#include <algorithm>
#include <thread>

namespace cldnn {

Expand Down Expand Up @@ -107,6 +108,12 @@ struct program_node {
virtual ~program_node() = default;

public:
static size_t unique_id_gen() {
return cur_id++;
}
static void reset_unique_id() {
cur_id = 0;
}
virtual const primitive_id& id() const { return desc->id; }
virtual primitive_type_id type() const { return desc->type; }
virtual std::shared_ptr<kernel_selector::fuse_params> get_fuse_params() const { return nullptr; }
Expand Down Expand Up @@ -351,19 +358,14 @@ struct program_node {

bool need_lockable_memory() const;

std::string get_unique_id() const { return unique_id; }
void set_unique_id(std::string id) {
unique_id = id;
if (myprog.get_parent_primitive() != "") {
auto loop_prim = myprog.get_parent_primitive();
std::replace(loop_prim.begin(), loop_prim.end(), '/', '_');
std::replace(loop_prim.begin(), loop_prim.end(), ':', '_');
unique_id = loop_prim + "_" + unique_id;
}
size_t get_unique_id() const { return unique_id; }
void set_unique_id() {
unique_id = unique_id_gen();
}

protected:
std::string unique_id = "";
size_t unique_id = 0;
static thread_local size_t cur_id;

std::shared_ptr<primitive> desc;
program& myprog;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/graph/kernel_selector_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ void set_params(const program_node& node, kernel_selector::params& params) {
const auto& program = node.get_program();
const auto& device_info = program.get_engine().get_device_info();

params.uniqueID = node.get_unique_id();
params.uniqueID = std::to_string(node.get_unique_id());
params.engineInfo.bSubGroupSupport = device_info.supports_subgroups;
params.engineInfo.bSubGroupShortSupport = device_info.supports_subgroups_short;
params.engineInfo.bSubGroupCharSupport = device_info.supports_subgroups_char;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_gpu/src/graph/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ program::program(engine& engine_ref,
prepare_nodes(topology);
_kernels_cache = std::unique_ptr<kernels_cache>(new kernels_cache(_engine, prog_id,
kernel_selector::KernelBase::get_db().get_batch_header_str()));
program_node::reset_unique_id();
if (no_optimizations) {
init_graph();
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/src/graph/program_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

using namespace cldnn;

thread_local size_t program_node::cur_id = 0;

program_node::program_node(std::shared_ptr<primitive> prim, program& prog)
: desc(prim), myprog(prog), org_id(prim ? (prim->id) : 0) {
if (prim)
Expand Down

0 comments on commit aba5ccf

Please sign in to comment.