View source on GitHub |
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
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, *, 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.
|