-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
It would be great if TensorKit provides out-of-box functions to save all kinds of tensors to disk and load it back (just like PyTorch's save and load). The issue I'm currently running into is the IO of a DiagonalTensorMap. For ordinary TensorMaps, I can use the following functions for IO (which, at least for ordinary TensorMaps, actually works for both 0.12.7 and newer versions of TensorKit):
using TensorKit
using JLD2
function save_tensor(filename::AbstractString, t::AbstractTensorMap)
# the resulting Dict is "dense", the same as an ordinary TensorMap
return JLD2.save_object(filename, convert(Dict, t))
end
function load_tensor(filename::AbstractString)
# conversion back to DiagonalTensorMap is not implemented
return convert(TensorMap, JLD2.load_object(filename))
endIn addition, there is not a convenient conversion from a diagonal TensorMap back to DiagonalTensorMap. Then I cannot easily load a saved tensor back as a DiagonalTensorMap. I guess there is a similar problem for some other special kind of tensors.
Metadata
Metadata
Assignees
Labels
No labels