Skip to content

Commit

Permalink
add assert to check div by zero and rewrite checkKernel function
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Balyshev committed Feb 15, 2024
1 parent c3742f5 commit fc67bf1
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(AbsTest, Float_P)
{
onert_micro::test_model::TestDataFloatAbs test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
12 changes: 6 additions & 6 deletions onert-micro/onert-micro/src/execute/kernels/tests/Add.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ TEST_F(AddTest, INT32_P)
const bool is_with_broadcast = false;
test_model::TestData32IntAdd test_data_add_no_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_no_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_no_broadcasting.get_output_data_by_index(0));
}
// With broadcast
{
const bool is_with_broadcast = true;
test_model::TestData32IntAdd test_data_add_with_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_with_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_with_broadcasting.get_output_data_by_index(0));
}
}
Expand All @@ -60,15 +60,15 @@ TEST_F(AddTest, INT64_P)
const bool is_with_broadcast = false;
test_model::TestData64IntAdd test_data_add_no_broadcasting(is_with_broadcast);
std::vector<int64_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int64_t>(&test_data_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<int64_t>(2, &test_data_add_no_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_no_broadcasting.get_output_data_by_index(0));
}
// With broadcast
{
const bool is_with_broadcast = true;
test_model::TestData64IntAdd test_data_add_with_broadcasting(is_with_broadcast);
std::vector<int64_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int64_t>(&test_data_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<int64_t>(2, &test_data_add_with_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_with_broadcasting.get_output_data_by_index(0));
}
}
Expand All @@ -80,7 +80,7 @@ TEST_F(AddTest, Float_P)
const bool is_with_broadcast = false;
test_model::TestDataFloatAdd test_data_float_add_no_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_no_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_no_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand All @@ -90,7 +90,7 @@ TEST_F(AddTest, Float_P)
const bool is_with_broadcast = true;
test_model::TestDataFloatAdd test_data_float_add_with_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_with_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_with_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ TEST_F(ConcatenationTest, INT64_P)
{
test_model::TestDataS64Concatenation test_data_kernel;
std::vector<int64_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int64_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<int64_t>(2, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(ConcatenationTest, INT32_P)
{
test_model::TestDataS32Concatenation test_data_kernel;
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(ConcatenationTest, Float_P)
{
test_model::TestDataFloatConcatenation test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_kernel);
EXPECT_THAT(output_data_vector,
FloatArrayNear(test_data_kernel.get_output_data_by_index(0), 0.0001f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(Conv2DTest, Float_P)
{
onert_micro::test_model::TestDataFloatConv2D test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector,
FloatArrayNear(test_data_kernel.get_output_data_by_index(0), 0.0001f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(FullyConnectedTest, Float_P)
{
onert_micro::test_model::TestDataFloatFullyConnected test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ TEST_F(GatherTest, Gather_Float_P)
{
onert_micro::test_model::TestDataFloatGather test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(GatherTest, Gather_Int_P)
{
onert_micro::test_model::TestDataIntGather test_data_kernel;
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<int32_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<int32_t>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(LogisticTest, Float_P)
{
onert_micro::test_model::TestDataFloatLogistic test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(MaxPool2DTest, Float_P)
{
onert_micro::test_model::TestDataFloatMaxPool2D test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ TEST_F(MulTest, INT_P)
const bool is_with_broadcast = false;
test_model::TestDataIntMul test_data_add_no_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_no_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_no_broadcasting.get_output_data_by_index(0));
}
// With broadcast
{
const bool is_with_broadcast = true;
test_model::TestDataIntMul test_data_add_with_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_with_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_with_broadcasting.get_output_data_by_index(0));
}
}
Expand All @@ -60,7 +60,7 @@ TEST_F(MulTest, Float_P)
const bool is_with_broadcast = false;
test_model::TestDataFloatMul test_data_float_add_no_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_no_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_no_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand All @@ -70,7 +70,7 @@ TEST_F(MulTest, Float_P)
const bool is_with_broadcast = true;
test_model::TestDataFloatMul test_data_float_add_with_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_with_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_with_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ TEST_F(PackTest, Float_P)
{
test_model::TestDataFloatPack test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(PackTest, Int_P)
{
test_model::TestDataIntPack test_data_kernel;
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ TEST_F(ReduceProdTest, Reduce_Prod_Float_P)
{
onert_micro::test_model::TestDataFloatReduceProd test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(ReduceProdTest, Reduce_Prod_Int_P)
{
onert_micro::test_model::TestDataIntReduceProd test_data_kernel;
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<int32_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<int32_t>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ TEST_F(ReshapeTest, MainTest_P)
{
onert_micro::test_model::TestDataReshapeKernel<float> test_data_kernel(false);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

TEST_F(ReshapeTest, MainTest_NEG)
{
onert_micro::test_model::TestDataReshapeKernel<float> test_data_kernel(true);
EXPECT_DEATH(checkSISOKernel(&test_data_kernel), "");
EXPECT_DEATH(checkKernel(1, &test_data_kernel), "");
}

} // namespace testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(ShapeTest, MainTest_P)
{
onert_micro::test_model::TestDataShapeKernel<float, int32_t> test_data_kernel;
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float, int32_t>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float, int32_t>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_F(StridedSliceTest, MainTest_P)
{
onert_micro::test_model::TestDataStridedSliceKernel<float> test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ TEST_F(SubTest, INT_P)
const bool is_with_broadcast = false;
test_model::TestDataIntSub test_data_add_no_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_no_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_no_broadcasting.get_output_data_by_index(0));
}
// With broadcast
{
const bool is_with_broadcast = true;
test_model::TestDataIntSub test_data_add_with_broadcasting(is_with_broadcast);
std::vector<int32_t> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<int32_t>(&test_data_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<int32_t>(2, &test_data_add_with_broadcasting);
EXPECT_THAT(output_data_vector, test_data_add_with_broadcasting.get_output_data_by_index(0));
}
}
Expand All @@ -60,7 +60,7 @@ TEST_F(SubTest, Float_P)
const bool is_with_broadcast = false;
test_model::TestDataFloatSub test_data_float_add_no_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_no_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_no_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_no_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand All @@ -70,7 +70,7 @@ TEST_F(SubTest, Float_P)
const bool is_with_broadcast = true;
test_model::TestDataFloatSub test_data_float_add_with_broadcasting(is_with_broadcast);
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkTISOKernel<float>(&test_data_float_add_with_broadcasting);
onert_micro::execute::testing::checkKernel<float>(2, &test_data_float_add_with_broadcasting);
EXPECT_THAT(
output_data_vector,
FloatArrayNear(test_data_float_add_with_broadcasting.get_output_data_by_index(0), 0.0001f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_F(UnidirLSTMTest, Float_P)
{
onert_micro::test_model::TestDataFloatUnidirectionalLSTM test_data_kernel;
std::vector<float> output_data_vector =
onert_micro::execute::testing::checkSISOKernel<float>(&test_data_kernel);
onert_micro::execute::testing::checkKernel<float>(1, &test_data_kernel);
EXPECT_THAT(output_data_vector,
FloatArrayNear(test_data_kernel.get_output_data_by_index(0), 0.0001f));
}
Expand Down

0 comments on commit fc67bf1

Please sign in to comment.