Added an 'identity' tensor splitting option#241
Added an 'identity' tensor splitting option#241rballester wants to merge 2 commits intojcmgray:mainfrom
Conversation
|
Hello @rballester! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
jcmgray
left a comment
There was a problem hiding this comment.
Hi @rballester, yes this seems like nice functionality to have, thanks! I've left a couple of comments to address, and if you have time, it would certainly be nice to also add a small unit test.
quimb/tensor/decomp.py
Outdated
| return do("eye", x.shape[0]), do("ones", x.shape[0]), x | ||
| else: | ||
| return x, do("ones", x.shape[1]), do("eye", x.shape[1]) |
There was a problem hiding this comment.
The middle element should probably just be left as None, otherwise it flags to calling functions above that 'singular values' have been returned. This happens with other methods only when the option absorb=None. Or one could add that option and but default to absorb=0 (which means absorbed on either side), if you imagine that it might be useful to initialize simple update gauges for example.
I also suggest here using do("eye", x.shape[0], like=x) and do("ones", x.shape[0], like=x) rather than backend_like since autoray now supports picking up the correct device and dtype for these array creation routines.
|
I have adapted the PR; please check. |
This PR adds an "identity" tensor split operation that does nothing, i.e. sets the identity matrix as either the left or the right split. One use is creating an MPS network from a dense tensor in very little time and zero error.
(forgive me if there's a way to do this already -- I didn't find it)