parameters: (self, input_dict: Dict[str, np.ndarray], output_dict: Dict[str, np.ndarray])
return_statement: return bindings
docstring: Helper function for binding several inputs at once and pre-allocating the results.
docstring_summary: Helper function for binding several inputs at once and pre-allocating the results.
docstring_tokens: Helper function for binding several inputs at once and pre - allocating the results .
function: def _allocate_memory(self, input_dict: Dict[str, np.ndarray], output_dict: Dict[str, np.ndarray]):
          """Helper function for binding several inputs at once and pre-allocating the results."""
          bindings = [None] * self.trt_engine.num_bindings
  
          for input_name, input_array in input_dict.items():
              # Allocate memory for inputs
              input_idx = self.trt_engine.get_binding_index(input_name)
              self.trt_context.set_binding_shape(input_idx, input_array.shape)
              bindings[input_idx] = input_array.data_ptr()
  
          assert self.trt_context.all_binding_shapes_specified
  
          for output_name, output_array in output_dict.items():
              # Output shape should be allocated from context size
              output_idx = self.trt_engine.get_binding_index(output_name)
              bindings[output_idx] = output_array.data_ptr()
  
          return bindings
function_tokens: def _allocate_memory ( self , input_dict : Dict [ str , np . ndarray ] , output_dict : Dict [ str , np . ndarray ] ) : bindings = [ None ] * self . trt_engine . num_bindings for input_name , input_array in input_dict . items ( ) : # Allocate memory for inputs input_idx = self . trt_engine . get_binding_index ( input_name ) self . trt_context . set_binding_shape ( input_idx , input_array . shape ) bindings [ input_idx ] = input_array . data_ptr ( ) assert self . trt_context . all_binding_shapes_specified for output_name , output_array in output_dict . items ( ) : # Output shape should be allocated from context size output_idx = self . trt_engine . get_binding_index ( output_name ) bindings [ output_idx ] = output_array . data_ptr ( ) return bindings