original_docstring: PS embeddingLookup cache check and process.
docstring: PS embeddingLookup cache check and process.
docstring_tokens: PS embeddingLookup cache check and process .
code: def _process_vocab_cache(self, slice_mode):
          """PS embeddingLookup cache check and process."""
          self.cache_enable = False
          if self.vocab_cache_size > 0:
              if self.target == 'CPU':
                  logger.warning("The configuration of 'vocab_cache_size' is valid only in 'DEVICE' target, "
                                 "current target is CPU, so it will be ignored.")
                  return
              enable_ps = _get_ps_context("enable_ps")
              if not enable_ps:
                  logger.warning("The configuration of 'vocab_cache_size' is valid only in parameter server training "
                                 "mode, current mode is not parameter server trainning mode, so it will be ignored.")
                  return
              parallel_mode = _get_parallel_mode()
              is_auto_parallel = parallel_mode in (ParallelMode.SEMI_AUTO_PARALLEL, ParallelMode.AUTO_PARALLEL)
              if is_auto_parallel:
                  rank_size = get_group_size()
                  rank_id = get_rank()
                  full_batch = _get_full_batch()
                  if rank_size > 1 and not (full_batch and slice_mode == "table_row_slice"):
                      raise ValueError(f"For '{self.cls_name}', the cache of parameter server parallel should only be "
                                       f"used in \"full_batch\" and the value of \"full_batch\" should be True. "
                                       f"Meanwhile, the value of 'slice_mode' should be \"table_row_slice\"."
                                       f"But got full_batch: {full_batch} and 'slice_mode': \"{slice_mode}\".")
                  self.vocab_cache_size = self.vocab_cache_size * rank_size
                  _set_rank_id(rank_id)
              self.cache_enable = True
              if _is_role_worker():
                  self.vocab_size = self.vocab_cache_size
                  if context.get_context("enable_sparse") != self.sparse:
                      raise ValueError(f"For '{self.cls_name}', the value of parameter 'sparse' must be same for all "
                                       f"kernels and equal the value of 'enable_sparse' in context setting in "
                                       f"parameter server cache mode, but got value of parameter 'sparse': {self.sparse}"
                                       f" and the 'enable_sparse' in context setting: "
                                       f"{context.get_context('enable_sparse')}.")
code_tokens: def _process_vocab_cache ( self , slice_mode ) : self . cache_enable = False if self . vocab_cache_size > 0 : if self . target == 'CPU' : logger . warning ( "The configuration of 'vocab_cache_size' is valid only in 'DEVICE' target, " "current target is CPU, so it will be ignored." ) return enable_ps = _get_ps_context ( "enable_ps" ) if not enable_ps : logger . warning ( "The configuration of 'vocab_cache_size' is valid only in parameter server training " "mode, current mode is not parameter server trainning mode, so it will be ignored." ) return parallel_mode = _get_parallel_mode ( ) is_auto_parallel = parallel_mode in ( ParallelMode . SEMI_AUTO_PARALLEL , ParallelMode . AUTO_PARALLEL ) if is_auto_parallel : rank_size = get_group_size ( ) rank_id = get_rank ( ) full_batch = _get_full_batch ( ) if rank_size > 1 and not ( full_batch and slice_mode == "table_row_slice" ) : raise ValueError ( f"For '{self.cls_name}', the cache of parameter server parallel should only be " f"used in \"full_batch\" and the value of \"full_batch\" should be True. " f"Meanwhile, the value of 'slice_mode' should be \"table_row_slice\"." f"But got full_batch: {full_batch} and 'slice_mode': \"{slice_mode}\"." ) self . vocab_cache_size = self . vocab_cache_size * rank_size _set_rank_id ( rank_id ) self . cache_enable = True if _is_role_worker ( ) : self . vocab_size = self . vocab_cache_size if context . get_context ( "enable_sparse" ) != self . sparse : raise ValueError ( f"For '{self.cls_name}', the value of parameter 'sparse' must be same for all " f"kernels and equal the value of 'enable_sparse' in context setting in " f"parameter server cache mode, but got value of parameter 'sparse': {self.sparse}" f" and the 'enable_sparse' in context setting: " f"{context.get_context('enable_sparse')}." )
short_docstring: PS embeddingLookup cache check and process.
short_docstring_tokens: PS embeddingLookup cache check and process .
comment: """PS embeddingLookup cache check and process."""