poprox_recommender.pytorch.decorators#

Decorators to help with Torch usage.

Functions

torch_inference(func)

Decorator for functions or methods that use PyTorch for inference (an thus torch.inference_mode() should be set for performance). It wraps the function in the following logic::.

poprox_recommender.pytorch.decorators.torch_inference(func)#

Decorator for functions or methods that use PyTorch for inference (an thus torch.inference_mode() should be set for performance). It wraps the function in the following logic:

with torch.inference_mode():
    func()
Parameters:

func (Callable[[~P], R]) – the function to wrap.

Return type:

Callable[[~P], R]