parameters: (self, engine_path)
docstring: :param engine_path: The path to the serialized engine to load from disk.
docstring_summary: :param engine_path: The path to the serialized engine to load from disk.
docstring_tokens: : param engine_path : The path to the serialized engine to load from disk .
function: def __init__(self, engine_path):
          """
          :param engine_path: The path to the serialized engine to load from disk.
          """
          # Load TRT engine
          self.logger = trt.Logger(trt.Logger.ERROR)
          with open(engine_path, "rb") as f, trt.Runtime(self.logger) as runtime:
              self.engine = runtime.deserialize_cuda_engine(f.read())
          self.context = self.engine.create_execution_context()
          assert self.engine
          assert self.context
  
          # Setup I/O bindings
          self.inputs = []
          self.outputs = []
          self.allocations = []
          for i in range(self.engine.num_bindings):
              is_input = False
              if self.engine.binding_is_input(i):
                  is_input = True
              name = self.engine.get_binding_name(i)
              dtype = self.engine.get_binding_dtype(i)
              shape = self.engine.get_binding_shape(i)
              if is_input:
                  self.batch_size = shape[0]
              size = np.dtype(trt.nptype(dtype)).itemsize
              for s in shape:
                  size *= s
              allocation = cuda.mem_alloc(size)
              binding = {
                  'index': i,
                  'name': name,
                  'dtype': np.dtype(trt.nptype(dtype)),
                  'shape': list(shape),
                  'allocation': allocation,
              }
              self.allocations.append(allocation)
              if self.engine.binding_is_input(i):
                  self.inputs.append(binding)
              else:
                  self.outputs.append(binding)
  
          assert self.batch_size > 0
          assert len(self.inputs) > 0
          assert len(self.outputs) > 0
          assert len(self.allocations) > 0
function_tokens: def __init__ ( self , engine_path ) : # Load TRT engine self . logger = trt . Logger ( trt . Logger . ERROR ) with open ( engine_path , "rb" ) as f , trt . Runtime ( self . logger ) as runtime : self . engine = runtime . deserialize_cuda_engine ( f . read ( ) ) self . context = self . engine . create_execution_context ( ) assert self . engine assert self . context # Setup I/O bindings self . inputs = [ ] self . outputs = [ ] self . allocations = [ ] for i in range ( self . engine . num_bindings ) : is_input = False if self . engine . binding_is_input ( i ) : is_input = True name = self . engine . get_binding_name ( i ) dtype = self . engine . get_binding_dtype ( i ) shape = self . engine . get_binding_shape ( i ) if is_input : self . batch_size = shape [ 0 ] size = np . dtype ( trt . nptype ( dtype ) ) . itemsize for s in shape : size *= s allocation = cuda . mem_alloc ( size ) binding = { 'index' : i , 'name' : name , 'dtype' : np . dtype ( trt . nptype ( dtype ) ) , 'shape' : list ( shape ) , 'allocation' : allocation , } self . allocations . append ( allocation ) if self . engine . binding_is_input ( i ) : self . inputs . append ( binding ) else : self . outputs . append ( binding ) assert self . batch_size > 0 assert len ( self . inputs ) > 0 assert len ( self . outputs ) > 0 assert len ( self . allocations ) > 0