Skip to content

Commit

Permalink
Delete Chain, Dense, Grid, Product types
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Oct 29, 2024
1 parent 7c67f58 commit 0bef4a9
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 1,559 deletions.
12 changes: 6 additions & 6 deletions ext/TenetQuacExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module TenetQuacExt
using Tenet
using Quac: Gate, Circuit, lanes, arraytype, Swap

function Tenet.Dense(gate::Gate)
return Tenet.Dense(
Operator(), arraytype(gate)(gate); sites=Site[Site.(lanes(gate))..., Site.(lanes(gate); dual=true)...]
)
end
# function Tenet.Dense(gate::Gate)
# return Tenet.Dense(
# Operator(), arraytype(gate)(gate); sites=Site[Site.(lanes(gate))..., Site.(lanes(gate); dual=true)...]
# )
# end

Tenet.evolve!(qtn::Ansatz, gate::Gate; kwargs...) = evolve!(qtn, Tenet.Dense(gate); kwargs...)
# Tenet.evolve!(qtn::Ansatz, gate::Gate; kwargs...) = evolve!(qtn, Tenet.Dense(gate); kwargs...)

function Tenet.Quantum(circuit::Circuit)
n = lanes(circuit)
Expand Down
20 changes: 10 additions & 10 deletions ext/TenetReactantExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ function Reactant.create_result(tocopy::Ansatz, @nospecialize(path), result_stor
end

# TODO try rely on generic fallback for ansatzes
function Reactant.create_result(tocopy::Tenet.Product, @nospecialize(path), result_stores)
tn = Reactant.create_result(Ansatz(tocopy), Reactant.append_path(path, :tn), result_stores)
return :($(Tenet.Product)($tn))
end
# function Reactant.create_result(tocopy::Tenet.Product, @nospecialize(path), result_stores)
# tn = Reactant.create_result(Ansatz(tocopy), Reactant.append_path(path, :tn), result_stores)
# return :($(Tenet.Product)($tn))
# end

for A in (MPS, MPO)
@eval function Reactant.create_result(tocopy::$A, @nospecialize(path), result_stores)
tn = Reactant.create_result(Ansatz(tocopy), Reactant.append_path(path, :tn), result_stores)
return :($A($tn, form(tocopy)))
end
end
# for A in (MPS, MPO)
# @eval function Reactant.create_result(tocopy::$A, @nospecialize(path), result_stores)
# tn = Reactant.create_result(Ansatz(tocopy), Reactant.append_path(path, :tn), result_stores)
# return :($A($tn, form(tocopy)))
# end
# end

function Reactant.push_val!(ad_inputs, x::TensorNetwork, path)
@assert length(path) == 2
Expand Down
Loading

0 comments on commit 0bef4a9

Please sign in to comment.