From 4ace393bea5003000d5bf3d3572210599796bedd Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 24 Jul 2019 14:27:29 -0700 Subject: [PATCH] Fix sign-compare warnings with gcc --- onnxruntime/core/graph/graph.cc | 2 +- onnxruntime/core/optimizer/unsqueeze_elimination.cc | 2 +- onnxruntime/test/onnx/runner.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/onnxruntime/core/graph/graph.cc b/onnxruntime/core/graph/graph.cc index 8c45b4a094..57ae2855aa 100644 --- a/onnxruntime/core/graph/graph.cc +++ b/onnxruntime/core/graph/graph.cc @@ -2459,7 +2459,7 @@ Status Graph::SetGraphInputsOutputs() { // calling private ctor GSL_SUPPRESS(r .11) gsl::not_null Graph::AllocateNode() { - ORT_ENFORCE(nodes_.size() < std::numeric_limits::max()); + ORT_ENFORCE(nodes_.size() < static_cast(std::numeric_limits::max())); std::unique_ptr new_node(new Node(nodes_.size(), *this)); Node* node{new_node.get()}; diff --git a/onnxruntime/core/optimizer/unsqueeze_elimination.cc b/onnxruntime/core/optimizer/unsqueeze_elimination.cc index c031fe143d..109be80ad7 100644 --- a/onnxruntime/core/optimizer/unsqueeze_elimination.cc +++ b/onnxruntime/core/optimizer/unsqueeze_elimination.cc @@ -29,7 +29,7 @@ Status UnsqueezeElimination::Apply(Graph& graph, Node& node, RewriteRuleEffect& ORT_ENFORCE(tensor_proto); std::vector new_dims(axes.size() + tensor_proto->dims().size(), 0); - if (new_dims.size() >= std::numeric_limits::max()) { + if (new_dims.size() >= static_cast(std::numeric_limits::max())) { return Status(ONNXRUNTIME, FAIL, "index out of range"); } diff --git a/onnxruntime/test/onnx/runner.cc b/onnxruntime/test/onnx/runner.cc index 3bb3648f71..575292fbc6 100644 --- a/onnxruntime/test/onnx/runner.cc +++ b/onnxruntime/test/onnx/runner.cc @@ -362,7 +362,7 @@ EXECUTE_RESULT DataRunner::RunTaskImpl(size_t task_id) { output_names[i] = output_name; default_allocator->Free(output_name); } - if (feeds.size() > std::numeric_limits::max()) { + if (feeds.size() > static_cast(std::numeric_limits::max())) { ORT_THROW("length overflow"); } std::vector input_names(feeds.size());