Skip to content

Commit b5a66b0

Browse files
[GPU]optimize id() and get_kernel_name() by returning reference to const (#25352)
### Details: - *[GPU]optimize id() and get_kernel_name() by returning reference to const* ### Tickets: - *144417*
1 parent 3640357 commit b5a66b0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/plugins/intel_gpu/src/graph/include/primitive_inst.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct primitive_impl {
5858
virtual void set_arguments(primitive_inst& instance) = 0;
5959
virtual void set_arguments(primitive_inst& instance, kernel_arguments_data& args) = 0;
6060
virtual event::ptr execute(const std::vector<event::ptr>& events, primitive_inst& instance) = 0;
61-
std::string get_kernel_name() const { return _kernel_name; }
61+
const std::string& get_kernel_name() const { return _kernel_name; }
6262

6363
// class typed_primitive_gpu_impl override this with return false;
6464
virtual bool is_cpu() const { return true; }
@@ -166,8 +166,8 @@ class primitive_inst {
166166
return true;
167167
}
168168
primitive_type_id type() const { return _type; }
169-
primitive_id id() const { return _id; }
170-
primitive_id org_id() const { return _org_id; }
169+
const primitive_id& id() const { return _id; }
170+
const primitive_id& org_id() const { return _org_id; }
171171
bool can_be_optimized() const { return _can_be_optimized; }
172172
void set_can_be_optimized(bool optimized) {
173173
// TODO: consolidate to _impl_param in the future

src/plugins/intel_gpu/src/graph/primitive_inst.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ event::ptr primitive_inst::realloc_if_needed() {
525525
auto dt_size = ov::element::Type(actual_layout.data_type).bitwidth();
526526
// read_value/assign nodes are supposed to always use variable memory
527527
if (auto stateful_prim = dynamic_cast<memory_state::variable*>(this)) {
528-
std::string variable_id = stateful_prim->variable_id();
528+
auto& variable_id = stateful_prim->variable_id();
529529
auto& variable = get_network().get_variable(variable_id);
530530
if (_node->is_type<kv_cache>()) {
531531
// Reuse state memory as output for kv cache if possible
@@ -1354,7 +1354,7 @@ bool primitive_inst::has_inner_networks() const {
13541354

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

0 commit comments

Comments
 (0)