未验证 提交 cda2e2d9 编写于 作者: H huzhiqiang 提交者: GitHub

[Windows] Fix compiling error on develop branch (#4383)

上级 ca9ec692
......@@ -161,7 +161,7 @@ class ContextProjectFunctor {
sequence_width});
if (up_pad > 0) { // add up pad
int padding_rows = std::min(
int padding_rows = (std::min)(
up_pad, static_cast<int>(lod_level_0[i + 1] - lod_level_0[i]));
for (int k = 0; k < padding_rows; ++k) {
......@@ -180,10 +180,10 @@ class ContextProjectFunctor {
}
if (down_pad > 0) { // add down pad
int down_pad_begin_row =
std::max(0,
(sequence_height - context_start - context_length) + 1) +
(std::max)(
0, (sequence_height - context_start - context_length) + 1) +
1;
int padding_begin = std::max(0, context_start - sequence_height);
int padding_begin = (std::max)(0, context_start - sequence_height);
int padding_size =
sequence_height - context_start >= context_length
? 1
......
......@@ -67,8 +67,8 @@ class Pool2dFunctor<lite::TargetType::kX86, PoolProcess, T> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -76,8 +76,8 @@ class Pool2dFunctor<lite::TargetType::kX86, PoolProcess, T> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
T ele = pool_process.initial();
......@@ -150,8 +150,8 @@ class Pool2dGradFunctor<lite::TargetType::kX86, PoolProcess, T> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -159,8 +159,8 @@ class Pool2dGradFunctor<lite::TargetType::kX86, PoolProcess, T> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
int pool_size = (exclusive || adaptive)
? (hend - hstart) * (wend - wstart)
......@@ -228,12 +228,12 @@ class MaxPool2dGradFunctor<lite::TargetType::kX86, T> {
for (int c = 0; c < output_channels; ++c) {
for (int ph = 0; ph < output_height; ++ph) {
int hstart = ph * stride_height - padding_height;
int hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
int hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
for (int pw = 0; pw < output_width; ++pw) {
int wstart = pw * stride_width - padding_width;
int wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
int wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
bool stop = false;
for (int h = hstart; h < hend && !stop; ++h) {
......@@ -337,8 +337,8 @@ class Pool3dFunctor<lite::TargetType::kX86, PoolProcess, T> {
dend = AdaptEndIndex(pd, input_depth, output_depth);
} else {
dstart = pd * stride_depth - padding_depth;
dend = std::min(dstart + ksize_depth, input_depth);
dstart = std::max(dstart, 0);
dend = (std::min)(dstart + ksize_depth, input_depth);
dstart = (std::max)(dstart, 0);
}
for (int ph = 0; ph < output_height; ++ph) {
if (adaptive) {
......@@ -346,8 +346,8 @@ class Pool3dFunctor<lite::TargetType::kX86, PoolProcess, T> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -355,8 +355,8 @@ class Pool3dFunctor<lite::TargetType::kX86, PoolProcess, T> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
int output_idx = (pd * output_height + ph) * output_width + pw;
T ele = pool_process.initial();
......@@ -441,8 +441,8 @@ class Pool3dGradFunctor<lite::TargetType::kX86, PoolProcess, T> {
dend = AdaptEndIndex(pd, input_depth, output_depth);
} else {
dstart = pd * stride_depth - padding_depth;
dend = std::min(dstart + ksize_depth, input_depth);
dstart = std::max(dstart, 0);
dend = (std::min)(dstart + ksize_depth, input_depth);
dstart = (std::max)(dstart, 0);
}
for (int ph = 0; ph < output_height; ++ph) {
if (adaptive) {
......@@ -450,8 +450,8 @@ class Pool3dGradFunctor<lite::TargetType::kX86, PoolProcess, T> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -459,8 +459,8 @@ class Pool3dGradFunctor<lite::TargetType::kX86, PoolProcess, T> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
int pool_size =
......@@ -540,16 +540,16 @@ class MaxPool3dGradFunctor<lite::TargetType::kX86, T> {
for (int c = 0; c < output_channels; ++c) {
for (int pd = 0; pd < output_depth; ++pd) {
int dstart = pd * stride_depth - padding_depth;
int dend = std::min(dstart + ksize_depth, input_depth);
dstart = std::max(dstart, 0);
int dend = (std::min)(dstart + ksize_depth, input_depth);
dstart = (std::max)(dstart, 0);
for (int ph = 0; ph < output_height; ++ph) {
int hstart = ph * stride_height - padding_height;
int hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
int hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
for (int pw = 0; pw < output_width; ++pw) {
int wstart = pw * stride_width - padding_width;
int wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
int wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
bool stop = false;
for (int d = dstart; d < dend && !stop; ++d) {
for (int h = hstart; h < hend && !stop; ++h) {
......@@ -651,8 +651,8 @@ class MaxPool2dWithIndexFunctor<lite::TargetType::kX86, T1, T2> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -660,8 +660,8 @@ class MaxPool2dWithIndexFunctor<lite::TargetType::kX86, T1, T2> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
T1 ele = static_cast<T1>(-FLT_MAX);
......@@ -794,8 +794,8 @@ class MaxPool3dWithIndexFunctor<lite::TargetType::kX86, T1, T2> {
dend = AdaptEndIndex(pd, input_depth, output_depth);
} else {
dstart = pd * stride_depth - padding_depth;
dend = std::min(dstart + ksize_depth, input_depth);
dstart = std::max(dstart, 0);
dend = (std::min)(dstart + ksize_depth, input_depth);
dstart = (std::max)(dstart, 0);
}
for (int ph = 0; ph < output_height; ++ph) {
if (adaptive) {
......@@ -803,8 +803,8 @@ class MaxPool3dWithIndexFunctor<lite::TargetType::kX86, T1, T2> {
hend = AdaptEndIndex(ph, input_height, output_height);
} else {
hstart = ph * stride_height - padding_height;
hend = std::min(hstart + ksize_height, input_height);
hstart = std::max(hstart, 0);
hend = (std::min)(hstart + ksize_height, input_height);
hstart = (std::max)(hstart, 0);
}
for (int pw = 0; pw < output_width; ++pw) {
if (adaptive) {
......@@ -812,8 +812,8 @@ class MaxPool3dWithIndexFunctor<lite::TargetType::kX86, T1, T2> {
wend = AdaptEndIndex(pw, input_width, output_width);
} else {
wstart = pw * stride_width - padding_width;
wend = std::min(wstart + ksize_width, input_width);
wstart = std::max(wstart, 0);
wend = (std::min)(wstart + ksize_width, input_width);
wstart = (std::max)(wstart, 0);
}
int output_idx = (pd * output_height + ph) * output_width + pw;
......
......@@ -35,7 +35,7 @@ inline static uint64_t MaximumSequenceLength(
uint64_t seq_num = seq_offset.size() - 1;
uint64_t max_seq_len = 0;
for (size_t i = 0; i < seq_num; ++i) {
max_seq_len = std::max(max_seq_len, seq_offset[i + 1] - seq_offset[i]);
max_seq_len = (std::max)(max_seq_len, seq_offset[i + 1] - seq_offset[i]);
}
return max_seq_len;
}
......
......@@ -26,7 +26,7 @@ namespace x86 {
static void SetNumThreads(int num_threads) {
#ifdef PADDLE_WITH_MKLML
int real_num_threads = std::max(num_threads, 1);
int real_num_threads = (std::max)(num_threads, 1);
x86::MKL_Set_Num_Threads(real_num_threads);
omp_set_num_threads(real_num_threads);
#endif
......@@ -52,14 +52,14 @@ static inline void RunParallelFor(const int64_t begin,
}
#ifdef PADDLE_WITH_MKLML
int64_t num_threads = std::min(GetMaxThreads(), end - begin);
int64_t num_threads = (std::min)(GetMaxThreads(), end - begin);
if (num_threads > 1) {
#pragma omp parallel num_threads(num_threads)
{
int64_t tid = omp_get_thread_num();
int64_t chunk_size = (end - begin + num_threads - 1) / num_threads;
int64_t begin_tid = begin + tid * chunk_size;
f(begin_tid, std::min(end, chunk_size + begin_tid));
f(begin_tid, (std::min)(end, chunk_size + begin_tid));
}
return;
}
......
......@@ -148,7 +148,7 @@ void MemoryOptimizePass::CollectLifeCycleByDevice(
int cur_life =
(*lifecycles)[TargetToStr(target_type)][var_name].second;
(*lifecycles)[TargetToStr(target_type)][var_name].second =
std::max(max_lifecycle_, cur_life);
(std::max)(max_lifecycle_, cur_life);
}
}
++max_lifecycle_;
......
......@@ -61,7 +61,7 @@ class StaticKernelPickPass : public mir::StmtPass {
float final_score{-1.};
Place winner_place{places[0]};
const int kMax =
std::numeric_limits<core::KernelPickFactor::value_type>::max();
(std::numeric_limits<core::KernelPickFactor::value_type>::max)();
size_t place_size = places.size();
// NOTE: We compare kernel's place with place in valid_places to select the
......
......@@ -52,7 +52,7 @@ void Decode(const Tensor& emission_weights,
for (int k = 1; k < seq_len; ++k) {
for (int i = 0; i < tag_num; ++i) {
T max_score = -std::numeric_limits<T>::max();
T max_score = -(std::numeric_limits<T>::max)();
int max_j = 0;
for (size_t j = 0; j < tag_num; ++j) {
T score = alpha_value[(k - 1) * tag_num + j] +
......@@ -67,7 +67,7 @@ void Decode(const Tensor& emission_weights,
}
}
T max_score = -std::numeric_limits<T>::max();
T max_score = -(std::numeric_limits<T>::max)();
int max_i = 0;
for (size_t i = 0; i < tag_num; ++i) {
T score = alpha_value[(seq_len - 1) * tag_num + i] + w[tag_num + i];
......
......@@ -72,10 +72,10 @@ static T JaccardOverlap(const T* box1, const T* box2, const bool normalized) {
box2[3] < box1[1]) {
return static_cast<T>(0.);
} else {
const T inter_xmin = std::max(box1[0], box2[0]);
const T inter_ymin = std::max(box1[1], box2[1]);
const T inter_xmax = std::min(box1[2], box2[2]);
const T inter_ymax = std::min(box1[3], box2[3]);
const T inter_xmin = (std::max)(box1[0], box2[0]);
const T inter_ymin = (std::max)(box1[1], box2[1]);
const T inter_xmax = (std::min)(box1[2], box2[2]);
const T inter_ymax = (std::min)(box1[3], box2[3]);
T norm = normalized ? static_cast<T>(0.) : static_cast<T>(1.);
T inter_w = inter_xmax - inter_xmin + norm;
T inter_h = inter_ymax - inter_ymin + norm;
......
......@@ -128,7 +128,7 @@ class TensorFormatter {
void FormatData(const Tensor& print_tensor, std::stringstream& log_stream) {
int64_t print_size = summarize_ == -1
? print_tensor.numel()
: std::min(summarize_, print_tensor.numel());
: (std::min)(summarize_, print_tensor.numel());
const T* data = print_tensor.data<T>(); // Always kHost, so unnessary to
// copy the data from device
log_stream << " - data: [";
......
......@@ -83,10 +83,10 @@ static inline T JaccardOverlap(const std::vector<T>& box1,
box2[3] < box1[1]) {
return static_cast<T>(0.);
} else {
const T inter_xmin = std::max(box1[0], box2[0]);
const T inter_ymin = std::max(box1[1], box2[1]);
const T inter_xmax = std::min(box1[2], box2[2]);
const T inter_ymax = std::min(box1[3], box2[3]);
const T inter_xmin = (std::max)(box1[0], box2[0]);
const T inter_ymin = (std::max)(box1[1], box2[1]);
const T inter_xmax = (std::min)(box1[2], box2[2]);
const T inter_ymax = (std::min)(box1[3], box2[3]);
T norm = normalized ? static_cast<T>(0.) : static_cast<T>(1.);
T inter_w = inter_xmax - inter_xmin + norm;
T inter_h = inter_ymax - inter_ymin + norm;
......@@ -183,10 +183,10 @@ void DeltaScoreToPrediction(
pred_box_xmax = pred_box_xmax / im_scale;
pred_box_ymax = pred_box_ymax / im_scale;
pred_box_xmin = std::max(std::min(pred_box_xmin, im_width - 1), zero);
pred_box_ymin = std::max(std::min(pred_box_ymin, im_height - 1), zero);
pred_box_xmax = std::max(std::min(pred_box_xmax, im_width - 1), zero);
pred_box_ymax = std::max(std::min(pred_box_ymax, im_height - 1), zero);
pred_box_xmin = (std::max)((std::min)(pred_box_xmin, im_width - 1), zero);
pred_box_ymin = (std::max)((std::min)(pred_box_ymin, im_height - 1), zero);
pred_box_xmax = (std::max)((std::min)(pred_box_xmax, im_width - 1), zero);
pred_box_ymax = (std::max)((std::min)(pred_box_ymax, im_height - 1), zero);
std::vector<T> one_pred;
one_pred.push_back(pred_box_xmin);
......
......@@ -71,7 +71,7 @@ inline void get_mid_dims(const lite::DDim &x_dims,
for (size_t j = 0; j < i; ++j) {
(*pre) *= y_dims[j];
}
*n = std::max(x_dims[i + axis], y_dims[i]);
*n = (std::max)(x_dims[i + axis], y_dims[i]);
*mid_flag = 1;
mid = i;
break;
......
......@@ -55,7 +55,7 @@ class SequenceArithmeticCompute
auto input_x = x_data + x_seq_offset[i] * inner_size;
auto input_y = y_data + y_seq_offset[i] * inner_size;
auto t_out = out_data + x_seq_offset[i] * inner_size;
int len = std::min(len_x, len_y);
int len = (std::min)(len_x, len_y);
for (int j = 0; j < len; j++) {
t_out[j] = input_x[j] + input_y[j];
}
......@@ -73,7 +73,7 @@ class SequenceArithmeticCompute
auto input_x = x_data + x_seq_offset[i] * inner_size;
auto input_y = y_data + y_seq_offset[i] * inner_size;
auto t_out = out_data + x_seq_offset[i] * inner_size;
int len = std::min(len_x, len_y);
int len = (std::min)(len_x, len_y);
for (int j = 0; j < len; j++) {
t_out[j] = input_x[j] - input_y[j];
}
......@@ -91,7 +91,7 @@ class SequenceArithmeticCompute
auto input_x = x_data + x_seq_offset[i] * inner_size;
auto input_y = y_data + y_seq_offset[i] * inner_size;
auto t_out = out_data + x_seq_offset[i] * inner_size;
int len = std::min(len_x, len_y);
int len = (std::min)(len_x, len_y);
for (int j = 0; j < len; j++) {
t_out[j] = input_x[j] * input_y[j];
}
......
......@@ -49,8 +49,8 @@ class SequenceConvCompute : public KernelLite<TARGET(kX86), PRECISION(kFloat)> {
bool padding_trainable = false;
const Tensor* padding_data = nullptr;
int up_pad = std::max(0, -context_start);
int down_pad = std::max(0, context_start + context_length - 1);
int up_pad = (std::max)(0, -context_start);
int down_pad = (std::max)(0, context_start + context_length - 1);
auto sequence_width = static_cast<int64_t>(in->dims()[1]);
std::vector<int64_t> col_shape{in->dims()[0],
......
......@@ -102,9 +102,9 @@ void slice_compute(const lite::Tensor* in,
start = starts[i] < 0 ? (starts[i] + dim_value) : starts[i];
end = ends[i] < 0 ? (ends[i] + dim_value) : ends[i];
start = std::max(start, 0);
end = std::max(end, 0);
end = std::min(end, dim_value);
start = (std::max)(start, 0);
end = (std::max)(end, 0);
end = (std::min)(end, dim_value);
CHECK_GT(end, start) << "end should greater than start";
out_dims[axes[i]] = end - start;
}
......@@ -172,7 +172,7 @@ void slice_compute(const lite::Tensor* in,
if (start < 0) {
start = (start + in_dims[axes[i]]);
}
start = std::max(start, 0);
start = (std::max)(start, 0);
offsets[axes[i]] = start;
}
auto in_t =
......
......@@ -391,7 +391,7 @@ void TensorToStream(std::ostream &os, const lite::Tensor &tensor) {
}
{ // the 3rd field, tensor data
uint64_t size = tensor.memory_size();
CHECK_LT(size, std::numeric_limits<std::streamsize>::max())
CHECK_LT(size, (std::numeric_limits<std::streamsize>::max)())
<< "Index overflow when writing tensor";
#ifdef LITE_WITH_CUDA
......@@ -461,7 +461,7 @@ void SetParamInfoNaive(naive_buffer::ParamDesc *param_desc,
}
desc.SetDim(tensor.dims().Vectorize());
uint64_t size = tensor.memory_size();
CHECK_LT(size, std::numeric_limits<std::streamsize>::max())
CHECK_LT(size, (std::numeric_limits<std::streamsize>::max)())
<< "Index overflow when writing tensor";
#ifdef LITE_WITH_CUDA
......
......@@ -62,7 +62,7 @@ void UpdatePaddingAndDilation(std::vector<int>* paddings,
if (padding_algorithm == "SAME") {
for (size_t i = 0; i < strides.size(); ++i) {
int out_size = (data_dims[i + 2] + strides[i] - 1) / strides[i];
int pad_sum = std::max(
int pad_sum = (std::max)(
(out_size - 1) * strides[i] + ksize[i + 2] - data_dims[i + 2],
(int64_t)0);
int pad_0 = pad_sum / 2;
......
......@@ -75,7 +75,7 @@ bool ElementwiseOp::InferShapeImpl() const {
if (x_dims_array[i] == -1 || y_dims_array[i] == -1) {
out_dims_array[i] = -1;
} else {
out_dims_array[i] = std::max(x_dims_array[i], y_dims_array[i]);
out_dims_array[i] = (std::max)(x_dims_array[i], y_dims_array[i]);
}
}
param_.Out->Resize(DDim(out_dims_array));
......
......@@ -128,7 +128,7 @@ inline void UpdatePadding(std::vector<int> *paddings,
for (size_t i = 0; i < strides.size(); ++i) {
int out_size = (data_dims[i + 2] + strides[i] - 1) / strides[i];
int pad_sum =
std::max((out_size - 1) * strides[i] + ksize[i] - data_dims[i + 2],
(std::max)((out_size - 1) * strides[i] + ksize[i] - data_dims[i + 2],
(int64_t)0);
int pad_0 = pad_sum / 2;
int pad_1 = pad_sum - pad_0;
......
......@@ -51,9 +51,9 @@ bool SliceOp::InferShapeImpl() const {
if (dim_value > 0) {
start = starts[i] < 0 ? (starts[i] + dim_value) : starts[i];
end = ends[i] < 0 ? (ends[i] + dim_value) : ends[i];
start = std::max(start, 0);
end = std::max(end, 0);
end = std::min(end, dim_value);
start = (std::max)(start, 0);
end = (std::max)(end, 0);
end = (std::min)(end, dim_value);
out_dims[axes[i]] = end - start;
}
}
......
......@@ -100,7 +100,6 @@ cd "%build_directory%"
-DPYTHON_EXECUTABLE="%python_path%"
call "%vcvarsall_dir%" amd64
cd "%build_directory%"
if "%BUILD_FOR_CI%"=="ON" (
msbuild /m /p:Configuration=Release lite\lite_compile_deps.vcxproj
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册