![]() |
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.
Methods
can_serialize_operation
@abc.abstractmethod
can_serialize_operation( op: cirq.Operation ) -> bool
Whether the given operation can be serialized by this serializer.
to_proto
@abc.abstractmethod
to_proto( op, msg=None, *, constants: List[
cirq_google.api.v2.program_pb2.Constant
], raw_constants: Dict[Any, int] ) -> Optional[Union[cirq_google.api.v2.program_pb2.CircuitOperation
,cirq_google.api.v2.program_pb2.Operation
]]
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. |
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.
|