Skip to content

Conversation

@rballester
Copy link

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)

@pep8speaks
Copy link

Hello @rballester! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 191:80: E501 line too long (143 > 79 characters)

Copy link
Owner

@jcmgray jcmgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 196 to 198
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])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Repository owner deleted a comment from sonarqubecloud bot Jul 10, 2024
@rballester
Copy link
Author

I have adapted the PR; please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants