-
Notifications
You must be signed in to change notification settings - Fork 1
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
Avoid in-place operations in adjoint
and conj
functions
#226
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there already tests for adjoint
and conj
? I guess that yes but not sure right now.
I am writting these right now. |
By the way, these errors appear now due to the issue reported in #225, since when we do See: julia> mps = rand(Chain, Open, State, n=6, χ=10)
MPS (inputs=0, outputs=6)
julia> mps'
ERROR: Index A must be open
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] addsite!(tn::Quantum, site::Site{1}, index::Symbol)
@ Tenet ~/git/Tenet.jl/src/Quantum.jl:279
[3] adjoint(tn::Quantum)
@ Main ./REPL[57]:8
[4] adjoint(chain::Chain)
@ Tenet ~/git/Tenet.jl/src/Ansatz/Chain.jl:209
[5] top-level scope
@ REPL[74]:1
julia> mps = rand(Chain, Open, State, n=6, χ=10, eltype=ComplexF64)
MPS (inputs=0, outputs=6)
julia> mps'
MPS (inputs=6, outputs=0) |
When the PR #227 is merged, I will cherry-pick the fixing commits to ensure everything works well. |
You don't need to cherry-pick if the PR is merged?? |
Just to run the tests before merge. |
Ah, you don't need to cherry-pick but to rebase on top of master. Actually, cherry-picking in that case can lead to merge conflicts. |
Summary
This PR modifies the
adjoint
andconj
functions forAbstractQuantum
andAbstractTensorNetwork
types to prevent errors when tensors contain immutable arrays. Instead of performing in-place operations, the functions now return a modified copy of the input.Some tensors within a
TensorNetwork
may have immutable arrays in their parent structures. Performing in-place operations likeconj!
oradjoint!
on these tensors can lead to errors because immutable arrays do not support thesetindex!
operation required for in-place modification.Example
Before this PR:
Now: