Skip to content

Commit

Permalink
[feature] add different shape to unit tests (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ye13ow77z authored Jul 30, 2024
1 parent 68f04c8 commit 16ee0d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions tests/test_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ def __init__(self, hidden_size: int, intermediate_size: int):
)


class LlamaTestCase(unittest.TestCase):
def test_forward(self):
input = torch.zeros((1, 8, hidden_size))
output: torch.Tensor = moe_layer(input)
self.assertEqual(output.shape, (1, 8, hidden_size))
class LlamaInputShapeTest(unittest.TestCase):
def test_forward_with_different_shape(self):
input_shapes = [
(2, 8, hidden_size),
(1, 16, hidden_size),
(4, 4, hidden_size)
]

for shape in input_shapes:
with self.subTest(shape=shape):
input = torch.zeros(shape)
output: torch.Tensor = moe_layer(input)
self.assertEqual(output.shape, shape)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_phi3.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, hidden_size: int, intermediate_size: int):
)


class LlamaTestCase(unittest.TestCase):
class Phi3TestCase(unittest.TestCase):
def test_forward(self):
input = torch.zeros((1, 8, hidden_size))
output: torch.Tensor = moe_layer(input)
Expand Down

0 comments on commit 16ee0d3

Please sign in to comment.