Skip to content

Replace instances of torch.no_grad() with torch.inference_mode() in evaluation reference scripts #4624

@fmassa

Description

@fmassa

Since last release of PyTorch, it now provides a new context manager / function decorator that enables faster execution than torch.no_grad() https://pytorch.org/docs/stable/generated/torch.inference_mode.html?highlight=inference_mode#torch.inference_mode

We should replace instances of torch.no_grad() in our reference scripts whenever torch.inference_mode() is the correct candidate (for example, in evaluation code as in

with torch.no_grad():

cc @datumbox

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions