Merge pull request #40697 from tg-at-google:sign-compare-warning-fixes-batch-3
PiperOrigin-RevId: 318142205 Change-Id: If6d4934375cf8cace73b1cfa54106605195bc5d6
This commit is contained in:
commit
60441f3e59
@ -116,7 +116,7 @@ Status UncompressElement(const CompressedElement& compressed,
|
||||
compressed_data.data(), compressed_data.size(), &uncompressed_size)) {
|
||||
return errors::Internal("Could not get snappy uncompressed length");
|
||||
}
|
||||
if (uncompressed_size != total_size) {
|
||||
if (uncompressed_size != static_cast<size_t>(total_size)) {
|
||||
return errors::Internal(
|
||||
"Uncompressed size mismatch. Snappy expects ", uncompressed_size,
|
||||
" whereas the tensor metadata suggests ", total_size);
|
||||
|
@ -598,7 +598,7 @@ class AddOpsRewriteStage : public ArithmeticNodesGroupOptimizerStage {
|
||||
std::deque<InputAndShape> add_ops;
|
||||
|
||||
// Prepare leaf AddN nodes for inputs of equal shape
|
||||
for (int i = 0; i < shapes.size(); ++i) {
|
||||
for (int i = 0, iter_limit = shapes.size(); i < iter_limit; ++i) {
|
||||
const auto node_name = leaf_node_name(i);
|
||||
const auto& inputs = shape_sig_to_inputs[ShapeSignature(shapes[i])];
|
||||
add_ops.push_back(AddInputsOfSymbolicallyEqualShape(*group.root_node,
|
||||
@ -750,7 +750,8 @@ class HoistCommonFactorOutOfAggregation : public ArithmeticOptimizerStage {
|
||||
ctx().node_map->AddOutput(new_add_node->name(), new_outer_node->name());
|
||||
|
||||
// Hoist non-shared factors up into the new AddN node.
|
||||
for (int i = 0; i < unique_factors.size(); ++i) {
|
||||
for (int i = 0, iter_limit = unique_factors.size(); i < iter_limit;
|
||||
++i) {
|
||||
const string& unique_factor_i = unique_factors[i];
|
||||
new_add_node->set_input(i, unique_factor_i);
|
||||
ctx().node_map->AddOutput(unique_factor_i, new_add_node->name());
|
||||
@ -1190,7 +1191,7 @@ class RemoveIdentityTranspose : public ArithmeticOptimizerStage {
|
||||
if (a.size() != b.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.size(); ++i) {
|
||||
for (int i = 0, iter_limit = a.size(); i < iter_limit; ++i) {
|
||||
if (a[b[i]] != i) {
|
||||
return false;
|
||||
}
|
||||
@ -1199,7 +1200,7 @@ class RemoveIdentityTranspose : public ArithmeticOptimizerStage {
|
||||
}
|
||||
|
||||
bool IsIdentityPermutation(const std::vector<int64>& perm) {
|
||||
for (int64 i = 0; i < perm.size(); ++i) {
|
||||
for (int64 i = 0, iter_limit = perm.size(); i < iter_limit; ++i) {
|
||||
if (i != perm[i]) {
|
||||
return false;
|
||||
}
|
||||
@ -1500,7 +1501,8 @@ class HoistCWiseUnaryChainsStage : public ArithmeticOptimizerStage {
|
||||
for (int i = start; i < end; ++i) {
|
||||
unique_inputs.insert(node.input(i));
|
||||
}
|
||||
return unique_inputs.size() == n;
|
||||
int unique_input_size = unique_inputs.size();
|
||||
return unique_input_size == n;
|
||||
}
|
||||
|
||||
// Returns the length of the common unary chain of ops that can be
|
||||
@ -3248,14 +3250,15 @@ class RemoveStackSliceSameAxis : public ArithmeticOptimizerStage {
|
||||
slice_begin_vec.size(), ") and size (",
|
||||
slice_size_vec.size(), ") vectors.");
|
||||
}
|
||||
int slice_begin_vec_size = slice_begin_vec.size();
|
||||
if (!pack_output_shape.unknown_rank() &&
|
||||
slice_begin_vec.size() != pack_output_shape.dims()) {
|
||||
slice_begin_vec_size != pack_output_shape.dims()) {
|
||||
return Status::OK();
|
||||
}
|
||||
if (pack_axis >= slice_begin_vec.size()) {
|
||||
if (pack_axis >= slice_begin_vec_size) {
|
||||
return errors::InvalidArgument(
|
||||
"Input to node ", node->name(), " had pack_axis ", pack_axis,
|
||||
" but rank was ", slice_begin_vec.size(), ".");
|
||||
" but rank was ", slice_begin_vec_size, ".");
|
||||
}
|
||||
|
||||
*slice_start_value = slice_begin_vec[pack_axis];
|
||||
@ -3264,7 +3267,7 @@ class RemoveStackSliceSameAxis : public ArithmeticOptimizerStage {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < slice_begin_vec.size(); ++i) {
|
||||
for (int i = 0; i < slice_begin_vec_size; ++i) {
|
||||
if (i != pack_axis) {
|
||||
if (slice_begin_vec[i] != 0 ||
|
||||
!(slice_size_vec[i] == -1 ||
|
||||
@ -3352,7 +3355,7 @@ class RemoveStackSliceSameAxis : public ArithmeticOptimizerStage {
|
||||
|
||||
int begin_index = -1;
|
||||
int64 begin_value = 0;
|
||||
for (int i = 0; i < slice_begin_vec.size(); ++i) {
|
||||
for (int i = 0, iter_limit = slice_begin_vec.size(); i < iter_limit; ++i) {
|
||||
const int64 v = slice_begin_vec[i];
|
||||
if (v != 0) {
|
||||
if (begin_index != -1) {
|
||||
@ -3366,7 +3369,7 @@ class RemoveStackSliceSameAxis : public ArithmeticOptimizerStage {
|
||||
|
||||
int end_index = -1;
|
||||
int64 end_value = 0;
|
||||
for (int i = 0; i < slice_end_vec.size(); ++i) {
|
||||
for (int i = 0, iter_limit = slice_begin_vec.size(); i < iter_limit; ++i) {
|
||||
const int64 v = slice_end_vec[i];
|
||||
if (v != pack_output_shape.dim_size(i)) {
|
||||
if (end_index != -1) {
|
||||
|
@ -479,7 +479,8 @@ Status ConstantFolding::MaterializeShapes(const GraphProperties& properties) {
|
||||
CHECK_EQ(op, "ShapeN");
|
||||
CHECK_EQ(input.size(), output.size());
|
||||
const NodeDef* const shape_n_node = node;
|
||||
for (int port_idx = 0; port_idx < output.size(); ++port_idx) {
|
||||
for (int port_idx = 0, idx_limit = output.size(); port_idx < idx_limit;
|
||||
++port_idx) {
|
||||
const DataType type = output[port_idx].dtype();
|
||||
CHECK(type == DT_INT32 || type == DT_INT64);
|
||||
const PartialTensorShape shape(input[port_idx].shape());
|
||||
@ -641,12 +642,12 @@ Status ConstantFolding::MaterializeBroadcastGradientArgs(
|
||||
// These extra dims could be equal to 1, in which case there is no
|
||||
// broadcasting. It could also be greater than 1, in which case there would
|
||||
// be broadcasting. Since we don't know, we'll just punt.
|
||||
for (int i = common_dims; i < shape1.size(); ++i) {
|
||||
for (int i = common_dims, iter_limit = shape1.size(); i < iter_limit; ++i) {
|
||||
if (shape1[i] < 0) {
|
||||
return Status::OK();
|
||||
}
|
||||
}
|
||||
for (int i = common_dims; i < shape2.size(); ++i) {
|
||||
for (int i = common_dims, iter_limit = shape2.size(); i < iter_limit; ++i) {
|
||||
if (shape2[i] < 0) {
|
||||
return Status::OK();
|
||||
}
|
||||
@ -1165,7 +1166,8 @@ bool IsValidConstShapeForMulConvPushDown(
|
||||
// If the const is a scalar, or it has fewer or same number of dimensions
|
||||
// than the filter and it only has single element, the optimization should
|
||||
// work.
|
||||
if (mul_const_input_shape.dim_size() <= data_format.size() &&
|
||||
if (mul_const_input_shape.dim_size() <=
|
||||
static_cast<int>(data_format.size()) &&
|
||||
TensorShape(mul_const_input_shape).num_elements() == 1) {
|
||||
return true;
|
||||
}
|
||||
@ -1461,7 +1463,7 @@ Status ConstantFolding::FoldNode(NodeDef* node, GraphDef* output_graph,
|
||||
VLOG(2) << "Folded node: " << SummarizeNodeDef(*node);
|
||||
|
||||
NodeDef* constant_output = nullptr;
|
||||
for (int i = 0; i < const_nodes.size(); i++) {
|
||||
for (int i = 0, iter_limit = const_nodes.size(); i < iter_limit; i++) {
|
||||
NodeDef* const_node = &const_nodes[i];
|
||||
VLOG(3) << "Generated constant node: " << SummarizeNodeDef(*const_node);
|
||||
if (const_node->name().empty()) {
|
||||
@ -1549,7 +1551,7 @@ Status ConstantFolding::FoldNode(NodeDef* node, GraphDef* output_graph,
|
||||
constant_output->name());
|
||||
*output->mutable_input(i) = AsControlDependency(*constant_output);
|
||||
}
|
||||
} else if (port < const_nodes.size() &&
|
||||
} else if (port < static_cast<int>(const_nodes.size()) &&
|
||||
!const_nodes[port].name().empty()) {
|
||||
// Replace alive outputs with the corresponding constant.
|
||||
node_map_->UpdateInput(output->name(), NodeName(output->input(i)),
|
||||
@ -2068,7 +2070,8 @@ Status ConstantFolding::RemoveShuffleOrTranspose(
|
||||
permutation.push_back(permutation_tensor.vec<int>()(j));
|
||||
}
|
||||
}
|
||||
if (permutation.size() != shape.dim_size()) {
|
||||
int permutation_size = permutation.size();
|
||||
if (permutation_size != shape.dim_size()) {
|
||||
// Number of elements in perm should be same as dim_size. Skip if not.
|
||||
return Status::OK();
|
||||
}
|
||||
@ -2245,9 +2248,10 @@ Status ConstantFolding::SimplifyStridedSlice(const GraphProperties& properties,
|
||||
// as many as expanded_ellipsis_indices.size() axes during computation.
|
||||
// We need to subtract this number from j.
|
||||
int i = j;
|
||||
int expanded_ellipsis_indices_size = expanded_ellipsis_indices.size();
|
||||
if (ellipsis_index != -1 &&
|
||||
j >= ellipsis_index + expanded_ellipsis_indices.size()) {
|
||||
i = j - expanded_ellipsis_indices.size();
|
||||
j >= ellipsis_index + expanded_ellipsis_indices_size) {
|
||||
i = j - expanded_ellipsis_indices_size;
|
||||
}
|
||||
int b = begin.dtype() == DT_INT32 ? begin.vec<int>()(i)
|
||||
: begin.vec<int64>()(i);
|
||||
@ -3479,15 +3483,16 @@ bool ConstantFolding::PartialAssocOpConstFolding(GraphDef* optimized_graph,
|
||||
}
|
||||
// Promote AccumulateNV2 with all constant inputs to AddN, since it is
|
||||
// a fake node that cannot be constant folded by itself.
|
||||
if (const_inputs.size() == num_non_control_inputs &&
|
||||
int const_inputs_size = const_inputs.size();
|
||||
if (const_inputs_size == num_non_control_inputs &&
|
||||
node->op() == "AccumulateNV2") {
|
||||
node->set_op("AddN");
|
||||
node->mutable_attr()->erase("shape");
|
||||
return true;
|
||||
}
|
||||
const string new_node_name = OptimizedNodeName(
|
||||
*node, strings::StrCat("_partial_split_", const_inputs.size()));
|
||||
if (const_inputs.size() > 1 && const_inputs.size() < num_non_control_inputs &&
|
||||
*node, strings::StrCat("_partial_split_", const_inputs_size));
|
||||
if (const_inputs_size > 1 && const_inputs_size < num_non_control_inputs &&
|
||||
!node_map_->NodeExists(new_node_name)) {
|
||||
NodeDef* added_node = optimized_graph->add_node();
|
||||
*added_node = *node;
|
||||
|
@ -242,7 +242,7 @@ Status Transposer::CreateConstPermNode(TransposeContext* context,
|
||||
|
||||
AttrValue attr_tensor;
|
||||
Tensor tensor(DT_INT32, TensorShape({4}));
|
||||
for (int i = 0; i < permutation.size(); i++) {
|
||||
for (int i = 0, iter_limit = permutation.size(); i < iter_limit; i++) {
|
||||
tensor.flat<int>()(i) = permutation[i];
|
||||
}
|
||||
tensor.AsProtoTensorContent(attr_tensor.mutable_tensor());
|
||||
@ -538,10 +538,11 @@ bool Transposer::IsFaninPortDimsNIfConst(const utils::MutableNodeView& node,
|
||||
if (!tensor.FromProto(value_attr->tensor())) {
|
||||
return false;
|
||||
}
|
||||
if (tensor.dims() != dims.size()) {
|
||||
const int dims_size = dims.size();
|
||||
if (tensor.dims() != dims_size) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < dims.size(); ++i) {
|
||||
for (int i = 0; i < dims_size; ++i) {
|
||||
if (tensor.dim_size(i) != dims[i]) {
|
||||
return false;
|
||||
}
|
||||
@ -863,12 +864,13 @@ inline bool IsValidConstPermTransposeNode(const utils::MutableNodeView& node,
|
||||
if (!GetValueAttrFromConstInputNode(node, IsTranspose, 1, &tensor)) {
|
||||
return false;
|
||||
}
|
||||
if (tensor.NumElements() != permutation.size()) {
|
||||
const int permutation_size = permutation.size();
|
||||
if (tensor.NumElements() != permutation_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& tensor_data = tensor.unaligned_flat<int32>();
|
||||
for (int i = 0; i < permutation.size(); i++) {
|
||||
for (int i = 0; i < permutation_size; i++) {
|
||||
if (permutation[i] != tensor_data(i)) {
|
||||
return false;
|
||||
}
|
||||
@ -1229,10 +1231,11 @@ bool ReduceTransposer::KeepDims(const utils::MutableNodeView& node) {
|
||||
|
||||
bool ReduceTransposer::IsAlongAxis(const Tensor& tensor,
|
||||
absl::Span<const int> axis, int rank) {
|
||||
if (tensor.dims() != 1 || tensor.dim_size(0) != axis.size()) {
|
||||
const int axis_size = axis.size();
|
||||
if (tensor.dims() != 1 || tensor.dim_size(0) != axis_size) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < axis.size(); ++i) {
|
||||
for (int i = 0; i < axis_size; ++i) {
|
||||
int local_axis = tensor.flat<int>()(i);
|
||||
if (local_axis < 0) {
|
||||
local_axis += rank;
|
||||
@ -1444,12 +1447,13 @@ bool SqueezeTransposer::IsAlongAxis(const AttrValue& attr,
|
||||
int rank) const {
|
||||
const auto& list = attr.list();
|
||||
// If list is empty, Squeeze op will squeeze all dimensions of size 1.
|
||||
int axis_size = axis.size();
|
||||
if (list.i_size() == 0) {
|
||||
return true;
|
||||
} else if (list.i_size() != axis.size()) {
|
||||
} else if (list.i_size() != axis_size) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < axis.size(); ++i) {
|
||||
for (int i = 0; i < axis_size; ++i) {
|
||||
int local_axis = list.i(i);
|
||||
if (local_axis < 0) {
|
||||
local_axis += rank;
|
||||
@ -1563,7 +1567,8 @@ Status StridedSliceTransposer::PermuteMask(TransposeContext* context,
|
||||
return errors::InvalidArgument("invalid mask value: ", mask_i);
|
||||
}
|
||||
int result = 0;
|
||||
for (int i = 0; i < context->src_to_dst.size(); i++) {
|
||||
for (int i = 0, iter_limit = context->src_to_dst.size(); i < iter_limit;
|
||||
i++) {
|
||||
const int final_pos = context->src_to_dst[i];
|
||||
const int position_mask = 1 << final_pos;
|
||||
const int bit_i = (mask_i & position_mask) >> final_pos;
|
||||
|
@ -528,11 +528,12 @@ template <typename T>
|
||||
Status PermuteSingle(absl::string_view location,
|
||||
absl::Span<const int> permutation, T* values) {
|
||||
DCHECK(values != nullptr);
|
||||
if (values->size() != permutation.size()) {
|
||||
int permutation_size = permutation.size();
|
||||
if (values->size() != permutation_size) {
|
||||
return Status(tensorflow::error::Code::INVALID_ARGUMENT,
|
||||
absl::StrCat("Size of values ", values->size(),
|
||||
" does not match size of permutation ",
|
||||
permutation.size(), " @ ", location));
|
||||
permutation_size, " @ ", location));
|
||||
}
|
||||
typedef typename T::value_type V;
|
||||
std::vector<V> elements(values->begin(), values->end());
|
||||
@ -549,11 +550,12 @@ template <typename T>
|
||||
Status PermuteDouble(absl::string_view location,
|
||||
absl::Span<const int> permutation, T* values) {
|
||||
DCHECK(values != nullptr);
|
||||
if (values->size() != permutation.size() * 2) {
|
||||
int permutation_size = permutation.size();
|
||||
if (values->size() != permutation_size * 2) {
|
||||
return Status(tensorflow::error::Code::INVALID_ARGUMENT,
|
||||
absl::StrCat("Size of values ", values->size(),
|
||||
" does not match twice the size of permutation ",
|
||||
permutation.size(), " @ ", location));
|
||||
permutation_size, " @ ", location));
|
||||
}
|
||||
typedef typename T::value_type V;
|
||||
std::vector<V> elements(values->begin(), values->end());
|
||||
|
@ -58,7 +58,7 @@ Status GetTensorProperties(const GraphOptimizerContext& ctx,
|
||||
|
||||
const auto& output_properties =
|
||||
ctx.graph_properties->GetOutputProperties(tensor_id.node());
|
||||
auto num_outputs = output_properties.size();
|
||||
int num_outputs = output_properties.size();
|
||||
|
||||
if (num_outputs == 0 || tensor_id.index() > num_outputs - 1) {
|
||||
return errors::InvalidArgument(
|
||||
|
@ -130,7 +130,7 @@ string FindForwardNode(utils::MutableNodeView* backward_node) {
|
||||
void UpdateForwardIdentityNodeDtype(utils::MutableNodeView* forward_node,
|
||||
const DataTypeVector& dtypes) {
|
||||
const auto& fanouts_vector = forward_node->GetRegularFanouts();
|
||||
for (int pos = 0; pos < fanouts_vector.size(); ++pos) {
|
||||
for (int pos = 0, pos_limit = fanouts_vector.size(); pos < pos_limit; ++pos) {
|
||||
const auto& fanouts_at_pos = fanouts_vector[pos];
|
||||
for (const auto& fanout : fanouts_at_pos) {
|
||||
if ("Identity" == fanout.node_view()->GetOp()) {
|
||||
|
@ -468,7 +468,8 @@ void RecomputationRewritingPass(RewriterConfig::MemOptType optimization_level,
|
||||
// with "gradients/" or contains "/gradients/".
|
||||
return absl::StartsWith(node.name(),
|
||||
recomputation_targets_name_scope) ||
|
||||
node.name().find("/" + recomputation_targets_name_scope) != -1;
|
||||
static_cast<int>(node.name().find(
|
||||
"/" + recomputation_targets_name_scope)) != -1;
|
||||
};
|
||||
|
||||
if (optimization_level == RewriterConfig::RECOMPUTATION_HEURISTICS ||
|
||||
|
@ -73,7 +73,8 @@ bool HasOpName(const string& node_name, const string& op_name) {
|
||||
Status GetOutputDataType(
|
||||
const std::vector<OpInfo::TensorProperties>& output_props, int output_index,
|
||||
DataType* dtype) {
|
||||
if (output_index >= output_props.size()) {
|
||||
int output_props_size = output_props.size();
|
||||
if (output_index >= output_props_size) {
|
||||
return errors::Internal("Invalid output index ", output_index,
|
||||
" size of output_props ", output_props.size());
|
||||
}
|
||||
@ -520,7 +521,7 @@ class UnaryElementwiseRewriter : public ScopedAllocatorOptimizer::Rewriter {
|
||||
|
||||
// Add control edges from the ScopedAllocatorOp to all of the
|
||||
// input nodes and mark them for allocation from backing tensor.
|
||||
for (int i = 0; i < inputs.size(); ++i) {
|
||||
for (int i = 0, iter_limit = inputs.size(); i < iter_limit; ++i) {
|
||||
auto& nd = inputs[i];
|
||||
if (IsArg(*nd.from_node_def)) {
|
||||
return errors::Internal(
|
||||
@ -547,7 +548,8 @@ class UnaryElementwiseRewriter : public ScopedAllocatorOptimizer::Rewriter {
|
||||
std::vector<InputDesc> inputs_to_first;
|
||||
LOG_WARNING_AND_RETURN_IF_ERROR(GetDataInputs(
|
||||
graph, sa_opti->node_map(), nd.from_node_def, &inputs_to_first));
|
||||
for (int i = 0; i < inputs_to_first.size(); ++i) {
|
||||
for (int i = 0, iter_limit = inputs_to_first.size(); i < iter_limit;
|
||||
++i) {
|
||||
if (fanout.find(inputs_to_first[i].from_node_def) != fanout.end()) {
|
||||
VLOG(2) << "Found node " << inputs_to_first[i].from_node_def->name()
|
||||
<< " in the fanout of " << sa_name;
|
||||
@ -587,7 +589,7 @@ class UnaryElementwiseRewriter : public ScopedAllocatorOptimizer::Rewriter {
|
||||
VLOG(2) << "BuildSAConcatNode " << sac_name;
|
||||
// control input: edge name -> source node name
|
||||
absl::flat_hash_map<string, string> sac_ctl_inputs;
|
||||
for (int i = 0; i < ops.size(); ++i) {
|
||||
for (int i = 0, iter_limit = ops.size(); i < iter_limit; ++i) {
|
||||
NodeDef* old_op = ops[i];
|
||||
for (const string& old_op_input : old_op->input()) {
|
||||
int position = 0;
|
||||
@ -708,7 +710,7 @@ class UnaryElementwiseRewriter : public ScopedAllocatorOptimizer::Rewriter {
|
||||
const std::set<string>& op_instance_names,
|
||||
const string& op_name, const string& sas_name) {
|
||||
VLOG(2) << "RewireSubgraph";
|
||||
for (int op_idx = 0; op_idx < ops.size(); ++op_idx) {
|
||||
for (int op_idx = 0, idx_limit = ops.size(); op_idx < idx_limit; ++op_idx) {
|
||||
NodeDef* old_op = ops[op_idx];
|
||||
// Copy the output node set since we'll be modifying the version
|
||||
// maintained by NodeMap in the loop.
|
||||
|
@ -99,7 +99,7 @@ Status ShapeOptimizer::Optimize(Cluster* cluster, const GrapplerItem& item,
|
||||
}
|
||||
const auto& prop =
|
||||
properties.GetOutputProperties(reduce_indices.node->name());
|
||||
int prop_size = prop.size();
|
||||
const int prop_size = prop.size();
|
||||
if (prop_size <= reduce_indices.port_id) {
|
||||
continue;
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ class SingleThreadedExecutorImpl : public Executor {
|
||||
std::vector<Node*> ordered_nodes;
|
||||
ordered_nodes.reserve(graph.num_nodes());
|
||||
GetReversePostOrder(graph, &ordered_nodes);
|
||||
|
||||
if (ordered_nodes.size() != graph.num_nodes()) {
|
||||
int ordered_nodes_size = ordered_nodes.size();
|
||||
if (ordered_nodes_size != graph.num_nodes()) {
|
||||
return errors::InvalidArgument("Graph had ", graph.num_nodes(),
|
||||
" but reverse post-order had ",
|
||||
ordered_nodes.size());
|
||||
|
@ -74,7 +74,7 @@ Status InitializableLookupTable::Initialize(InitTableIterator& iter) {
|
||||
|
||||
Status InitializableLookupTable::AreEntriesSame(const InitTableIterator& iter,
|
||||
bool* result) {
|
||||
*result = iter.total_size() == size();
|
||||
*result = static_cast<size_t>(iter.total_size()) == size();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,8 @@ RemoteFusedGraphExecuteUtils::AddOutputTensorShapeTypeByTensorShapeMap(
|
||||
if (data_types.empty()) {
|
||||
return false;
|
||||
}
|
||||
CHECK(data_types.size() > port);
|
||||
int data_types_size = data_types.size();
|
||||
CHECK(data_types_size > port);
|
||||
*data_type = data_types.at(port);
|
||||
*shape = shapes.at(port);
|
||||
return true;
|
||||
@ -788,7 +789,8 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
|
||||
++input_count;
|
||||
}
|
||||
}
|
||||
CHECK(input_count == 0 || input_count == node->in_edges().size())
|
||||
int node_in_edges_size = node->in_edges().size();
|
||||
CHECK(input_count == 0 || input_count == node_in_edges_size)
|
||||
<< "Invalid input_count(" << input_count << ", "
|
||||
<< node->in_edges().size() << ") " << node_name;
|
||||
|
||||
@ -968,10 +970,11 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
|
||||
border_inputs, border_outputs, require_shape_type, &graph, &fused_node));
|
||||
|
||||
for (const Node* node : graph.nodes()) {
|
||||
for (int i = 0; i < node->num_inputs(); ++i) {
|
||||
for (int i = 0, iter_limit = node->num_inputs(); i < iter_limit; ++i) {
|
||||
const Edge* edge = nullptr;
|
||||
TF_RETURN_IF_ERROR(node->input_edge(i, &edge));
|
||||
for (int j = 0; j < border_outputs.size(); ++j) {
|
||||
for (int j = 0, second_iter_limit = border_outputs.size();
|
||||
j < second_iter_limit; ++j) {
|
||||
const string& output = border_outputs.at(j);
|
||||
const TensorId tid = ParseTensorName(output);
|
||||
const string output_name(tid.first);
|
||||
@ -1333,8 +1336,8 @@ RemoteFusedGraphExecuteUtils::FuseRemoteGraphByPlacedArguments(
|
||||
|
||||
/* static */ Status RemoteFusedGraphExecuteUtils::CopyByteArrayToTensor(
|
||||
const void* src_ptr, const int src_size, Tensor* tensor) {
|
||||
CHECK(tensor->TotalBytes() >= src_size)
|
||||
<< tensor->TotalBytes() << ", " << src_size;
|
||||
int tensor_TotalBytes = tensor->TotalBytes();
|
||||
CHECK(tensor_TotalBytes >= src_size) << tensor_TotalBytes << ", " << src_size;
|
||||
void* dst_ptr;
|
||||
switch (tensor->dtype()) {
|
||||
case DT_FLOAT:
|
||||
|
@ -57,7 +57,8 @@ class Stack : public ResourceBase {
|
||||
Status Push(const TensorAndAllocation& value) {
|
||||
mutex_lock l(mu_);
|
||||
TF_RETURN_IF_ERROR(CheckNotClosed());
|
||||
if (max_size_ >= 0 && stack_.size() >= max_size_) {
|
||||
int stack_size = stack_.size();
|
||||
if (max_size_ >= 0 && stack_size >= max_size_) {
|
||||
return errors::InvalidArgument("Stack[", stack_name_, "] overflowed ",
|
||||
"its max_size (", max_size_, ")");
|
||||
}
|
||||
|
@ -336,7 +336,8 @@ Status LoadOpShapeFunction::operator()(
|
||||
});
|
||||
std::vector<shape_inference::ShapeHandle> inputs(user_param_count);
|
||||
int input_index = 0;
|
||||
for (int i = 0; i < state_variable_specs.size(); ++i) {
|
||||
for (int i = 0, iter_limit = state_variable_specs.size(); i < iter_limit;
|
||||
++i) {
|
||||
if (state_variable_specs[i].has_user_defined() || is_debug_op_) {
|
||||
std::vector<shape_inference::ShapeHandle> input_temp;
|
||||
TF_RETURN_IF_ERROR(c->input(state_variable_specs[i].name(), &input_temp));
|
||||
@ -388,7 +389,8 @@ Status RetrieveOpShapeFunction::operator()(
|
||||
TF_RETURN_IF_ERROR(c->GetAttr("num_shards", &num_shards));
|
||||
int shard_id;
|
||||
TF_RETURN_IF_ERROR(c->GetAttr("shard_id", &shard_id));
|
||||
for (int j = 0; j < state_variable_specs.size(); ++j) {
|
||||
for (int j = 0, iter_limit = state_variable_specs.size(); j < iter_limit;
|
||||
++j) {
|
||||
if (state_variable_specs[j].has_user_defined() || is_debug_op_) {
|
||||
auto shape = c->MakeShape(
|
||||
std::vector<shape_inference::DimensionHandle>(2, c->UnknownDim()));
|
||||
|
@ -139,7 +139,7 @@ BCastList<N>::BCastList(const BCastList::Vec (&x)[N],
|
||||
if (x[i] != x[0]) {
|
||||
all_equal = false;
|
||||
}
|
||||
if (x[i].size() > largest_rank) {
|
||||
if (static_cast<int>(x[i].size()) > largest_rank) {
|
||||
largest_rank = x[i].size();
|
||||
}
|
||||
}
|
||||
@ -176,7 +176,7 @@ BCastList<N>::BCastList(const BCastList::Vec (&x)[N],
|
||||
|
||||
// 1-extend and align all vectors.
|
||||
for (int i = 0; i < N; ++i) {
|
||||
if (copy[i].size() < largest_rank) {
|
||||
if (static_cast<int>(copy[i].size()) < largest_rank) {
|
||||
copy[i].resize(largest_rank, 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user