Skip to content

Commit

Permalink
[GPU]optimize id() and get_kernel_name() by returning reference to co…
Browse files Browse the repository at this point in the history
…nst (#25352)

### Details:
- *[GPU]optimize id() and get_kernel_name() by returning reference to
const*

### Tickets:
 - *144417*
  • Loading branch information
ceciliapeng2011 authored Jul 3, 2024
1 parent 3640357 commit b5a66b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/plugins/intel_gpu/src/graph/include/primitive_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct primitive_impl {
virtual void set_arguments(primitive_inst& instance) = 0;
virtual void set_arguments(primitive_inst& instance, kernel_arguments_data& args) = 0;
virtual event::ptr execute(const std::vector<event::ptr>& events, primitive_inst& instance) = 0;
std::string get_kernel_name() const { return _kernel_name; }
const std::string& get_kernel_name() const { return _kernel_name; }

// class typed_primitive_gpu_impl override this with return false;
virtual bool is_cpu() const { return true; }
Expand Down Expand Up @@ -166,8 +166,8 @@ class primitive_inst {
return true;
}
primitive_type_id type() const { return _type; }
primitive_id id() const { return _id; }
primitive_id org_id() const { return _org_id; }
const primitive_id& id() const { return _id; }
const primitive_id& org_id() const { return _org_id; }
bool can_be_optimized() const { return _can_be_optimized; }
void set_can_be_optimized(bool optimized) {
// TODO: consolidate to _impl_param in the future
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/intel_gpu/src/graph/primitive_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ event::ptr primitive_inst::realloc_if_needed() {
auto dt_size = ov::element::Type(actual_layout.data_type).bitwidth();
// read_value/assign nodes are supposed to always use variable memory
if (auto stateful_prim = dynamic_cast<memory_state::variable*>(this)) {
std::string variable_id = stateful_prim->variable_id();
auto& variable_id = stateful_prim->variable_id();
auto& variable = get_network().get_variable(variable_id);
if (_node->is_type<kv_cache>()) {
// Reuse state memory as output for kv cache if possible
Expand Down Expand Up @@ -1354,7 +1354,7 @@ bool primitive_inst::has_inner_networks() const {

event::ptr primitive_inst::execute(const std::vector<event::ptr>& events) {
OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("primitive_inst::execute: " + id()));
const auto primitive_id = id();
const auto& primitive_id = id();
OPENVINO_ASSERT(_has_valid_input, primitive_id, " has invalid/unset input");
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_TRACE_DETAIL << "-----------------------------------------------------------------" << std::endl;
Expand Down Expand Up @@ -1497,7 +1497,7 @@ event::ptr primitive_inst::execute(const std::vector<event::ptr>& events) {
if (out_of_order_queue || (_impl->is_cpu() && !can_be_optimized()) || (can_be_optimized() && needs_completion_event() && !is_output())) {
dependencies.reserve(dependencies.size() + _exec_deps.size());
for (auto& input : _exec_deps) {
auto id = input->id();
auto& id = input->id();
try {
// if the requested event does not exists it means that it has not been executed, so the processing_order is
// wrong or synchronization failed.
Expand Down

0 comments on commit b5a66b0

Please sign in to comment.