Skip to content

Commit

Permalink
Add negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dayo09 committed Jan 23, 2025
1 parent 1113cad commit 17590cf
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions compiler/luci/pass/src/ExpandBroadcastConstPass.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ TEST_F(ExpandBroadcastRank2ConstTest, remove_broadcast)
}
}

TEST_F(ExpandBroadcastRank2ConstTest, broadcast_diff_rank_NEG)
{
_y->shape({N});
_y->size<loco::DataType::FLOAT32>(N);

luci::ExpandBroadcastConstPass pass;
ASSERT_FALSE(pass.run(&_g));
}

/****************************************************************************
* TESTS FOR RANK 4
****************************************************************************/
Expand Down Expand Up @@ -264,6 +273,15 @@ TEST_F(ExpandBroadcastRank4ConstTest1, broadcast_impossible_NEG)
ASSERT_FALSE(pass.run(&_g));
}

TEST_F(ExpandBroadcastRank4ConstTest1, broadcast_diff_rank_NEG)
{
_y->shape({N, H, W});
_y->size<loco::DataType::FLOAT32>(N * H * W);

luci::ExpandBroadcastConstPass pass;
ASSERT_FALSE(pass.run(&_g));
}

TEST_F(ExpandBroadcastRank4ConstTest2, remove_broadcast)
{
for (uint32_t i = 0; i < N * W * D; ++i)
Expand Down Expand Up @@ -325,3 +343,12 @@ TEST_F(ExpandBroadcastRank4ConstTest2, broadcast_impossible_NEG)
luci::ExpandBroadcastConstPass pass;
ASSERT_FALSE(pass.run(&_g));
}

TEST_F(ExpandBroadcastRank4ConstTest2, broadcast_diff_rank_NEG)
{
_y->shape({N, H, W + 4});
_y->size<loco::DataType::FLOAT32>(N * H * (W + 4));

luci::ExpandBroadcastConstPass pass;
ASSERT_FALSE(pass.run(&_g));
}

0 comments on commit 17590cf

Please sign in to comment.