tfq.append_circuit

Merge programs in the input tensors.

Given two tensors of programs, this function merges the programs pairwise and returns a single tensor containing the merged programs. Note that this function is not differentiable because the output has type string.

q = cirq.GridQubit(0, 0)
p0 = [cirq.Circuit(cirq.H(q)), cirq.Circuit(cirq.S(q))]
p1 = [cirq.Circuit(cirq.Z(q)), cirq.Circuit(cirq.X(q))]
p0_t = tfq.convert_to_tensor(p0)
p1_t = tfq.convert_to_tensor(p1)
tfq.from_tensor(append_circuit(p0_t, p1_t))
array([cirq.Circuit([
    cirq.Moment(
        cirq.H(cirq.GridQubit(0, 0)),
    ),
    cirq.Moment(
        cirq.Z(cirq.GridQubit(0, 0)),
    ),
]),
       cirq.Circuit([
    cirq.Moment(
        cirq.S(cirq.GridQubit(0, 0)),
    ),
    cirq.Moment(
        cirq.X(cirq.GridQubit(0, 0)),
    ),
])], dtype=object)

programs tf.Tensor of strings with shape [batch_size] containing the string representations of circuits.
programs_to_append tf.Tensor of strings with shape [batch_size] containing the string representations of circuits to append.

tf.Tensor with shape [batch_size]. Entry i is the string representing the circuit which is programs_to_append[i] appended to programs[i].