Unverified Commit a6f29d41 authored by Juha Reunanen's avatar Juha Reunanen Committed by GitHub
Browse files

Avoid different kinds of compiler warnings (#2481)

* Avoid different kinds of compiler warnings that started to appear when upgrading my build environment

* Avoid more compiler warnings

* Revert the overly verbose static_cast changes

* Make resize_bilinear and resize_bilinear_gradient take long long (previously just long)

* Circumvent what appears to be a bug in Visual Studio 2019's optimizer
(see: https://forum.juce.com/t/warning-in-the-lastest-vs2019/38267)
parent 994df341
...@@ -2000,11 +2000,11 @@ namespace dlib ...@@ -2000,11 +2000,11 @@ namespace dlib
void resize_bilinear ( void resize_bilinear (
tensor& dest, tensor& dest,
long dest_row_stride, long long dest_row_stride,
long dest_channel_stride, long long dest_channel_stride,
const tensor& src, const tensor& src,
long src_row_stride, long long src_row_stride,
long src_channel_stride long long src_channel_stride
) )
{ {
DLIB_CASSERT(is_same_object(dest, src)==false); DLIB_CASSERT(is_same_object(dest, src)==false);
...@@ -2028,11 +2028,11 @@ namespace dlib ...@@ -2028,11 +2028,11 @@ namespace dlib
void resize_bilinear_gradient ( void resize_bilinear_gradient (
tensor& grad, tensor& grad,
long grad_row_stride, long long grad_row_stride,
long grad_channel_stride, long long grad_channel_stride,
const tensor& gradient_input, const tensor& gradient_input,
long gradient_input_row_stride, long long gradient_input_row_stride,
long gradient_input_channel_stride long long gradient_input_channel_stride
) )
{ {
DLIB_CASSERT(is_same_object(grad, gradient_input)==false); DLIB_CASSERT(is_same_object(grad, gradient_input)==false);
......
...@@ -423,20 +423,20 @@ namespace dlib ...@@ -423,20 +423,20 @@ namespace dlib
void resize_bilinear ( void resize_bilinear (
tensor& dest, tensor& dest,
long dest_row_stride, long long dest_row_stride,
long dest_channel_stride, long long dest_channel_stride,
const tensor& src, const tensor& src,
long src_row_stride, long long src_row_stride,
long src_channel_stride long long src_channel_stride
); );
void resize_bilinear_gradient ( void resize_bilinear_gradient (
tensor& grad, tensor& grad,
long grad_row_stride, long long grad_row_stride,
long grad_channel_stride, long long grad_channel_stride,
const tensor& gradient_input, const tensor& gradient_input,
long gradient_input_row_stride, long long gradient_input_row_stride,
long gradient_input_channel_stride long long gradient_input_channel_stride
); );
inline void resize_bilinear ( inline void resize_bilinear (
......
...@@ -1732,11 +1732,11 @@ namespace dlib ...@@ -1732,11 +1732,11 @@ namespace dlib
void resize_bilinear ( void resize_bilinear (
tensor& dest, tensor& dest,
long dest_row_stride, long long dest_row_stride,
long dest_channel_stride, long long dest_channel_stride,
const tensor& src, const tensor& src,
long src_row_stride, long long src_row_stride,
long src_channel_stride long long src_channel_stride
) )
{ {
DLIB_CASSERT(is_same_object(dest, src)==false); DLIB_CASSERT(is_same_object(dest, src)==false);
...@@ -1838,11 +1838,11 @@ namespace dlib ...@@ -1838,11 +1838,11 @@ namespace dlib
void resize_bilinear_gradient ( void resize_bilinear_gradient (
tensor& grad, tensor& grad,
long grad_row_stride, long long grad_row_stride,
long grad_channel_stride, long long grad_channel_stride,
const tensor& gradient_input, const tensor& gradient_input,
long gradient_input_row_stride, long long gradient_input_row_stride,
long gradient_input_channel_stride long long gradient_input_channel_stride
) )
{ {
DLIB_CASSERT(is_same_object(grad, gradient_input)==false); DLIB_CASSERT(is_same_object(grad, gradient_input)==false);
......
...@@ -467,20 +467,20 @@ namespace dlib ...@@ -467,20 +467,20 @@ namespace dlib
void resize_bilinear ( void resize_bilinear (
tensor& dest, tensor& dest,
long dest_row_stride, long long dest_row_stride,
long dest_channel_stride, long long dest_channel_stride,
const tensor& src, const tensor& src,
long src_row_stride, long long src_row_stride,
long src_channel_stride long long src_channel_stride
); );
void resize_bilinear_gradient ( void resize_bilinear_gradient (
tensor& grad, tensor& grad,
long grad_row_stride, long long grad_row_stride,
long grad_channel_stride, long long grad_channel_stride,
const tensor& gradient_input, const tensor& gradient_input,
long gradient_input_row_stride, long long gradient_input_row_stride,
long gradient_input_channel_stride long long gradient_input_channel_stride
); );
inline void resize_bilinear ( inline void resize_bilinear (
......
...@@ -110,7 +110,7 @@ namespace dlib ...@@ -110,7 +110,7 @@ namespace dlib
tensor& operator/= (float val) tensor& operator/= (float val)
{ {
*this *= 1.0/val; *this *= 1.f/val;
return *this; return *this;
} }
......
...@@ -1868,7 +1868,7 @@ namespace dlib { namespace tt ...@@ -1868,7 +1868,7 @@ namespace dlib { namespace tt
if (items.size() < 1) if (items.size() < 1)
return; return;
scale = 1.0/items.size(); scale = 1.f/items.size();
// split item into groups of accessible devices // split item into groups of accessible devices
std::vector<tensor*> group, unused; std::vector<tensor*> group, unused;
......
...@@ -40,9 +40,9 @@ namespace dlib ...@@ -40,9 +40,9 @@ namespace dlib
input_rgb_image ( input_rgb_image (
) : ) :
avg_red(122.782), avg_red(122.782f),
avg_green(117.001), avg_green(117.001f),
avg_blue(104.298) avg_blue(104.298f)
{ {
} }
......
...@@ -745,7 +745,7 @@ namespace dlib ...@@ -745,7 +745,7 @@ namespace dlib
unsigned long total_num_labels = 0; unsigned long total_num_labels = 0;
// We make it true that: possible_labels[classifier][label_idx_lookup[classifier][label]] == label // We make it true that: possible_labels[classifier][label_idx_lookup[classifier][label]] == label
std::map<std::string, std::map<std::string,long>> label_idx_lookup; std::map<std::string, std::map<std::string, size_t>> label_idx_lookup;
// Scratch doesn't logically contribute to the state of this object. It's just // Scratch doesn't logically contribute to the state of this object. It's just
...@@ -2188,8 +2188,8 @@ namespace dlib ...@@ -2188,8 +2188,8 @@ namespace dlib
{ {
// These values used to be hard coded, so for this version of the metric // These values used to be hard coded, so for this version of the metric
// learning loss we just use these values. // learning loss we just use these values.
item.margin = 0.1; item.margin = 0.1f;
item.dist_thresh = 0.75; item.dist_thresh = 0.75f;
return; return;
} }
else if (version == "loss_metric_2") else if (version == "loss_metric_2")
...@@ -2215,8 +2215,8 @@ namespace dlib ...@@ -2215,8 +2215,8 @@ namespace dlib
} }
private: private:
float margin = 0.04; float margin = 0.04f;
float dist_thresh = 0.6; float dist_thresh = 0.6f;
// These variables are only here to avoid being reallocated over and over in // These variables are only here to avoid being reallocated over and over in
......
...@@ -24,7 +24,7 @@ namespace dlib ...@@ -24,7 +24,7 @@ namespace dlib
} }
sgd( sgd(
) : sgd(0.0005, 0.9) ) : sgd(0.0005f, 0.9f)
{ {
} }
...@@ -209,7 +209,7 @@ namespace dlib ...@@ -209,7 +209,7 @@ namespace dlib
} }
adam( adam(
) : adam(0.0005, 0.9, 0.999) ) : adam(0.0005f, 0.9f, 0.999f)
{} {}
float get_momentum1 ( float get_momentum1 (
......
...@@ -748,6 +748,10 @@ namespace dlib ...@@ -748,6 +748,10 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// Circumvent what appears to be a bug in Visual Studio 2019's optimizer
// (see: https://forum.juce.com/t/warning-in-the-lastest-vs2019/38267)
#pragma warning ( push )
#pragma warning ( disable: 4723 )
inline rectangle set_rect_area ( inline rectangle set_rect_area (
const rectangle& rect, const rectangle& rect,
unsigned long area unsigned long area
...@@ -768,6 +772,7 @@ namespace dlib ...@@ -768,6 +772,7 @@ namespace dlib
return centered_rect(rect, (long)std::round(rect.width()*scale), (long)std::round(rect.height()*scale)); return centered_rect(rect, (long)std::round(rect.width()*scale), (long)std::round(rect.height()*scale));
} }
} }
#pragma warning ( pop )
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -22,7 +22,7 @@ namespace dlib ...@@ -22,7 +22,7 @@ namespace dlib
) )
{ {
std::map<unsigned long,unsigned long> class_labels; std::map<unsigned long,unsigned long> class_labels;
for (unsigned long i = 0; i < row_labels.size(); ++i) for (size_t i = 0; i < row_labels.size(); ++i)
{ {
const unsigned long next = class_labels.size(); const unsigned long next = class_labels.size();
if (class_labels.count(row_labels[i]) == 0) if (class_labels.count(row_labels[i]) == 0)
......
...@@ -111,7 +111,7 @@ namespace dlib ...@@ -111,7 +111,7 @@ namespace dlib
{ {
// if they are trying to push back a character that they didn't read last // if they are trying to push back a character that they didn't read last
// that is an error // that is an error
const unsigned long prev = read_pos-1; const auto prev = read_pos-1;
if (c != EOF && prev < buffer.size() && if (c != EOF && prev < buffer.size() &&
c != static_cast<unsigned char>(buffer[prev])) c != static_cast<unsigned char>(buffer[prev]))
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment