Utilities
model_navigator.api.utilities
Public utilities for the Model Navigator API.
UnpackedDataloader
A wrapper around a SizedDataLoader that applies a function to each sample.
Parameters:
-
dataloader
(SizedDataLoader
) –A SizedDataLoader.
-
unpack_fn
(Callable
) –A function that takes a sample and returns a new sample.
Returns:
-
–
An iterator over the samples in the dataloader with the unpack_fn applied.
Example
dataloader = [1, 2, 3] unpacked_dataloader = UnpackedDataloader(dataloader, lambda x: x + 1)
unpacked_dataloader is now [2, 3, 4]
Initialize the UnpackedDataloader.
Source code in model_navigator/api/utilities.py
__iter__
Return an iterator over the samples in the dataloader with the unpack_fn applied.
find_max_batch_size_till_oom
find_max_batch_size_till_oom(
framework, model, dataloader, batch_dim=0, max_batch_size_search_limit=None, runner_config=None
)
Find the maximum batch size for a model.
Search is performed by running the model on the dataloader until an OOM error is encountered.
Parameters:
-
framework
(Framework
) –The framework of the model.
-
model
(Any
) –The model.
-
dataloader
(SizedDataLoader
) –A SizedDataLoader.
-
batch_dim
(int
, default:0
) –The batch dimension of the model.
-
max_batch_size_search_limit
(Optional[int]
, default:None
) –Limit the search for the maximum batch size to this value.
-
runner_config
(Optional[Dict]
, default:None
) –Additional runner configuration.
Source code in model_navigator/api/utilities.py
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 |
|