diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/CL/kernels/CLActivationLayerKernel.cpp | 4 | ||||
-rw-r--r-- | src/core/Utils.cpp | 34 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLPoolingLayer.cpp | 2 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/core/CL/kernels/CLActivationLayerKernel.cpp b/src/core/CL/kernels/CLActivationLayerKernel.cpp index 0f7003a38c..8172aafca9 100644 --- a/src/core/CL/kernels/CLActivationLayerKernel.cpp +++ b/src/core/CL/kernels/CLActivationLayerKernel.cpp @@ -131,8 +131,8 @@ void CLActivationLayerKernel::configure(ICLTensor *input, ICLTensor *output, Act } else { - a_const_int = input->info()->quantization_info().quantize(a_const); - b_const_int = input->info()->quantization_info().quantize(b_const); + a_const_int = input->info()->quantization_info().quantize(a_const, RoundingPolicy::TO_NEAREST_UP); + b_const_int = input->info()->quantization_info().quantize(b_const, RoundingPolicy::TO_NEAREST_UP); } } diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index af864f57f7..af50bbbaf7 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -21,10 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + #include "arm_compute/core/Utils.h" #include "arm_compute/core/FixedPoint.h" +#include "support/ToolchainSupport.h" + #include <algorithm> #include <cmath> #include <cstdint> @@ -387,3 +390,34 @@ int arm_compute::max_consecutive_elements_display_width(std::ostream &s, DataTyp } return 0; } + +int arm_compute::round(float x, RoundingPolicy rounding_policy) +{ + using namespace std; + int rounded = 0; + switch(rounding_policy) + { + case RoundingPolicy::TO_ZERO: + { + rounded = static_cast<int>(x); + break; + } + case RoundingPolicy::TO_NEAREST_UP: + { + rounded = static_cast<int>(support::cpp11::round(x)); + break; + } + case RoundingPolicy::TO_NEAREST_EVEN: + { + ARM_COMPUTE_ERROR("TO_NEAREST_EVEN rounding policy is not supported."); + break; + } + default: + { + ARM_COMPUTE_ERROR("Unsupported rounding policy."); + break; + } + } + + return rounded; +} diff --git a/src/runtime/CL/functions/CLPoolingLayer.cpp b/src/runtime/CL/functions/CLPoolingLayer.cpp index ac360fbb3d..20564f6c9d 100644 --- a/src/runtime/CL/functions/CLPoolingLayer.cpp +++ b/src/runtime/CL/functions/CLPoolingLayer.cpp @@ -46,7 +46,7 @@ void CLPoolingLayer::configure(ICLTensor *input, ICLTensor *output, const Poolin uint32_t border_value = 0; if(is_data_type_quantized_asymmetric(input->info()->data_type()) && !pool_info.exclude_padding()) { - border_value = static_cast<uint32_t>(input->info()->quantization_info().quantize(0)); + border_value = static_cast<uint32_t>(input->info()->quantization_info().quantize(0.f, RoundingPolicy::TO_NEAREST_UP)); } _border_handler.configure(input, _kernel->border_size(), border_mode, PixelValue(border_value)); |