cirq_google.serialization.SerializableGateSet

A class for serializing and deserializing programs and operations.

Inherits From: Serializer

This class is for cirq_google.api.v2. protos.

gate_set_name The name used to identify the gate set.
serializers The OpSerializers to use for serialization. Multiple serializers for a given gate type are allowed and will be checked for a given type in the order specified here. This allows for a given gate type to be serialized into different serialized form depending on the parameters of the gate.
deserializers The OpDeserializers to convert serialized forms of gates or circuits into Operations.

Methods

deserialize

View source

Deserialize a Circuit from a cirq_google.api.v2.Program.

Args
proto A dictionary representing a cirq_google.api.v2.Program proto.
device If the proto is for a schedule, a device is required Otherwise optional.

Returns
The deserialized Circuit, with a device if device was not None.

deserialize_circuit_op

View source

Deserialize a CircuitOperation from a cirq.google.api.v2.CircuitOperation.

Args
operation_proto A dictionary representing a cirq.google.api.v2.CircuitOperation proto.
arg_function_language The arg_function_language field from Program.Language.
constants The list of Constant protos referenced by constant table indices in proto.
deserialized_constants The deserialized contents of constants.

Returns
The deserialized CircuitOperation.

deserialize_gate_op

View source

Deserialize an Operation from a cirq_google.api.v2.Operation.

Args
operation_proto A dictionary representing a cirq.google.api.v2.Operation proto.
arg_function_language The arg_function_language field from Program.Language.
constants The list of Constant protos referenced by constant table indices in proto.
deserialized_constants The deserialized contents of constants. cirq_google.api.v2.Operation proto.

Returns
The deserialized Operation.

deserialize_op

View source

Disambiguation for operation deserialization.

is_supported

View source

Whether the given object contains only supported operations.

is_supported_operation

View source

Whether or not the given gate can be serialized by this gate set.

serialize

View source

Serialize a Circuit to cirq_google.api.v2.Program proto.

Args
program The Circuit to serialize.
msg An optional proto object to populate with the serialization results.
arg_function_language The arg_function_language field from Program.Language.
use_constants Whether to use constants in serialization. This is required to be True for serializing CircuitOperations.

serialize_circuit_op

View source

Serialize a CircuitOperation to cirq.google.api.v2.CircuitOperation proto.

Args
op The circuit operation to serialize.
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 cirq.google.api.v2.CircuitOperation proto.

serialize_gate_op

View source

Serialize an Operation to cirq_google.api.v2.Operation proto.

Args
op The operation to serialize.
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 cirq.google.api.v2.Operation proto.

serialize_op

View source

Disambiguation for operation serialization.

supported_gate_types

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.13.

Use supported_internal_types instead.

supported_internal_types

View source

with_added_gates

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.13.

Use with_added_types instead.

with_added_types

View source

Creates a new gateset with additional (de)serializers.

Args
gate_set_name Optional new name of the gateset. If not given, use the same name as this gateset.
serializers Serializers to add to those in this gateset.
deserializers Deserializers to add to those in this gateset.