diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..854f6dc9d --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,12 @@ +# Usage: run the following command to configure git to use this file: +# +# git config blame.ignoreRevsFile .git-blame-ignore-revs +# +# Summary: `git-blame` can be instructed to ignore certain commits. This is +# useful to do for commits that only involve large refactoring and reformatting +# operations. The format of this file is one full 40-character commit hash +# (SHA-1) per line. Blank lines and comments (such as this) are allowed. +# ============================================================================== + +# Output of running ./scripts/format_all.sh (PR #926). +17b108d8485cb7848f8eae5b87c9cc521987bca9 diff --git a/tensorflow_quantum/core/ops/tfq_calculate_unitary_op.cc b/tensorflow_quantum/core/ops/tfq_calculate_unitary_op.cc index 4f1f662ca..2bde517ef 100644 --- a/tensorflow_quantum/core/ops/tfq_calculate_unitary_op.cc +++ b/tensorflow_quantum/core/ops/tfq_calculate_unitary_op.cc @@ -41,10 +41,10 @@ typedef qsim::Circuit QsimCircuit; class TfqCalculateUnitaryOp : public tensorflow::OpKernel { public: - explicit TfqCalculateUnitaryOp(tensorflow::OpKernelConstruction *context) + explicit TfqCalculateUnitaryOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {} - void Compute(tensorflow::OpKernelContext *context) override { + void Compute(tensorflow::OpKernelContext* context) override { // TODO (mbbrough): add more dimension checks for other inputs here. DCHECK_EQ(3, context->num_inputs()); @@ -99,13 +99,13 @@ class TfqCalculateUnitaryOp : public tensorflow::OpKernel { output_shape.AddDim(1 << max_num_qubits); output_shape.AddDim(1 << max_num_qubits); - tensorflow::Tensor *output = nullptr; + tensorflow::Tensor* output = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output)); auto output_tensor = output->tensor, 3>(); // Instantiate qsim objects. const auto tfq_for = tfq::QsimFor(context); - using UCalculator = qsim::unitary::UnitaryCalculator; + using UCalculator = qsim::unitary::UnitaryCalculator; using UnitarySpace = UCalculator::UnitarySpace; using Unitary = UnitarySpace::Unitary; @@ -166,7 +166,7 @@ REGISTER_OP("TfqCalculateUnitary") .Input("symbol_names: string") .Input("symbol_values: float") .Output("unitary: complex64") - .SetShapeFn([](tensorflow::shape_inference::InferenceContext *c) { + .SetShapeFn([](tensorflow::shape_inference::InferenceContext* c) { tensorflow::shape_inference::ShapeHandle programs_shape; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &programs_shape)); diff --git a/tensorflow_quantum/core/ops/tfq_circuit_append_op.cc b/tensorflow_quantum/core/ops/tfq_circuit_append_op.cc index 582bd1681..39d9f27ce 100644 --- a/tensorflow_quantum/core/ops/tfq_circuit_append_op.cc +++ b/tensorflow_quantum/core/ops/tfq_circuit_append_op.cc @@ -31,10 +31,10 @@ using ::tfq::proto::Program; class TfqCircuitAppendOp : public tensorflow::OpKernel { public: - explicit TfqCircuitAppendOp(tensorflow::OpKernelConstruction *context) + explicit TfqCircuitAppendOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {} - void Compute(tensorflow::OpKernelContext *context) override { + void Compute(tensorflow::OpKernelContext* context) override { std::vector programs; std::vector programs_to_append; @@ -46,7 +46,7 @@ class TfqCircuitAppendOp : public tensorflow::OpKernel { OP_REQUIRES_OK(context, GetProgramsAndProgramsToAppend( context, &programs, &programs_to_append)); - tensorflow::Tensor *output = nullptr; + tensorflow::Tensor* output = nullptr; OP_REQUIRES_OK(context, context->allocate_output( 0, context->input(0).shape(), &output)); auto output_tensor = output->flat(); @@ -56,7 +56,7 @@ class TfqCircuitAppendOp : public tensorflow::OpKernel { for (int i = start; i < end; i++) { for (int j = 0; j < programs_to_append.at(i).circuit().moments().size(); j++) { - Moment *new_moment = programs.at(i).mutable_circuit()->add_moments(); + Moment* new_moment = programs.at(i).mutable_circuit()->add_moments(); *new_moment = programs_to_append.at(i).circuit().moments(j); } programs.at(i).SerializeToString(&temp); @@ -80,7 +80,7 @@ REGISTER_OP("TfqAppendCircuit") .Input("programs: string") .Input("programs_to_append: string") .Output("programs_extended: string") - .SetShapeFn([](tensorflow::shape_inference::InferenceContext *c) { + .SetShapeFn([](tensorflow::shape_inference::InferenceContext* c) { tensorflow::shape_inference::ShapeHandle programs_shape; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &programs_shape)); diff --git a/tensorflow_quantum/core/ops/tfq_ps_decompose_op.cc b/tensorflow_quantum/core/ops/tfq_ps_decompose_op.cc index 669ea6368..6ebe2031c 100644 --- a/tensorflow_quantum/core/ops/tfq_ps_decompose_op.cc +++ b/tensorflow_quantum/core/ops/tfq_ps_decompose_op.cc @@ -37,10 +37,10 @@ using ::tfq::proto::Program; class TfqPsDecomposeOp : public tensorflow::OpKernel { public: - explicit TfqPsDecomposeOp(tensorflow::OpKernelConstruction *context) + explicit TfqPsDecomposeOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {} - void Compute(tensorflow::OpKernelContext *context) override { + void Compute(tensorflow::OpKernelContext* context) override { std::vector programs; const int num_inputs = context->num_inputs(); @@ -50,7 +50,7 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { OP_REQUIRES_OK(context, ParsePrograms(context, "programs", &programs)); - tensorflow::Tensor *output = nullptr; + tensorflow::Tensor* output = nullptr; OP_REQUIRES_OK(context, context->allocate_output( 0, context->input(0).shape(), &output)); auto output_tensor = output->flat(); @@ -71,7 +71,7 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { int num_extra_moments = 0; for (int k = 0; k < cur_moment.operations().size(); k++) { Operation cur_op = cur_moment.operations().at(k); - auto &cur_op_map = *cur_op.mutable_args(); + auto& cur_op_map = *cur_op.mutable_args(); if (cur_op.gate().id() == "PISP") { auto exponent = cur_op_map.at("exponent"); auto phase_exponent = cur_op_map.at("phase_exponent"); @@ -161,17 +161,17 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { private: // Helper functions for decompositions of ISwapPowGate, PhasedX, FSIM, // PhasedISwapPow. - Operation getOpForISP(Operation &cur_op, std::string id, std::string symbol) { + Operation getOpForISP(Operation& cur_op, std::string id, std::string symbol) { // Step 1. parse the current op. - auto &cur_op_map = *cur_op.mutable_args(); + auto& cur_op_map = *cur_op.mutable_args(); float cur_exponent_scalar = cur_op_map["exponent_scalar"].arg_value().float_value(); - auto &cur_op_qubits = cur_op.qubits(); + auto& cur_op_qubits = cur_op.qubits(); // Step 2. create a new op. Operation new_op; new_op.mutable_gate()->set_id(id); // Step 3. add global_shift, exponent_scalar, exponent. - auto &new_op_map = *new_op.mutable_args(); + auto& new_op_map = *new_op.mutable_args(); new_op_map["global_shift"].mutable_arg_value()->set_float_value(-0.5); new_op_map["exponent_scalar"].mutable_arg_value()->set_float_value( cur_exponent_scalar * -0.5); @@ -186,11 +186,11 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { return new_op; } - Operation getOpForPXP(Operation &cur_op, std::string id, std::string key, + Operation getOpForPXP(Operation& cur_op, std::string id, std::string key, bool sign_flip = false) { // Step 1. parse the current op. - auto &cur_op_map = *cur_op.mutable_args(); - auto &cur_op_qubits = cur_op.qubits(); + auto& cur_op_map = *cur_op.mutable_args(); + auto& cur_op_qubits = cur_op.qubits(); auto target_exponent = cur_op_map[key]; float target_exponent_scalar = cur_op_map[absl::StrCat(key, "_scalar")].arg_value().float_value(); @@ -199,7 +199,7 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { Operation new_op; new_op.mutable_gate()->set_id(id); // Step 3. add global_shift, exponent_scalar, exponent. - auto &new_op_map = *new_op.mutable_args(); + auto& new_op_map = *new_op.mutable_args(); new_op_map["global_shift"].mutable_arg_value()->set_float_value(0.0); switch (target_exponent.arg_case()) { case Arg::ArgCase::kSymbol: @@ -228,10 +228,10 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { return new_op; } - Operation getOpForPISP(Operation &cur_op, bool sign_flip, bool use_target) { + Operation getOpForPISP(Operation& cur_op, bool sign_flip, bool use_target) { // Step 1. parse the current op. - auto &cur_op_map = *cur_op.mutable_args(); - auto &cur_op_qubits = cur_op.qubits(); + auto& cur_op_map = *cur_op.mutable_args(); + auto& cur_op_qubits = cur_op.qubits(); auto target_exponent = cur_op_map["phase_exponent"]; float target_exponent_scalar = cur_op_map["phase_exponent_scalar"].arg_value().float_value(); @@ -240,7 +240,7 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { Operation new_op; new_op.mutable_gate()->set_id("ZP"); // Step 3. add global_shift, exponent_scalar, exponent. - auto &new_op_map = *new_op.mutable_args(); + auto& new_op_map = *new_op.mutable_args(); new_op_map["global_shift"].mutable_arg_value()->set_float_value(0.0); switch (target_exponent.arg_case()) { case Arg::ArgCase::kSymbol: @@ -269,11 +269,11 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { return new_op; } - Operation getOpForFSIM(Operation &cur_op, std::string id, std::string key, + Operation getOpForFSIM(Operation& cur_op, std::string id, std::string key, bool use_global_shift = false) { // Step 1. parse the current op. - auto &cur_op_map = *cur_op.mutable_args(); - auto &cur_op_qubits = cur_op.qubits(); + auto& cur_op_map = *cur_op.mutable_args(); + auto& cur_op_qubits = cur_op.qubits(); auto target_exponent = cur_op_map[key]; float target_exponent_scalar = cur_op_map[absl::StrCat(key, "_scalar")].arg_value().float_value(); @@ -283,7 +283,7 @@ class TfqPsDecomposeOp : public tensorflow::OpKernel { Operation new_op; new_op.mutable_gate()->set_id(id); // Step 3. add global_shift, exponent_scalar, exponent. - auto &new_op_map = *new_op.mutable_args(); + auto& new_op_map = *new_op.mutable_args(); new_op_map["global_shift"].mutable_arg_value()->set_float_value( global_shift); switch (target_exponent.arg_case()) { @@ -320,7 +320,7 @@ REGISTER_KERNEL_BUILDER(Name("TfqPsDecompose").Device(tensorflow::DEVICE_CPU), REGISTER_OP("TfqPsDecompose") .Input("programs: string") .Output("ps_programs: string") - .SetShapeFn([](tensorflow::shape_inference::InferenceContext *c) { + .SetShapeFn([](tensorflow::shape_inference::InferenceContext* c) { tensorflow::shape_inference::ShapeHandle programs_shape; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &programs_shape)); diff --git a/tensorflow_quantum/core/ops/tfq_ps_symbol_replace_op.cc b/tensorflow_quantum/core/ops/tfq_ps_symbol_replace_op.cc index d5b4ef9a7..6cbf13675 100644 --- a/tensorflow_quantum/core/ops/tfq_ps_symbol_replace_op.cc +++ b/tensorflow_quantum/core/ops/tfq_ps_symbol_replace_op.cc @@ -36,10 +36,10 @@ using ::tensorflow::Tensor; class TfqPsSymbolReplaceOp : public tensorflow::OpKernel { public: - explicit TfqPsSymbolReplaceOp(tensorflow::OpKernelConstruction *context) + explicit TfqPsSymbolReplaceOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {} - void Compute(tensorflow::OpKernelContext *context) override { + void Compute(tensorflow::OpKernelContext* context) override { std::vector programs; const int num_inputs = context->num_inputs(); @@ -50,7 +50,7 @@ class TfqPsSymbolReplaceOp : public tensorflow::OpKernel { OP_REQUIRES_OK(context, ParsePrograms(context, "programs", &programs)); // Parse the input string here. - const Tensor *symbols_tensor; + const Tensor* symbols_tensor; OP_REQUIRES_OK(context, context->input("symbols", &symbols_tensor)); OP_REQUIRES( context, symbols_tensor->dims() == 1, @@ -61,7 +61,7 @@ class TfqPsSymbolReplaceOp : public tensorflow::OpKernel { const size_t n_symbols = symbols.size(); // Parse the replacement string here. - const Tensor *replacement_symbols_tensor; + const Tensor* replacement_symbols_tensor; OP_REQUIRES_OK(context, context->input("replacement_symbols", &replacement_symbols_tensor)); OP_REQUIRES(context, replacement_symbols_tensor->dims() == 1, @@ -96,7 +96,7 @@ class TfqPsSymbolReplaceOp : public tensorflow::OpKernel { for (auto l = cur_op.args().begin(); l != cur_op.args().end(); l++) { const std::string key = (*l).first; - const Arg &arg = (*l).second; + const Arg& arg = (*l).second; if (arg.symbol() == symbol_to_replace) { // Copy the proto, modify the symbol and append to output. Program temp(cur_program); @@ -144,7 +144,7 @@ class TfqPsSymbolReplaceOp : public tensorflow::OpKernel { } } - tensorflow::Tensor *output = nullptr; + tensorflow::Tensor* output = nullptr; tensorflow::TensorShape output_shape; // batch size. output_shape.AddDim(programs.size()); @@ -190,7 +190,7 @@ REGISTER_OP("TfqPsSymbolReplace") .Input("symbols: string") .Input("replacement_symbols: string") .Output("ps_programs: string") - .SetShapeFn([](tensorflow::shape_inference::InferenceContext *c) { + .SetShapeFn([](tensorflow::shape_inference::InferenceContext* c) { tensorflow::shape_inference::ShapeHandle programs_shape; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &programs_shape)); diff --git a/tensorflow_quantum/core/ops/tfq_ps_weights_from_symbols_op.cc b/tensorflow_quantum/core/ops/tfq_ps_weights_from_symbols_op.cc index 7ffebfd22..9cd997935 100644 --- a/tensorflow_quantum/core/ops/tfq_ps_weights_from_symbols_op.cc +++ b/tensorflow_quantum/core/ops/tfq_ps_weights_from_symbols_op.cc @@ -37,10 +37,10 @@ using ::tfq::proto::Program; class TfqPsWeightsFromSymbolOp : public tensorflow::OpKernel { public: - explicit TfqPsWeightsFromSymbolOp(tensorflow::OpKernelConstruction *context) + explicit TfqPsWeightsFromSymbolOp(tensorflow::OpKernelConstruction* context) : OpKernel(context) {} - void Compute(tensorflow::OpKernelContext *context) override { + void Compute(tensorflow::OpKernelContext* context) override { std::vector programs; const int num_inputs = context->num_inputs(); @@ -51,7 +51,7 @@ class TfqPsWeightsFromSymbolOp : public tensorflow::OpKernel { OP_REQUIRES_OK(context, ParsePrograms(context, "programs", &programs)); // Parse the input string here. - const Tensor *symbols_tensor; + const Tensor* symbols_tensor; OP_REQUIRES_OK(context, context->input("symbols", &symbols_tensor)); OP_REQUIRES( context, symbols_tensor->dims() == 1, @@ -88,7 +88,7 @@ class TfqPsWeightsFromSymbolOp : public tensorflow::OpKernel { Operation cur_op = cur_moment.operations().at(k); if (ignored_symbol_set.contains(cur_op.gate().id())) continue; - const auto &cur_op_map = *cur_op.mutable_args(); + const auto& cur_op_map = *cur_op.mutable_args(); const auto exponent = cur_op_map.at("exponent"); if (exponent.arg_case() == Arg::ArgCase::kSymbol) { // this gate has parameterized exponent. @@ -131,7 +131,7 @@ class TfqPsWeightsFromSymbolOp : public tensorflow::OpKernel { std::max(n_single_symbol.at(i), largest_single_symbol); } - tensorflow::Tensor *output = nullptr; + tensorflow::Tensor* output = nullptr; tensorflow::TensorShape output_shape; // batch size. output_shape.AddDim(programs.size()); @@ -171,7 +171,7 @@ REGISTER_OP("TfqPsWeightsFromSymbols") .Input("programs: string") .Input("symbols: string") .Output("weights: float") - .SetShapeFn([](tensorflow::shape_inference::InferenceContext *c) { + .SetShapeFn([](tensorflow::shape_inference::InferenceContext* c) { tensorflow::shape_inference::ShapeHandle programs_shape; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &programs_shape));