compiler
compiler
¤
CompiledCircuit = TypeVar('CompiledCircuit')
module-attribute
¤
InitializerCompilationSign = type[Initializer]
module-attribute
¤
LayerCompilationSign = type[Layer]
module-attribute
¤
ParameterCompilationSign = type[ParameterNode]
module-attribute
¤
SUPPORTED_BACKENDS = ['torch']
module-attribute
¤
AbstractCompiler
¤
Bases: ABC
Source code in cirkit/backend/compiler.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
_compiled_circuits = CompiledCircuitsMap()
instance-attribute
¤
_flags = flags
instance-attribute
¤
_initializers_registry = initializers_registry
instance-attribute
¤
_layers_registry = layers_registry
instance-attribute
¤
_parameters_registry = parameters_registry
instance-attribute
¤
__init__(layers_registry, parameters_registry, initializers_registry, **flags)
¤
Source code in cirkit/backend/compiler.py
156 157 158 159 160 161 162 163 164 165 166 167 | |
add_initializer_rule(func)
¤
Source code in cirkit/backend/compiler.py
190 191 | |
add_layer_rule(func)
¤
Source code in cirkit/backend/compiler.py
184 185 | |
add_parameter_rule(func)
¤
Source code in cirkit/backend/compiler.py
187 188 | |
compile(sc)
¤
Source code in cirkit/backend/compiler.py
206 207 208 209 | |
compile_pipeline(sc)
abstractmethod
¤
Source code in cirkit/backend/compiler.py
211 212 213 | |
get_compiled_circuit(sc)
¤
Source code in cirkit/backend/compiler.py
175 176 | |
get_symbolic_circuit(cc)
¤
Source code in cirkit/backend/compiler.py
178 179 | |
has_symbolic(cc)
¤
Source code in cirkit/backend/compiler.py
172 173 | |
is_compiled(sc)
¤
Source code in cirkit/backend/compiler.py
169 170 | |
register_compiled_circuit(sc, cc)
¤
Source code in cirkit/backend/compiler.py
181 182 | |
retrieve_initializer_rule(signature)
¤
Source code in cirkit/backend/compiler.py
201 202 203 204 | |
retrieve_layer_rule(signature)
¤
Source code in cirkit/backend/compiler.py
193 194 | |
retrieve_parameter_rule(signature)
¤
Source code in cirkit/backend/compiler.py
196 197 198 199 | |
CompilationRuleNotFound
¤
Bases: Exception
An exception that is raised when a compilation rule is not found.
Source code in cirkit/backend/compiler.py
91 92 93 94 95 96 97 98 99 100 | |
__init__(msg)
¤
Initializes a compilation rule not found exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
The message of the exception. |
required |
Source code in cirkit/backend/compiler.py
94 95 96 97 98 99 100 | |
CompiledCircuitsMap
¤
Source code in cirkit/backend/compiler.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
_bimap = BiMap[Circuit, CompiledCircuit]()
instance-attribute
¤
__init__()
¤
Source code in cirkit/backend/compiler.py
17 18 | |
get_compiled_circuit(sc)
¤
Source code in cirkit/backend/compiler.py
26 27 | |
get_symbolic_circuit(cc)
¤
Source code in cirkit/backend/compiler.py
29 30 | |
has_symbolic(cc)
¤
Source code in cirkit/backend/compiler.py
23 24 | |
is_compiled(sc)
¤
Source code in cirkit/backend/compiler.py
20 21 | |
register_compiled_circuit(sc, cc)
¤
Source code in cirkit/backend/compiler.py
32 33 | |
CompilerInitializerRegistry
¤
Bases: CompilerRegistry[InitializerCompilationSign, InitializerCompilationFunc]
Source code in cirkit/backend/compiler.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
_retrieve_signature(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
147 148 149 150 151 152 | |
_validate_rule_function(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
140 141 142 143 144 145 | |
CompilerLayerRegistry
¤
Bases: CompilerRegistry[LayerCompilationSign, LayerCompilationFunc]
Source code in cirkit/backend/compiler.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
_retrieve_signature(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
111 112 113 114 115 116 | |
_validate_rule_function(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
104 105 106 107 108 109 | |
CompilerParameterRegistry
¤
Bases: CompilerRegistry[ParameterCompilationSign, ParameterCompilationFunc]
Source code in cirkit/backend/compiler.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
_retrieve_signature(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
129 130 131 132 133 134 | |
_validate_rule_function(func)
classmethod
¤
Source code in cirkit/backend/compiler.py
122 123 124 125 126 127 | |
InitializerCompilationFunc
¤
Bases: Protocol
The initialization method compilation function protocol.
Source code in cirkit/backend/compiler.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
__call__(compiler, init, **kwargs)
¤
Compile a symbolic initializer, given a compiler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compiler
|
AbstractCompiler
|
The compiler. |
required |
init
|
Initializer
|
The symbolic initializer. |
required |
**kwargs
|
The optional arguments for the compilation. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A representation of the compiled initializer, which depends on the chosen compilation backend. |
Source code in cirkit/backend/compiler.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
LayerCompilationFunc
¤
Bases: Protocol
The layer compilation function protocol.
Source code in cirkit/backend/compiler.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
__call__(compiler, sl, **kwargs)
¤
Compile a symbolic layer, given a compiler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compiler
|
AbstractCompiler
|
The compiler. |
required |
sl
|
Layer
|
The symbolic layer. |
required |
**kwargs
|
The optional arguments for the compilation. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A representation of the compiled layer, which depends on the chosen compilation backend. |
Source code in cirkit/backend/compiler.py
44 45 46 47 48 49 50 51 52 53 54 | |
ParameterCompilationFunc
¤
Bases: Protocol
The parameter node compilation function protocol.
Source code in cirkit/backend/compiler.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
__call__(compiler, p, **kwargs)
¤
Compile a symbolic parameter node, given a compiler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compiler
|
AbstractCompiler
|
The compiler. |
required |
p
|
ParameterNode
|
The symbolic parameter node. |
required |
**kwargs
|
The optional arguments for the compilation. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A representation of the compiled parameter node, which depends on the chosen compilation backend. |
Source code in cirkit/backend/compiler.py
60 61 62 63 64 65 66 67 68 69 70 71 | |