diff options
author | SiCongLi <sicong.li@arm.com> | 2022-01-05 12:18:03 +0000 |
---|---|---|
committer | SiCong Li <sicong.li@arm.com> | 2022-01-06 10:11:49 +0000 |
commit | b99e54e05a4e9fed3bae1172c874af87e712526b (patch) | |
tree | 88922f42d49da97b404636d591aeee344502f056 | |
parent | c4270cf958e85e0c41590030e1f9e228493a5ba0 (diff) | |
download | ComputeLibrary-b99e54e05a4e9fed3bae1172c874af87e712526b.tar.gz |
Add signbit support for f16 type
Resolves COMPMID-5037
Change-Id: I648e8810dfd86e2ebcc16554f3f4cc58a5fd8c32
Signed-off-by: SiCongLi <sicong.li@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6899
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | support/ToolchainSupport.h | 19 | ||||
-rw-r--r-- | tests/validation/Validation.h | 5 |
3 files changed, 22 insertions, 4 deletions
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2021 Arm Limited +Copyright (c) 2017-2022 Arm Limited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h index f19a8da627..cddcd542c8 100644 --- a/support/ToolchainSupport.h +++ b/support/ToolchainSupport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Arm Limited. + * Copyright (c) 2017-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -309,6 +309,23 @@ inline bool isfinite(bfloat16 value) { return std::isfinite(float(value)); } + +// std::signbit +template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type> +inline bool signbit(T value) +{ + return std::signbit(value); +} + +inline bool signbit(half_float::half value) +{ + return half_float::signbit(value); +} + +inline bool signbit(bfloat16 value) +{ + return std::signbit(float(value)); +} } // namespace cpp11 } // namespace support } // namespace arm_compute diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index 7bad1a2286..289aca4d08 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021 Arm Limited. + * Copyright (c) 2017-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -51,7 +51,8 @@ namespace template <typename T> inline bool are_equal_infs(T val0, T val1) { - return (!support::cpp11::isfinite(val0)) && (!support::cpp11::isfinite(val1)) && (std::signbit(val0) == std::signbit(val1)); + const auto same_sign = support::cpp11::signbit(val0) == support::cpp11::signbit(val1); + return (!support::cpp11::isfinite(val0)) && (!support::cpp11::isfinite(val1)) && same_sign; } } // namespace |