From the link:

You can use  memory_allocated()  145 and  max_memory_allocated()  156 to monitor memory occupied by tensors, and use  memory_cached()  21 and max_memory_cached()  13 to monitor memory managed by the caching allocator.