diff --git a/include/aidge/backend/cpu/operator/ResizeImpl_kernels.hpp b/include/aidge/backend/cpu/operator/ResizeImpl_kernels.hpp index 6449417baf855620669aba11ebca16d9384c4e7c..fe82f194c1d1f49306392dd02d2b79e6d67d81b2 100644 --- a/include/aidge/backend/cpu/operator/ResizeImpl_kernels.hpp +++ b/include/aidge/backend/cpu/operator/ResizeImpl_kernels.hpp @@ -50,12 +50,13 @@ void ResizeImpl_cpu_forward_kernel( outputDims.cend(), 1, std::multiplies<DimSize_t>()); - std::vector<float> coordInApprox(inputDims.size()); - std::vector<std::size_t> coordIn(inputDims.size()); - std::vector<DimSize_t> coordOut; + +#ifdef _OPENMP + #pragma omp parallel for if (outputLen >= 16) +#endif for (DimSize_t idxFlatOut = 0; idxFlatOut < outputLen; ++idxFlatOut) { - coordOut = Tensor::toCoord(outputDims, idxFlatOut); - coordInApprox = + const auto coordOut = Tensor::toCoord(outputDims, idxFlatOut); + auto coordInApprox = Interpolation::untransformCoordinates(coordOut, inputDims, outputDims, @@ -72,6 +73,7 @@ void ResizeImpl_cpu_forward_kernel( coordInApprox[i] = std::ceil(coordInApprox[i] - 0.5f); } } + std::vector<std::size_t> coordIn(inputDims.size()); if (Tensor::isInBounds<float>(inputDims, coordInApprox)) { for (std::size_t i = 0; i < coordInApprox.size(); ++i) { coordIn[i] = static_cast<std::size_t>(coordInApprox[i]); diff --git a/include/aidge/backend/cpu/operator/TopKImpl_kernels.hpp b/include/aidge/backend/cpu/operator/TopKImpl_kernels.hpp index 3d6bc3c8a00540a2dd26a1e11986e2ccd1de26b7..5156818872f2242e674d45042dfdd07002951bf1 100644 --- a/include/aidge/backend/cpu/operator/TopKImpl_kernels.hpp +++ b/include/aidge/backend/cpu/operator/TopKImpl_kernels.hpp @@ -47,6 +47,9 @@ void TopKImpl_cpu_forward_kernel(int64_t axis, const std::size_t dim_i = inputDims[axis]; std::vector<std::pair<I, int64_t>> buffer(dim_i); +#ifdef _OPENMP + #pragma omp parallel for collapse(2) if (stride_pre * stride_post >= 16) +#endif for (std::size_t pre = 0; pre < stride_pre; ++pre) { for (std::size_t post = 0; post < stride_post; ++post) { const std::size_t idx_i = pre * dim_i * stride_post + post; diff --git a/src/data/Interpolation.cpp b/src/data/Interpolation.cpp index fbf224d84f65c442e98967783d303605a177d390..a5ab8f95ce460456df57da54bd29d45d87d20fbd 100644 --- a/src/data/Interpolation.cpp +++ b/src/data/Interpolation.cpp @@ -79,10 +79,10 @@ InterpolationCPU::linearRecurse(const std::vector<float> &coordToInterpolate, pointsCoords, alongDim); } - Log::debug("\nEntering linear recurse with {} points.", points.size()); - Log::debug("Points : {}", extractPtCoords(points)); - Log::debug("coordsToInterpolate : {}", coordToInterpolate); - Log::debug("alongDim : {}", alongDim); + //Log::debug("\nEntering linear recurse with {} points.", points.size()); + //Log::debug("Points : {}", extractPtCoords(points)); + //Log::debug("coordsToInterpolate : {}", coordToInterpolate); + //Log::debug("alongDim : {}", alongDim); /////////////////// // COMPUTATION @@ -98,9 +98,9 @@ InterpolationCPU::linearRecurse(const std::vector<float> &coordToInterpolate, upperPoints.insert(point); } } - Log::debug("alongDim : {}", alongDim); - Log::debug("lowerPoints : {}", extractPtCoords(lowerPoints)); - Log::debug("upperPoints : {}", extractPtCoords(upperPoints)); + //Log::debug("alongDim : {}", alongDim); + //Log::debug("lowerPoints : {}", extractPtCoords(lowerPoints)); + //Log::debug("upperPoints : {}", extractPtCoords(upperPoints)); // Here are 3 cases // 1. upper/lowerPoints.size() == 0 @@ -174,7 +174,7 @@ InterpolationCPU::linearRecurse(const std::vector<float> &coordToInterpolate, // 0 is just a sanity check to ensure later that all dims have been // interpolate interpolatedPoint.first[alongDim] = 0; - Log::debug("successfully returned from alongDim : {}", alongDim); + //Log::debug("successfully returned from alongDim : {}", alongDim); return std::set<Point<T>>({interpolatedPoint}); }