This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
301 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
struct TensorNetwork | ||
code::AbstractEinsum | ||
tensors::Vector | ||
end | ||
function Base.show(io::IO, c::TensorNetwork) | ||
print(io, "TensorNetwork") | ||
print(io, "\n") | ||
print(io, contraction_complexity(c)) | ||
end | ||
function Base.show(io::IO, ::MIME"text/plain", c::TensorNetwork) | ||
print(io, c) | ||
end | ||
function Base.iterate(c::TensorNetwork, state=1) | ||
if state > 2 | ||
return nothing | ||
elseif state == 1 | ||
return (c.code, 2) | ||
else | ||
return (c.tensors, 3) | ||
end | ||
end | ||
function contract(c::TensorNetwork) | ||
return c.code(c.tensors...; size_info=uniformsize(c.code, 2)) | ||
end | ||
function OMEinsum.optimize_code(c::TensorNetwork, args...) | ||
optcode = optimize_code(c.code, uniformsize(c.code, 2), args...) | ||
return TensorNetwork(optcode, c.tensors) | ||
end | ||
function OMEinsum.contraction_complexity(c::TensorNetwork) | ||
return contraction_complexity(c.code, uniformsize(c.code, 2)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.