Improve acos ref accuracy for integral types (#19470)
This commit is contained in:
parent
7c751883fc
commit
dd258f9607
@ -7,8 +7,21 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "openvino/reference/utils/type_util.hpp"
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace reference {
|
namespace reference {
|
||||||
|
namespace func {
|
||||||
|
template <class T, typename std::enable_if<ov::is_floating_point<T>()>::type* = nullptr>
|
||||||
|
T acos(const T in) {
|
||||||
|
return std::acos(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
|
||||||
|
T acos(const T in) {
|
||||||
|
return static_cast<T>(std::round(std::acos(in)));
|
||||||
|
}
|
||||||
|
} // namespace func
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reference implementation of Acos operator.
|
* @brief Reference implementation of Acos operator.
|
||||||
@ -17,11 +30,9 @@ namespace reference {
|
|||||||
* @param out Output buffer pointer with results.
|
* @param out Output buffer pointer with results.
|
||||||
* @param count Number of elements in input buffer.
|
* @param count Number of elements in input buffer.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <class T>
|
||||||
void acos(const T* arg, T* out, const size_t count) {
|
void acos(const T* arg, T* out, const size_t count) {
|
||||||
std::transform(arg, arg + count, out, [](T in) {
|
std::transform(arg, arg + count, out, &func::acos<T>);
|
||||||
return static_cast<T>(std::acos(in));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} // namespace reference
|
} // namespace reference
|
||||||
} // namespace ov
|
} // namespace ov
|
||||||
|
@ -24,7 +24,7 @@ T acosh(const T in) {
|
|||||||
} // namespace func
|
} // namespace func
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reference implementation of Acos operator.
|
* @brief Reference implementation of Acosh operator.
|
||||||
*
|
*
|
||||||
* @param arg Input buffer pointer with input data.
|
* @param arg Input buffer pointer with input data.
|
||||||
* @param out Output buffer pointer with results.
|
* @param out Output buffer pointer with results.
|
||||||
|
@ -68,15 +68,15 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
0.00000000f}}),
|
0.00000000f}}),
|
||||||
Builder {}
|
Builder {}
|
||||||
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
|
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
|
||||||
.expected({{3}, element::i32, std::vector<int32_t> {3, 1, 0}}),
|
.expected({{3}, element::i32, std::vector<int32_t> {3, 2, 0}}),
|
||||||
Builder {}
|
Builder {}
|
||||||
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
|
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
|
||||||
.expected({{3}, element::i64, std::vector<int64_t> {3, 1, 0}}),
|
.expected({{3}, element::i64, std::vector<int64_t> {3, 2, 0}}),
|
||||||
Builder {}
|
Builder {}
|
||||||
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
|
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
|
||||||
.expected({{2}, element::u32, std::vector<uint32_t> {1, 0}}),
|
.expected({{2}, element::u32, std::vector<uint32_t> {2, 0}}),
|
||||||
Builder {}
|
Builder {}
|
||||||
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
|
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
|
||||||
.expected({{2}, element::u64, std::vector<uint64_t> {1, 0}})),
|
.expected({{2}, element::u64, std::vector<uint64_t> {2, 0}})),
|
||||||
ReferenceAcosLayerTest::getTestCaseName);
|
ReferenceAcosLayerTest::getTestCaseName);
|
||||||
} // namespace reference_tests
|
} // namespace reference_tests
|
||||||
|
Loading…
Reference in New Issue
Block a user