add float32, uint8 and int8 unit_tests for transposeConv2d
Signed-off-by: Jing.Deng <Jing.Deng@verisilicon.com>
This commit is contained in:
parent
1e42cfd668
commit
be066fb9bd
|
|
@ -75,7 +75,7 @@ if (TIM_VX_ENABLE_TEST)
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|
||||||
add_executable(unit_test ${UT_SRC})
|
add_executable(unit_test ${UT_SRC})
|
||||||
target_link_libraries(unit_test gtest gtest_main ${TARGET_NAME}-static)
|
target_link_libraries(unit_test gtest gtest_main gmock gmock_main ${TARGET_NAME}-static)
|
||||||
|
|
||||||
install(TARGETS unit_test DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/)
|
install(TARGETS unit_test DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -5,6 +5,20 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
// A gmock matcher that check that elements of a float vector match to a given
|
||||||
|
// tolerance.
|
||||||
|
inline std::vector<::testing::Matcher<float>> ArrayFloatNear(
|
||||||
|
const std::vector<float>& values, float max_abs_error = 1e-5) {
|
||||||
|
std::vector<::testing::Matcher<float>> matchers;
|
||||||
|
matchers.reserve(values.size());
|
||||||
|
for (const float& v : values) {
|
||||||
|
matchers.emplace_back(testing::FloatNear(v, max_abs_error));
|
||||||
|
}
|
||||||
|
return matchers;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::pair<float, int32_t> QuantizationParams(float f_min, float f_max) {
|
std::pair<float, int32_t> QuantizationParams(float f_min, float f_max) {
|
||||||
|
|
@ -84,4 +98,16 @@ inline std::vector<T> Quantize(const std::vector<float>& data, float scale,
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline std::vector<float> Dequantize(const std::vector<T>& data, float scale,
|
||||||
|
int32_t zero_point) {
|
||||||
|
std::vector<float> f;
|
||||||
|
f.reserve(data.size());
|
||||||
|
for (const T& q : data) {
|
||||||
|
f.push_back(scale * (q - zero_point));
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* TIM_VX_TEST_UTILS_H_ */
|
#endif /* TIM_VX_TEST_UTILS_H_ */
|
||||||
Loading…
Reference in New Issue