Refine RNNCell/HardSwish/Reduce_sum ut (#660)
Modify tolerance in some of these op unit tests for StreamProcessor Type: Bug Fix Issue: 37103 Signed-off-by: Feiyue Chen <Feiyue.Chen@verisilicon.com>
This commit is contained in:
parent
4fde0badb2
commit
8267effdfb
|
|
@ -12,6 +12,7 @@
|
|||
TEST(RNNCell, layout_infer_align) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 1e-4f : 1e-5f;
|
||||
|
||||
uint32_t input_size = 3, batch_size = 2, num_units = 4;
|
||||
|
||||
|
|
@ -99,13 +100,14 @@ TEST(RNNCell, layout_infer_align) {
|
|||
std::vector<uint8_t> state_out(state_out_golden.size());
|
||||
EXPECT_TRUE(infer_output->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(infer_output_state->CopyDataFromTensor(state_out.data()));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, tolerance));
|
||||
EXPECT_EQ(state_out_golden, state_out);
|
||||
}
|
||||
|
||||
TEST(RNNCell, layout_infer_notalign) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 1e-4f : 1e-5f;
|
||||
|
||||
uint32_t input_size = 3, batch_size = 2, num_units = 4;
|
||||
|
||||
|
|
@ -200,6 +202,6 @@ TEST(RNNCell, layout_infer_notalign) {
|
|||
std::vector<uint8_t> state_out(state_out_golden.size());
|
||||
EXPECT_TRUE(infer_output->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(infer_output_state->CopyDataFromTensor(state_out.data()));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, tolerance));
|
||||
EXPECT_EQ(state_out_golden, state_out);
|
||||
}
|
||||
|
|
@ -462,6 +462,7 @@ TEST(SoftSign, shape_5_1_fp32) {
|
|||
TEST(HardSwish, 40_f32) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 1e-3f : 1e-5f;
|
||||
|
||||
tim::vx::ShapeType io_shape({40});
|
||||
tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, io_shape,
|
||||
|
|
@ -500,5 +501,5 @@ TEST(HardSwish, 40_f32) {
|
|||
EXPECT_TRUE(graph->Run());
|
||||
std::vector<float> output(40);
|
||||
EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, tolerance));
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
TEST(Reduce_sum, NotKeepDims) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 0.01568627544 : 1e-5f;
|
||||
|
||||
tim::vx::ShapeType input_shape({2, 3, 1});
|
||||
tim::vx::ShapeType output_shape({2, 1});
|
||||
|
|
@ -75,12 +76,13 @@ TEST(Reduce_sum, NotKeepDims) {
|
|||
|
||||
std::vector<float> output(golden.size());
|
||||
EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, tolerance));
|
||||
}
|
||||
|
||||
TEST(Reduce_sum, KeepDims) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
if (ctx->isClOnly()) GTEST_SKIP();
|
||||
float tolerance = ctx->hasSP() ? 0.01568627544 : 1e-5f;
|
||||
|
||||
auto graph = ctx->CreateGraph();
|
||||
tim::vx::ShapeType input_shape({2, 3});
|
||||
|
|
@ -127,7 +129,7 @@ TEST(Reduce_sum, KeepDims) {
|
|||
|
||||
std::vector<float> output(golden.size());
|
||||
EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(golden, output, tolerance));
|
||||
}
|
||||
|
||||
TEST(Reduce_all, KeepDims) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
TEST(RNNCell, shape_3_2_4_float) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 1e-4f : 1e-5f;
|
||||
|
||||
uint32_t input_size = 3, batch_size = 2, num_units = 4;
|
||||
|
||||
|
|
@ -118,13 +119,14 @@ TEST(RNNCell, shape_3_2_4_float) {
|
|||
EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(state_out_tensor->CopyDataFromTensor(state_out.data()));
|
||||
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output,1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, tolerance));
|
||||
EXPECT_EQ(state_out_golden, state_out);
|
||||
}
|
||||
|
||||
TEST(RNNCell, seperate) {
|
||||
auto ctx = tim::vx::Context::Create();
|
||||
auto graph = ctx->CreateGraph();
|
||||
float tolerance = ctx->hasSP() ? 1e-4f : 1e-5f;
|
||||
std::vector<float> in_data = {
|
||||
0.12609188, 0.46347019, 0.89598465,
|
||||
0.35867718, 0.36897406, 0.73463392,
|
||||
|
|
@ -236,6 +238,6 @@ TEST(RNNCell, seperate) {
|
|||
std::vector<uint8_t> state_out(state_out_golden.size());
|
||||
EXPECT_TRUE(activation_out_tensor->CopyDataFromTensor(output.data()));
|
||||
EXPECT_TRUE(convert_tensor->CopyDataFromTensor(state_out.data()));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, 1e-5f));
|
||||
EXPECT_TRUE(ArraysMatch(output_golden, output, tolerance));
|
||||
EXPECT_EQ(state_out_golden, state_out);
|
||||
}
|
||||
Loading…
Reference in New Issue