Skip to content

Commit e578c38

Browse files
authored
Fix internal build error (#600)
* Update util_qsim.h * Update util_qsim_test.cc * Update circuit_parser_qsim_test.cc * Update tfq_inner_product_grad.cc * Fix format * Fix interal errors
1 parent 68e0ec3 commit e578c38

File tree

7 files changed

+11
-12
lines changed

7 files changed

+11
-12
lines changed

tensorflow_quantum/core/ops/math_ops/tfq_inner_product_grad.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,6 @@ REGISTER_OP("TfqInnerProductGrad")
477477

478478
tensorflow::shape_inference::DimensionHandle output_rows =
479479
c->Dim(programs_shape, 0);
480-
tensorflow::shape_inference::DimensionHandle output_cols =
481-
c->Dim(symbol_names_shape, 0);
482480

483481
// Use kUnknownDim instead to prevent shape inference from breaking
484482
// @tf.custom_gradient code in fidelity_op.py. The grad function has

tensorflow_quantum/core/ops/noise/tfq_noisy_sampled_expectation.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
196196
int nq = num_qubits[i];
197197

198198
// (#679) Just ignore empty program
199-
if (ncircuits[i].channels.size() == 0) {
199+
if (ncircuits[i].channels.empty()) {
200200
for (int j = 0; j < pauli_sums[i].size(); j++) {
201201
(*output_tensor)(i, j) = -2.0;
202202
}
@@ -315,7 +315,7 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
315315
int rep_offset = rep_offsets[start][i];
316316

317317
// (#679) Just ignore empty program
318-
if (ncircuits[i].channels.size() == 0) {
318+
if (ncircuits[i].channels.empty()) {
319319
for (int j = 0; j < pauli_sums[i].size(); j++) {
320320
(*output_tensor)(i, j) = -2.0;
321321
}

tensorflow_quantum/core/src/circuit_parser_qsim_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ TEST(QsimCircuitParserTest, NoisyEmpty) {
15351535
Program program_proto;
15361536
Circuit* circuit_proto = program_proto.mutable_circuit();
15371537
circuit_proto->set_scheduling_strategy(circuit_proto->MOMENT_BY_MOMENT);
1538-
Moment* moments_proto = circuit_proto->add_moments();
1538+
(void)circuit_proto->add_moments();
15391539

15401540
NoisyQsimCircuit test_circuit;
15411541
ASSERT_EQ(

tensorflow_quantum/core/src/util_qsim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ tensorflow::Status ComputeSampledExpectationQsim(
235235
unsigned int location;
236236
// GridQubit id should be parsed down to integer at this upstream
237237
// so it is safe to just use atoi.
238-
bool unused = absl::SimpleAtoi(pair.qubit_id(), &location);
238+
(void)absl::SimpleAtoi(pair.qubit_id(), &location);
239239
// Parity functions use little-endian indexing
240240
parity_bits.push_back(state.num_qubits() - location - 1);
241241
}

tensorflow_quantum/core/src/util_qsim_test.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ TEST(UtilQsimTest, AccumulateOperatorsBasic) {
493493
p_term_scratch2->set_coefficient_real(-5.0);
494494

495495
// 0.5 * (0.123ZX -3X + 4I) + 0.25 * (-5I) applied onto psi.
496-
AccumulateOperators({p_sum, p_sum2}, {0.5, 0.25}, sim, ss, sv, scratch, dest);
496+
(void)AccumulateOperators({p_sum, p_sum2}, {0.5, 0.25}, sim, ss, sv, scratch,
497+
dest);
497498

498499
// Check that dest got accumulated onto.
499500
EXPECT_NEAR(ss.GetAmpl(dest, 0).real(), 0.577925, 1e-5);
@@ -535,7 +536,7 @@ TEST(UtilQsimTest, AccumulateOperatorsEmpty) {
535536
auto scratch = ss.Create(2);
536537
auto dest = ss.Create(2);
537538

538-
AccumulateOperators({}, {}, sim, ss, sv, scratch, dest);
539+
(void)AccumulateOperators({}, {}, sim, ss, sv, scratch, dest);
539540

540541
// Check sv is still in zero state.
541542
EXPECT_NEAR(ss.GetAmpl(sv, 0).real(), 1.0, 1e-5);
@@ -599,7 +600,7 @@ TEST(UtilQsimTest, AccumulateFusedCircuitsBasic) {
599600
// Initialize coeffs.
600601
std::vector<float> coeffs = {1.23, 4.56};
601602

602-
AccumulateFusedCircuits(coeffs, fused_circuits, sim, ss, scratch, dest);
603+
(void)AccumulateFusedCircuits(coeffs, fused_circuits, sim, ss, scratch, dest);
603604

604605
// Scratch has coeffs[r][c] * fused circuits[r][c] where r, c = last indices.
605606
// Check that dest got accumulated onto.
@@ -628,7 +629,7 @@ TEST(UtilQsimTest, AccumulateFusedCircuitsEmpty) {
628629
auto scratch = ss.Create(2);
629630
auto dest = ss.Create(2);
630631

631-
AccumulateFusedCircuits({}, {}, sim, ss, scratch, dest);
632+
(void)AccumulateFusedCircuits({}, {}, sim, ss, scratch, dest);
632633

633634
// scratch has garbage value.
634635
// Check that dest contains all zeros.

tensorflow_quantum/python/layers/high_level/controlled_pqc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def __init__(self,
215215
"tfq.layers.ControlledPQC. Please use "
216216
"tfq.layers.NoisyControlledPQC instead.")
217217

218-
not_default = backend is not 'noiseless'
218+
not_default = backend != 'noiseless'
219219
not_default &= backend is not None # legacy backend=None support.
220220
if not isinstance(
221221
backend,

tensorflow_quantum/python/layers/high_level/pqc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def __init__(
230230
"tfq.layers.PQC. Please use tfq.layers.NoisyPQC "
231231
"instead.")
232232

233-
not_default = backend is not 'noiseless'
233+
not_default = backend != 'noiseless'
234234
not_default &= backend is not None # legacy backend=None support.
235235
if not isinstance(
236236
backend,

0 commit comments

Comments
 (0)