MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / test2

Function test2

deepspeed/runtime/zero/test.py:44–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def test2():
45 mem = ContiguousMemoryAllocator(512, torch.half, 'cpu')
46 a1 = mem.allocate_tensor(64).mul_(0.0).add_(1.0)
47 a2 = mem.allocate_tensor(64).mul_(0.0).add_(2.0)
48 a3 = mem.allocate_tensor(64).mul_(0.0).add_(3.0)
49 a4 = mem.allocate_tensor(64).mul_(0.0).add_(4.0)
50 a5 = mem.allocate_tensor(64).mul_(0.0).add_(5.0)
51 a6 = mem.allocate_tensor(64).mul_(0.0).add_(6.0)
52 a7 = mem.allocate_tensor(64).mul_(0.0).add_(7.0)
53 a8 = mem.allocate_tensor(64).mul_(0.0).add_(8.0)
54 mem.release_tensor(a2)
55 mem.release_tensor(a4)
56 mem.release_tensor(a6)
57 mem.release_tensor(a8)
58 mem.print_allocation(resolution=100)
59
60 a9 = mem.allocate_tensor(128).mul_(0.0).add_(9.0)
61 a10 = mem.allocate_tensor(64).mul_(0.0).add_(10.0)
62 a11 = mem.allocate_tensor(64).mul_(0.0).add_(11.0)
63 mem.release_tensor(a1)
64 mem.release_tensor(a5)
65 mem.print_allocation(resolution=100)
66 a12 = mem.allocate_tensor(128).mul_(0.0).add_(12.0)
67 mem.print_allocation(resolution=100)
68 print(f"a7:{a7}")
69 print(f"a9:{a9}")
70 print(f"a10:{a10}")
71 print(f"a11:{a11}")
72 print(f"a12:{a12}")
73 assert (a7.norm() + a9.norm() + a10.norm() + a11.norm() + a12.norm()) == 460.75, "TestFailed"
74
75
76test1()

Callers 1

test.pyFile · 0.85

Calls 4

allocate_tensorMethod · 0.95
release_tensorMethod · 0.95
print_allocationMethod · 0.95

Tested by

no test coverage detected