MCPcopy Index your code
hub / github.com/OpenDriveLab/ReSim / test_speed

Function test_speed

SwissArmyTransformer/tests/test_speed.py:4–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import torch
3
4def test_speed():
5 import time
6 model = BaseModel(args=BaseModel.get_args(
7 num_layers=40,
8 hidden_size=2048,
9 num_attn_heads=32,
10 max_sequence_length=1024,
11 vocab_size=32000,
12 layernorm_order='sandwich',
13 fp16=True
14 )).cuda()
15 data = torch.zeros(4, 1024, dtype=torch.long).cuda()
16 start = time.time()
17 for i in range(100):
18 with torch.no_grad():
19 model(data, data, None)
20 print('average time: ', (time.time() - start) / 100, 's')
21
22if __name__ == '__main__':
23 test_speed()

Callers 1

test_speed.pyFile · 0.85

Calls 3

BaseModelClass · 0.90
get_argsMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected