Skip to content
Snippets Groups Projects
Commit e7e7ac2a authored by Maxence Naud's avatar Maxence Naud Committed by Olivier BICHLER
Browse files

fix padding of resize, remove cpp17 clamp functions

parent 7b678ed9
No related branches found
No related tags found
2 merge requests!118v0.4.0,!104update Resize operator
......@@ -45,8 +45,8 @@ void ResizeImpl_cpu_forward_kernel(
const IO *input = static_cast<const IO *>(input_);
IO *output = static_cast<IO *>(output_);
DimSize_t outputLen = std::accumulate(outputDims.begin(),
outputDims.end(),
const DimSize_t outputLen = std::accumulate(outputDims.cbegin(),
outputDims.cend(),
1,
std::multiplies<DimSize_t>());
std::vector<float> coordInApprox;
......
......@@ -112,31 +112,31 @@ InterpolationCPU::linearRecurse(const std::vector<float> &coordToInterpolate,
// points have not been all discriminated and must be further split
// so we call linearRecurse()
switch (lowerPoints.size()) {
case 0: {
return linearRecurse(coordToInterpolate, upperPoints, alongDim + 1);
}
case 1: {
break;
}
default: {
lowerPoints =
linearRecurse(coordToInterpolate, lowerPoints, alongDim + 1);
break;
}
case 0: {
return linearRecurse(coordToInterpolate, upperPoints, alongDim + 1);
}
case 1: {
break;
}
default: {
lowerPoints =
linearRecurse(coordToInterpolate, lowerPoints, alongDim + 1);
break;
}
}
switch (upperPoints.size()) {
case 0: {
return linearRecurse(coordToInterpolate, lowerPoints, alongDim + 1);
}
case 1: {
break;
}
default: {
upperPoints =
linearRecurse(coordToInterpolate, upperPoints, alongDim + 1);
break;
}
case 0: {
return linearRecurse(coordToInterpolate, lowerPoints, alongDim + 1);
}
case 1: {
break;
}
default: {
upperPoints =
linearRecurse(coordToInterpolate, upperPoints, alongDim + 1);
break;
}
}
// At this point lowerPoints & upperPoints are garanteed to be
......@@ -164,8 +164,8 @@ InterpolationCPU::linearRecurse(const std::vector<float> &coordToInterpolate,
// interpolate
interpolatedPoint.first[alongDim] = 0;
Log::debug("successfully returned from alongDim : {}", alongDim);
return std::set({interpolatedPoint});
};
return std::set<Point<T>>({interpolatedPoint});
}
template <typename T>
T InterpolationCPU::linear(const std::vector<float> &coordToInterpolate,
......
......@@ -9,20 +9,19 @@
*
********************************************************************************/
#include <cstdint>
#include <memory>
#include <aidge/data/Data.hpp>
#include <aidge/data/Interpolation.hpp>
#include <aidge/data/half.hpp>
#include <aidge/operator/Pad.hpp>
#include <aidge/utils/ArrayHelpers.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cstdint>
#include <memory>
#include "aidge/data/Tensor.hpp"
#include "aidge/operator/OperatorTensor.hpp"
#include "aidge/operator/Resize.hpp"
#include "aidge/utils/TensorUtils.hpp"
namespace Aidge {
......@@ -83,7 +82,7 @@ TEST_CASE("[cpu/operator] Resize(forward)", "[Resize][CPU]") {
op,
Interpolation::Linear,
Interpolation::CoordinateTransformation::HalfPixel,
PadBorderType::Nearest,
PadBorderType::Edge,
std::make_shared<Tensor>(
Array4D<float, 1, 1, 1, 1>{{{{{0.417022}}}}}),
nullptr,
......@@ -102,7 +101,7 @@ TEST_CASE("[cpu/operator] Resize(forward)", "[Resize][CPU]") {
op,
Interpolation::Linear,
Interpolation::Asymmetric,
PadBorderType::Nearest,
PadBorderType::Edge,
std::make_shared<Tensor>(
Array4D<float, 1, 1, 5, 5>{{{{{7.20324516e-01,
1.14374816e-04,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment