diff --git a/tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_cpu.h b/tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_cpu.h index 82bc90d09..bc64d71da 100644 --- a/tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_cpu.h +++ b/tensorflow_recommenders_addons/dynamic_embedding/core/kernels/lookup_impl/lookup_table_op_cpu.h @@ -311,14 +311,10 @@ class TableWrapperOptimized final : public TableWrapperBase { while (i < file_size) { TF_RETURN_IF_ERROR(reader.ReadNBytes(record_len, &content)); - K k; - std::memcpy(&k, reinterpret_cast(content.data()), sizeof(K)); - - ValueType value_vec; - std::memcpy(value_vec.data(), - reinterpret_cast(content.data()) + sizeof(K), - value_len); - table_->insert_or_assign(k, value_vec); + K* k = reinterpret_cast(content.data()); + ValueType* value_vec = + reinterpret_cast(content.data() + sizeof(K)); + table_->insert_or_assign(*k, *value_vec); i += record_len; } return Status::OK();