From 82fc8a17f5a81bb06225def16fc702a534bdfdc2 Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Mon, 28 Nov 2022 17:32:06 +0800 Subject: [PATCH] [Function] Fix slice function (#724) Add () --- fastdeploy/function/slice.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fastdeploy/function/slice.cc b/fastdeploy/function/slice.cc index 8b50bf422..f374034f2 100644 --- a/fastdeploy/function/slice.cc +++ b/fastdeploy/function/slice.cc @@ -65,25 +65,25 @@ void CheckAndUpdateSliceAttrs(const std::vector& in_dims, step); int64_t start = (*starts)[i] < 0 ? ((*starts)[i] + dim_value) : (*starts)[i]; - start = std::max(start, static_cast(0)); + start = (std::max)(start, static_cast(0)); int64_t end = 0 < step && (*ends)[i] < 0 ? ((*ends)[i] + dim_value) : (*ends)[i]; - end = std::min(end, dim_value); + end = (std::min)(end, dim_value); if (step > 0) { - start = std::min(start, dim_value); - end = std::max(end, static_cast(0)); + start = (std::min)(start, dim_value); + end = (std::max)(end, static_cast(0)); FDASSERT(end > start, "When step > 0, end should be greater than start, but " "received end = %d, start = %d.", end, start) } else { - start = std::min(start, dim_value - 1); + start = (std::min)(start, dim_value - 1); if (end < -1) { end += dim_value; } - end = std::max(end, static_cast(-1)); + end = (std::max)(end, static_cast(-1)); FDASSERT(start >= end, "When step < 0, start should be greater than end, but " "received start = %d, end = %d.", @@ -164,4 +164,4 @@ void Slice(const FDTensor& x, const std::vector& axes, } } // namespace function -} // namespace fastdeploy \ No newline at end of file +} // namespace fastdeploy