tket
Loading...
Searching...
No Matches
OpTypeInfo.cpp
Go to the documentation of this file.
1// Copyright Quantinuum
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17#include <memory>
18#include <optional>
19
21
22namespace tket {
23const std::map<OpType, OpTypeInfo>& optypeinfo() {
24 static const op_signature_t noargs;
25 static const op_signature_t singleq(1, EdgeType::Quantum);
26 static const op_signature_t doubleq(2, EdgeType::Quantum);
27 static const op_signature_t tripleq(3, EdgeType::Quantum);
28
29 // No memory leak since the objects are only constructed once and
30 // the memory is reclaimed on program termination.
31
32 // OpTypeInfo: name, latex_name, param_mod, signature
33 static const std::map<OpType, OpTypeInfo> typeinfo{
34 {OpType::Phase, {"Phase", "Phase", {2}, noargs}},
35 {OpType::Z, {"Z", "$Z$", {}, singleq}},
36 {OpType::X, {"X", "$X$", {}, singleq}},
37 {OpType::Y, {"Y", "$Y$", {}, singleq}},
38 {OpType::S, {"S", "$S$", {}, singleq}},
39 {OpType::Sdg, {"Sdg", "$S^\\dagger$", {}, singleq}},
40 {OpType::T, {"T", "$T$", {}, singleq}},
41 {OpType::Tdg, {"Tdg", "$T^\\dagger$", {}, singleq}},
42 {OpType::V, {"V", "$R_X{\\frac12}$", {}, singleq}},
43 {OpType::Vdg, {"Vdg", "$R_X(\\frac12)^\\dagger$", {}, singleq}},
44 {OpType::SX, {"SX", "$\\sqrt{X}$", {}, singleq}},
45 {OpType::SXdg, {"SXdg", "$\\sqrt{X}^\\dagger$", {}, singleq}},
46 {OpType::H, {"H", "$H$", {}, singleq}},
47 {OpType::Rx, {"Rx", "$R_X$", {4}, singleq}},
48 {OpType::Ry, {"Ry", "$R_Y$", {4}, singleq}},
49 {OpType::Rz, {"Rz", "$R_Z$", {4}, singleq}},
50 {OpType::U3, {"U3", "U3", {4, 2, 2}, singleq}},
51 {OpType::U2, {"U2", "U2", {2, 2}, singleq}},
52 {OpType::U1, {"U1", "U1", {2}, singleq}},
53 {OpType::CX, {"CX", "CX", {}, doubleq}},
54 {OpType::CY, {"CY", "CY", {}, doubleq}},
55 {OpType::CZ, {"CZ", "CZ", {}, doubleq}},
56 {OpType::CH, {"CH", "CH", {}, doubleq}},
57 {OpType::CV, {"CV", "CV", {}, doubleq}},
58 {OpType::CVdg, {"CVdg", "$CV^\\dagger$", {}, doubleq}},
59 {OpType::CSX, {"CSX", "CSX", {}, doubleq}},
60 {OpType::CSXdg, {"CSXdg", "$CSX^\\dagger$", {}, doubleq}},
61 {OpType::CS, {"CS", "CS", {}, doubleq}},
62 {OpType::CSdg, {"CSdg", "$CS^\\dagger$", {}, doubleq}},
63 {OpType::CRz, {"CRz", "CRz", {4}, doubleq}},
64 {OpType::CRx, {"CRx", "CRx", {4}, doubleq}},
65 {OpType::CRy, {"CRy", "CRy", {4}, doubleq}},
66 {OpType::CU1, {"CU1", "CU1", {2}, doubleq}},
67 {OpType::CU3, {"CU3", "CU3", {4, 2, 2}, doubleq}},
69 {"PhaseGadget", "$Z^{\\otimes n}$", {4}, std::nullopt}},
70 {OpType::CCX, {"CCX", "CCX", {}, tripleq}},
71 {OpType::SWAP, {"SWAP", "SWAP", {}, doubleq}},
72 {OpType::CSWAP, {"CSWAP", "CSWAP", {}, tripleq}},
73 {OpType::BRIDGE, {"BRIDGE", "BRIDGE", {}, tripleq}},
74 {OpType::Input, {"Input", "Q IN", {}, singleq}},
75 {OpType::Output, {"Output", "Q OUT", {}, singleq}},
76 {OpType::Create, {"Create", "Q CREATE", {}, singleq}},
77 {OpType::Discard, {"Discard", "Q DISCARD", {}, singleq}},
79 {"ClInput", "C IN", {}, op_signature_t({EdgeType::Classical})}},
81 {"ClOutput", "C OUT", {}, op_signature_t({EdgeType::Classical})}},
83 {"WASMInput", "WASMIN", {}, op_signature_t({EdgeType::WASM})}},
85 {"WASMOutput", "WASMOUT", {}, op_signature_t({EdgeType::WASM})}},
86 {OpType::Label, {"Label", "Label", {}, noargs}},
88 {"Branch", "Branch", {}, op_signature_t({EdgeType::Boolean})}},
89 {OpType::Goto, {"Goto", "Goto", {}, noargs}},
90 {OpType::Stop, {"Stop", "Stop", {}, noargs}},
91 {OpType::noop, {"noop", "-", {}, singleq}},
92 {OpType::CircBox, {"CircBox", "CircBox", {}, std::nullopt}},
93 {OpType::Unitary1qBox, {"Unitary1qBox", "Unitary1qBox", {}, singleq}},
94 {OpType::Unitary2qBox, {"Unitary2qBox", "Unitary2qBox", {}, doubleq}},
95 {OpType::Unitary3qBox, {"Unitary3qBox", "Unitary3qBox", {}, tripleq}},
96 {OpType::ExpBox, {"ExpBox", "ExpBox", {}, doubleq}},
97 {OpType::PauliExpBox, {"PauliExpBox", "PauliExpBox", {}, std::nullopt}},
99 {"PauliExpPairBox", "PauliExpPairBox", {}, std::nullopt}},
101 {"PauliExpCommutingSetBox",
102 "PauliExpCommutingSetBox",
103 {},
104 std::nullopt}},
106 {"TermSequenceBox", "TermSequenceBox", {}, std::nullopt}},
107 {OpType::CustomGate, {"CustomGate", "CustomGate", {}, std::nullopt}},
108 {OpType::Barrier, {"Barrier", "Barrier", {}, std::nullopt}},
110 {"Measure",
111 "Measure",
112 {},
114 {OpType::Collapse, {"Collapse", "Collapse", {}, singleq}},
115 {OpType::Reset, {"Reset", "Reset", {}, singleq}},
116 {OpType::ECR, {"ECR", "ECR", {}, doubleq}},
117 {OpType::ISWAP, {"ISWAP", "ISWAP", {4}, doubleq}},
118 {OpType::PhasedX, {"PhasedX", "Ph$X$", {4, 2}, singleq}},
119 {OpType::NPhasedX, {"NPhasedX", "n-Ph$X$", {4, 2}, std::nullopt}},
120 {OpType::ZZMax, {"ZZMax", "$ZZ(\\frac{\\pi}{4})$", {}, doubleq}},
121 {OpType::XXPhase, {"XXPhase", "$R_{XX}$", {4}, doubleq}},
122 {OpType::YYPhase, {"YYPhase", "$R_{YY}$", {4}, doubleq}},
123 {OpType::ZZPhase, {"ZZPhase", "$R_{ZZ}$", {4}, doubleq}},
125 {"XXPhase3", "$R_{X_0X_1}R_{X_0X_2}R_{X_1X_2}$", {4}, tripleq}},
126 {OpType::CnRy, {"CnRy", "CnRy", {4}, std::nullopt}},
127 {OpType::CnRx, {"CnRx", "CnRx", {4}, std::nullopt}},
128 {OpType::CnRz, {"CnRz", "CnRz", {4}, std::nullopt}},
129 {OpType::CnX, {"CnX", "CnX", {}, std::nullopt}},
130 {OpType::CnZ, {"CnZ", "CnZ", {}, std::nullopt}},
131 {OpType::CnY, {"CnY", "CnY", {}, std::nullopt}},
132 {OpType::GPI, {"GPI", "GPI", {2}, singleq}},
133 {OpType::GPI2, {"GPI2", "GPI2", {2}, singleq}},
134 {OpType::AAMS, {"AAMS", "AAMS", {4, 2, 2}, doubleq}},
135 {OpType::TK1, {"TK1", "TK1", {4, 4, 4}, singleq}},
136 {OpType::TK2, {"TK2", "TK2", {4, 4, 4}, doubleq}},
137 {OpType::ESWAP, {"ESWAP", "$\\mathrm{eSWAP}$", {4}, doubleq}},
138 {OpType::FSim, {"FSim", "$\\mathrm{fSim}$", {2, 2}, doubleq}},
139 {OpType::Sycamore, {"Sycamore", "\\mathrm{Syc}", {}, doubleq}},
140 {OpType::ISWAPMax, {"ISWAPMax", "ISWAP", {}, doubleq}},
141 {OpType::PhasedISWAP, {"PhasedISWAP", "PhasedISWAP", {1, 4}, doubleq}},
142 {OpType::CliffBox, {"CliffBox", "Clifford", {}, std::nullopt}},
144 {"PhasePolyBox", "PhasePolyBox", {}, std::nullopt}},
145 {OpType::QControlBox, {"QControlBox", "Ctrl", {}, std::nullopt}},
147 {"MultiplexorBox", "MultiplexorBox", {}, std::nullopt}},
149 {"MultiplexedRotationBox", "MultiplexedRotationBox", {}, std::nullopt}},
151 {"MultiplexedU2Box", "MultiplexedU2Box", {}, std::nullopt}},
153 {"MultiplexedTensoredU2Box",
154 "MultiplexedTensoredU2Box",
155 {},
156 std::nullopt}},
158 {"StatePreparationBox", "StatePreparationBox", {}, std::nullopt}},
159 {OpType::DiagonalBox, {"DiagonalBox", "DiagonalBox", {}, std::nullopt}},
161 {"ConjugationBox", "ConjugationBox", {}, std::nullopt}},
162 {OpType::Conditional, {"Conditional", "If", {}, std::nullopt}},
164 {"ProjectorAssertionBox", "ProjectorAssertionBox", {}, std::nullopt}},
166 {"StabiliserAssertionBox", "StabiliserAssertionBox", {}, std::nullopt}},
167 {OpType::ToffoliBox, {"ToffoliBox", "ToffoliBox", {}, std::nullopt}},
168 {OpType::DummyBox, {"DummyBox", "DummyBox", {}, std::nullopt}},
170 {"ClassicalTransform", "ClassicalTransform", {}, std::nullopt}},
171 {OpType::WASM, {"WASM", "WASM", {}, std::nullopt}},
172 {OpType::SetBits, {"SetBits", "SetBits", {}, std::nullopt}},
173 {OpType::CopyBits, {"CopyBits", "CopyBits", {}, std::nullopt}},
175 {"RangePredicate", "RangePredicate", {}, std::nullopt}},
177 {"ExplicitPredicate", "ExplicitPredicate", {}, std::nullopt}},
179 {"ExplicitModifier", "ExplicitModifier", {}, std::nullopt}},
180 {OpType::MultiBit, {"MultiBit", "MultiBit", {}, std::nullopt}},
182 {"UnitaryTableauBox", "UnitaryTableauBox", {}, std::nullopt}},
183 {OpType::ClExpr, {"ClExpr", "ClExpr", {}, std::nullopt}}};
184 static std::unique_ptr<const std::map<OpType, OpTypeInfo>> opinfo =
185 std::make_unique<const std::map<OpType, OpTypeInfo>>(typeinfo);
186 return *opinfo;
187}
188
189} // namespace tket
Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWA...
Definition Path.cpp:22
@ ToffoliBox
See ToffoliBox.
@ DummyBox
See DummyBox.
@ QControlBox
See QControlBox.
@ Measure
Measure a qubit, producing a classical output.
@ CVdg
Controlled OpType::Vdg.
@ Stop
Execution halts and the program terminates.
@ CnRx
Multiply-controlled OpType::Rx.
@ CRz
Controlled OpType::Rz.
@ MultiBit
A classical operation applied to multiple bits simultaneously.
@ CH
Controlled OpType::H.
@ ConjugationBox
See ConjugationBox.
@ PhasePolyBox
See PhasePolyBox.
@ Output
Quantum output node of the circuit.
@ NPhasedX
PhasedX gates on multiple qubits.
@ CU1
Controlled OpType::U1.
@ Collapse
Measure a qubit producing no output.
@ CircBox
See CircBox.
@ Input
Quantum input node of the circuit.
@ Sycamore
Fixed instance of a OpType::FSim gate with parameters : .
@ Unitary1qBox
See Unitary1qBox.
@ CSXdg
Controlled OpType::SXdg.
@ StatePreparationBox
See StatePreparationBox.
@ ExplicitModifier
An operation defined by a truth table that modifies one bit.
@ MultiplexedTensoredU2Box
See MultiplexedTensoredU2Box.
@ SWAP
Swap two qubits.
@ Barrier
No-op that must be preserved by compilation.
@ MultiplexedRotationBox
See MultiplexedRotationBox.
@ CustomGate
See CustomGate.
@ RangePredicate
A classical predicate defined by a range of values in binary encoding.
@ CSdg
Controlled OpType::Sdg.
@ Reset
Reset a qubit to the zero state.
@ MultiplexorBox
See MultiplexorBox.
@ noop
Identity.
@ StabiliserAssertionBox
See StabiliserAssertionBox.
@ MultiplexedU2Box
See MultiplexedU2Box.
@ TermSequenceBox
See TermSequenceBox.
@ SetBits
An operation to set some bits to specified values.
@ CRx
Controlled OpType::Rx.
@ ClassicalTransform
A general classical operation where all inputs are also outputs.
@ CSWAP
Controlled OpType::SWAP.
@ CCX
Controlled OpType::CX.
@ CnRz
Multiply-controlled OpType::Rz.
@ Create
Quantum node with no predecessors, implicitly in zero state.
@ ClOutput
Classical output node of the circuit.
@ WASMOutput
WASM output node of the circuit.
@ PauliExpCommutingSetBox
See PauliExpCommutingSetBox.
@ CnZ
Multiply-controlled OpType::Z.
@ ExpBox
See ExpBox.
@ CX
Controlled OpType::X.
@ ClInput
Classical input node of the circuit.
@ UnitaryTableauBox
See UnitaryTableauBox.
@ ISWAPMax
Fixed instance of a OpType::ISWAP gate with parameter : .
@ DiagonalBox
See DiagonalBox.
@ CS
Controlled OpType::S.
@ CY
Controlled OpType::Y.
@ ProjectorAssertionBox
See ProjectorAssertionBox.
@ CZ
Controlled OpType::Z.
@ Conditional
See Conditional.
@ CV
Controlled OpType::V.
@ XXPhase3
Three-qubit phase MSGate.
@ BRIDGE
Three-qubit gate that swaps the first and third qubits.
@ ExplicitPredicate
A classical predicate defined by a truth table.
@ PauliExpBox
See PauliExpBox.
@ Goto
Execution jumps to a label unconditionally.
@ Label
FlowOp introducing a target for Branch or Goto commands.
@ CnRy
Multiply-controlled OpType::Ry.
@ CopyBits
An operation to copy some bit values.
@ ClExpr
Function defined over bits and sequences of bits treated as integers.
@ CnY
Multiply-controlled OpType::Y.
@ Unitary2qBox
See Unitary2qBox.
@ WASM
Op containing a classical wasm function call.
@ CRy
Controlled OpType::Ry.
@ CSX
Controlled OpType::SX.
@ Discard
Quantum node with no successors, not composable with input nodes of other circuits.
@ Branch
Execution jumps to a label if a condition bit is true (1), otherwise continues to next command.
@ CnX
Multiply-controlled OpType::X.
@ WASMInput
WASM input node of the circuit.
@ CU3
Controlled OpType::U3.
@ PauliExpPairBox
See PauliExpPairBox.
@ Unitary3qBox
See Unitary3qBox.
@ Quantum
A wire carrying quantum information, corresponding to some allocated Qubit.
@ Classical
A wire carrying classical information, corresponding to some allocated Bit.
@ Boolean
A wire carrying a bit of classical information from a classical output port of one op to a classical ...
@ WASM
A wire to connect the wasm ops in the order they should be executed in.
std::vector< EdgeType > op_signature_t
Definition EdgeType.hpp:61
const std::map< OpType, OpTypeInfo > & optypeinfo()
Information including name and shape of each operation type.