zero.module.ecall

zero.module.ecall(module, *args, **kwargs)[source]

Call the module (torch.no_grad() + module.eval() + input.to(device)).

The function:

  1. switches the module to the evaluation mode

  2. turns off gradients

  3. moves the arguments to the module’s device

  4. calls the module and returns the result

In fact, the function is just a shortcut for the combination of evaluation and call (hence, all constraints of the call 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