Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance replace!(tn::TensorNetwork, ...) function for more flexible Tensor replacements #56

Closed
jofrevalles opened this issue May 22, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@jofrevalles
Copy link
Member

Summary

Currently, the replace! function can replace a Tensor within a TensorNetwork but only under the condition that the new Tensor has the same labels as the original one. This restriction imposes a considerable limitation on our usage of this function, especially in scenarios where we might want to replace a tensor with another one that differs in size and consequently, in labels.

At the moment, this implementation could potentially introduce problems. Specifically, the TensorNetwork has an inds field that links indexes with tensors. In its current form, we cannot add a new index to a TensorNetwork because of the immutable nature of this struct.

The recent refactor presented in PR #55 removes the inds field, allowing a more generalized replacement of tensors like the one just explained.

@jofrevalles jofrevalles added enhancement New feature or request on hold Blocked due to some reason labels May 22, 2023
@jofrevalles
Copy link
Member Author

Marked with the "on hold" label, since we are waiting for the new refactor to be merged

@mofeing
Copy link
Member

mofeing commented Jun 6, 2023

#55 includes a new replace! method that can replace a Tensor with a TensorNetwork as long as the open indices of the TensorNetwork match the labels of the Tensor.

@jofrevalles
Copy link
Member Author

We could now enhance the replace! function so it enables the replacement of tensors that have different labels. However, we should discuss how we want that and what happens to the other tensors connected to the replaced tensor.

@jofrevalles jofrevalles removed the on hold Blocked due to some reason label Jun 13, 2023
@jofrevalles
Copy link
Member Author

Update: this can be already implemented

@mofeing
Copy link
Member

mofeing commented Jun 13, 2023

Update: this can be already implemented

But we haven't discussed the semantics yet... I have concerns on adding new labels not in the Tensor Network (or renaming) or resizing an index from a Tensor.

If you suggest some coherent semantics, I will consider them.

@mofeing
Copy link
Member

mofeing commented Jun 17, 2024

@jofrevalles I think we can close this since we now have @unsafe_region right?

@jofrevalles
Copy link
Member Author

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants