-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_modules.py
57 lines (40 loc) · 1.39 KB
/
test_modules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import unittest
import torch
from src.model import ResidualBlock, RecurrentBlock
from src.modules import RG_LRU, RMSNorm, Gated_MLP
x = torch.randn(1, 33, 10)
class TestResidual(unittest.TestCase):
def test_forward(self):
block = ResidualBlock(
temporal="recurrent",
input_size=10,
rnn_width=13
)
self.assertEqual(
block.forward(x).shape, x.shape, "Residual test failed."
)
class TestRecurrent(unittest.TestCase):
def test_forward(self):
block = RecurrentBlock(
input_size=10,
rnn_width=13
)
self.assertEqual(
block.forward(x).shape, x.shape, "Recurrent test failed."
)
# class TestGatedMLP(unittest.TestCase):
# def test_forward(self):
# block = Gated_MLP(input_size=10)
# self.assertEqual(block.forward(x).shape, x.shape, "Gated MLP test failed.")
# class TestRMSNorm(unittest.TestCase):
# def test_forward(self):
# block = RMSNorm(input_size=10)
# self.assertEqual(block.forward(x).shape, x.shape, "RMSNorm test failed.")
# class TestRGLRU(unittest.TestCase):
# def test_forward(self):
# block = RG_LRU(rnn_width=13)
# outputs, h = block.forward(x)
# self.assertEqual(outputs.shape, x.shape, "RG-LRU test failed.")
# Run the tests
if __name__ == "__main__":
unittest.main()