-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* auto fix * add more * sort Co-authored-by: Steve <[email protected]>
- Loading branch information
1 parent
23d0905
commit d78a3a4
Showing
45 changed files
with
978 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 24 additions & 20 deletions
44
benchmarks/benchmarks/api/bench_builtin_update_all_coo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
import time | ||
import dgl | ||
import torch | ||
|
||
import numpy as np | ||
import torch | ||
|
||
import dgl | ||
import dgl.function as fn | ||
|
||
from .. import utils | ||
|
||
|
||
@utils.benchmark('time', timeout=600) | ||
@utils.parametrize('graph_name', ['ogbn-arxiv']) | ||
@utils.parametrize('format', ['coo']) | ||
@utils.parametrize('feat_size', [4, 32, 256]) | ||
@utils.parametrize('msg_type', ['copy_u', 'u_mul_e']) | ||
@utils.parametrize('reduce_type', ['sum', 'mean', 'max']) | ||
@utils.benchmark("time", timeout=600) | ||
@utils.parametrize("graph_name", ["ogbn-arxiv"]) | ||
@utils.parametrize("format", ["coo"]) | ||
@utils.parametrize("feat_size", [4, 32, 256]) | ||
@utils.parametrize("msg_type", ["copy_u", "u_mul_e"]) | ||
@utils.parametrize("reduce_type", ["sum", "mean", "max"]) | ||
def track_time(graph_name, format, feat_size, msg_type, reduce_type): | ||
device = utils.get_bench_device() | ||
graph = utils.get_graph(graph_name, format) | ||
graph = graph.to(device) | ||
graph.ndata['h'] = torch.randn( | ||
(graph.num_nodes(), feat_size), device=device) | ||
graph.edata['e'] = torch.randn( | ||
(graph.num_edges(), 1), device=device) | ||
graph.ndata["h"] = torch.randn( | ||
(graph.num_nodes(), feat_size), device=device | ||
) | ||
graph.edata["e"] = torch.randn((graph.num_edges(), 1), device=device) | ||
|
||
msg_builtin_dict = { | ||
'copy_u': fn.copy_u('h', 'x'), | ||
'u_mul_e': fn.u_mul_e('h', 'e', 'x'), | ||
"copy_u": fn.copy_u("h", "x"), | ||
"u_mul_e": fn.u_mul_e("h", "e", "x"), | ||
} | ||
|
||
reduce_builtin_dict = { | ||
'sum': fn.sum('x', 'h_new'), | ||
'mean': fn.mean('x', 'h_new'), | ||
'max': fn.max('x', 'h_new'), | ||
"sum": fn.sum("x", "h_new"), | ||
"mean": fn.mean("x", "h_new"), | ||
"max": fn.max("x", "h_new"), | ||
} | ||
|
||
# dry run | ||
graph.update_all(msg_builtin_dict[msg_type], | ||
reduce_builtin_dict[reduce_type]) | ||
graph.update_all( | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type] | ||
) | ||
|
||
# timing | ||
|
||
with utils.Timer() as t: | ||
for i in range(3): | ||
graph.update_all( | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type]) | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type] | ||
) | ||
|
||
return t.elapsed_secs / 3 |
46 changes: 25 additions & 21 deletions
46
benchmarks/benchmarks/api/bench_builtin_update_all_csc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,53 @@ | ||
import time | ||
import dgl | ||
import torch | ||
|
||
import numpy as np | ||
import torch | ||
|
||
import dgl | ||
import dgl.function as fn | ||
|
||
from .. import utils | ||
|
||
|
||
@utils.benchmark('time', timeout=600) | ||
@utils.parametrize('graph_name', ['ogbn-arxiv', 'reddit', 'ogbn-proteins']) | ||
@utils.parametrize('format', ['csc']) | ||
@utils.parametrize('feat_size', [4, 32, 256]) | ||
@utils.parametrize('msg_type', ['copy_u', 'u_mul_e']) | ||
@utils.parametrize('reduce_type', ['sum', 'mean', 'max']) | ||
@utils.benchmark("time", timeout=600) | ||
@utils.parametrize("graph_name", ["ogbn-arxiv", "reddit", "ogbn-proteins"]) | ||
@utils.parametrize("format", ["csc"]) | ||
@utils.parametrize("feat_size", [4, 32, 256]) | ||
@utils.parametrize("msg_type", ["copy_u", "u_mul_e"]) | ||
@utils.parametrize("reduce_type", ["sum", "mean", "max"]) | ||
def track_time(graph_name, format, feat_size, msg_type, reduce_type): | ||
device = utils.get_bench_device() | ||
graph = utils.get_graph(graph_name, format) | ||
graph = graph.to(device) | ||
graph.ndata['h'] = torch.randn( | ||
(graph.num_nodes(), feat_size), device=device) | ||
graph.edata['e'] = torch.randn( | ||
(graph.num_edges(), 1), device=device) | ||
graph.ndata["h"] = torch.randn( | ||
(graph.num_nodes(), feat_size), device=device | ||
) | ||
graph.edata["e"] = torch.randn((graph.num_edges(), 1), device=device) | ||
|
||
msg_builtin_dict = { | ||
'copy_u': fn.copy_u('h', 'x'), | ||
'u_mul_e': fn.u_mul_e('h', 'e', 'x'), | ||
"copy_u": fn.copy_u("h", "x"), | ||
"u_mul_e": fn.u_mul_e("h", "e", "x"), | ||
} | ||
|
||
reduce_builtin_dict = { | ||
'sum': fn.sum('x', 'h_new'), | ||
'mean': fn.mean('x', 'h_new'), | ||
'max': fn.max('x', 'h_new'), | ||
"sum": fn.sum("x", "h_new"), | ||
"mean": fn.mean("x", "h_new"), | ||
"max": fn.max("x", "h_new"), | ||
} | ||
|
||
# dry run | ||
|
||
for i in range(3): | ||
graph.update_all(msg_builtin_dict[msg_type], | ||
reduce_builtin_dict[reduce_type]) | ||
graph.update_all( | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type] | ||
) | ||
|
||
# timing | ||
|
||
with utils.Timer() as t: | ||
for i in range(10): | ||
graph.update_all( | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type]) | ||
msg_builtin_dict[msg_type], reduce_builtin_dict[reduce_type] | ||
) | ||
|
||
return t.elapsed_secs / 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.