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.

Methods

can_serialize_operation

View source

Whether the given operation can be serialized by this serializer.

to_proto

View source

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.