cirq_google.serialization.op_serializer.OpSerializer
Generic supertype for operation serializers.
Each operation serializer describes how to serialize a specific type of
Cirq operation to its corresponding proto format. Multiple operation types
may serialize to the same format.
Attributes |
can_serialize_predicate
|
The method used to determine if this can serialize an operation.
Depending on the serializer, additional checks may be required.
|
internal_type
|
Returns the type that the operation contains.
For GateOperations, this is the gate type.
For CircuitOperations, this is FrozenCircuit.
|
serialized_id
|
Returns the string identifier for the resulting serialized object.
This ID denotes the serialization format this serializer produces. For
example, one of the common serializers assigns the id 'xy' to XPowGates,
as they serialize into a format also used by YPowGates.
|
Methods
can_serialize_operation
View source
can_serialize_operation(
op: cirq.Operation
) -> bool
Whether the given operation can be serialized by this serializer.
to_proto
View source
@abc.abstractmethod
to_proto(
op,
msg=None,
*,
arg_function_language: Optional[str] = '',
constants: List[cirq_google.api.v2.program_pb2.Constant
],
raw_constants: Dict[Any, int]
) -> Optional[cirq_google.api.v2.program_pb2.CircuitOperation
]
Converts op to proto using this serializer.
If self.can_serialize_operation(op) == false, this should return None.
Args |
op
|
The Cirq operation to be serialized.
|
msg
|
An optional proto object to populate with the serialization
results.
|
arg_function_language
|
The arg_function_language field from
Program.Language .
|
constants
|
The list of previously-serialized Constant protos.
|
raw_constants
|
A map raw objects to their respective indices in
constants .
|
Returns |
The proto-serialized version of op . If msg was provided, it is
the returned object.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]