Add abs functions

This commit is contained in:
zhoushunjie
2022-11-24 04:02:00 +00:00
parent a14c55069f
commit 12af6b4464
4 changed files with 34 additions and 0 deletions

View File

@@ -83,5 +83,18 @@ TEST(fastdeploy, exp_sqrt_round_log) {
log_result.size());
}
TEST(fastdeploy, abs) {
CheckShape check_shape;
CheckData check_data;
FDTensor x, y;
std::vector<float> test_data = {-1, 2, 3, -5, -4, -6};
x.SetExternalData({2, 3}, FDDataType::FP32, test_data.data());
std::vector<float> result = {1, 2, 3, 5, 4, 6};
Abs(x, &y);
check_shape(y.shape, {2, 3});
check_data(reinterpret_cast<const float*>(y.Data()), result.data(),
result.size());
}
} // namespace function
} // namespace fastdeploy