diff --git a/src/tim/vx/ops/layernormalization_test.cc b/src/tim/vx/ops/layernormalization_test.cc index cc80a53..a7b627d 100644 --- a/src/tim/vx/ops/layernormalization_test.cc +++ b/src/tim/vx/ops/layernormalization_test.cc @@ -33,7 +33,7 @@ TEST(LayerNorm, axis_0_shape_3_6_1_float) { float tolerance = ctx->hasSP() ? 0.01 : 1e-5f; tim::vx::ShapeType io_shape({3, 6, 1}); - tim::vx::ShapeType param_shape({6}); + tim::vx::ShapeType param_shape({3}); tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, io_shape, tim::vx::TensorAttribute::INPUT); tim::vx::TensorSpec param_spec(tim::vx::DataType::FLOAT32, @@ -54,11 +54,9 @@ TEST(LayerNorm, axis_0_shape_3_6_1_float) { -6, 0, 6, -7, 0, 7 }; std::vector gamma = { - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; std::vector beta = { - .0f, .0f, .0f, .0f, .0f, .0f }; std::vector golden = { @@ -91,7 +89,7 @@ TEST(LayerNorm, axis_0_shape_2_3_6_1_float) { float tolerance = ctx->hasSP() ? 0.01 : 1e-5f; tim::vx::ShapeType io_shape({2, 3, 6, 1}); - tim::vx::ShapeType param_shape({6}); + tim::vx::ShapeType param_shape({2}); tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, io_shape, tim::vx::TensorAttribute::INPUT); tim::vx::TensorSpec param_spec(tim::vx::DataType::FLOAT32, @@ -113,12 +111,10 @@ TEST(LayerNorm, axis_0_shape_2_3_6_1_float) { -7, 7, -7, 7, -7, 7 }; std::vector gamma = { - 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f + 1.0f, 1.0f }; std::vector beta = { - .0f, .0f, .0f, - .0f, .0f, .0f + .0f, .0f }; std::vector golden = { -1.f, 1.f, -1.f, 1.f, -1.f, 1.f, @@ -150,7 +146,7 @@ TEST(LayerNorm, axis_2_shape_4_2_3_1_float) { float tolerance = ctx->hasSP() ? 0.01 : 1e-5f; tim::vx::ShapeType io_shape({4, 2, 3, 1}); - tim::vx::ShapeType param_shape({1,1,3,1}); + tim::vx::ShapeType param_shape({1, 1, 3, 1}); tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, io_shape, tim::vx::TensorAttribute::INPUT); tim::vx::TensorSpec param_spec(tim::vx::DataType::FLOAT32, diff --git a/src/tim/vx/ops/logsoftmax_test.cc b/src/tim/vx/ops/logsoftmax_test.cc index 3e51231..cd2f890 100644 --- a/src/tim/vx/ops/logsoftmax_test.cc +++ b/src/tim/vx/ops/logsoftmax_test.cc @@ -30,6 +30,7 @@ TEST(LogSoftmax, shape_6_1_float_axis_0) { auto ctx = tim::vx::Context::Create(); auto graph = ctx->CreateGraph(); + float tolerance = ctx->hasSP() ? 0.01 : 1e-5f; tim::vx::ShapeType io_shape({6, 1}); tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, @@ -57,12 +58,13 @@ TEST(LogSoftmax, shape_6_1_float_axis_0) { std::vector output(golden.size() * sizeof(float)); EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data())); - EXPECT_TRUE(ArraysMatch(golden, output, 1e-5f)); + EXPECT_TRUE(ArraysMatch(golden, output, tolerance)); } TEST(LogSoftmax, shape_3_6_1_float_axis_1) { auto ctx = tim::vx::Context::Create(); auto graph = ctx->CreateGraph(); + float tolerance = ctx->hasSP() ? 0.01 : 1e-5f; tim::vx::ShapeType io_shape({3, 6, 1}); tim::vx::TensorSpec input_spec(tim::vx::DataType::FLOAT32, @@ -100,7 +102,7 @@ TEST(LogSoftmax, shape_3_6_1_float_axis_1) { std::vector output(golden.size() * sizeof(float)); EXPECT_TRUE(output_tensor->CopyDataFromTensor(output.data())); - EXPECT_TRUE(ArraysMatch(golden, output, 1e-5f)); + EXPECT_TRUE(ArraysMatch(golden, output, tolerance)); } TEST(LogSoftmax, shape_3_6_1_uint8_axis_1) {