예제 #1
0
 def _deserialize_schedule(self, schedule_proto: v2.program_pb2.Schedule,
                           device: 'cirq.Device') -> schedules.Schedule:
     scheduled_ops = []
     for scheduled_op_proto in schedule_proto.scheduled_operations:
         if not scheduled_op_proto.HasField('operation'):
             raise ValueError('Scheduled op missing an operation {}'.format(
                 scheduled_op_proto))
         scheduled_op = schedules.ScheduledOperation.op_at_on(
             operation=self.deserialize_op(scheduled_op_proto.operation),
             time=value.Timestamp(picos=scheduled_op_proto.start_time_picos),
             device=device)
         scheduled_ops.append(scheduled_op)
     return schedules.Schedule(device, scheduled_ops)
예제 #2
0
 def _deserialize_schedule(self, schedule_proto: Dict,
                           device: devices.Device) -> schedules.Schedule:
     if 'scheduled_operations' not in schedule_proto:
         raise ValueError('Schedule proto missing scheduled operations.')
     scheduled_ops = []
     for scheduled_op_proto in schedule_proto['scheduled_operations']:
         if 'operation' not in scheduled_op_proto:
             raise ValueError('Scheduled op missing an operation {}'.format(
                 scheduled_op_proto))
         if 'start_time_picos' not in scheduled_op_proto:
             raise ValueError('Scheduled op missing a start time {}'.format(
                 scheduled_op_proto))
         scheduled_op = schedules.ScheduledOperation.op_at_on(
             operation=self.deserialize_op(scheduled_op_proto['operation']),
             time=value.Timestamp(
                 picos=scheduled_op_proto['start_time_picos']),
             device=device)
         scheduled_ops.append(scheduled_op)
     return schedules.Schedule(device, scheduled_ops)