parameters: (self, batch_size, sequence_length)
return_statement: return selected_profile_idx
docstring: Provided helper function to obtain a profile optimization.
docstring_summary: Provided helper function to obtain a profile optimization.
docstring_tokens: Provided helper function to obtain a profile optimization .
function: def get_optimization_profile(self, batch_size, sequence_length):
          """Provided helper function to obtain a profile optimization."""
          # Select an optimization profile
          # inspired by demo/BERT/inference.py script
          selected_profile_idx = None
          for idx in range(self.trt_engine.num_optimization_profiles):
              profile_shape = self.trt_engine.get_profile_shape(profile_index=idx, binding=idx * self._num_bindings_per_profile)
  
              if profile_shape[0][0] <= batch_size and profile_shape[2][0] >= batch_size \
                 and profile_shape[0][1] <=  sequence_length and profile_shape[2][1] >= sequence_length:
                  G_LOGGER.debug("Selected profile: {}".format(profile_shape))
                  selected_profile_idx = idx
                  break
  
          if selected_profile_idx == -1:
              raise RuntimeError("Could not find any profile that matches batch_size={}, sequence_length={}".format(batch_size, sequence_length))
  
          return selected_profile_idx
function_tokens: def get_optimization_profile ( self , batch_size , sequence_length ) : # Select an optimization profile # inspired by demo/BERT/inference.py script selected_profile_idx = None for idx in range ( self . trt_engine . num_optimization_profiles ) : profile_shape = self . trt_engine . get_profile_shape ( profile_index = idx , binding = idx * self . _num_bindings_per_profile ) if profile_shape [ 0 ] [ 0 ] <= batch_size and profile_shape [ 2 ] [ 0 ] >= batch_size and profile_shape [ 0 ] [ 1 ] <= sequence_length and profile_shape [ 2 ] [ 1 ] >= sequence_length : G_LOGGER . debug ( "Selected profile: {}" . format ( profile_shape ) ) selected_profile_idx = idx break if selected_profile_idx == - 1 : raise RuntimeError ( "Could not find any profile that matches batch_size={}, sequence_length={}" . format ( batch_size , sequence_length ) ) return selected_profile_idx