Describes how to serialize a GateOperation for a given Gate type.

gate_type The type of the gate that is being serialized.
serialized_gate_id The string id of the gate when serialized.
can_serialize_predicate Sometimes an Operation can only be serialized for particular parameters. This predicate will be checked before attempting to serialize the Operation. If the predicate is False, serialization will result in a None value. Default value is a lambda that always returns True.
args A list of specification of the arguments to the gate when serializing, including how to get this information from the gate of the given gate type.

gate_type The type of the gate that can be serialized.
serialized_gate_id The id used when serializing the gate.
serialize_tokens Whether to convert CalibrationTags into tokens on the Operation proto. Defaults to True.



View source

Whether the given operation can be serialized by this serializer.

This checks that the gate is a subclass of the gate type for this serializer, and that the gate returns true for can_serializer_predicate called on the gate.


View source

Returns the cirq_google.api.v2.Operation message as a proto dict.

Note that this function may modify the constant list if it adds tokens to the circuit's constant table.