diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-12-06 23:14:18 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-12-06 23:18:04 -0800 |
commit | b9df87ffc4a53566320e2baf17f0daeca25fdde9 (patch) | |
tree | d384f0063178404b88ef4fb322fc9463a8435339 | |
parent | 10197197fd43af6027c62e57bd3be375075e90e3 (diff) |
Wrap macro bodies in do{}while(0) to prevent capture of else-clauses.
PiperOrigin-RevId: 178202725
-rw-r--r-- | tensorflow/contrib/nearest_neighbor/kernels/hyperplane_lsh_probes.cc | 15 | ||||
-rw-r--r-- | tensorflow/contrib/resampler/kernels/resampler_ops.cc | 8 | ||||
-rw-r--r-- | tensorflow/core/framework/op_kernel.h | 22 | ||||
-rw-r--r-- | tensorflow/core/kernels/conditional_accumulator_base.h | 10 | ||||
-rw-r--r-- | tensorflow/core/kernels/quantized_concat_op.cc | 4 | ||||
-rw-r--r-- | tensorflow/core/kernels/variable_ops.h | 2 |
6 files changed, 34 insertions, 27 deletions
diff --git a/tensorflow/contrib/nearest_neighbor/kernels/hyperplane_lsh_probes.cc b/tensorflow/contrib/nearest_neighbor/kernels/hyperplane_lsh_probes.cc index 62ee6630ac..2b412fac9a 100644 --- a/tensorflow/contrib/nearest_neighbor/kernels/hyperplane_lsh_probes.cc +++ b/tensorflow/contrib/nearest_neighbor/kernels/hyperplane_lsh_probes.cc @@ -45,16 +45,16 @@ class HyperplaneLSHProbesOp : public OpKernel { const Tensor& products_tensor = context->input(0); OP_REQUIRES(context, products_tensor.dims() == 2, InvalidArgument("Need a two-dimensional products tensor, got ", - products_tensor.dims(), " dimensions.")) + products_tensor.dims(), " dimensions.")); const Tensor& num_tables_tensor = context->input(1); OP_REQUIRES(context, num_tables_tensor.dims() == 0, InvalidArgument("Need a scalar num_tables tensor, got ", - num_tables_tensor.dims(), " dimensions.")) + num_tables_tensor.dims(), " dimensions.")); int num_tables = num_tables_tensor.scalar<int32>()(); OP_REQUIRES(context, num_tables >= 1, InvalidArgument("num_tables must be at least 1 but got ", - num_tables, ".")) + num_tables, ".")); OP_REQUIRES(context, num_tables <= 1000, InvalidArgument("Need num_tables <= 1000, got ", num_tables, ". This is mostly to protect against incorrect " @@ -66,12 +66,13 @@ class HyperplaneLSHProbesOp : public OpKernel { InvalidArgument("Need a scalar num_hyperplanes_per_table " "tensor, got ", num_hyperplanes_per_table_tensor.dims(), - " dimensions.")) + " dimensions.")); int num_hyperplanes_per_table = num_hyperplanes_per_table_tensor.scalar<int32>()(); OP_REQUIRES(context, num_hyperplanes_per_table >= 1, InvalidArgument("num_hyperplanes_per_table must be at least 1 " - "but got ", num_hyperplanes_per_table, ".")) + "but got ", + num_hyperplanes_per_table, ".")); OP_REQUIRES(context, num_hyperplanes_per_table <= 30, InvalidArgument("Need num_hyperplanes_per_table <= 30, got ", num_hyperplanes_per_table, ". " @@ -81,10 +82,10 @@ class HyperplaneLSHProbesOp : public OpKernel { const Tensor& num_probes_tensor = context->input(3); OP_REQUIRES(context, num_probes_tensor.dims() == 0, InvalidArgument("Need a scalar num_probes tensor, got ", - num_probes_tensor.dims(), " dimensions.")) + num_probes_tensor.dims(), " dimensions.")); int num_probes = num_probes_tensor.scalar<int32>()(); OP_REQUIRES(context, num_probes >= 1, - InvalidArgument("num_probes must be at least 1.")) + InvalidArgument("num_probes must be at least 1.")); int expected_num_hyperplanes = num_tables * num_hyperplanes_per_table; OP_REQUIRES( diff --git a/tensorflow/contrib/resampler/kernels/resampler_ops.cc b/tensorflow/contrib/resampler/kernels/resampler_ops.cc index 7d9ef14cef..e02c1b6a2b 100644 --- a/tensorflow/contrib/resampler/kernels/resampler_ops.cc +++ b/tensorflow/contrib/resampler/kernels/resampler_ops.cc @@ -406,10 +406,10 @@ class ResamplerGradOp : public ::tensorflow::OpKernel { data_channels); OP_REQUIRES(ctx, grad_output_shape == resampler_output_shape, ::tensorflow::errors::InvalidArgument( - "grad_output shape is not consistent with data and warp " - "shapes; it should be ", - resampler_output_shape.DebugString(), " but is ", - grad_output_shape.DebugString())) + "grad_output shape is not consistent with data and warp " + "shapes; it should be ", + resampler_output_shape.DebugString(), " but is ", + grad_output_shape.DebugString())); const int num_sampling_points = warp.NumElements() / batch_size / 2; ::tensorflow::Tensor* grad_data = nullptr; ::tensorflow::Tensor* grad_warp = nullptr; diff --git a/tensorflow/core/framework/op_kernel.h b/tensorflow/core/framework/op_kernel.h index a7b9bb393d..3a9a6121c0 100644 --- a/tensorflow/core/framework/op_kernel.h +++ b/tensorflow/core/framework/op_kernel.h @@ -1492,10 +1492,12 @@ inline void OpOutputList::set_ref(int i, mutex* mu, Tensor* tensor_for_ref) { // } #define OP_REQUIRES(CTX, EXP, STATUS) \ - if (!TF_PREDICT_TRUE(EXP)) { \ - (CTX)->CtxFailure((STATUS)); \ - return; \ - } + do { \ + if (!TF_PREDICT_TRUE(EXP)) { \ + (CTX)->CtxFailure((STATUS)); \ + return; \ + } \ + } while (0) #define OP_REQUIRES_OK(CTX, ...) \ do { \ @@ -1507,11 +1509,13 @@ inline void OpOutputList::set_ref(int i, mutex* mu, Tensor* tensor_for_ref) { } while (0) #define OP_REQUIRES_ASYNC(CTX, EXP, STATUS, CALLBACK) \ - if (!TF_PREDICT_TRUE(EXP)) { \ - (CTX)->CtxFailure((STATUS)); \ - (CALLBACK)(); \ - return; \ - } + do { \ + if (!TF_PREDICT_TRUE(EXP)) { \ + (CTX)->CtxFailure((STATUS)); \ + (CALLBACK)(); \ + return; \ + } \ + } while (0) #define OP_REQUIRES_OK_ASYNC(CTX, STATUS, CALLBACK) \ do { \ diff --git a/tensorflow/core/kernels/conditional_accumulator_base.h b/tensorflow/core/kernels/conditional_accumulator_base.h index 05ee855dae..27db6ee785 100644 --- a/tensorflow/core/kernels/conditional_accumulator_base.h +++ b/tensorflow/core/kernels/conditional_accumulator_base.h @@ -162,10 +162,12 @@ class ConditionalAccumulatorBase : public ResourceBase { * function can get an indication that a failure has occurred. */ #define OP_REQUIRES_BOOLEAN(CTX, EXP, STATUS) \ - if (!TF_PREDICT_TRUE(EXP)) { \ - (CTX)->CtxFailure((STATUS)); \ - return false; \ - } + do { \ + if (!TF_PREDICT_TRUE(EXP)) { \ + (CTX)->CtxFailure((STATUS)); \ + return false; \ + } \ + } while (0) #define OP_REQUIRES_OK_BOOLEAN(CTX, STATUS) \ do { \ diff --git a/tensorflow/core/kernels/quantized_concat_op.cc b/tensorflow/core/kernels/quantized_concat_op.cc index ee573f1bb8..d67f1ab3ec 100644 --- a/tensorflow/core/kernels/quantized_concat_op.cc +++ b/tensorflow/core/kernels/quantized_concat_op.cc @@ -174,13 +174,13 @@ class QuantizedConcatOp : public OpKernel { OP_REQUIRES(context, (input_mins.size() == N), errors::InvalidArgument( "QuantizedConcatOp : Expected mins input list length ", - input_mins.size(), " to equal values length ", N)) + input_mins.size(), " to equal values length ", N)); OpInputList input_maxes; OP_REQUIRES_OK(context, context->input_list("input_maxes", &input_maxes)); OP_REQUIRES(context, (input_maxes.size() == N), errors::InvalidArgument( "QuantizedConcatOp : Expected maxes input list length ", - input_maxes.size(), " to equal values length ", N)) + input_maxes.size(), " to equal values length ", N)); const int input_dims = values[0].dims(); const TensorShape& input_shape = values[0].shape(); OP_REQUIRES( diff --git a/tensorflow/core/kernels/variable_ops.h b/tensorflow/core/kernels/variable_ops.h index 355140d44c..820b90d041 100644 --- a/tensorflow/core/kernels/variable_ops.h +++ b/tensorflow/core/kernels/variable_ops.h @@ -160,7 +160,7 @@ class DestroyTemporaryVariableOp : public OpKernel { explicit DestroyTemporaryVariableOp(OpKernelConstruction* context) : OpKernel(context) { OP_REQUIRES(context, IsRefType(context->input_type(0)), - errors::InvalidArgument("lhs input needs to be a ref type")) + errors::InvalidArgument("lhs input needs to be a ref type")); OP_REQUIRES_OK(context, context->GetAttr("var_name", &var_name_)); OP_REQUIRES(context, var_name_ != "", errors::InvalidArgument("Missing var_name attribute")); |