Skip to content

Commit

Permalink
use local unordered_map
Browse files Browse the repository at this point in the history
  • Loading branch information
wilson-seok committed Nov 25, 2024
1 parent 144e565 commit 032a572
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#include "scatter_nd_update_inst.h"
#include "program_helpers.h"

#include <unordered_map>

using namespace cldnn;

void mark_runtime_skippable_nodes::run(program& p) {
std::unordered_map<primitive_id, uint8_t> runtime_skippable_depth;
auto itr = p.get_processing_order().begin();

while (itr != p.get_processing_order().end()) {
Expand Down Expand Up @@ -55,18 +58,19 @@ void mark_runtime_skippable_nodes::run(program& p) {
// Check whether consecutive runtime skippable nodes is lower than max count.
// Too long consecutive runtime skippable nodes causes huge time consumption in add_memory_dependency() of basic_memory_dependencies pass.
// max count 7 is experimentally selected in specific model.
const uint8_t max_consecutive_runtime_skippable_nodes = 7;
uint8_t dep_consecutive_runtime_skippable_count = 0;
const uint8_t max_runtime_skippable_depth = 7;
uint8_t dep_runtime_skippable_depth = 0;
for (const auto& dep : node->get_dependencies()) {
if (dep.first->is_runtime_skippable()) {
dep_consecutive_runtime_skippable_count = (dep.first->get_consecutive_runtime_skippable_count() > dep_consecutive_runtime_skippable_count) ?
dep.first->get_consecutive_runtime_skippable_count() : dep_consecutive_runtime_skippable_count;
if (dep.first->is_runtime_skippable() &&
(runtime_skippable_depth.find(dep.first->get_org_primitive_id()) != runtime_skippable_depth.end())) {
dep_runtime_skippable_depth = (runtime_skippable_depth[dep.first->get_org_primitive_id()] > dep_runtime_skippable_depth) ?
runtime_skippable_depth[dep.first->get_org_primitive_id()] : dep_runtime_skippable_depth;
}
}
if (!node->is_runtime_skippable() && (dep_consecutive_runtime_skippable_count >= max_consecutive_runtime_skippable_nodes)) {
if (!node->is_runtime_skippable() && (dep_runtime_skippable_depth >= max_runtime_skippable_depth)) {
GPU_DEBUG_TRACE_DETAIL << "[mark_runtime_skippable_nodes] : " << node->id()
<< " doesn't have runtime skippable due to max_consecutive_runtime_skippable_nodes("
<< max_consecutive_runtime_skippable_nodes << ")." << std::endl;
<< " doesn't have runtime skippable due to max_runtime_skippable_depth("
<< static_cast<int>(max_runtime_skippable_depth) << ")." << std::endl;
continue;
}

Expand Down Expand Up @@ -275,7 +279,7 @@ void mark_runtime_skippable_nodes::run(program& p) {
});

if (node->is_runtime_skippable()) {
node->set_consecutive_runtime_skippable_count(dep_consecutive_runtime_skippable_count + 1);
runtime_skippable_depth[node->get_org_primitive_id()] = dep_runtime_skippable_depth + 1;
}
}
}
5 changes: 0 additions & 5 deletions src/plugins/intel_gpu/src/graph/include/program_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,6 @@ struct program_node {
bool is_runtime_skippable() const { return runtime_skippable; }
void set_runtime_skippable(bool skippable) { runtime_skippable = skippable; }

// get/set
uint8_t get_consecutive_runtime_skippable_count() const { return consecutive_runtime_skippable_count; }
void set_consecutive_runtime_skippable_count(uint8_t count) { consecutive_runtime_skippable_count = count; }

// check/set if the node's buffer can be shared during the memory pool optimization
bool can_share_buffer() const { return share_buffer; }
void can_share_buffer(bool share) { share_buffer = share; }
Expand Down Expand Up @@ -508,7 +504,6 @@ struct program_node {
bool data_flow = false;
bool in_shape_of_subgraph = false;
bool runtime_skippable = false;
uint8_t consecutive_runtime_skippable_count = 0;

std::set<const program_node*> dependant_shape_of_nodes;

Expand Down

0 comments on commit 032a572

Please sign in to comment.