Skip to content

Commit 9f11f19

Browse files
committed
Change deprecated tensorflow::mutex() to absl::Mutex()
1 parent 08f9175 commit 9f11f19

16 files changed

Lines changed: 29 additions & 29 deletions

tensorflow_quantum/core/ops/math_ops/tfq_inner_product.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class TfqInnerProductOp : public tensorflow::OpKernel {
9393
QsimFusedCircuit({}));
9494

9595
Status parse_status = ::tensorflow::Status();
96-
auto p_lock = tensorflow::mutex();
96+
auto p_lock = absl::Mutex();
9797
auto construct_f = [&](int start, int end) {
9898
for (int i = start; i < end; i++) {
9999
Status local =

tensorflow_quantum/core/ops/math_ops/tfq_inner_product_grad.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TfqInnerProductGradOp : public tensorflow::OpKernel {
118118
programs.size(), std::vector<GradientOfGate>({}));
119119

120120
Status parse_status = ::tensorflow::Status();
121-
auto p_lock = tensorflow::mutex();
121+
auto p_lock = absl::Mutex();
122122
auto construct_f = [&](int start, int end) {
123123
for (int i = start; i < end; i++) {
124124
Status local = QsimCircuitFromProgram(

tensorflow_quantum/core/ops/math_ops/tfq_simulate_1d_expectation.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TfqSimulateMPS1DExpectationOp : public tensorflow::OpKernel {
106106
std::vector<QsimFusedCircuit> fused_circuits(programs.size(),
107107
QsimFusedCircuit({}));
108108
Status parse_status = ::tensorflow::Status();
109-
auto p_lock = tensorflow::mutex();
109+
auto p_lock = absl::Mutex();
110110
auto construct_f = [&](int start, int end) {
111111
for (int i = start; i < end; i++) {
112112
Status local =
@@ -159,7 +159,7 @@ class TfqSimulateMPS1DExpectationOp : public tensorflow::OpKernel {
159159
const int output_dim_op_size = output_tensor->dimension(1);
160160

161161
Status compute_status = ::tensorflow::Status();
162-
auto c_lock = tensorflow::mutex();
162+
auto c_lock = absl::Mutex();
163163
auto DoWork = [&](int start, int end) {
164164
int old_batch_index = -2;
165165
int cur_batch_index = -1;

tensorflow_quantum/core/ops/math_ops/tfq_simulate_1d_sampled_expectation.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class TfqSimulateMPS1DSampledExpectationOp : public tensorflow::OpKernel {
119119
programs.size(), std::vector<qsim::GateFused<QsimGate>>({}));
120120

121121
Status parse_status = ::tensorflow::Status();
122-
auto p_lock = tensorflow::mutex();
122+
auto p_lock = absl::Mutex();
123123
auto construct_f = [&](int start, int end) {
124124
for (int i = start; i < end; i++) {
125125
Status local =
@@ -185,7 +185,7 @@ class TfqSimulateMPS1DSampledExpectationOp : public tensorflow::OpKernel {
185185
->workers->NumThreads();
186186

187187
Status compute_status = ::tensorflow::Status();
188-
auto c_lock = tensorflow::mutex();
188+
auto c_lock = absl::Mutex();
189189
auto DoWork = [&](int start, int end) {
190190
int old_batch_index = -2;
191191
int cur_batch_index = -1;

tensorflow_quantum/core/ops/math_ops/tfq_simulate_1d_samples.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class TfqSimulateMPS1DSamplesOp : public tensorflow::OpKernel {
8686
programs.size(), std::vector<qsim::GateFused<QsimGate>>({}));
8787

8888
Status parse_status = ::tensorflow::Status();
89-
auto p_lock = tensorflow::mutex();
89+
auto p_lock = absl::Mutex();
9090
auto construct_f = [&](int start, int end) {
9191
for (int i = start; i < end; i++) {
9292
Status local =

tensorflow_quantum/core/ops/noise/tfq_noisy_expectation.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TfqNoisyExpectationOp : public tensorflow::OpKernel {
118118
NoisyQsimCircuit());
119119

120120
Status parse_status = ::tensorflow::Status();
121-
auto p_lock = tensorflow::mutex();
121+
auto p_lock = absl::Mutex();
122122
auto construct_f = [&](int start, int end) {
123123
for (int i = start; i < end; i++) {
124124
Status local = NoisyQsimCircuitFromProgram(
@@ -269,7 +269,7 @@ class TfqNoisyExpectationOp : public tensorflow::OpKernel {
269269
qsim::MultiQubitGateFuser, Simulator>;
270270

271271
const int output_dim_batch_size = output_tensor->dimension(0);
272-
std::vector<tensorflow::mutex> batch_locks(output_dim_batch_size);
272+
std::vector<absl::Mutex> batch_locks(output_dim_batch_size);
273273

274274
const int num_threads = context->device()
275275
->tensorflow_cpu_worker_threads()
@@ -293,7 +293,7 @@ class TfqNoisyExpectationOp : public tensorflow::OpKernel {
293293
random_gen.Init(tensorflow::random::New64(), tensorflow::random::New64());
294294

295295
Status compute_status = ::tensorflow::Status();
296-
auto c_lock = tensorflow::mutex();
296+
auto c_lock = absl::Mutex();
297297
auto DoWork = [&](int start, int end) {
298298
// Begin simulation.
299299
const auto tfq_for = qsim::SequentialFor(1);
@@ -368,12 +368,12 @@ class TfqNoisyExpectationOp : public tensorflow::OpKernel {
368368
}
369369
if (break_loop) {
370370
// Lock writing to this batch index in output_tensor.
371-
batch_locks[i].lock();
371+
batch_locks[i].Lock();
372372
for (size_t j = 0; j < num_samples[i].size(); j++) {
373373
rolling_sums[j] /= num_samples[i][j];
374374
(*output_tensor)(i, j) += static_cast<float>(rolling_sums[j]);
375375
}
376-
batch_locks[i].unlock();
376+
batch_locks[i].Unlock();
377377
break;
378378
}
379379
}

tensorflow_quantum/core/ops/noise/tfq_noisy_sampled_expectation.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
119119
NoisyQsimCircuit());
120120

121121
Status parse_status = ::tensorflow::Status();
122-
auto p_lock = tensorflow::mutex();
122+
auto p_lock = absl::Mutex();
123123
auto construct_f = [&](int start, int end) {
124124
for (int i = start; i < end; i++) {
125125
Status local = NoisyQsimCircuitFromProgram(
@@ -273,7 +273,7 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
273273
qsim::MultiQubitGateFuser, Simulator>;
274274

275275
const int output_dim_batch_size = output_tensor->dimension(0);
276-
std::vector<tensorflow::mutex> batch_locks(output_dim_batch_size);
276+
std::vector<absl::Mutex> batch_locks(output_dim_batch_size);
277277

278278
const int num_threads = context->device()
279279
->tensorflow_cpu_worker_threads()
@@ -300,7 +300,7 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
300300
random_gen.Init(tensorflow::random::New64(), tensorflow::random::New64());
301301

302302
Status compute_status = ::tensorflow::Status();
303-
auto c_lock = tensorflow::mutex();
303+
auto c_lock = absl::Mutex();
304304
auto DoWork = [&](int start, int end) {
305305
// Begin simulation.
306306
const auto tfq_for = qsim::SequentialFor(1);
@@ -374,12 +374,12 @@ class TfqNoisySampledExpectationOp : public tensorflow::OpKernel {
374374
}
375375
if (break_loop) {
376376
// Lock writing to this batch index in output_tensor.
377-
batch_locks[i].lock();
377+
batch_locks[i].Lock();
378378
for (size_t j = 0; j < num_samples[i].size(); j++) {
379379
rolling_sums[j] /= num_samples[i][j];
380380
(*output_tensor)(i, j) += static_cast<float>(rolling_sums[j]);
381381
}
382-
batch_locks[i].unlock();
382+
batch_locks[i].Unlock();
383383
break;
384384
}
385385
}

tensorflow_quantum/core/ops/noise/tfq_noisy_samples.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class TfqNoisySamplesOp : public tensorflow::OpKernel {
8484
NoisyQsimCircuit());
8585

8686
Status parse_status = ::tensorflow::Status();
87-
auto p_lock = tensorflow::mutex();
87+
auto p_lock = absl::Mutex();
8888
auto construct_f = [&](int start, int end) {
8989
for (int i = start; i < end; i++) {
9090
auto r = NoisyQsimCircuitFromProgram(

tensorflow_quantum/core/ops/parse_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ limitations under the License.
1919
// Syncs a threads work status with some global status.
2020
#define NESTED_FN_STATUS_SYNC(global_status, local_status, global_lock) \
2121
if (TF_PREDICT_FALSE(!local_status.ok())) { \
22-
global_lock.lock(); \
22+
global_lock.Lock(); \
2323
global_status = local_status; \
24-
global_lock.unlock(); \
24+
global_lock.Unlock(); \
2525
return; \
2626
}
2727

tensorflow_quantum/core/ops/tfq_adj_grad_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class TfqAdjointGradientOp : public tensorflow::OpKernel {
110110
programs.size(), std::vector<GradientOfGate>({}));
111111

112112
Status parse_status = ::tensorflow::Status();
113-
auto p_lock = tensorflow::mutex();
113+
auto p_lock = absl::Mutex();
114114
auto construct_f = [&](int start, int end) {
115115
for (int i = start; i < end; i++) {
116116
Status local = QsimCircuitFromProgram(programs[i], maps[i],

0 commit comments

Comments
 (0)