parameters: (
      network: TRTNetwork,
      tensor: TRTTensor,
      name: str,
      num_prepend_ones: int,
  )
return_statement: return layer.get_output(0)
docstring: Prepend 1s to the shape of TensorRT ITensor `tensor`.
  
      Args:
          network (TRTNetwork): The TensorRT network that `tensor`
              belongs to.
          tensor (TRTTensor): A TensorRT tensor.
          name (str): Name of the TensorRT Shuffle layer which is used to prepend
              1s.
          num_prepend_ones (int): Number of 1s that will be prepend.
  
      Returns:
          A Tensorrt ITensor which contains the same value as `tensor` but with
          more 1s prepended to the beginning of `tensor` shape.
docstring_summary: Prepend 1s to the shape of TensorRT ITensor `tensor`.
docstring_tokens: Prepend 1s to the shape of TensorRT ITensor tensor .
function: def prepend_ones(
      network: TRTNetwork,
      tensor: TRTTensor,
      name: str,
      num_prepend_ones: int,
  ) -> TRTTensor:
      """
      Prepend 1s to the shape of TensorRT ITensor `tensor`.
  
      Args:
          network (TRTNetwork): The TensorRT network that `tensor`
              belongs to.
          tensor (TRTTensor): A TensorRT tensor.
          name (str): Name of the TensorRT Shuffle layer which is used to prepend
              1s.
          num_prepend_ones (int): Number of 1s that will be prepend.
  
      Returns:
          A Tensorrt ITensor which contains the same value as `tensor` but with
          more 1s prepended to the beginning of `tensor` shape.
      """
      layer = network.add_shuffle(tensor)
  
      # If there're dynamic dim in tensor's shape, we need to use shape layer to
      # compute the final shape.
      if has_dynamic_shape(tensor.shape):
          tensor_shape_layer = network.add_shape(tensor)
          tensor_shape_layer.name = f"{name}_broadcast_orig_shape"
          prepend_shape_layer = network.add_constant(
              (num_prepend_ones,), np.ones((num_prepend_ones,), dtype=np.int32)
          )
          prepend_shape_layer.name = f"{name}_broadcast_prepend_ones"
          reshape_dim_layer = network.add_concatenation(
              [prepend_shape_layer.get_output(0), tensor_shape_layer.get_output(0)]
          )
          reshape_dim_layer.axis = 0
          reshape_dim_layer.name = f"{name}_broadcast_final_shape"
          layer.set_input(1, reshape_dim_layer.get_output(0))
      else:
          layer.reshape_dims = (1,) * num_prepend_ones + tuple(tensor.shape)
  
      layer.name = name
      return layer.get_output(0)
function_tokens: def prepend_ones ( network : TRTNetwork , tensor : TRTTensor , name : str , num_prepend_ones : int , ) -> TRTTensor : layer = network . add_shuffle ( tensor ) # If there're dynamic dim in tensor's shape, we need to use shape layer to # compute the final shape. if has_dynamic_shape ( tensor . shape ) : tensor_shape_layer = network . add_shape ( tensor ) tensor_shape_layer . name = f"{name}_broadcast_orig_shape" prepend_shape_layer = network . add_constant ( ( num_prepend_ones , ) , np . ones ( ( num_prepend_ones , ) , dtype = np . int32 ) ) prepend_shape_layer . name = f"{name}_broadcast_prepend_ones" reshape_dim_layer = network . add_concatenation ( [ prepend_shape_layer . get_output ( 0 ) , tensor_shape_layer . get_output ( 0 ) ] ) reshape_dim_layer . axis = 0 reshape_dim_layer . name = f"{name}_broadcast_final_shape" layer . set_input ( 1 , reshape_dim_layer . get_output ( 0 ) ) else : layer . reshape_dims = ( 1 , ) * num_prepend_ones + tuple ( tensor . shape ) layer . name = name return layer . get_output ( 0 )