When the functional APIs need to create local numpy array and use as weights for constant or other layers, they need to register the ndarray objects to the TRT-LLM Network to prolong the lifetime of the ndarray, such that weights are still valid when functional API returned.
(self, ndarray: np.ndarray)
| 299 | layer.metadata = layer.name |
| 300 | |
| 301 | def register_ndarray(self, ndarray: np.ndarray) -> None: |
| 302 | ''' When the functional APIs need to create local numpy array and use as weights for constant or other layers, |
| 303 | they need to register the ndarray objects to the TRT-LLM Network to prolong the lifetime of the ndarray, such that weights are |
| 304 | still valid when functional API returned. |
| 305 | All the weights referenced by the trt Network are weak referenced, it's TRT-LLM's responsibility to keep the weights alive |
| 306 | during the TRT network construction and TRT engine building process. |
| 307 | ''' |
| 308 | self._registered_ndarrays.append(ndarray) |
| 309 | |
| 310 | def _generate_optimization_profiles(self) -> List[trt.IOptimizationProfile]: |
| 311 | input_tensors = self._inputs |
no test coverage detected