| 229 | |
| 230 | |
| 231 | class TensorRTConfig: |
| 232 | def __init__( |
| 233 | self, |
| 234 | inputs: list, |
| 235 | min_subgraph_size: int | None = 3, |
| 236 | save_model_dir: str | None = None, |
| 237 | disable_ops: str | list | None = None, |
| 238 | precision_mode: PrecisionMode = PrecisionMode.FP32, |
| 239 | ops_run_float: str | list | None = None, |
| 240 | optimization_level: int | None = 3, |
| 241 | disable_passes: list = [], |
| 242 | workspace_size: int | None = 1 << 30, |
| 243 | use_cuda_graph: bool | None = False, |
| 244 | refit_params_path: str | None = None, |
| 245 | disable_logging: bool | None = True, |
| 246 | ) -> None: |
| 247 | """ |
| 248 | A class for configuring TensorRT optimizations. |
| 249 | |
| 250 | Args: |
| 251 | inputs (list): |
| 252 | A list of Input configurations |
| 253 | min_subgraph_size (int, optional): |
| 254 | The minimum number of operations in a subgraph for TensorRT to optimize (default is 3). |
| 255 | save_model_dir (str, optional): |
| 256 | The directory where the optimized model will be saved (default is not to save). |
| 257 | disable_ops : (str|list, optional): |
| 258 | A string representing the names of operations that should not be entering by TensorRT (default is None). |
| 259 | precision_mode (PrecisionMode, optional): |
| 260 | Specifies the precision mode for TensorRT optimization. The options are: |
| 261 | - PrecisionMode.FP32: 32-bit floating point precision (default). |
| 262 | - PrecisionMode.FP16: 16-bit floating point precision. |
| 263 | - PrecisionMode.INT8: 8-bit integer precision. |
| 264 | - PrecisionMode.BF16: 16-bit Brain Floating Point precision. Only supported in TensorRT versions greater than 9.0. |
| 265 | ops_run_float (str|list, optional): |
| 266 | A set of operation names that should be executed using FP32 precision regardless of the `tensorrt_precision_mode` setting. |
| 267 | optimization_level (int, optional): |
| 268 | Set TensorRT optimization level (default is 3). Only supported in TensorRT versions greater than 8.6. |
| 269 | disable_passes : (str|list, optional): |
| 270 | A list of string representing the names of pass that should not be used for origin program (default is []). |
| 271 | workspace_size (int, optional): |
| 272 | Specifies the maximum GPU memory (in bytes) that TensorRT can use for the optimization process (default is 1 << 30). |
| 273 | use_cuda_graph (bool, optional): |
| 274 | Specify whether TensorRT enables cuda_graph during the optimization process (default is false). |
| 275 | refit_params_path(str, optional): |
| 276 | The path to the weights that need to be refitted. |
| 277 | disable_logging (bool, optional): |
| 278 | Specifies whether to enable GLOG info output during the optimization process (default is true). |
| 279 | Returns: |
| 280 | None |
| 281 | |
| 282 | Examples: |
| 283 | .. code-block:: pycon |
| 284 | |
| 285 | >>> # example 1: |
| 286 | >>> from paddle.tensorrt.export import ( |
| 287 | >>> Input, |
| 288 | >>> TensorRTConfig, |
no outgoing calls