Skip to content

Commit

Permalink
Add more test to kvstore (dmlc#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksnzhy authored Oct 21, 2019
1 parent ff9f67e commit 70ee4b5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/compute/test_kvstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ def start_client():

assert torch.equal(new_tensor_2, target_tensor) == True

client.push_all('embed_0', client.pull_all('embed_0'))
client.push_all('embed_1', client.pull_all('embed_1'))
client.push_all('embed_2', client.pull_all('embed_2'))

# Pull
tensor_id = torch.tensor([0, 1, 2, 6, 7, 8])
new_tensor_0 = client.pull('embed_0', tensor_id)
new_tensor_1 = client.pull('embed_1', tensor_id)
new_tensor_2 = client.pull('embed_2', tensor_id)

target_tensor = torch.tensor(
[[ 0., 0., 0.],
[ 10., 10., 10.],
[20., 20., 20.],
[ 0., 0., 0.],
[ 10., 10., 10.],
[20., 20., 20.]])

assert torch.equal(new_tensor_0, target_tensor) == True
assert torch.equal(new_tensor_1, target_tensor) == True

target_tensor = tensor.tensor([20., 20., 20., 30., 30., 30.])

assert torch.equal(new_tensor_2, target_tensor) == True

client.shut_down()

if __name__ == '__main__':
Expand Down

0 comments on commit 70ee4b5

Please sign in to comment.