torchfunc.performance¶
This package allows you to get info and tips about performance of your neural networks.
Following functions should be considered as general recommendations. For specific/customized tips, use specific submodules.
-
torchfunc.performance.
report
(module: torch.nn.modules.module.Module) → Dict[str, Any][source]¶ Run essential module’s performance analysis with default settings.
Following tests will be performed:
Module being an instance of
torch.nn.ScriptModule
Apex (mixed precision training) availability
Any inplace ops used
Analysis of compliance with
TensorCores
technologyAny depthwise convolution used
Report returns data in machine-ready type; if you wish to have easy to follow guidelines use function
tips
.Example:
model = torch.nn.Sequential( torch.nn.Linear(784, 100), torch.nn.ReLU(), torch.nn.Linear(100, 50), torch.nn.ReLU(), torch.nn.Linear(50, 10), ) report = torchfunc.performance.report(model)
- Parameters
module (torch.nn.Module) – Module to be tested against test suite.
- Returns
Dictionary with keys:
torchscript: True if module is an instance of torch.jit.ScriptModule
apex: True if apex installed (recommended mixed precision training library from NVidia for PyTorch)
tensorcores: same as
torchscript.performance.technology.TensorCores
inplace: same as
torchscript.performance.layers.Inplace
depthwise: same as
torchscript.performance.layers.Depthwise
- Return type
Dict[str, Any]
-
torchfunc.performance.
tips
(module: torch.nn.modules.module.Module, general: bool = True, specific: bool = True)[source]¶ Return string describing possible performance improvements one can undertake.
Internally report will be called and it’s output parsed and described. It is the easiest way to get information about your module/network and to quickly check possible performance improvements you could use.
Example:
model = torch.nn.Sequential( torch.nn.Linear(784, 100), torch.nn.ReLU(), torch.nn.Linear(100, 50), torch.nn.ReLU(), torch.nn.Linear(50, 10), ) print(torchfunc.performance.tips(model)) # Display found vulnerabilities
- Parameters
module (torch.nn.Module) – Module to be tested against test suite.
general (bool, optional) – Return general (not specific to your module) tips. Default: True
specific (bool, optional) – Return specific tips for your module. Default: True
- Returns
Human readable version of report, highlighting steps one can take to improve module’s performance.
- Return type
str