Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
4cd5c19e
Unverified
Commit
4cd5c19e
authored
Sep 16, 2019
by
Chao Ma
Committed by
GitHub
Sep 16, 2019
Browse files
use np.unique instead of loop (#858)
parent
a8c28825
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
python/dgl/contrib/dis_kvstore.py
python/dgl/contrib/dis_kvstore.py
+6
-4
No files found.
python/dgl/contrib/dis_kvstore.py
View file @
4cd5c19e
...
...
@@ -367,8 +367,9 @@ class KVClient(object):
numpy_id
=
F
.
asnumpy
(
ID
)
count
=
math
.
ceil
(
self
.
_data_size
[
name
]
/
self
.
_server_count
)
server_id
=
numpy_id
/
count
for
id
in
server_id
:
group_size
[
int
(
id
)]
+=
1
id_list
,
id_count
=
np
.
unique
(
server_id
,
return_counts
=
True
)
for
idx
in
range
(
len
(
id_list
)):
group_size
[
int
(
id_list
[
idx
])]
+=
id_count
[
idx
]
min_idx
=
0
max_idx
=
0
for
idx
in
range
(
self
.
_server_count
):
...
...
@@ -426,8 +427,9 @@ class KVClient(object):
numpy_id
=
F
.
asnumpy
(
ID
)
count
=
math
.
ceil
(
self
.
_data_size
[
name
]
/
self
.
_server_count
)
server_id
=
numpy_id
/
count
for
id
in
server_id
:
group_size
[
int
(
id
)]
+=
1
id_list
,
id_count
=
np
.
unique
(
server_id
,
return_counts
=
True
)
for
idx
in
range
(
len
(
id_list
)):
group_size
[
int
(
id_list
[
idx
])]
+=
id_count
[
idx
]
min_idx
=
0
max_idx
=
0
server_count
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment