@@ -138,7 +138,6 @@ class InitializeKvVariableOp : public OpKernel {
138138 &false_positive_probability_));
139139 OP_REQUIRES_OK (c, c->GetAttr (" l2_weight_threshold" ,
140140 &l2_weight_threshold_));
141- OP_REQUIRES_OK (c, c->GetAttr (" layout" , &layout_));
142141 OP_REQUIRES_OK (c, c->GetAttr (" default_value_dim" , &default_value_dim_));
143142 OP_REQUIRES_OK (c, c->GetAttr (" slot_num" , &slot_num_));
144143 OP_REQUIRES_OK (c, c->GetAttr (" record_freq" , &record_freq_));
@@ -156,6 +155,20 @@ class InitializeKvVariableOp : public OpKernel {
156155 filter_freq_ = 0 ;
157156 }
158157
158+ if ((filter_freq_ != 0 && max_element_size_ == 0 )
159+ || steps_to_live_ != 0 || record_freq_
160+ || record_version_ || storage_type > 5 ) {
161+ if (block_num_ > 1 || (filter_freq_ != 0 && storage_type <= 5 )) {
162+ layout_ = " normal" ;
163+ } else {
164+ layout_ = " normal_contiguous" ;
165+ }
166+ } else {
167+ layout_ = " light" ;
168+ }
169+
170+ CHECK (block_num_ == 1 || layout_ != " normal_contiguous" );
171+
159172 if (steps_to_live_ == kEmbeddingVarUseDB ||
160173 steps_to_live_ == kInitializableEmbeddingVarUseDB ) {
161174 LOG (INFO) << " hashmap use db" ;
@@ -199,7 +212,6 @@ class InitializeKvVariableOp : public OpKernel {
199212 std::string opname = handle_self.name ();
200213
201214 EmbeddingVar<TKey, TValue>* ev = nullptr ;
202- CHECK (block_num_ == 1 || layout_ != " normal_contiguous" );
203215
204216 if (handle_self.name () == handle_primary.name () &&
205217 handle_self.container () == handle_primary.container ()) {
@@ -642,7 +654,6 @@ class KvResourceImportV2Op: public AsyncOpKernel {
642654 &false_positive_probability_));
643655 OP_REQUIRES_OK (c, c->GetAttr (" l2_weight_threshold" ,
644656 &l2_weight_threshold_));
645- OP_REQUIRES_OK (c, c->GetAttr (" layout" , &layout_));
646657 OP_REQUIRES_OK (c, c->GetAttr (" max_freq" , &max_freq_));
647658 OP_REQUIRES_OK (c, c->GetAttr (" default_value_dim" ,
648659 &default_value_dim_));
@@ -656,6 +667,20 @@ class KvResourceImportV2Op: public AsyncOpKernel {
656667 OP_REQUIRES_OK (c, c->GetAttr (" record_freq" , &record_freq_));
657668 OP_REQUIRES_OK (c, c->GetAttr (" record_version" , &record_version_));
658669
670+ if ((filter_freq_ != 0 && max_element_size_ == 0 )
671+ || steps_to_live_ != -1 || record_freq_
672+ || record_version_ || storage_type > 5 ) {
673+ if (block_num_ > 1 || (filter_freq_ != 0 && storage_type <= 5 )) {
674+ layout_ = " normal" ;
675+ } else {
676+ layout_ = " normal_contiguous" ;
677+ }
678+ } else {
679+ layout_ = " light" ;
680+ }
681+
682+ CHECK (block_num_ == 1 || layout_ != " normal_contiguous" );
683+
659684 TF_CHECK_OK (ReadBoolFromEnvVar (" TF_ENABLE_EV_ASYNC_RESTORE" , true ,
660685 &ev_async_restore_));
661686 }
0 commit comments