lenskit.torch ============= .. py:module:: lenskit.torch .. autoapi-nested-parse:: PyTorch utility functions. Functions --------- .. autoapisummary:: lenskit.torch.inference_mode lenskit.torch.sparse_row lenskit.torch.safe_tensor Module Contents --------------- .. py:function:: inference_mode(func) Function decorator that puts PyTorch in inference mode. .. py:function:: sparse_row(mat, row) Get a row of a sparse (CSR) tensor. This is needed because indexing a tensor does not work in inference mode. .. py:function:: safe_tensor(array) Safely convert an array into a NumPy tensor. This includes copying it to writable memory if necessary.