diff --git a/src/graph/backend/dnnl/common.cpp b/src/graph/backend/dnnl/common.cpp index e678de34098..f4e33655578 100644 --- a/src/graph/backend/dnnl/common.cpp +++ b/src/graph/backend/dnnl/common.cpp @@ -646,7 +646,7 @@ dnnl::memory::format_tag get_format_tag(const dnnl::memory::desc &md) { return format_tag; } -size_t generate_constant_cache_key( +size_t generate_constant_md_hash( size_t part_id, const std::vector &const_mds) { size_t key = 0; key = hash_combine(key, part_id); diff --git a/src/graph/backend/dnnl/common.hpp b/src/graph/backend/dnnl/common.hpp index f53450bb373..5f3ad3634f7 100644 --- a/src/graph/backend/dnnl/common.hpp +++ b/src/graph/backend/dnnl/common.hpp @@ -141,7 +141,7 @@ std::string get_format_tag_str(const dnnl::memory::desc &md); dnnl::memory::format_tag get_format_tag(const dnnl::memory::desc &md); -size_t generate_constant_cache_key( +size_t generate_constant_md_hash( size_t part_id, const std::vector &const_mds); #ifndef NDEBUG diff --git a/src/graph/backend/dnnl/kernels/batch_norm.cpp b/src/graph/backend/dnnl/kernels/batch_norm.cpp index eb9aadc54ef..48afa45df65 100644 --- a/src/graph/backend/dnnl/kernels/batch_norm.cpp +++ b/src/graph/backend/dnnl/kernels/batch_norm.cpp @@ -109,7 +109,7 @@ status_t batch_norm_fwd_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -135,7 +135,8 @@ status_t batch_norm_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -205,7 +206,8 @@ status_t batch_norm_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -281,7 +283,8 @@ status_t batch_norm_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/batch_norm.hpp b/src/graph/backend/dnnl/kernels/batch_norm.hpp index 258487b796b..3abfd6f438b 100644 --- a/src/graph/backend/dnnl/kernels/batch_norm.hpp +++ b/src/graph/backend/dnnl/kernels/batch_norm.hpp @@ -46,7 +46,7 @@ struct batch_norm_fwd_t : public kernel_base_t { memory_planner_t memory_planner_; std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: batch_norm_fwd_t() { diff --git a/src/graph/backend/dnnl/kernels/conv.cpp b/src/graph/backend/dnnl/kernels/conv.cpp index 60dd968f42b..685e0fa83fa 100644 --- a/src/graph/backend/dnnl/kernels/conv.cpp +++ b/src/graph/backend/dnnl/kernels/conv.cpp @@ -134,7 +134,7 @@ status_t conv_fwd_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -202,7 +202,7 @@ status_t conv_bwd_data_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; diff --git a/src/graph/backend/dnnl/kernels/conv_base.cpp b/src/graph/backend/dnnl/kernels/conv_base.cpp index 256e1426471..280f5974949 100644 --- a/src/graph/backend/dnnl/kernels/conv_base.cpp +++ b/src/graph/backend/dnnl/kernels/conv_base.cpp @@ -63,7 +63,8 @@ status_t conv_base_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -133,7 +134,8 @@ status_t conv_base_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -209,7 +211,8 @@ status_t conv_base_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/conv_base.hpp b/src/graph/backend/dnnl/kernels/conv_base.hpp index 877ac5604b2..08728d63e44 100644 --- a/src/graph/backend/dnnl/kernels/conv_base.hpp +++ b/src/graph/backend/dnnl/kernels/conv_base.hpp @@ -47,7 +47,7 @@ struct conv_base_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: conv_base_t() { diff --git a/src/graph/backend/dnnl/kernels/conv_transpose.cpp b/src/graph/backend/dnnl/kernels/conv_transpose.cpp index 330e22b8050..425990556e0 100644 --- a/src/graph/backend/dnnl/kernels/conv_transpose.cpp +++ b/src/graph/backend/dnnl/kernels/conv_transpose.cpp @@ -114,7 +114,7 @@ status_t conv_transpose_fwd_t::compile_impl( return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -183,7 +183,7 @@ status_t conv_transpose_bwd_data_t::compile_impl( return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; diff --git a/src/graph/backend/dnnl/kernels/eltwise.cpp b/src/graph/backend/dnnl/kernels/eltwise.cpp index e8abe4a368c..72ede8ca406 100644 --- a/src/graph/backend/dnnl/kernels/eltwise.cpp +++ b/src/graph/backend/dnnl/kernels/eltwise.cpp @@ -91,7 +91,7 @@ status_t eltwise_fwd_t::compile_impl( return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -138,7 +138,8 @@ status_t eltwise_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -209,7 +210,8 @@ status_t eltwise_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -286,7 +288,8 @@ status_t eltwise_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/eltwise.hpp b/src/graph/backend/dnnl/kernels/eltwise.hpp index 537ac67805e..cc1b318ab38 100644 --- a/src/graph/backend/dnnl/kernels/eltwise.hpp +++ b/src/graph/backend/dnnl/kernels/eltwise.hpp @@ -49,7 +49,7 @@ struct eltwise_fwd_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: eltwise_fwd_t() { diff --git a/src/graph/backend/dnnl/kernels/group_norm.cpp b/src/graph/backend/dnnl/kernels/group_norm.cpp index 2b11861c1e4..4b39f7500ee 100644 --- a/src/graph/backend/dnnl/kernels/group_norm.cpp +++ b/src/graph/backend/dnnl/kernels/group_norm.cpp @@ -97,7 +97,7 @@ status_t group_norm_fwd_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -143,7 +143,8 @@ status_t group_norm_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -213,7 +214,8 @@ status_t group_norm_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -289,7 +291,8 @@ status_t group_norm_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/group_norm.hpp b/src/graph/backend/dnnl/kernels/group_norm.hpp index e4c2192b9f0..ab571415201 100644 --- a/src/graph/backend/dnnl/kernels/group_norm.hpp +++ b/src/graph/backend/dnnl/kernels/group_norm.hpp @@ -48,7 +48,7 @@ struct group_norm_fwd_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: group_norm_fwd_t() { diff --git a/src/graph/backend/dnnl/kernels/kernel_base.cpp b/src/graph/backend/dnnl/kernels/kernel_base.cpp index 798ddaebaa3..cfb5b2f50b1 100644 --- a/src/graph/backend/dnnl/kernels/kernel_base.cpp +++ b/src/graph/backend/dnnl/kernels/kernel_base.cpp @@ -48,14 +48,9 @@ size_t kernel_base_t::encode_constant_cache_key( // Encode the constant memory address into cache key for differentiation size_t encoded_cache_key = cache_key; for (const auto &in : inputs) { - if (in.get_logical_tensor().property - == dnnl_graph_tensor_property_t:: - dnnl_graph_tensor_property_constant) { - auto data_handle = in.get_data_handle(); - if (data_handle != nullptr) { - encoded_cache_key = hash_combine(encoded_cache_key, - reinterpret_cast(data_handle)); - } + if (logical_tensor_wrapper_t(in.get_logical_tensor()).is_constant()) { + encoded_cache_key = hash_combine(encoded_cache_key, + reinterpret_cast(in.get_data_handle())); } } return encoded_cache_key; diff --git a/src/graph/backend/dnnl/kernels/large_partition.cpp b/src/graph/backend/dnnl/kernels/large_partition.cpp index a8d8393ac42..e60234882c3 100644 --- a/src/graph/backend/dnnl/kernels/large_partition.cpp +++ b/src/graph/backend/dnnl/kernels/large_partition.cpp @@ -222,7 +222,7 @@ status_t larger_partition_kernel_t::compile_impl( return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -248,7 +248,8 @@ status_t larger_partition_kernel_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -317,7 +318,8 @@ status_t larger_partition_kernel_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -391,7 +393,8 @@ status_t larger_partition_kernel_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/large_partition.hpp b/src/graph/backend/dnnl/kernels/large_partition.hpp index b6fc59d63a7..dc3a903945e 100644 --- a/src/graph/backend/dnnl/kernels/large_partition.hpp +++ b/src/graph/backend/dnnl/kernels/large_partition.hpp @@ -48,7 +48,7 @@ class larger_partition_kernel_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; std::once_flag once_flag_; subgraph_visualizer_t vis_; diff --git a/src/graph/backend/dnnl/kernels/layer_norm.cpp b/src/graph/backend/dnnl/kernels/layer_norm.cpp index f7a4d084987..9b7c234ad20 100644 --- a/src/graph/backend/dnnl/kernels/layer_norm.cpp +++ b/src/graph/backend/dnnl/kernels/layer_norm.cpp @@ -94,7 +94,7 @@ status_t layer_norm_fwd_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -140,7 +140,8 @@ status_t layer_norm_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -210,7 +211,8 @@ status_t layer_norm_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -286,7 +288,8 @@ status_t layer_norm_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/layer_norm.hpp b/src/graph/backend/dnnl/kernels/layer_norm.hpp index 7d104117b7f..169c1e54022 100644 --- a/src/graph/backend/dnnl/kernels/layer_norm.hpp +++ b/src/graph/backend/dnnl/kernels/layer_norm.hpp @@ -48,7 +48,7 @@ struct layer_norm_fwd_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: layer_norm_fwd_t() { diff --git a/src/graph/backend/dnnl/kernels/matmul.cpp b/src/graph/backend/dnnl/kernels/matmul.cpp index 80146cdbc96..c0583359cde 100644 --- a/src/graph/backend/dnnl/kernels/matmul.cpp +++ b/src/graph/backend/dnnl/kernels/matmul.cpp @@ -145,7 +145,7 @@ status_t matmul_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -193,7 +193,8 @@ status_t matmul_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -264,7 +265,8 @@ status_t matmul_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -341,7 +343,8 @@ status_t matmul_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/matmul.hpp b/src/graph/backend/dnnl/kernels/matmul.hpp index a88f71bcf60..9a3d6be11b2 100644 --- a/src/graph/backend/dnnl/kernels/matmul.hpp +++ b/src/graph/backend/dnnl/kernels/matmul.hpp @@ -49,7 +49,7 @@ struct matmul_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: matmul_t() { diff --git a/src/graph/backend/dnnl/kernels/pool.cpp b/src/graph/backend/dnnl/kernels/pool.cpp index 9703ffe0495..3db019e97f5 100644 --- a/src/graph/backend/dnnl/kernels/pool.cpp +++ b/src/graph/backend/dnnl/kernels/pool.cpp @@ -122,7 +122,7 @@ status_t pooling_fwd_t::compile_impl( return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -170,7 +170,8 @@ status_t pooling_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -241,7 +242,8 @@ status_t pooling_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -318,7 +320,8 @@ status_t pooling_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/pool.hpp b/src/graph/backend/dnnl/kernels/pool.hpp index 7a58f51d75d..57884e7394e 100644 --- a/src/graph/backend/dnnl/kernels/pool.hpp +++ b/src/graph/backend/dnnl/kernels/pool.hpp @@ -49,7 +49,7 @@ struct pooling_fwd_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: pooling_fwd_t() { diff --git a/src/graph/backend/dnnl/kernels/quantize.cpp b/src/graph/backend/dnnl/kernels/quantize.cpp index 31388ef5d10..fbc90bb73fa 100644 --- a/src/graph/backend/dnnl/kernels/quantize.cpp +++ b/src/graph/backend/dnnl/kernels/quantize.cpp @@ -88,7 +88,7 @@ status_t quantize_dequantize_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -134,7 +134,8 @@ status_t quantize_dequantize_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -209,7 +210,8 @@ status_t quantize_dequantize_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -285,7 +287,8 @@ status_t quantize_dequantize_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/quantize.hpp b/src/graph/backend/dnnl/kernels/quantize.hpp index 5c434a111af..369b197af88 100644 --- a/src/graph/backend/dnnl/kernels/quantize.hpp +++ b/src/graph/backend/dnnl/kernels/quantize.hpp @@ -46,7 +46,7 @@ struct quantize_dequantize_t : public kernel_base_t { memory_planner_t memory_planner_; std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: quantize_dequantize_t() { diff --git a/src/graph/backend/dnnl/kernels/reorder.cpp b/src/graph/backend/dnnl/kernels/reorder.cpp index b4f38f8376c..e513ab7be9e 100644 --- a/src/graph/backend/dnnl/kernels/reorder.cpp +++ b/src/graph/backend/dnnl/kernels/reorder.cpp @@ -105,7 +105,7 @@ status_t reorder_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -153,7 +153,8 @@ status_t reorder_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -224,7 +225,8 @@ status_t reorder_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -301,7 +303,8 @@ status_t reorder_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/reorder.hpp b/src/graph/backend/dnnl/kernels/reorder.hpp index a4e3e16408b..9993c5458fe 100644 --- a/src/graph/backend/dnnl/kernels/reorder.hpp +++ b/src/graph/backend/dnnl/kernels/reorder.hpp @@ -49,7 +49,7 @@ struct reorder_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: reorder_t() { diff --git a/src/graph/backend/dnnl/kernels/select.cpp b/src/graph/backend/dnnl/kernels/select.cpp index 3cbb75f2aff..9990937d9ba 100644 --- a/src/graph/backend/dnnl/kernels/select.cpp +++ b/src/graph/backend/dnnl/kernels/select.cpp @@ -88,7 +88,7 @@ status_t select_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -134,7 +134,8 @@ status_t select_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -204,7 +205,8 @@ status_t select_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -280,7 +282,8 @@ status_t select_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/select.hpp b/src/graph/backend/dnnl/kernels/select.hpp index 58c9ef6abe6..fc4259bd28f 100644 --- a/src/graph/backend/dnnl/kernels/select.hpp +++ b/src/graph/backend/dnnl/kernels/select.hpp @@ -48,7 +48,7 @@ struct select_t : public kernel_base_t { std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: select_t() { diff --git a/src/graph/backend/dnnl/kernels/softmax.cpp b/src/graph/backend/dnnl/kernels/softmax.cpp index 1474f6abac9..d2600dd14bd 100644 --- a/src/graph/backend/dnnl/kernels/softmax.cpp +++ b/src/graph/backend/dnnl/kernels/softmax.cpp @@ -91,7 +91,7 @@ status_t softmax_fwd_t::compile_impl(const dnnl_partition_impl_t *part, return this->memory_planner_.get_exec_args_set().clone(); }; - constant_key_ = generate_constant_cache_key(part->id(), + const_md_hash_ = generate_constant_md_hash(part->id(), memory_planner_.get_exec_args_set().get_persistent_mem_desc_list()); return status::success; @@ -137,7 +137,8 @@ status_t softmax_fwd_t::execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -207,7 +208,8 @@ status_t softmax_fwd_t::sycl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, @@ -283,7 +285,8 @@ status_t softmax_fwd_t::ocl_execute_impl(const stream_t *g_stream, constant_cache_t::cached_t c_buffer; if (enabled_constant_cache()) { - size_t encoded_key = encode_constant_cache_key(inputs, constant_key_); + const size_t encoded_key + = encode_constant_cache_key(inputs, const_md_hash_); std::promise c_promise; constant_cache_t::value_t cached_value = dnnl_constant_cache_get_or_add(p_engine_, encoded_key, diff --git a/src/graph/backend/dnnl/kernels/softmax.hpp b/src/graph/backend/dnnl/kernels/softmax.hpp index 72de9943455..d80f88fba9d 100644 --- a/src/graph/backend/dnnl/kernels/softmax.hpp +++ b/src/graph/backend/dnnl/kernels/softmax.hpp @@ -46,7 +46,7 @@ struct softmax_fwd_t : public kernel_base_t { memory_planner_t memory_planner_; std::function()> resource_ctor_; - constant_cache_t::key_t constant_key_ = 0; + size_t const_md_hash_ = 0; public: softmax_fwd_t() {