zero.module.ecall¶
-
zero.module.
ecall
(module, *args, **kwargs)[source]¶ Call the module (torch.no_grad() + module.eval() + input.to(device)).
The function:
switches the module to the evaluation mode
turns off gradients
moves the arguments to the module’s device
calls the module and returns the result
In fact, the function is just a shortcut for the combination of
evaluation
andcall
(hence, all constraints of thecall
function are inherited, see the its documentation for details), i.e.:result = ecall(model, x) # is equivalent to: with evaluation(model): result = call(model, x)
- Parameters
module (Union[torch.nn.modules.module.Module, torch.nn.parallel.data_parallel.DataParallel]) –
args –
kwargs –
- Returns
- Return type
result
See also