parameters: (default_shapes, min_args, opt_args, max_args)
return_statement: return profiles
docstring: Parses TensorRT profile options from command-line arguments.
  
      Args:
          default_shapes (TensorMetadata): The inference input shapes.
  
      Returns:
       List[Tuple[OrderedDict[str, Shape]]]:
              A list of profiles with each profile comprised of three dictionaries
              (min, opt, max) mapping input names to shapes.
docstring_summary: Parses TensorRT profile options from command-line arguments.
docstring_tokens: Parses TensorRT profile options from command - line arguments .
function: def parse_profile_shapes(default_shapes, min_args, opt_args, max_args):
      """
      Parses TensorRT profile options from command-line arguments.
  
      Args:
          default_shapes (TensorMetadata): The inference input shapes.
  
      Returns:
       List[Tuple[OrderedDict[str, Shape]]]:
              A list of profiles with each profile comprised of three dictionaries
              (min, opt, max) mapping input names to shapes.
      """
  
      def get_shapes(lst, idx):
          nonlocal default_shapes
          default_shapes = copy.copy(default_shapes)
          if idx < len(lst):
              default_shapes.update(args_util.parse_meta(lst[idx], includes_dtype=False))
  
          # Don't care about dtype, and need to override dynamic dimensions
          shapes = {name: util.override_dynamic_shape(shape) for name, (_, shape) in default_shapes.items()}
  
          for name, shape in shapes.items():
              if tuple(default_shapes[name].shape) != tuple(shape):
                  G_LOGGER.warning(
                      "Input tensor: {:} | For TensorRT profile, overriding dynamic shape: {:} to: {:}".format(
                          name, default_shapes[name].shape, shape
                      ),
                      mode=LogMode.ONCE,
                  )
  
          return shapes
  
      num_profiles = max(len(min_args), len(opt_args), len(max_args))
  
      # For cases where input shapes are provided, we have to generate a profile
      if not num_profiles and default_shapes:
          num_profiles = 1
  
      profiles = []
      for idx in range(num_profiles):
          min_shapes = get_shapes(min_args, idx)
          opt_shapes = get_shapes(opt_args, idx)
          max_shapes = get_shapes(max_args, idx)
          if sorted(min_shapes.keys()) != sorted(opt_shapes.keys()):
              G_LOGGER.critical(
                  "Mismatch in input names between minimum shapes ({:}) and optimum shapes "
                  "({:})".format(list(min_shapes.keys()), list(opt_shapes.keys()))
              )
          elif sorted(opt_shapes.keys()) != sorted(max_shapes.keys()):
              G_LOGGER.critical(
                  "Mismatch in input names between optimum shapes ({:}) and maximum shapes "
                  "({:})".format(list(opt_shapes.keys()), list(max_shapes.keys()))
              )
  
          profiles.append((min_shapes, opt_shapes, max_shapes))
      return profiles
function_tokens: def parse_profile_shapes ( default_shapes , min_args , opt_args , max_args ) : def get_shapes ( lst , idx ) : nonlocal default_shapes default_shapes = copy . copy ( default_shapes ) if idx < len ( lst ) : default_shapes . update ( args_util . parse_meta ( lst [ idx ] , includes_dtype = False ) ) # Don't care about dtype, and need to override dynamic dimensions shapes = { name : util . override_dynamic_shape ( shape ) for name , ( _ , shape ) in default_shapes . items ( ) } for name , shape in shapes . items ( ) : if tuple ( default_shapes [ name ] . shape ) != tuple ( shape ) : G_LOGGER . warning ( "Input tensor: {:} | For TensorRT profile, overriding dynamic shape: {:} to: {:}" . format ( name , default_shapes [ name ] . shape , shape ) , mode = LogMode . ONCE , ) return shapes num_profiles = max ( len ( min_args ) , len ( opt_args ) , len ( max_args ) ) # For cases where input shapes are provided, we have to generate a profile if not num_profiles and default_shapes : num_profiles = 1 profiles = [ ] for idx in range ( num_profiles ) : min_shapes = get_shapes ( min_args , idx ) opt_shapes = get_shapes ( opt_args , idx ) max_shapes = get_shapes ( max_args , idx ) if sorted ( min_shapes . keys ( ) ) != sorted ( opt_shapes . keys ( ) ) : G_LOGGER . critical ( "Mismatch in input names between minimum shapes ({:}) and optimum shapes " "({:})" . format ( list ( min_shapes . keys ( ) ) , list ( opt_shapes . keys ( ) ) ) ) elif sorted ( opt_shapes . keys ( ) ) != sorted ( max_shapes . keys ( ) ) : G_LOGGER . critical ( "Mismatch in input names between optimum shapes ({:}) and maximum shapes " "({:})" . format ( list ( opt_shapes . keys ( ) ) , list ( max_shapes . keys ( ) ) ) ) profiles . append ( ( min_shapes , opt_shapes , max_shapes ) ) return profiles