Skip to content

Commit

Permalink
Fix CPP style (tensorflow#546)
Browse files Browse the repository at this point in the history
* update circuit parser

* build hints and adjoint update

* format
  • Loading branch information
Antonio Martinez authored Apr 20, 2021
1 parent ca4d0cb commit b14639c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion tensorflow_quantum/core/ops/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ cc_binary(
deps = [
":parse_context",
# cirq cc proto
# pauli sum cc proto
":tfq_simulate_utils",
"//tensorflow_quantum/core/src:adj_util",
"//tensorflow_quantum/core/src:circuit_parser_qsim",
Expand Down Expand Up @@ -266,6 +267,7 @@ cc_binary(
":tfq_simulate_utils",
# cirq cc proto
"//tensorflow_quantum/core/proto:program_cc_proto",
"//tensorflow_quantum/core/src:program_resolution",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/types:optional",
Expand Down Expand Up @@ -369,8 +371,9 @@ py_library(
data = [":_tfq_adj_grad.so"],
srcs_version = "PY3",
deps = [
# tensorflow framework for wrappers
":load_module",
# pauli sum cc proto
# tensorflow framework for wrappers
],
)

Expand Down
8 changes: 4 additions & 4 deletions tensorflow_quantum/core/ops/tfq_adj_grad_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ class TfqAdjointGradientOp : public tensorflow::OpKernel {
// sv now contains psi
// scratch contains (sum_j paulis_sums[i][j] * downstream_grads[j])|psi>
// scratch2 now contains psi as well.
AccumulateOperators(pauli_sums[i], downstream_grads[i], sim, ss, sv,
scratch2, scratch);
Status unused = AccumulateOperators(pauli_sums[i], downstream_grads[i],
sim, ss, sv, scratch2, scratch);

for (int j = partial_fused_circuits[i].size() - 1; j >= 0; j--) {
for (int k = partial_fused_circuits[i][j].size() - 1; k >= 0; k--) {
Expand Down Expand Up @@ -321,8 +321,8 @@ class TfqAdjointGradientOp : public tensorflow::OpKernel {
// sv now contains psi
// scratch contains (sum_j paulis_sums[i][j] * downstream_grads[j])|psi>
// scratch2 now contains psi as well.
AccumulateOperators(pauli_sums[i], downstream_grads[i], sim, ss, sv,
scratch2, scratch);
Status unused = AccumulateOperators(pauli_sums[i], downstream_grads[i],
sim, ss, sv, scratch2, scratch);

for (int j = partial_fused_circuits[i].size() - 1; j >= 0; j--) {
for (int k = partial_fused_circuits[i][j].size() - 1; k >= 0; k--) {
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_quantum/core/src/circuit_parser_qsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline Status SingleConstantGate(
const unsigned int num_qubits, const unsigned int time,
QsimCircuit* circuit, std::vector<GateMetaData>* metadata) {
unsigned int q0;
bool unused = absl::SimpleAtoi(op.qubits(0).id(), &q0);
(void)absl::SimpleAtoi(op.qubits(0).id(), &q0);
auto gate = create_f(time, num_qubits - q0 - 1);
Status s = OptionalInsertControls(op, num_qubits, &gate);
if (!s.ok()) {
Expand Down Expand Up @@ -810,7 +810,7 @@ tensorflow::Status NoisyQsimCircuitFromProgram(const Program& program,
} else if (status.ok()) {
// gate found. succeeded in parsing.
ncircuit->channels.push_back(
std::move(qsim::MakeChannelFromGate(time, placeholder.gates[0])));
qsim::MakeChannelFromGate(time, placeholder.gates[0]));
} else {
// got not found. Attempt to find and append channel.
status = ParseAppendChannel(op, num_qubits, time, ncircuit);
Expand Down

0 comments on commit b14639c

Please sign in to comment.