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)
This commit is contained in:
Juha Reunanen 2022-01-06 16:03:48 +02:00 committed by GitHub
parent 994df341a2
commit a6f29d41ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 46 deletions

View File

@ -2000,11 +2000,11 @@ namespace dlib
void resize_bilinear (
tensor& dest,
long dest_row_stride,
long dest_channel_stride,
long long dest_row_stride,
long long dest_channel_stride,
const tensor& src,
long src_row_stride,
long src_channel_stride
long long src_row_stride,
long long src_channel_stride
)
{
DLIB_CASSERT(is_same_object(dest, src)==false);
@ -2028,11 +2028,11 @@ namespace dlib
void resize_bilinear_gradient (
tensor& grad,
long grad_row_stride,
long grad_channel_stride,
long long grad_row_stride,
long long grad_channel_stride,
const tensor& gradient_input,
long gradient_input_row_stride,
long gradient_input_channel_stride
long long gradient_input_row_stride,
long long gradient_input_channel_stride
)
{
DLIB_CASSERT(is_same_object(grad, gradient_input)==false);

View File

@ -423,20 +423,20 @@ namespace dlib
void resize_bilinear (
tensor& dest,
long dest_row_stride,
long dest_channel_stride,
long long dest_row_stride,
long long dest_channel_stride,
const tensor& src,
long src_row_stride,
long src_channel_stride
long long src_row_stride,
long long src_channel_stride
);
void resize_bilinear_gradient (
tensor& grad,
long grad_row_stride,
long grad_channel_stride,
long long grad_row_stride,
long long grad_channel_stride,
const tensor& gradient_input,
long gradient_input_row_stride,
long gradient_input_channel_stride
long long gradient_input_row_stride,
long long gradient_input_channel_stride
);
inline void resize_bilinear (

View File

@ -1732,11 +1732,11 @@ namespace dlib
void resize_bilinear (
tensor& dest,
long dest_row_stride,
long dest_channel_stride,
long long dest_row_stride,
long long dest_channel_stride,
const tensor& src,
long src_row_stride,
long src_channel_stride
long long src_row_stride,
long long src_channel_stride
)
{
DLIB_CASSERT(is_same_object(dest, src)==false);
@ -1838,11 +1838,11 @@ namespace dlib
void resize_bilinear_gradient (
tensor& grad,
long grad_row_stride,
long grad_channel_stride,
long long grad_row_stride,
long long grad_channel_stride,
const tensor& gradient_input,
long gradient_input_row_stride,
long gradient_input_channel_stride
long long gradient_input_row_stride,
long long gradient_input_channel_stride
)
{
DLIB_CASSERT(is_same_object(grad, gradient_input)==false);

View File

@ -467,20 +467,20 @@ namespace dlib
void resize_bilinear (
tensor& dest,
long dest_row_stride,
long dest_channel_stride,
long long dest_row_stride,
long long dest_channel_stride,
const tensor& src,
long src_row_stride,
long src_channel_stride
long long src_row_stride,
long long src_channel_stride
);
void resize_bilinear_gradient (
tensor& grad,
long grad_row_stride,
long grad_channel_stride,
long long grad_row_stride,
long long grad_channel_stride,
const tensor& gradient_input,
long gradient_input_row_stride,
long gradient_input_channel_stride
long long gradient_input_row_stride,
long long gradient_input_channel_stride
);
inline void resize_bilinear (

View File

@ -110,7 +110,7 @@ namespace dlib
tensor& operator/= (float val)
{
*this *= 1.0/val;
*this *= 1.f/val;
return *this;
}

View File

@ -1868,7 +1868,7 @@ namespace dlib { namespace tt
if (items.size() < 1)
return;
scale = 1.0/items.size();
scale = 1.f/items.size();
// split item into groups of accessible devices
std::vector<tensor*> group, unused;

View File

@ -40,9 +40,9 @@ namespace dlib
input_rgb_image (
) :
avg_red(122.782),
avg_green(117.001),
avg_blue(104.298)
avg_red(122.782f),
avg_green(117.001f),
avg_blue(104.298f)
{
}

View File

@ -745,7 +745,7 @@ namespace dlib
unsigned long total_num_labels = 0;
// 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
@ -2188,8 +2188,8 @@ namespace dlib
{
// These values used to be hard coded, so for this version of the metric
// learning loss we just use these values.
item.margin = 0.1;
item.dist_thresh = 0.75;
item.margin = 0.1f;
item.dist_thresh = 0.75f;
return;
}
else if (version == "loss_metric_2")
@ -2215,8 +2215,8 @@ namespace dlib
}
private:
float margin = 0.04;
float dist_thresh = 0.6;
float margin = 0.04f;
float dist_thresh = 0.6f;
// These variables are only here to avoid being reallocated over and over in

View File

@ -24,7 +24,7 @@ namespace dlib
}
sgd(
) : sgd(0.0005, 0.9)
) : sgd(0.0005f, 0.9f)
{
}
@ -209,7 +209,7 @@ namespace dlib
}
adam(
) : adam(0.0005, 0.9, 0.999)
) : adam(0.0005f, 0.9f, 0.999f)
{}
float get_momentum1 (

View File

@ -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 (
const rectangle& rect,
unsigned long area
@ -768,6 +772,7 @@ namespace dlib
return centered_rect(rect, (long)std::round(rect.width()*scale), (long)std::round(rect.height()*scale));
}
}
#pragma warning ( pop )
// ----------------------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@ namespace dlib
)
{
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();
if (class_labels.count(row_labels[i]) == 0)

View File

@ -111,7 +111,7 @@ namespace dlib
{
// if they are trying to push back a character that they didn't read last
// that is an error
const unsigned long prev = read_pos-1;
const auto prev = read_pos-1;
if (c != EOF && prev < buffer.size() &&
c != static_cast<unsigned char>(buffer[prev]))
{