PyTorch
model_navigator.torch
Torch optimize API.
optimize
optimize(model, dataloader, sample_count=DEFAULT_SAMPLE_COUNT, batching=True, input_names=None, output_names=None, target_formats=None, target_device=DeviceKind.CUDA, runners=None, optimization_profile=None, workspace=None, verbose=False, debug=False, verify_func=None, custom_configs=None)
Entrypoint for Torch optimize.
Perform export, conversion, correctness testing, profiling and model verification.
Parameters:
-
model
(Module
) –PyTorch model object
-
dataloader
(SizedDataLoader
) –Sized iterable with data that will be feed to the model
-
sample_count
(Optional[int]
, default:DEFAULT_SAMPLE_COUNT
) –Limits how many samples will be used from dataloader
-
batching
(Optional[bool]
, default:True
) –Enable or disable batching on first (index 0) dimension of the model
-
input_names
(Optional[Tuple[str, ...]]
, default:None
) –Model input names
-
output_names
(Optional[Tuple[str, ...]]
, default:None
) –Model output names
-
target_formats
(Optional[Tuple[Union[str, Format], ...]]
, default:None
) –Target model formats for optimize process
-
target_device
(Optional[DeviceKind]
, default:CUDA
) –Target device for optimize process, default is CUDA
-
runners
(Optional[Tuple[Union[str, Type[NavigatorRunner]], ...]]
, default:None
) –Use only runners provided as parameter
-
optimization_profile
(Optional[OptimizationProfile]
, default:None
) –Optimization profile for conversion and profiling
-
workspace
(Optional[Path]
, default:None
) –Workspace where packages will be extracted
-
verbose
(Optional[bool]
, default:False
) –Enable verbose logging
-
debug
(Optional[bool]
, default:False
) –Enable debug logging from commands
-
verify_func
(Optional[VerifyFunction]
, default:None
) –Function for additional model verification
-
custom_configs
(Optional[Sequence[CustomConfig]]
, default:None
) –Sequence of CustomConfigs used to control produced artifacts
Returns:
-
Package
–Package descriptor representing created package.
Source code in model_navigator/torch/__init__.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|