├── .clang-format ├── .github ├── ISSUE_TEMPLATE │ ├── --work-item--dev-only-.md │ ├── bug-report.md │ ├── documentation.md │ ├── feature-request.md │ └── questions-help-support.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── lint.yml │ └── stale.yml ├── .gitignore ├── .gitmodules ├── .lintrunner.toml ├── CMakeLists.txt ├── CONTRIBUTORS.md ├── Jenkinsfile ├── LICENSE ├── NEWS.md ├── README.md ├── apps └── life_sci │ └── README.md ├── benchmarks ├── .gitignore ├── Jenkinsfile ├── README.md ├── asv.conf.json ├── benchmarks │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ ├── bench_add_self_loop.py │ │ ├── bench_batch.py │ │ ├── bench_builtin_apply_edges.py │ │ ├── bench_builtin_apply_edges_hetero.py │ │ ├── bench_builtin_multi_update_all.py │ │ ├── bench_builtin_update_all_coo.py │ │ ├── bench_builtin_update_all_csc.py │ │ ├── bench_edge_ids.py │ │ ├── bench_edge_subgraph.py │ │ ├── bench_find_edges.py │ │ ├── bench_format_conversion.py │ │ ├── bench_heterograph_construction.py │ │ ├── bench_homograph_edge_construction.py │ │ ├── bench_homograph_scipy_construction.py │ │ ├── bench_in_degrees.py │ │ ├── bench_in_edges.py │ │ ├── bench_in_subgraph.py │ │ ├── bench_khop.py │ │ ├── bench_knn_graph.py │ │ ├── bench_metis_partition.py │ │ ├── bench_nn_graphconv.py │ │ ├── bench_nn_heterographconv.py │ │ ├── bench_node_subgraph.py │ │ ├── bench_random_walk.py │ │ ├── bench_readout.py │ │ ├── bench_reverse.py │ │ ├── bench_sample_neighbors.py │ │ ├── bench_to_block.py │ │ ├── bench_udf_apply_edges.py │ │ ├── bench_udf_multi_update_all.py │ │ ├── bench_udf_update_all.py │ │ └── bench_unbatch.py │ ├── kernel │ │ ├── __init__.py │ │ ├── bench_edgesoftmax.py │ │ ├── bench_gsddmm_u_dot_v.py │ │ ├── bench_gspmm_copy_u.py │ │ └── bench_gspmm_u_mul_e_sum.py │ ├── model_acc │ │ ├── __init__.py │ │ ├── bench_gat.py │ │ ├── bench_gcn.py │ │ ├── bench_gcn_udf.py │ │ ├── bench_rgcn_base.py │ │ ├── bench_rgcn_ns.py │ │ ├── bench_sage.py │ │ └── bench_sage_ns.py │ ├── model_speed │ │ ├── __init__.py │ │ ├── bench_gat.py │ │ ├── bench_gat_ns.py │ │ ├── bench_gcn_udf.py │ │ ├── bench_pinsage.py │ │ ├── bench_rgcn_base.py │ │ ├── bench_rgcn_hetero_ns.py │ │ ├── bench_rgcn_homogeneous_ns.py │ │ ├── bench_sage.py │ │ ├── bench_sage_ns.py │ │ └── bench_sage_unsupervised_ns.py │ ├── multigpu │ │ ├── __init__.py │ │ ├── bench_multigpu_rgcn.py │ │ ├── bench_multigpu_sage.py │ │ └── rgcn_model.py │ ├── rgcn.py │ └── utils.py ├── run.sh ├── scripts │ ├── README.md │ ├── build_dgl_asv.sh │ ├── fix_ram_info.py │ ├── generate_excel.py │ ├── install_dgl_asv.sh │ ├── publish.sh │ ├── replace_branch.py │ └── torch_gpu_pip.txt └── task.json ├── cmake ├── config.cmake ├── modules │ └── CUDA.cmake └── util │ ├── FindCUDA.cmake │ ├── MshadowUtil.cmake │ └── Util.cmake ├── conda └── dgl │ ├── README.md │ ├── bld.bat │ ├── build.sh │ ├── conda_build_config.yaml │ ├── meta.yaml │ ├── run_test.bat │ └── run_test.sh ├── dgl_sparse ├── CMakeLists.txt ├── build.bat ├── build.sh ├── find_cmake.py ├── include │ └── sparse │ │ ├── dgl_headers.h │ │ ├── elementwise_op.h │ │ ├── matrix_ops.h │ │ ├── reduction.h │ │ ├── sddmm.h │ │ ├── softmax.h │ │ ├── sparse_format.h │ │ ├── sparse_matrix.h │ │ ├── spmm.h │ │ └── spspmm.h └── src │ ├── elemenwise_op.cc │ ├── matmul.cc │ ├── matmul.h │ ├── matrix_ops.cc │ ├── python_binding.cc │ ├── reduction.cc │ ├── sddmm.cc │ ├── softmax.cc │ ├── sparse_format.cc │ ├── sparse_matrix.cc │ ├── sparse_matrix_coalesce.cc │ ├── spmm.cc │ ├── spspmm.cc │ └── utils.h ├── dglgo ├── README.md ├── dglgo.png ├── dglgo │ ├── __init__.py │ ├── apply_pipeline │ │ ├── __init__.py │ │ ├── graphpred │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── graphpred.jinja-py │ │ ├── nodepred │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── nodepred.jinja-py │ │ └── nodepred_sample │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── nodepred-ns.jinja-py │ ├── cli │ │ ├── __init__.py │ │ ├── apply_cli.py │ │ ├── cli.py │ │ ├── config_apply_cli.py │ │ ├── config_cli.py │ │ ├── export_cli.py │ │ ├── recipe_cli.py │ │ └── train_cli.py │ ├── model │ │ ├── __init__.py │ │ ├── edge_encoder │ │ │ ├── __init__.py │ │ │ ├── bilinear.py │ │ │ ├── dot.py │ │ │ └── ele.py │ │ ├── graph_encoder │ │ │ ├── __init__.py │ │ │ ├── gin_ogbg.py │ │ │ └── pna.py │ │ └── node_encoder │ │ │ ├── __init__.py │ │ │ ├── gat.py │ │ │ ├── gcn.py │ │ │ ├── gin.py │ │ │ ├── sage.py │ │ │ └── sgc.py │ ├── pipeline │ │ ├── __init__.py │ │ ├── graphpred │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── graphpred.jinja-py │ │ ├── linkpred │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── linkpred.jinja-py │ │ ├── nodepred │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── nodepred.jinja-py │ │ └── nodepred_sample │ │ │ ├── __init__.py │ │ │ ├── gen.py │ │ │ └── nodepred-ns.jinja-py │ └── utils │ │ ├── __init__.py │ │ ├── base_model.py │ │ ├── early_stop.py │ │ ├── enter_config.py │ │ ├── factory.py │ │ ├── optimizer_config.py │ │ └── yaml_dump.py ├── recipes │ ├── __init__.py │ ├── graphpred_hiv_gin.yaml │ ├── graphpred_hiv_pna.yaml │ ├── graphpred_pcba_gin.yaml │ ├── linkpred_citation2_sage.yaml │ ├── linkpred_collab_sage.yaml │ ├── linkpred_cora_sage.yaml │ ├── nodepred-ns_arxiv_gcn.yaml │ ├── nodepred-ns_product_sage.yaml │ ├── nodepred_citeseer_gat.yaml │ ├── nodepred_citeseer_gcn.yaml │ ├── nodepred_citeseer_sage.yaml │ ├── nodepred_cora_gat.yaml │ ├── nodepred_cora_gcn.yaml │ ├── nodepred_cora_sage.yaml │ ├── nodepred_pubmed_gat.yaml │ ├── nodepred_pubmed_gcn.yaml │ └── nodepred_pubmed_sage.yaml ├── setup.py └── tests │ ├── cfg.yml │ ├── run_test.sh │ └── test_pipeline.py ├── docker ├── Dockerfile.awscli ├── Dockerfile.ci_benchmark ├── Dockerfile.ci_cpu ├── Dockerfile.ci_cpu_torch_1.2.0 ├── Dockerfile.ci_gpu ├── Dockerfile.ci_gpu_cu101 ├── Dockerfile.ci_gpu_torch_1.2.0 ├── Dockerfile.ci_lint ├── README.md ├── install │ ├── conda_env │ │ ├── kg_cpu.yml │ │ ├── kg_gpu.yml │ │ ├── mxnet_cpu.yml │ │ ├── mxnet_gpu.yml │ │ ├── tensorflow_cpu.yml │ │ ├── tensorflow_gpu.yml │ │ ├── torch_cpu.yml │ │ ├── torch_cpu_pip.txt │ │ ├── torch_gpu.yml │ │ └── torch_gpu_pip.txt │ ├── ubuntu_install_antlr.sh │ ├── ubuntu_install_build.sh │ ├── ubuntu_install_conda.sh │ ├── ubuntu_install_core.sh │ ├── ubuntu_install_java.sh │ ├── ubuntu_install_mxnet_cpu.sh │ ├── ubuntu_install_mxnet_gpu.sh │ ├── ubuntu_install_python.sh │ ├── ubuntu_install_python_package.sh │ ├── ubuntu_install_torch.sh │ └── ubuntu_install_torch_1.2.0.sh └── pods │ ├── ci-compile-cpu.yaml │ ├── ci-compile-gpu.yaml │ ├── ci-cpu.yaml │ ├── ci-gpu.yaml │ └── ci-lint.yaml ├── docs ├── .gitignore ├── Makefile ├── README.md ├── clean.sh ├── migrate-guide-0.5.md └── source │ ├── _static │ ├── blitz_1_introduction.png │ ├── blitz_2_dglgraph.png │ ├── blitz_3_message_passing.png │ ├── blitz_4_link_predict.png │ ├── blitz_5_graph_classification.png │ ├── blitz_6_load_data.png │ ├── css │ │ └── custom.css │ └── large_L0_neighbor_sampling_overview.png │ ├── _templates │ └── classtemplate.rst │ ├── api │ └── python │ │ ├── dgl.DGLGraph.rst │ │ ├── dgl.data.rst │ │ ├── dgl.dataloading.rst │ │ ├── dgl.distributed.rst │ │ ├── dgl.function.rst │ │ ├── dgl.geometry.rst │ │ ├── dgl.multiprocessing.rst │ │ ├── dgl.ops.rst │ │ ├── dgl.optim.rst │ │ ├── dgl.rst │ │ ├── dgl.sampling.rst │ │ ├── dgl.sparse_v0.rst │ │ ├── index.rst │ │ ├── knn_benchmark.rst │ │ ├── nn-mxnet.rst │ │ ├── nn-pytorch.rst │ │ ├── nn-tensorflow.rst │ │ ├── nn.functional.rst │ │ ├── transforms.rst │ │ └── udf.rst │ ├── conf.py │ ├── contribute.rst │ ├── developer │ └── ffi.rst │ ├── env_var.rst │ ├── faq.rst │ ├── features │ └── dataset.rst │ ├── gen_dataset_stat.py │ ├── guide │ ├── data-dataset.rst │ ├── data-download.rst │ ├── data-loadcsv.rst │ ├── data-loadogb.rst │ ├── data-process.rst │ ├── data-savenload.rst │ ├── data.rst │ ├── distributed-apis.rst │ ├── distributed-hetero.rst │ ├── distributed-partition.rst │ ├── distributed-preprocessing.rst │ ├── distributed-tools.rst │ ├── distributed.rst │ ├── graph-basic.rst │ ├── graph-external.rst │ ├── graph-feature.rst │ ├── graph-gpu.rst │ ├── graph-graphs-nodes-edges.rst │ ├── graph-heterogeneous.rst │ ├── graph.rst │ ├── index.rst │ ├── message-api.rst │ ├── message-efficient.rst │ ├── message-heterograph.rst │ ├── message-part.rst │ ├── message.rst │ ├── minibatch-custom-sampler.rst │ ├── minibatch-edge.rst │ ├── minibatch-gpu-sampling.rst │ ├── minibatch-inference.rst │ ├── minibatch-link.rst │ ├── minibatch-nn.rst │ ├── minibatch-node.rst │ ├── minibatch-prefetching.rst │ ├── minibatch.rst │ ├── mixed_precision.rst │ ├── nn-construction.rst │ ├── nn-forward.rst │ ├── nn-heterograph.rst │ ├── nn.rst │ ├── training-edge.rst │ ├── training-eweight.rst │ ├── training-graph.rst │ ├── training-link.rst │ ├── training-node.rst │ └── training.rst │ ├── guide_cn │ ├── data-dataset.rst │ ├── data-download.rst │ ├── data-loadogb.rst │ ├── data-process.rst │ ├── data-savenload.rst │ ├── data.rst │ ├── distributed-apis.rst │ ├── distributed-preprocessing.rst │ ├── distributed-tools.rst │ ├── distributed.rst │ ├── graph-basic.rst │ ├── graph-external.rst │ ├── graph-feature.rst │ ├── graph-gpu.rst │ ├── graph-graphs-nodes-edges.rst │ ├── graph-heterogeneous.rst │ ├── graph.rst │ ├── index.rst │ ├── message-api.rst │ ├── message-efficient.rst │ ├── message-heterograph.rst │ ├── message-part.rst │ ├── message.rst │ ├── minibatch-custom-sampler.rst │ ├── minibatch-edge.rst │ ├── minibatch-inference.rst │ ├── minibatch-link.rst │ ├── minibatch-nn.rst │ ├── minibatch-node.rst │ ├── minibatch.rst │ ├── nn-construction.rst │ ├── nn-forward.rst │ ├── nn-heterograph.rst │ ├── nn.rst │ ├── training-edge.rst │ ├── training-eweight.rst │ ├── training-graph.rst │ ├── training-link.rst │ ├── training-node.rst │ └── training.rst │ ├── guide_ko │ ├── data-dataset.rst │ ├── data-download.rst │ ├── data-loadogb.rst │ ├── data-process.rst │ ├── data-savenload.rst │ ├── data.rst │ ├── distributed-apis.rst │ ├── distributed-hetero.rst │ ├── distributed-preprocessing.rst │ ├── distributed-tools.rst │ ├── distributed.rst │ ├── graph-basic.rst │ ├── graph-external.rst │ ├── graph-feature.rst │ ├── graph-gpu.rst │ ├── graph-graphs-nodes-edges.rst │ ├── graph-heterogeneous.rst │ ├── graph.rst │ ├── index.rst │ ├── message-api.rst │ ├── message-edge.rst │ ├── message-efficient.rst │ ├── message-heterograph.rst │ ├── message-part.rst │ ├── message.rst │ ├── minibatch-custom-sampler.rst │ ├── minibatch-edge.rst │ ├── minibatch-gpu-sampling.rst │ ├── minibatch-inference.rst │ ├── minibatch-link.rst │ ├── minibatch-nn.rst │ ├── minibatch-node.rst │ ├── minibatch.rst │ ├── mixed_precision.rst │ ├── nn-construction.rst │ ├── nn-forward.rst │ ├── nn-heterograph.rst │ ├── nn.rst │ ├── training-edge.rst │ ├── training-graph.rst │ ├── training-link.rst │ ├── training-node.rst │ └── training.rst │ ├── index.rst │ ├── install │ └── index.rst │ ├── notebooks │ └── sparse │ │ ├── gcn.nblink │ │ ├── graph_diffusion.nblink │ │ ├── graph_transformer.nblink │ │ ├── hgnn.nblink │ │ ├── index.rst │ │ └── quickstart.nblink │ ├── performance.rst │ └── resources.rst ├── examples ├── README.md ├── advanced │ └── cugraph │ │ ├── graphsage.py │ │ └── rgcn.py ├── core │ ├── gat │ │ ├── README.md │ │ └── train.py │ └── gated_gcn │ │ ├── README.md │ │ └── train.py ├── multigpu │ ├── README.md │ └── node_classification_sage.py ├── mxnet │ ├── README.md │ ├── appnp │ │ ├── README.md │ │ └── appnp.py │ ├── gat │ │ ├── README.md │ │ ├── gat.py │ │ ├── train.py │ │ └── utils.py │ ├── gcn │ │ ├── README.md │ │ ├── gcn.py │ │ ├── gcn_concat.py │ │ ├── gcn_mp.py │ │ └── train.py │ ├── gin │ │ ├── README.md │ │ ├── dataloader.py │ │ ├── gin.py │ │ ├── main.py │ │ └── parser.py │ ├── graphsage │ │ ├── README.md │ │ └── main.py │ ├── monet │ │ ├── README.md │ │ └── citation.py │ ├── rgcn │ │ ├── README.md │ │ ├── entity_classify.py │ │ └── model.py │ ├── scenegraph │ │ ├── README.md │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── dataloader.py │ │ │ ├── object.py │ │ │ ├── prepare_visualgenome.py │ │ │ └── relation.py │ │ ├── demo_reldn.py │ │ ├── model │ │ │ ├── __init__.py │ │ │ ├── faster_rcnn.py │ │ │ └── reldn.py │ │ ├── train_faster_rcnn.py │ │ ├── train_faster_rcnn.sh │ │ ├── train_freq_prior.py │ │ ├── train_reldn.py │ │ ├── train_reldn.sh │ │ ├── utils │ │ │ ├── __init__.py │ │ │ ├── build_graph.py │ │ │ ├── metric.py │ │ │ ├── sampling.py │ │ │ └── viz.py │ │ ├── validate_reldn.py │ │ └── validate_reldn.sh │ ├── sgc │ │ ├── README.md │ │ └── sgc.py │ ├── tagcn │ │ ├── README.md │ │ ├── tagcn.py │ │ └── train.py │ ├── tree_lstm │ │ ├── README.md │ │ ├── train.py │ │ └── tree_lstm.py │ └── util.py ├── pytorch │ ├── GATNE-T │ │ ├── README.md │ │ ├── requirements.txt │ │ ├── scripts │ │ │ ├── run_example.sh │ │ │ ├── run_example_sparse.sh │ │ │ └── run_example_sparse_multi_gpus.sh │ │ └── src │ │ │ ├── main.py │ │ │ ├── main_sparse.py │ │ │ ├── main_sparse_multi_gpus.py │ │ │ └── utils.py │ ├── GNN-FiLM │ │ ├── README.md │ │ ├── data_loader.py │ │ ├── main.py │ │ └── utils.py │ ├── NGCF │ │ ├── Data │ │ │ ├── load_amazon-book.sh │ │ │ └── load_gowalla.sh │ │ ├── NGCF │ │ │ ├── main.py │ │ │ ├── model.py │ │ │ └── utility │ │ │ │ ├── batch_test.py │ │ │ │ ├── helper.py │ │ │ │ ├── load_data.py │ │ │ │ ├── metrics.py │ │ │ │ └── parser.py │ │ └── README.md │ ├── P-GNN │ │ ├── README.md │ │ ├── main.py │ │ ├── model.py │ │ └── utils.py │ ├── TAHIN │ │ ├── TAHIN.py │ │ ├── data_loader.py │ │ ├── main.py │ │ ├── readme.md │ │ └── utils.py │ ├── appnp │ │ ├── README.md │ │ ├── appnp.py │ │ └── train.py │ ├── arma │ │ ├── README.md │ │ ├── citation.py │ │ └── model.py │ ├── bgnn │ │ ├── BGNN.py │ │ ├── Readme.md │ │ └── run.py │ ├── bgrl │ │ ├── README.md │ │ ├── eval_function.py │ │ ├── main.py │ │ ├── model.py │ │ └── utils.py │ ├── capsule │ │ ├── DGLDigitCapsule.py │ │ ├── DGLRoutingLayer.py │ │ ├── README.md │ │ ├── main.py │ │ ├── model.py │ │ └── simple_routing.py │ ├── caregnn │ │ ├── README.md │ │ ├── main.py │ │ ├── main_sampling.py │ │ ├── model.py │ │ ├── model_sampling.py │ │ └── utils.py │ ├── cluster_gcn │ │ ├── README.md │ │ └── cluster_gcn.py │ ├── compGCN │ │ ├── README.md │ │ ├── data_loader.py │ │ ├── get_fb15k-237.sh │ │ ├── get_wn18rr.sh │ │ ├── main.py │ │ ├── models.py │ │ └── utils.py │ ├── correct_and_smooth │ │ ├── README.md │ │ ├── main.py │ │ └── model.py │ ├── dagnn │ │ ├── README.md │ │ ├── main.py │ │ └── utils.py │ ├── deepergcn │ │ ├── README.md │ │ ├── layers.py │ │ ├── main.py │ │ ├── models.py │ │ └── modules.py │ ├── deepwalk │ │ └── README.md │ ├── dgi │ │ ├── README.md │ │ ├── dgi.py │ │ ├── gcn.py │ │ └── train.py │ ├── dgmg │ │ ├── README.md │ │ ├── configure.py │ │ ├── cycles.py │ │ ├── main.py │ │ ├── model.py │ │ └── utils.py │ ├── diffpool │ │ ├── README.md │ │ ├── data_utils.py │ │ ├── model │ │ │ ├── __init__.py │ │ │ ├── dgl_layers │ │ │ │ ├── __init__.py │ │ │ │ ├── aggregator.py │ │ │ │ ├── bundler.py │ │ │ │ └── gnn.py │ │ │ ├── encoder.py │ │ │ ├── loss.py │ │ │ ├── model_utils.py │ │ │ └── tensorized_layers │ │ │ │ ├── __init__.py │ │ │ │ ├── assignment.py │ │ │ │ ├── diffpool.py │ │ │ │ └── graphsage.py │ │ └── train.py │ ├── dimenet │ │ ├── README.md │ │ ├── config │ │ │ ├── convert.yaml │ │ │ ├── dimenet.yaml │ │ │ └── dimenet_pp.yaml │ │ ├── convert_tf_ckpt_to_pytorch.py │ │ ├── main.py │ │ ├── modules │ │ │ ├── activations.py │ │ │ ├── basis_utils.py │ │ │ ├── bessel_basis_layer.py │ │ │ ├── dimenet.py │ │ │ ├── dimenet_pp.py │ │ │ ├── embedding_block.py │ │ │ ├── envelope.py │ │ │ ├── initializers.py │ │ │ ├── interaction_block.py │ │ │ ├── interaction_pp_block.py │ │ │ ├── output_block.py │ │ │ ├── output_pp_block.py │ │ │ ├── residual_layer.py │ │ │ └── spherical_basis_layer.py │ │ └── qm9.py │ ├── dtgrnn │ │ ├── README.md │ │ ├── dataloading.py │ │ ├── dcrnn.py │ │ ├── gaan.py │ │ ├── model.py │ │ ├── train.py │ │ └── utils.py │ ├── eeg-gcnn │ │ ├── EEGGraphDataset.py │ │ ├── README.md │ │ ├── deep_EEGGraphConvNet.py │ │ ├── main.py │ │ └── shallow_EEGGraphConvNet.py │ ├── eges │ │ ├── .gitignore │ │ ├── README.md │ │ ├── main.py │ │ ├── model.py │ │ ├── sampler.py │ │ └── utils.py │ ├── evolveGCN │ │ ├── README.md │ │ ├── dataset.py │ │ ├── model.py │ │ ├── train.py │ │ └── utils.py │ ├── gas │ │ ├── README.md │ │ ├── dataloader.py │ │ ├── main.py │ │ ├── main_sampling.py │ │ ├── model.py │ │ ├── model_sampling.py │ │ └── variant.png │ ├── gat │ │ ├── README.md │ │ ├── train.py │ │ └── train_ppi.py │ ├── gatv2 │ │ ├── README.md │ │ ├── gatv2.py │ │ └── train.py │ ├── gcmc │ │ ├── README.md │ │ ├── data.py │ │ ├── model.py │ │ ├── train.py │ │ ├── train_sampling.py │ │ └── utils.py │ ├── gcn │ │ ├── README.md │ │ └── train.py │ ├── geniepath │ │ ├── README.md │ │ ├── model.py │ │ ├── ppi.py │ │ └── pubmed.py │ ├── ggnn │ │ ├── README.md │ │ ├── data_utils.py │ │ ├── ggnn_gc.py │ │ ├── ggnn_ns.py │ │ ├── ggsnn.py │ │ ├── train_gc.py │ │ ├── train_ns.py │ │ └── train_path_finding.py │ ├── gin │ │ ├── README.md │ │ └── train.py │ ├── gnn_explainer │ │ ├── README.md │ │ ├── explain_main.py │ │ ├── gnn_subgraph │ │ │ ├── 1 │ │ │ │ ├── graph.json │ │ │ │ ├── model_list.json │ │ │ │ ├── subgraph_1.json │ │ │ │ └── subgraph_list.json │ │ │ └── dataset_list.json │ │ ├── models.py │ │ └── train_main.py │ ├── grace │ │ ├── README.md │ │ ├── aug.py │ │ ├── dataset.py │ │ ├── eval.py │ │ ├── main.py │ │ └── model.py │ ├── grand │ │ ├── README.md │ │ ├── main.py │ │ └── model.py │ ├── graph_matching │ │ ├── README.md │ │ ├── examples.py │ │ └── ged.py │ ├── graphsage │ │ ├── README.md │ │ ├── advanced │ │ │ ├── README.md │ │ │ ├── model.py │ │ │ ├── negative_sampler.py │ │ │ └── train_lightning_unsupervised.py │ │ ├── dist │ │ │ ├── README.md │ │ │ ├── ip_config.txt │ │ │ ├── partition_graph.py │ │ │ ├── train_dist.py │ │ │ ├── train_dist_transductive.py │ │ │ ├── train_dist_unsupervised.py │ │ │ └── train_dist_unsupervised_transductive.py │ │ ├── lightning │ │ │ └── node_classification.py │ │ ├── link_pred.py │ │ ├── load_graph.py │ │ ├── node_classification.py │ │ └── train_full.py │ ├── graphsaint │ │ ├── README.md │ │ ├── config.py │ │ ├── modules.py │ │ ├── sampler.py │ │ ├── train_sampling.py │ │ └── utils.py │ ├── graphsim │ │ ├── README.md │ │ ├── dataloader.py │ │ ├── models.py │ │ ├── n_body_sim.py │ │ ├── train.py │ │ └── utils.py │ ├── graphwriter │ │ ├── README.md │ │ ├── graphwriter.py │ │ ├── modules.py │ │ ├── opts.py │ │ ├── prepare_data.sh │ │ ├── run.sh │ │ ├── test.sh │ │ ├── train.py │ │ └── utlis.py │ ├── gxn │ │ ├── README.md │ │ ├── data_preprocess.py │ │ ├── layers.py │ │ ├── main.py │ │ ├── main_early_stop.py │ │ ├── networks.py │ │ ├── scripts │ │ │ ├── run_gxn.sh │ │ │ └── run_gxn_early_stop.sh │ │ └── utils.py │ ├── han │ │ ├── README.md │ │ ├── main.py │ │ ├── model.py │ │ ├── model_hetero.py │ │ ├── train_sampling.py │ │ └── utils.py │ ├── hardgat │ │ ├── README.md │ │ ├── hgao.py │ │ ├── train.py │ │ └── utils.py │ ├── hgp_sl │ │ ├── README.md │ │ ├── functions.py │ │ ├── layers.py │ │ ├── main.py │ │ ├── networks.py │ │ └── utils.py │ ├── hgt │ │ ├── README.md │ │ ├── model.py │ │ └── train_acm.py │ ├── hilander │ │ ├── PSS │ │ │ ├── README.md │ │ │ ├── Smooth_AP │ │ │ │ ├── README.md │ │ │ │ └── src │ │ │ │ │ ├── auxiliaries.py │ │ │ │ │ ├── datasets.py │ │ │ │ │ ├── evaluate.py │ │ │ │ │ ├── evaluate_model.py │ │ │ │ │ ├── finetune_1head.py │ │ │ │ │ ├── get_features.py │ │ │ │ │ ├── losses.py │ │ │ │ │ ├── main.py │ │ │ │ │ └── netlib.py │ │ │ ├── __init__.py │ │ │ ├── test.sh │ │ │ ├── test_subg_inat.py │ │ │ ├── train.sh │ │ │ └── train_subg_inat.py │ │ ├── README.md │ │ ├── __init__.py │ │ ├── checkpoint │ │ │ └── .gitkeep │ │ ├── data │ │ │ └── .gitkeep │ │ ├── dataset │ │ │ ├── __init__.py │ │ │ └── dataset.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── focal_loss.py │ │ │ ├── graphconv.py │ │ │ └── lander.py │ │ ├── scripts │ │ │ ├── test_deepglint_hannah.sh │ │ │ ├── test_deepglint_imdb.sh │ │ │ ├── test_deepglint_imdb_sampled_as_deepglint.sh │ │ │ ├── test_inat.sh │ │ │ ├── test_inat_train_on_resampled_1_in_6_per_class.sh │ │ │ ├── train_deepglint.sh │ │ │ ├── train_inat.sh │ │ │ └── train_inat_resampled_1_in_6_per_class.sh │ │ ├── test.py │ │ ├── test_subg.py │ │ ├── train.py │ │ ├── train_subg.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── adjacency.py │ │ │ ├── deduce.py │ │ │ ├── density.py │ │ │ ├── evaluate.py │ │ │ ├── faiss_gpu.py │ │ │ ├── faiss_search.py │ │ │ ├── knn.py │ │ │ ├── metrics.py │ │ │ └── misc.py │ ├── infograph │ │ ├── README.md │ │ ├── evaluate_embedding.py │ │ ├── model.py │ │ ├── semisupervised.py │ │ ├── unsupervised.py │ │ └── utils.py │ ├── jknet │ │ ├── README.md │ │ ├── main.py │ │ └── model.py │ ├── jtnn │ │ ├── README.md │ │ ├── jtnn │ │ │ ├── __init__.py │ │ │ ├── chemutils.py │ │ │ ├── datautils.py │ │ │ ├── jtmpn.py │ │ │ ├── jtnn_dec.py │ │ │ ├── jtnn_enc.py │ │ │ ├── jtnn_vae.py │ │ │ ├── line_profiler_integration.py │ │ │ ├── mol_tree.py │ │ │ ├── mol_tree_nx.py │ │ │ ├── mpn.py │ │ │ └── nnutils.py │ │ └── vaetrain_dgl.py │ ├── label_propagation │ │ ├── README.md │ │ └── main.py │ ├── lda │ │ ├── README.md │ │ ├── example_20newsgroups.py │ │ └── lda_model.py │ ├── line_graph │ │ ├── README.md │ │ ├── gnn.py │ │ └── train.py │ ├── metapath2vec │ │ ├── README.md │ │ ├── download.py │ │ ├── metapath2vec.py │ │ ├── model.py │ │ ├── reading_data.py │ │ ├── sampler.py │ │ └── test.py │ ├── mixhop │ │ ├── README.md │ │ └── main.py │ ├── model_zoo │ │ ├── README.md │ │ ├── citation_network │ │ │ ├── README.md │ │ │ ├── conf.py │ │ │ ├── models.py │ │ │ └── run.py │ │ └── geometric │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── coarsening.py │ │ │ ├── coordinate.py │ │ │ ├── grid_graph.py │ │ │ └── mnist.py │ ├── monet │ │ ├── README.md │ │ └── citation.py │ ├── multigpu │ │ ├── README.md │ │ ├── multi_gpu_graph_prediction.py │ │ ├── multi_gpu_link_prediction.py │ │ └── multi_gpu_node_classification.py │ ├── mvgrl │ │ ├── README.md │ │ ├── graph │ │ │ ├── dataset.py │ │ │ ├── main.py │ │ │ ├── model.py │ │ │ └── utils.py │ │ └── node │ │ │ ├── dataset.py │ │ │ ├── main.py │ │ │ ├── main_sample.py │ │ │ └── model.py │ ├── node2vec │ │ ├── README.md │ │ ├── main.py │ │ ├── model.py │ │ └── utils.py │ ├── ogb │ │ ├── README.md │ │ ├── cluster-gat │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ ├── partition_utils.py │ │ │ └── sampler.py │ │ ├── cluster-sage │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ ├── partition_utils.py │ │ │ └── sampler.py │ │ ├── deepwalk │ │ │ ├── README.md │ │ │ ├── deepwalk.py │ │ │ ├── load_dataset.py │ │ │ ├── model.py │ │ │ ├── reading_data.py │ │ │ └── utils.py │ │ ├── directional_GSN │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ └── preprocessing.py │ │ ├── line │ │ │ ├── README.md │ │ │ ├── line.py │ │ │ ├── load_dataset.py │ │ │ ├── model.py │ │ │ ├── reading_data.py │ │ │ └── utils.py │ │ ├── ngnn │ │ │ ├── README.md │ │ │ └── main.py │ │ ├── ngnn_seal │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ ├── models.py │ │ │ └── utils.py │ │ ├── ogbn-arxiv │ │ │ ├── README.md │ │ │ ├── correct_and_smooth.py │ │ │ ├── gat.py │ │ │ ├── gcn.py │ │ │ └── models.py │ │ ├── ogbn-mag │ │ │ ├── README.md │ │ │ └── hetero_rgcn.py │ │ ├── ogbn-products │ │ │ ├── gat │ │ │ │ ├── README.md │ │ │ │ ├── gat.py │ │ │ │ ├── main.py │ │ │ │ └── models.py │ │ │ ├── graphsage │ │ │ │ ├── README.md │ │ │ │ └── main.py │ │ │ └── mlp │ │ │ │ ├── README.md │ │ │ │ ├── mlp.py │ │ │ │ └── models.py │ │ ├── ogbn-proteins │ │ │ ├── README.md │ │ │ ├── configure.py │ │ │ ├── gat.py │ │ │ ├── main_proteins_full_dgl.py │ │ │ ├── models.py │ │ │ └── utils.py │ │ ├── seal_ogbl │ │ │ ├── README.md │ │ │ └── main.py │ │ └── sign │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── dataset.py │ │ │ └── sign.py │ ├── ogb_lsc │ │ ├── MAG240M │ │ │ ├── README.md │ │ │ ├── preprocess.py │ │ │ ├── train.py │ │ │ └── train_multi_gpus.py │ │ ├── PCQM4M │ │ │ ├── README.md │ │ │ ├── conv.py │ │ │ ├── gnn.py │ │ │ ├── main.py │ │ │ └── test_inference.py │ │ └── README.md │ ├── pagerank.py │ ├── pinsage │ │ ├── README.md │ │ ├── builder.py │ │ ├── data_utils.py │ │ ├── evaluation.py │ │ ├── layers.py │ │ ├── model.py │ │ ├── model_sparse.py │ │ ├── process_movielens1m.py │ │ ├── process_nowplaying_rs.py │ │ └── sampler.py │ ├── pointcloud │ │ ├── bipointnet │ │ │ ├── ModelNetDataLoader.py │ │ │ ├── README.md │ │ │ ├── basic.py │ │ │ ├── bipointnet2.py │ │ │ ├── bipointnet_cls.py │ │ │ └── train_cls.py │ │ ├── edgeconv │ │ │ ├── README.md │ │ │ ├── main.py │ │ │ ├── model.py │ │ │ └── modelnet.py │ │ ├── pct │ │ │ ├── ModelNetDataLoader.py │ │ │ ├── README.md │ │ │ ├── ShapeNet.py │ │ │ ├── helper.py │ │ │ ├── pct.py │ │ │ ├── provider.py │ │ │ ├── train_cls.py │ │ │ └── train_partseg.py │ │ ├── point_transformer │ │ │ ├── ModelNetDataLoader.py │ │ │ ├── README.md │ │ │ ├── ShapeNet.py │ │ │ ├── helper.py │ │ │ ├── point_transformer.py │ │ │ ├── provider.py │ │ │ ├── train_cls.py │ │ │ └── train_partseg.py │ │ └── pointnet │ │ │ ├── ModelNetDataLoader.py │ │ │ ├── README.md │ │ │ ├── ShapeNet.py │ │ │ ├── pointnet2.py │ │ │ ├── pointnet2_partseg.py │ │ │ ├── pointnet_cls.py │ │ │ ├── pointnet_partseg.py │ │ │ ├── provider.py │ │ │ ├── train_cls.py │ │ │ ├── train_partseg.py │ │ │ └── vis.png │ ├── rect │ │ ├── README.md │ │ ├── classify.py │ │ ├── label_utils.py │ │ ├── main.py │ │ ├── model.py │ │ └── utils.py │ ├── rgat │ │ ├── README.md │ │ └── train.py │ ├── rgcn-hetero │ │ ├── .gitignore │ │ ├── README.md │ │ ├── entity_classify.py │ │ ├── entity_classify_heteroAPI.py │ │ ├── entity_classify_mb.py │ │ ├── model.py │ │ └── test_classify.py │ ├── rgcn │ │ ├── README.md │ │ ├── entity.py │ │ ├── entity_sample.py │ │ ├── entity_sample_multi_gpu.py │ │ ├── entity_utils.py │ │ ├── experimental │ │ │ ├── README.md │ │ │ ├── entity_classify_dist.py │ │ │ ├── get_mag_data.py │ │ │ ├── partition_graph.py │ │ │ ├── preprocessing_dist_training │ │ │ │ ├── edges │ │ │ │ │ ├── identity1 │ │ │ │ │ │ └── sample.csv │ │ │ │ │ ├── identity2 │ │ │ │ │ │ └── sample.csv │ │ │ │ │ └── identity3 │ │ │ │ │ │ └── sample.csv │ │ │ │ ├── metis_creation.py │ │ │ │ ├── nodes │ │ │ │ │ └── order │ │ │ │ │ │ └── sample.csv │ │ │ │ └── pre_process_dist_training.sh │ │ │ ├── verify_mag_partitions.py │ │ │ └── write_mag.py │ │ ├── link.py │ │ └── model.py │ ├── rrn │ │ ├── README.md │ │ ├── rrn.py │ │ ├── sudoku.py │ │ ├── sudoku_data.py │ │ ├── sudoku_solver.py │ │ └── train_sudoku.py │ ├── sagpool │ │ ├── README.md │ │ ├── grid_search.py │ │ ├── grid_search_config.json │ │ ├── layer.py │ │ ├── main.py │ │ ├── network.py │ │ └── utils.py │ ├── seal │ │ ├── README.md │ │ ├── logger.py │ │ ├── main.py │ │ ├── model.py │ │ ├── sampler.py │ │ └── utils.py │ ├── sgc │ │ ├── README.md │ │ ├── sgc.py │ │ └── sgc_reddit.py │ ├── sign │ │ ├── README.md │ │ ├── dataset.py │ │ └── sign.py │ ├── stgcn_wave │ │ ├── README.md │ │ ├── load_data.py │ │ ├── main.py │ │ ├── model.py │ │ ├── sensors2graph.py │ │ └── utils.py │ ├── tagcn │ │ ├── README.md │ │ ├── tagcn.py │ │ └── train.py │ ├── tgn │ │ └── README.md │ ├── transformer │ │ ├── .gitignore │ │ ├── README.md │ │ ├── dataset │ │ │ ├── __init__.py │ │ │ ├── fields.py │ │ │ ├── graph.py │ │ │ └── utils.py │ │ ├── loss │ │ │ └── __init__.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── act.py │ │ │ ├── attention.py │ │ │ ├── config.py │ │ │ ├── embedding.py │ │ │ ├── functions.py │ │ │ ├── layers.py │ │ │ ├── models.py │ │ │ └── viz.py │ │ ├── optims │ │ │ ├── __init__.py │ │ │ └── noamopt.py │ │ ├── translation_test.py │ │ └── translation_train.py │ ├── tree_lstm │ │ ├── README.md │ │ ├── train.py │ │ └── tree_lstm.py │ ├── vgae │ │ ├── README.md │ │ ├── input_data.py │ │ ├── model.py │ │ ├── preprocess.py │ │ └── train.py │ └── vrgcn │ │ ├── README.md │ │ ├── train_cv.py │ │ └── train_cv_multi_gpu.py ├── sparse │ ├── appnp.py │ ├── c_and_s.py │ ├── gat.py │ ├── gcn.py │ ├── gcnii.py │ ├── graph_transformer.py │ ├── han.py │ ├── hgnn.py │ ├── hypergraphatt.py │ ├── sgc.py │ ├── sign.py │ └── twirls.py └── tensorflow │ ├── dgi │ ├── README.md │ ├── dgi.py │ ├── gcn.py │ └── train.py │ ├── gat │ ├── README.md │ ├── gat.py │ ├── train.py │ └── utils.py │ ├── gcn │ ├── README.md │ ├── gcn.py │ ├── gcn_builtin.py │ ├── gcn_mp.py │ └── train.py │ ├── rgcn │ ├── README.md │ ├── entity_classify.py │ ├── model.py │ └── utils.py │ └── sgc │ ├── README.md │ └── sgc.py ├── featgraph ├── CMakeLists.txt ├── README.md ├── include │ └── featgraph.h ├── pack_featgraph.py ├── sddmm.py ├── src │ ├── featgraph.cc │ └── tvm_runtime_pack.cc └── test.py ├── graphbolt ├── CMakeLists.txt ├── build.bat ├── build.sh ├── find_cmake.py ├── include │ └── graphbolt │ │ ├── compact.h │ │ ├── csc_sampling_graph.h │ │ ├── neighbor.h │ │ └── serialize.h └── src │ ├── compact.cc │ ├── csc_sampling_graph.cc │ ├── neighbor.cc │ └── serialize.cc ├── include ├── dgl │ ├── array.h │ ├── array_iterator.h │ ├── aten │ │ ├── array_ops.h │ │ ├── coo.h │ │ ├── csr.h │ │ ├── macro.h │ │ ├── spmat.h │ │ └── types.h │ ├── base_heterograph.h │ ├── bcast.h │ ├── env_variable.h │ ├── graph.h │ ├── graph_interface.h │ ├── graph_op.h │ ├── graph_serializer.h │ ├── graph_traversal.h │ ├── immutable_graph.h │ ├── kernel.h │ ├── lazy.h │ ├── nodeflow.h │ ├── packed_func_ext.h │ ├── random.h │ ├── runtime │ │ ├── bfloat16.h │ │ ├── c_backend_api.h │ │ ├── c_object_api.h │ │ ├── c_runtime_api.h │ │ ├── config.h │ │ ├── container.h │ │ ├── device_api.h │ │ ├── dlpack_convert.h │ │ ├── module.h │ │ ├── ndarray.h │ │ ├── object.h │ │ ├── packed_func.h │ │ ├── parallel_for.h │ │ ├── registry.h │ │ ├── serializer.h │ │ ├── shared_mem.h │ │ ├── smart_ptr_serializer.h │ │ ├── tensordispatch.h │ │ ├── threading_backend.h │ │ └── util.h │ ├── sampler.h │ ├── sampling │ │ ├── negative.h │ │ ├── neighbor.h │ │ └── randomwalks.h │ ├── scheduler.h │ ├── transform.h │ └── zerocopy_serializer.h └── intel │ ├── cpu_support.h │ └── meta_utils.h ├── notebooks └── sparse │ ├── gcn.ipynb │ ├── graph_diffusion.ipynb │ ├── graph_transformer.ipynb │ ├── hgnn.ipynb │ └── quickstart.ipynb ├── pyproject.toml ├── python ├── dgl │ ├── __init__.py │ ├── _api_internal.py │ ├── _ffi │ │ ├── README.md │ │ ├── __init__.py │ │ ├── _ctypes │ │ │ ├── __init__.py │ │ │ ├── function.py │ │ │ ├── ndarray.py │ │ │ ├── object.py │ │ │ └── types.py │ │ ├── _cy2 │ │ │ └── __init__.py │ │ ├── _cy3 │ │ │ └── __init__.py │ │ ├── _cython │ │ │ ├── .gitignore │ │ │ ├── base.pxi │ │ │ ├── core.pyx │ │ │ ├── function.pxi │ │ │ ├── ndarray.pxi │ │ │ └── object.pxi │ │ ├── base.py │ │ ├── capi.py │ │ ├── function.py │ │ ├── libinfo.py │ │ ├── ndarray.py │ │ ├── object.py │ │ ├── object_generic.py │ │ ├── runtime_ctypes.py │ │ └── streams.py │ ├── _sparse_ops.py │ ├── backend │ │ ├── __init__.py │ │ ├── backend.py │ │ ├── mxnet │ │ │ ├── __init__.py │ │ │ ├── sparse.py │ │ │ ├── sparse_optim.py │ │ │ └── tensor.py │ │ ├── pytorch │ │ │ ├── __init__.py │ │ │ ├── sparse.py │ │ │ └── tensor.py │ │ ├── set_default_backend.py │ │ └── tensorflow │ │ │ ├── __init__.py │ │ │ ├── sparse.py │ │ │ ├── sparse_optim.py │ │ │ └── tensor.py │ ├── base.py │ ├── batch.py │ ├── container.py │ ├── convert.py │ ├── core.py │ ├── cuda │ │ ├── __init__.py │ │ └── nccl.py │ ├── data │ │ ├── __init__.py │ │ ├── actor.py │ │ ├── adapter.py │ │ ├── bitcoinotc.py │ │ ├── citation_graph.py │ │ ├── cluster.py │ │ ├── csv_dataset.py │ │ ├── csv_dataset_base.py │ │ ├── dgl_dataset.py │ │ ├── fakenews.py │ │ ├── flickr.py │ │ ├── fraud.py │ │ ├── gdelt.py │ │ ├── geom_gcn.py │ │ ├── gindt.py │ │ ├── gnn_benchmark.py │ │ ├── graph_serialize.py │ │ ├── heterograph_serialize.py │ │ ├── icews18.py │ │ ├── karate.py │ │ ├── knowledge_graph.py │ │ ├── minigc.py │ │ ├── pattern.py │ │ ├── ppi.py │ │ ├── qm7b.py │ │ ├── qm9.py │ │ ├── qm9_edge.py │ │ ├── rdf.py │ │ ├── reddit.py │ │ ├── sbm.py │ │ ├── synthetic.py │ │ ├── tensor_serialize.py │ │ ├── tree.py │ │ ├── tu.py │ │ ├── utils.py │ │ ├── wikics.py │ │ ├── yelp.py │ │ └── zinc.py │ ├── dataloading │ │ ├── __init__.py │ │ ├── base.py │ │ ├── cluster_gcn.py │ │ ├── dataloader.py │ │ ├── dist_dataloader.py │ │ ├── graphsaint.py │ │ ├── labor_sampler.py │ │ ├── negative_sampler.py │ │ ├── neighbor_sampler.py │ │ └── shadow.py │ ├── distgnn │ │ ├── __init__.py │ │ ├── partition │ │ │ ├── __init__.py │ │ │ └── libra_partition.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ └── tools.py │ ├── distributed │ │ ├── __init__.py │ │ ├── constants.py │ │ ├── dist_context.py │ │ ├── dist_dataloader.py │ │ ├── dist_graph.py │ │ ├── dist_tensor.py │ │ ├── graph_partition_book.py │ │ ├── graph_services.py │ │ ├── id_map.py │ │ ├── kvstore.py │ │ ├── nn │ │ │ ├── __init__.py │ │ │ ├── mxnet │ │ │ │ └── __init__.py │ │ │ ├── pytorch │ │ │ │ ├── __init__.py │ │ │ │ └── sparse_emb.py │ │ │ └── tensorflow │ │ │ │ └── __init__.py │ │ ├── optim │ │ │ ├── __init__.py │ │ │ ├── mxnet │ │ │ │ └── __init__.py │ │ │ ├── pytorch │ │ │ │ ├── __init__.py │ │ │ │ ├── sparse_optim.py │ │ │ │ └── utils.py │ │ │ └── tensorflow │ │ │ │ └── __init__.py │ │ ├── partition.py │ │ ├── role.py │ │ ├── rpc.py │ │ ├── rpc_client.py │ │ ├── rpc_server.py │ │ ├── server_state.py │ │ ├── shared_mem_utils.py │ │ └── standalone_kvstore.py │ ├── frame.py │ ├── function │ │ ├── __init__.py │ │ ├── base.py │ │ ├── message.py │ │ └── reducer.py │ ├── generators.py │ ├── geometry │ │ ├── __init__.py │ │ ├── capi.py │ │ ├── edge_coarsening.py │ │ └── fps.py │ ├── global_config.py │ ├── graph_index.py │ ├── graphbolt │ │ ├── __init__.py │ │ ├── dataloader.py │ │ └── itemset.py │ ├── heterograph.py │ ├── heterograph_index.py │ ├── homophily.py │ ├── init.py │ ├── logging.py │ ├── merge.py │ ├── mpops │ │ ├── __init__.py │ │ ├── edgewise.py │ │ ├── fused.py │ │ └── nodewise.py │ ├── multiprocessing │ │ ├── __init__.py │ │ └── pytorch.py │ ├── ndarray.py │ ├── network.py │ ├── nn │ │ ├── __init__.py │ │ ├── functional │ │ │ └── __init__.py │ │ ├── mxnet │ │ │ ├── __init__.py │ │ │ ├── conv │ │ │ │ ├── __init__.py │ │ │ │ ├── agnnconv.py │ │ │ │ ├── appnpconv.py │ │ │ │ ├── chebconv.py │ │ │ │ ├── densechebconv.py │ │ │ │ ├── densegraphconv.py │ │ │ │ ├── densesageconv.py │ │ │ │ ├── edgeconv.py │ │ │ │ ├── gatconv.py │ │ │ │ ├── gatedgraphconv.py │ │ │ │ ├── ginconv.py │ │ │ │ ├── gmmconv.py │ │ │ │ ├── graphconv.py │ │ │ │ ├── nnconv.py │ │ │ │ ├── relgraphconv.py │ │ │ │ ├── sageconv.py │ │ │ │ ├── sgconv.py │ │ │ │ └── tagconv.py │ │ │ ├── glob.py │ │ │ ├── hetero.py │ │ │ ├── softmax.py │ │ │ └── utils.py │ │ ├── pytorch │ │ │ ├── __init__.py │ │ │ ├── conv │ │ │ │ ├── __init__.py │ │ │ │ ├── agnnconv.py │ │ │ │ ├── appnpconv.py │ │ │ │ ├── atomicconv.py │ │ │ │ ├── cfconv.py │ │ │ │ ├── chebconv.py │ │ │ │ ├── cugraph_base.py │ │ │ │ ├── cugraph_gatconv.py │ │ │ │ ├── cugraph_relgraphconv.py │ │ │ │ ├── cugraph_sageconv.py │ │ │ │ ├── densechebconv.py │ │ │ │ ├── densegraphconv.py │ │ │ │ ├── densesageconv.py │ │ │ │ ├── dgnconv.py │ │ │ │ ├── dotgatconv.py │ │ │ │ ├── edgeconv.py │ │ │ │ ├── edgegatconv.py │ │ │ │ ├── egatconv.py │ │ │ │ ├── egnnconv.py │ │ │ │ ├── gatconv.py │ │ │ │ ├── gatedgcnconv.py │ │ │ │ ├── gatedgraphconv.py │ │ │ │ ├── gatv2conv.py │ │ │ │ ├── gcn2conv.py │ │ │ │ ├── ginconv.py │ │ │ │ ├── gineconv.py │ │ │ │ ├── gmmconv.py │ │ │ │ ├── graphconv.py │ │ │ │ ├── grouprevres.py │ │ │ │ ├── hgtconv.py │ │ │ │ ├── nnconv.py │ │ │ │ ├── pnaconv.py │ │ │ │ ├── relgraphconv.py │ │ │ │ ├── sageconv.py │ │ │ │ ├── sgconv.py │ │ │ │ ├── tagconv.py │ │ │ │ └── twirlsconv.py │ │ │ ├── explain │ │ │ │ ├── __init__.py │ │ │ │ ├── gnnexplainer.py │ │ │ │ ├── pgexplainer.py │ │ │ │ └── subgraphx.py │ │ │ ├── factory.py │ │ │ ├── glob.py │ │ │ ├── gt │ │ │ │ ├── __init__.py │ │ │ │ ├── biased_mha.py │ │ │ │ ├── degree_encoder.py │ │ │ │ ├── graphormer.py │ │ │ │ ├── lap_pos_encoder.py │ │ │ │ ├── path_encoder.py │ │ │ │ └── spatial_encoder.py │ │ │ ├── hetero.py │ │ │ ├── linear.py │ │ │ ├── link │ │ │ │ ├── __init__.py │ │ │ │ ├── edgepred.py │ │ │ │ ├── transe.py │ │ │ │ └── transr.py │ │ │ ├── network_emb.py │ │ │ ├── softmax.py │ │ │ ├── sparse_emb.py │ │ │ └── utils.py │ │ └── tensorflow │ │ │ ├── __init__.py │ │ │ ├── conv │ │ │ ├── __init__.py │ │ │ ├── appnpconv.py │ │ │ ├── chebconv.py │ │ │ ├── densechebconv.py │ │ │ ├── edgeconv.py │ │ │ ├── gatconv.py │ │ │ ├── ginconv.py │ │ │ ├── graphconv.py │ │ │ ├── relgraphconv.py │ │ │ ├── sageconv.py │ │ │ └── sgconv.py │ │ │ ├── glob.py │ │ │ ├── hetero.py │ │ │ ├── softmax.py │ │ │ └── utils.py │ ├── ops │ │ ├── __init__.py │ │ ├── edge_softmax.py │ │ ├── gather_mm.py │ │ ├── sddmm.py │ │ ├── segment.py │ │ └── spmm.py │ ├── optim │ │ ├── __init__.py │ │ ├── mxnet │ │ │ └── __init__.py │ │ ├── pytorch │ │ │ ├── __init__.py │ │ │ └── sparse_optim.py │ │ └── tensorflow │ │ │ └── __init__.py │ ├── partition.py │ ├── propagate.py │ ├── random.py │ ├── readout.py │ ├── sampling │ │ ├── __init__.py │ │ ├── labor.py │ │ ├── negative.py │ │ ├── neighbor.py │ │ ├── node2vec_randomwalk.py │ │ ├── pinsage.py │ │ ├── randomwalks.py │ │ └── utils.py │ ├── sparse │ │ ├── __init__.py │ │ ├── broadcast.py │ │ ├── elementwise_op.py │ │ ├── elementwise_op_sp.py │ │ ├── matmul.py │ │ ├── reduction.py │ │ ├── sddmm.py │ │ ├── softmax.py │ │ ├── sparse_matrix.py │ │ ├── unary_op.py │ │ └── utils.py │ ├── storages │ │ ├── __init__.py │ │ ├── base.py │ │ ├── numpy.py │ │ ├── pytorch_tensor.py │ │ └── tensor.py │ ├── subgraph.py │ ├── transforms │ │ ├── __init__.py │ │ ├── functional.py │ │ ├── module.py │ │ └── to_block.py │ ├── traversal.py │ ├── udf.py │ ├── utils │ │ ├── __init__.py │ │ ├── checks.py │ │ ├── data.py │ │ ├── exception.py │ │ ├── filter.py │ │ ├── internal.py │ │ ├── pin_memory.py │ │ └── shared_mem.py │ └── view.py ├── setup.py └── update_version.py ├── readthedocs.yml ├── script ├── build_dgl.sh ├── build_doc.sh ├── create_dev_conda_env.sh ├── dgl_dev.yml.template └── run_pytest.sh ├── src ├── api │ ├── api_container.cc │ └── api_test.cc ├── array │ ├── arith.h │ ├── array.cc │ ├── array_arith.cc │ ├── array_op.h │ ├── check.h │ ├── cpu │ │ ├── array_cumsum.cc │ │ ├── array_index_select.cc │ │ ├── array_nonzero.cc │ │ ├── array_op_impl.cc │ │ ├── array_pack.cc │ │ ├── array_repeat.cc │ │ ├── array_scatter.cc │ │ ├── array_sort.cc │ │ ├── array_utils.h │ │ ├── concurrent_id_hash_map.cc │ │ ├── concurrent_id_hash_map.h │ │ ├── coo_coalesce.cc │ │ ├── coo_linegraph.cc │ │ ├── coo_remove.cc │ │ ├── coo_sort.cc │ │ ├── csr_get_data.cc │ │ ├── csr_mm.cc │ │ ├── csr_remove.cc │ │ ├── csr_sort.cc │ │ ├── csr_sum.cc │ │ ├── csr_to_simple.cc │ │ ├── csr_union.cc │ │ ├── disjoint_union.cc │ │ ├── gather_mm.cc │ │ ├── gather_mm.h │ │ ├── labor_pick.h │ │ ├── labor_sampling.cc │ │ ├── negative_sampling.cc │ │ ├── rowwise_pick.h │ │ ├── rowwise_sampling.cc │ │ ├── rowwise_topk.cc │ │ ├── sddmm.cc │ │ ├── sddmm.h │ │ ├── segment_reduce.cc │ │ ├── segment_reduce.h │ │ ├── spmat_op_impl_coo.cc │ │ ├── spmat_op_impl_csr.cc │ │ ├── spmm.cc │ │ ├── spmm.h │ │ ├── spmm_binary_ops.h │ │ ├── spmm_blocking_libxsmm.h │ │ ├── traversal.cc │ │ └── traversal.h │ ├── cuda │ │ ├── array_cumsum.cu │ │ ├── array_index_select.cu │ │ ├── array_index_select.cuh │ │ ├── array_nonzero.cu │ │ ├── array_op_impl.cu │ │ ├── array_scatter.cu │ │ ├── array_sort.cu │ │ ├── atomic.cuh │ │ ├── bf16.cuh │ │ ├── coo2csr.cu │ │ ├── coo_sort.cu │ │ ├── csr2coo.cu │ │ ├── csr_get_data.cu │ │ ├── csr_mm.cu │ │ ├── csr_sort.cu │ │ ├── csr_sum.cu │ │ ├── csr_transpose.cc │ │ ├── cuda_filter.cu │ │ ├── cusparse_dispatcher.cuh │ │ ├── dgl_cub.cuh │ │ ├── disjoint_union.cu │ │ ├── fp16.cuh │ │ ├── functor.cuh │ │ ├── gather_mm.cu │ │ ├── ge_spmm.cuh │ │ ├── labor_sampling.cu │ │ ├── macro.cuh │ │ ├── negative_sampling.cu │ │ ├── rowwise_sampling.cu │ │ ├── rowwise_sampling_prob.cu │ │ ├── sddmm.cu │ │ ├── sddmm.cuh │ │ ├── sddmm_hetero_coo.cu │ │ ├── sddmm_hetero_csr.cu │ │ ├── segment_reduce.cu │ │ ├── segment_reduce.cuh │ │ ├── spmat_op_impl_coo.cu │ │ ├── spmat_op_impl_csr.cu │ │ ├── spmm.cu │ │ ├── spmm.cuh │ │ ├── spmm_hetero.cu │ │ ├── utils.cu │ │ ├── utils.h │ │ └── uvm │ │ │ ├── array_index_select_uvm.cu │ │ │ └── array_index_select_uvm.cuh │ ├── filter.cc │ ├── filter.h │ ├── kernel.cc │ ├── kernel_decl.h │ ├── libra_partition.cc │ ├── selector.h │ ├── union_partition.cc │ ├── uvm_array.cc │ └── uvm_array_op.h ├── bcast.cc ├── c_api_common.cc ├── c_api_common.h ├── geometry │ ├── cpu │ │ └── geometry_op_impl.cc │ ├── cuda │ │ ├── edge_coarsening_impl.cu │ │ └── geometry_op_impl.cu │ ├── geometry.cc │ └── geometry_op.h ├── graph │ ├── creators.cc │ ├── gk_ops.cc │ ├── graph.cc │ ├── graph_apis.cc │ ├── graph_op.cc │ ├── graph_traversal.cc │ ├── heterograph.cc │ ├── heterograph.h │ ├── heterograph_capi.cc │ ├── immutable_graph.cc │ ├── metis_partition.cc │ ├── network.cc │ ├── network.h │ ├── nodeflow.cc │ ├── pickle.cc │ ├── sampler.cc │ ├── sampling │ │ ├── negative │ │ │ └── global_uniform.cc │ │ ├── neighbor │ │ │ └── neighbor.cc │ │ └── randomwalks │ │ │ ├── frequency_hashmap.cu │ │ │ ├── frequency_hashmap.cuh │ │ │ ├── get_node_types_cpu.cc │ │ │ ├── get_node_types_gpu.cu │ │ │ ├── metapath_randomwalk.h │ │ │ ├── node2vec.cc │ │ │ ├── node2vec_cpu.cc │ │ │ ├── node2vec_impl.h │ │ │ ├── node2vec_randomwalk.h │ │ │ ├── randomwalk_cpu.cc │ │ │ ├── randomwalk_gpu.cu │ │ │ ├── randomwalk_with_restart_cpu.cc │ │ │ ├── randomwalks.cc │ │ │ ├── randomwalks_cpu.h │ │ │ └── randomwalks_impl.h │ ├── serialize │ │ ├── dglgraph_data.h │ │ ├── dglgraph_serialize.cc │ │ ├── dglstream.h │ │ ├── graph_serialize.cc │ │ ├── graph_serialize.h │ │ ├── heterograph_data.h │ │ ├── heterograph_serialize.cc │ │ ├── tensor_serialize.cc │ │ └── zerocopy_serializer.cc │ ├── shared_mem_manager.cc │ ├── shared_mem_manager.h │ ├── subgraph.cc │ ├── transform │ │ ├── compact.cc │ │ ├── compact.h │ │ ├── cpu │ │ │ ├── kdtree_ndarray_adapter.h │ │ │ └── knn.cc │ │ ├── cuda │ │ │ ├── cuda_compact_graph.cu │ │ │ ├── cuda_map_edges.cuh │ │ │ ├── cuda_to_block.cu │ │ │ └── knn.cu │ │ ├── knn.cc │ │ ├── knn.h │ │ ├── line_graph.cc │ │ ├── metis_partition_hetero.cc │ │ ├── partition_hetero.cc │ │ ├── remove_edges.cc │ │ ├── to_block.cc │ │ ├── to_block.h │ │ ├── to_simple.cc │ │ └── union_partition.cc │ ├── traversal.cc │ ├── traversal.h │ ├── unit_graph.cc │ └── unit_graph.h ├── partition │ ├── cuda │ │ └── partition_op.cu │ ├── ndarray_partition.cc │ ├── ndarray_partition.h │ └── partition_op.h ├── random │ ├── cpu │ │ ├── choice.cc │ │ └── sample_utils.h │ └── random.cc ├── rpc │ ├── net_type.h │ ├── network │ │ ├── common.cc │ │ ├── common.h │ │ ├── communicator.h │ │ ├── msg_queue.cc │ │ ├── msg_queue.h │ │ ├── socket_communicator.cc │ │ ├── socket_communicator.h │ │ ├── socket_pool.cc │ │ ├── socket_pool.h │ │ ├── tcp_socket.cc │ │ └── tcp_socket.h │ ├── rpc.cc │ ├── rpc.h │ ├── rpc_msg.h │ ├── server_state.h │ └── tensorpipe │ │ ├── README.md │ │ ├── queue.h │ │ ├── tp_communicator.cc │ │ └── tp_communicator.h ├── runtime │ ├── c_object_api.cc │ ├── c_runtime_api.cc │ ├── config.cc │ ├── cpu_device_api.cc │ ├── cuda │ │ ├── cuda_common.h │ │ ├── cuda_device_api.cc │ │ ├── cuda_hashtable.cu │ │ └── cuda_hashtable.cuh │ ├── dlpack_convert.cc │ ├── dso_module.cc │ ├── file_util.cc │ ├── file_util.h │ ├── meta_data.h │ ├── module.cc │ ├── module_util.cc │ ├── module_util.h │ ├── ndarray.cc │ ├── object.cc │ ├── pack_args.h │ ├── parallel_for.cpp │ ├── registry.cc │ ├── resource_manager.cc │ ├── resource_manager.h │ ├── runtime_base.h │ ├── semaphore_wrapper.cc │ ├── semaphore_wrapper.h │ ├── shared_mem.cc │ ├── system_lib_module.cc │ ├── tensordispatch.cc │ ├── thread_pool.cc │ ├── thread_storage_scope.h │ ├── threading_backend.cc │ ├── utils.cc │ ├── workspace.h │ ├── workspace_pool.cc │ └── workspace_pool.h └── scheduler │ ├── scheduler.cc │ └── scheduler_apis.cc ├── tensoradapter ├── include │ ├── tensoradapter.h │ └── tensoradapter_exports.h └── pytorch │ ├── CMakeLists.txt │ ├── build.bat │ ├── build.sh │ ├── find_cmake.py │ └── torch.cpp ├── tests ├── README.md ├── backend │ ├── __init__.py │ ├── backend_unittest.py │ ├── mxnet │ │ └── __init__.py │ ├── pytorch │ │ └── __init__.py │ └── tensorflow │ │ └── __init__.py ├── cpp │ ├── common.h │ ├── graph_index_test.cc │ ├── message_queue_test.cc │ ├── socket_communicator_test.cc │ ├── string_test.cc │ ├── test_aten.cc │ ├── test_concurrent_id_hash_map.cc │ ├── test_csrmm.cc │ ├── test_partition.cc │ ├── test_rowwise.cc │ ├── test_sampler.cc │ ├── test_serialize.cc │ ├── test_smart_ptr_serialize.cc │ ├── test_spmat_coo.cc │ ├── test_spmat_csr.cc │ ├── test_spmm.cc │ ├── test_unit_graph.cc │ └── test_zerocopy_serialize.cc ├── cugraph │ ├── cugraph-ops │ │ ├── test_cugraph_gatconv.py │ │ ├── test_cugraph_relgraphconv.py │ │ └── test_cugraph_sageconv.py │ └── test_basics.py ├── dist │ ├── cpp │ │ ├── rpc_base.h │ │ ├── rpc_client.cc │ │ └── rpc_server.cc │ ├── python │ │ ├── rpc_basic.py │ │ └── run_dist_objects.py │ ├── test_cpp.py │ ├── test_dist_objects.py │ ├── test_rpc.py │ └── utils.py ├── distributed │ ├── test_dist_graph_store.py │ ├── test_dist_tensor.py │ ├── test_distributed_sampling.py │ ├── test_mp_dataloader.py │ ├── test_new_kvstore.py │ ├── test_partition.py │ ├── test_rpc.py │ └── utils.py ├── examples │ └── test_sparse_examples.py ├── go │ ├── test_model.py │ └── test_pipeline.py ├── lint │ ├── clangformat_linter.py │ ├── lint.py │ ├── pip_init.py │ ├── pylintrc │ └── ufmt_linter.py ├── python │ ├── common │ │ ├── backend │ │ │ ├── test_set_default_backend.py │ │ │ └── test_tensor.py │ │ ├── data │ │ │ ├── data │ │ │ │ ├── 1.bin │ │ │ │ ├── 1.npy │ │ │ │ ├── 2.bin │ │ │ │ ├── 2.npy │ │ │ │ ├── graph_0.9a220622.dgl │ │ │ │ └── hetero1.bin │ │ │ ├── test_actor.py │ │ │ ├── test_data.py │ │ │ ├── test_geom_gcn.py │ │ │ ├── test_serialize.py │ │ │ └── test_utils.py │ │ ├── dataloading │ │ │ └── test_dataloader.py │ │ ├── function │ │ │ └── test_basics.py │ │ ├── ops │ │ │ ├── test_edge_softmax.py │ │ │ └── test_ops.py │ │ ├── sampling │ │ │ └── test_sampling.py │ │ ├── test_batch-graph.py │ │ ├── test_batch-heterograph.py │ │ ├── test_ffi.py │ │ ├── test_frame.py │ │ ├── test_generators.py │ │ ├── test_heterograph-apply-edges.py │ │ ├── test_heterograph-index.py │ │ ├── test_heterograph-kernel.py │ │ ├── test_heterograph-misc.py │ │ ├── test_heterograph-pickle.py │ │ ├── test_heterograph-remove.py │ │ ├── test_heterograph-shared-memory.py │ │ ├── test_heterograph-specialization.py │ │ ├── test_heterograph-update-all.py │ │ ├── test_heterograph.py │ │ ├── test_homophily.py │ │ ├── test_merge.py │ │ ├── test_partition.py │ │ ├── test_propagate.py │ │ ├── test_random.py │ │ ├── test_readout.py │ │ ├── test_sparse_ops-csr.py │ │ ├── test_subgraph.py │ │ ├── test_traversal.py │ │ ├── transforms │ │ │ ├── test_functional-sort.py │ │ │ ├── test_to_block.py │ │ │ └── test_transform.py │ │ └── utils │ │ │ ├── test_filter.py │ │ │ └── test_pin_memory.py │ ├── mxnet │ │ ├── ip_config.txt │ │ ├── test_geometry.py │ │ └── test_nn.py │ ├── pytorch │ │ ├── cuda │ │ │ └── test_nccl.py │ │ ├── dataloading │ │ │ └── test_dataloader.py │ │ ├── distributed │ │ │ └── optim │ │ │ │ └── test_dist_optim.py │ │ ├── geometry │ │ │ └── test_geometry.py │ │ ├── graphbolt │ │ │ └── test_itemset.py │ │ ├── ip_config.txt │ │ ├── mpops │ │ │ └── test_edgewise.py │ │ ├── nn │ │ │ ├── conv │ │ │ │ └── test_gatedgcnconv.py │ │ │ ├── test_nn.py │ │ │ └── test_sparse_emb.py │ │ ├── optim │ │ │ └── test_optim.py │ │ ├── sparse │ │ │ ├── __init__.py │ │ │ ├── test_broadcast.py │ │ │ ├── test_elementwise_op.py │ │ │ ├── test_elementwise_op_sp.py │ │ │ ├── test_matmul.py │ │ │ ├── test_reduction.py │ │ │ ├── test_sddmm.py │ │ │ ├── test_softmax.py │ │ │ ├── test_sparse_matrix.py │ │ │ ├── test_unary_op.py │ │ │ └── utils.py │ │ ├── test_ffi-stream.py │ │ ├── test_heterograph-pickle.py │ │ ├── test_multiprocessing-ipc.py │ │ └── utils │ │ │ └── test_pin_memory.py │ └── tensorflow │ │ ├── test_basic.py │ │ └── test_nn.py ├── scripts │ ├── build_dgl.bat │ ├── build_dgl.sh │ ├── ci_report │ │ ├── report.py │ │ └── status.py │ ├── cugraph_unit_test.sh │ ├── task_cpp_unit_test.bat │ ├── task_cpp_unit_test.sh │ ├── task_dist_test.sh │ ├── task_distributed_test.sh │ ├── task_example_test.bat │ ├── task_example_test.sh │ ├── task_go_test.sh │ ├── task_lint.sh │ ├── task_pytorch_tutorial_test.sh │ ├── task_unit_test.bat │ └── task_unit_test.sh ├── tools │ ├── pytest_utils.py │ ├── test_array_readwriter.py │ ├── test_change_etype_to_canonical_etype.py │ ├── test_convert_partition.py │ ├── test_dist_lookup.py │ ├── test_dist_part.py │ ├── test_launch.py │ ├── test_parmetis.py │ └── test_parmetis_preproc.py └── utils │ ├── __init__.py │ ├── checks.py │ └── graph_cases.py ├── tools ├── README.md ├── change_etype_to_canonical_etype.py ├── chunk_graph.py ├── copy_files.py ├── dispatch_data.py ├── distgraphlaunch.py ├── distpartitioning │ ├── README.md │ ├── array_readwriter │ │ ├── __init__.py │ │ ├── csv.py │ │ ├── numpy_array.py │ │ ├── parquet.py │ │ └── registry.py │ ├── constants.py │ ├── convert_partition.py │ ├── data_proc_pipeline.py │ ├── data_shuffle.py │ ├── dataset_utils.py │ ├── dist_lookup.py │ ├── globalids.py │ ├── gloo_wrapper.py │ ├── parmetis_postprocess.py │ ├── parmetis_preprocess.py │ ├── parmetis_wrapper.py │ └── utils.py ├── files.py ├── launch.py ├── partition_algo │ ├── base.py │ └── random_partition.py ├── verification_utils.py └── verify_partitions.py └── tutorials ├── blitz ├── .gitignore ├── 1_introduction.py ├── 2_dglgraph.py ├── 3_message_passing.py ├── 4_link_predict.py ├── 5_graph_classification.py ├── 6_load_data.py └── README.txt ├── cpu ├── README.txt └── cpu_best_practises.py ├── dist ├── 1_node_classification.py ├── 2_link_prediction.py └── README.txt ├── large ├── .gitignore ├── L0_neighbor_sampling_overview.py ├── L1_large_node_classification.py ├── L2_large_link_prediction.py ├── L4_message_passing.py └── README.txt ├── models ├── 1_gnn │ ├── 1_gcn.py │ ├── 4_rgcn.py │ ├── 6_line_graph.py │ ├── 9_gat.py │ └── README.txt ├── 2_small_graph │ ├── 3_tree-lstm.py │ └── README.txt ├── 3_generative_model │ ├── 5_dgmg.py │ └── README.txt ├── 4_old_wines │ ├── 2_capsule.py │ ├── 7_transformer.py │ └── README.txt └── README.txt ├── multi ├── 1_graph_classification.py ├── 2_node_classification.py └── README.txt └── requirements.txt /.github/ISSUE_TEMPLATE/--work-item--dev-only-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F528Work Item (DEV ONLY)" 3 | about: Work item issue for tracking progress. Dev team only. 4 | title: '' 5 | labels: Work Item 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## 🔨Work Item 11 | 12 | **IMPORTANT:** 13 | * This template is only for dev team to track project progress. For feature request or bug report, please use the corresponding issue templates. 14 | * DO NOT create a new work item if the purpose is to fix an existing issue or feature request. We will directly use the issue in the project tracker. 15 | 16 | Project tracker: https://github.com/orgs/dmlc/projects/2 17 | 18 | ## Description 19 | 20 | 21 | 22 | ## Depending work items or issues 23 | 24 | 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F4DA Documentation" 3 | about: Report an issue related to docs.dgl.ai 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## 📚 Documentation 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature Request" 3 | about: Submit a proposal/request for a new DGL feature 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## 🚀 Feature 11 | 12 | 13 | ## Motivation 14 | 15 | 18 | 19 | ## Alternatives 20 | 21 | 22 | 23 | ## Pitch 24 | 25 | 26 | 27 | ## Additional context 28 | 29 | 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/questions-help-support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "❓Questions/Help/Support" 3 | about: Do you need support? We have resources. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## ❓ Questions and Help 11 | 12 | Before proceeding, please note that we recommend 13 | using our discussion forum (https://discuss.dgl.ai) for 14 | general questions. As a result, this issue will 15 | likely be CLOSED shortly. 16 | -------------------------------------------------------------------------------- /apps/life_sci/README.md: -------------------------------------------------------------------------------- 1 | # DGL-LifeSci 2 | 3 | DGL-LifeSci is moved [here](https://github.com/awslabs/dgl-lifesci). 4 | -------------------------------------------------------------------------------- /benchmarks/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | results 3 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/__init__.py -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/api/__init__.py -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_add_self_loop.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.benchmark("time") 13 | @utils.parametrize("graph_name", ["cora", "livejournal"]) 14 | @utils.parametrize("format", ["coo"]) 15 | def track_time(graph_name, format): 16 | device = utils.get_bench_device() 17 | graph = utils.get_graph(graph_name, format) 18 | graph = graph.to(device) 19 | 20 | # dry run 21 | for i in range(3): 22 | g = graph.add_self_loop() 23 | 24 | # timing 25 | 26 | with utils.Timer() as t: 27 | for i in range(3): 28 | edges = graph.add_self_loop() 29 | 30 | return t.elapsed_secs / 3 31 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_batch.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import torch 6 | 7 | from .. import utils 8 | 9 | 10 | @utils.benchmark("time") 11 | @utils.parametrize("batch_size", [4, 32, 256, 1024]) 12 | def track_time(batch_size): 13 | device = utils.get_bench_device() 14 | ds = dgl.data.QM7bDataset() 15 | # prepare graph 16 | graphs = [] 17 | for graph in ds[0:batch_size][0]: 18 | g = graph.to(device) 19 | graphs.append(g) 20 | 21 | # dry run 22 | for i in range(10): 23 | g = dgl.batch(graphs) 24 | 25 | # timing 26 | 27 | with utils.Timer() as t: 28 | for i in range(100): 29 | g = dgl.batch(graphs) 30 | 31 | return t.elapsed_secs / 100 32 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_edge_subgraph.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.benchmark("time") 13 | @utils.parametrize("graph_name", ["livejournal", "reddit"]) 14 | @utils.parametrize("format", ["coo"]) 15 | @utils.parametrize("seed_egdes_num", [500, 5000, 50000]) 16 | def track_time(graph_name, format, seed_egdes_num): 17 | device = utils.get_bench_device() 18 | graph = utils.get_graph(graph_name, format) 19 | graph = graph.to(device) 20 | 21 | seed_edges = np.random.randint(0, graph.num_edges(), seed_egdes_num) 22 | seed_edges = torch.from_numpy(seed_edges).to(device) 23 | 24 | # dry run 25 | for i in range(3): 26 | dgl.edge_subgraph(graph, seed_edges) 27 | 28 | # timing 29 | num_iters = 50 30 | with utils.Timer() as t: 31 | for i in range(num_iters): 32 | dgl.edge_subgraph(graph, seed_edges) 33 | 34 | return t.elapsed_secs / num_iters 35 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_heterograph_construction.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.benchmark("time") 13 | @utils.parametrize("num_relations", [5, 50, 500]) 14 | def track_time(num_relations): 15 | dd = {} 16 | candidate_edges = [ 17 | dgl.data.CoraGraphDataset(verbose=False)[0].edges(), 18 | dgl.data.PubmedGraphDataset(verbose=False)[0].edges(), 19 | dgl.data.CiteseerGraphDataset(verbose=False)[0].edges(), 20 | ] 21 | for i in range(num_relations): 22 | dd[("n1", "e_{}".format(i), "n2")] = candidate_edges[ 23 | i % len(candidate_edges) 24 | ] 25 | 26 | # dry run 27 | graph = dgl.heterograph(dd) 28 | 29 | # timing 30 | with utils.Timer() as t: 31 | for i in range(3): 32 | graph = dgl.heterograph(dd) 33 | 34 | return t.elapsed_secs / 3 35 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_homograph_edge_construction.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.skip_if_gpu() 13 | @utils.benchmark("time") 14 | @utils.parametrize("size", ["small", "large"]) 15 | def track_time(size): 16 | edge_list = { 17 | "small": dgl.data.CiteseerGraphDataset(verbose=False)[0].edges(), 18 | "large": utils.get_livejournal().edges(), 19 | } 20 | 21 | # dry run 22 | dgl.graph(edge_list[size]) 23 | 24 | # timing 25 | with utils.Timer() as t: 26 | for i in range(10): 27 | g = dgl.graph(edge_list[size]) 28 | 29 | return t.elapsed_secs / 10 30 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_homograph_scipy_construction.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.skip_if_gpu() 13 | @utils.benchmark("time") 14 | @utils.parametrize("size", ["small", "large"]) 15 | @utils.parametrize("scipy_format", ["coo", "csr"]) 16 | def track_time(size, scipy_format): 17 | matrix_dict = { 18 | "small": dgl.data.CiteseerGraphDataset(verbose=False)[0].adj_external( 19 | scipy_fmt=scipy_format 20 | ), 21 | "large": utils.get_livejournal().adj_external(scipy_fmt=scipy_format), 22 | } 23 | 24 | # dry run 25 | dgl.from_scipy(matrix_dict[size]) 26 | 27 | # timing 28 | with utils.Timer() as t: 29 | for i in range(3): 30 | dgl.from_scipy(matrix_dict[size]) 31 | 32 | return t.elapsed_secs / 3 33 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_in_subgraph.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.benchmark("time") 13 | @utils.parametrize("graph_name", ["livejournal", "reddit"]) 14 | @utils.parametrize("format", ["csc"]) # coo is not supported 15 | @utils.parametrize("seed_nodes_num", [200, 5000, 20000]) 16 | def track_time(graph_name, format, seed_nodes_num): 17 | device = utils.get_bench_device() 18 | graph = utils.get_graph(graph_name, format) 19 | graph = graph.to(device) 20 | 21 | seed_nodes = np.random.randint(0, graph.num_nodes(), seed_nodes_num) 22 | seed_nodes = torch.from_numpy(seed_nodes).to(device) 23 | 24 | # dry run 25 | for i in range(3): 26 | dgl.in_subgraph(graph, seed_nodes) 27 | 28 | # timing 29 | num_iters = 50 30 | with utils.Timer() as t: 31 | for i in range(num_iters): 32 | dgl.in_subgraph(graph, seed_nodes) 33 | 34 | return t.elapsed_secs / num_iters 35 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_khop.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | import torch 7 | 8 | from .. import utils 9 | 10 | 11 | @utils.benchmark("time", timeout=60) 12 | @utils.parametrize("graph_name", ["cora"]) 13 | @utils.parametrize("format", ["coo", "csr"]) 14 | @utils.parametrize("k", [1, 3, 5]) 15 | def track_time(graph_name, format, k): 16 | device = utils.get_bench_device() 17 | graph = utils.get_graph(graph_name, format) 18 | graph = graph.to(device) 19 | graph = graph.formats([format]) 20 | # dry run 21 | dgl.khop_graph(graph, k) 22 | 23 | # timing 24 | with utils.Timer() as t: 25 | for i in range(10): 26 | gg = dgl.khop_graph(graph, k) 27 | 28 | return t.elapsed_secs / 10 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_knn_graph.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | import torch 7 | 8 | from .. import utils 9 | 10 | 11 | @utils.benchmark("time", timeout=60) 12 | @utils.parametrize("k", [8, 64]) 13 | @utils.parametrize("size", [1000, 10000]) 14 | @utils.parametrize("dim", [4, 32, 256]) 15 | @utils.parametrize_cpu( 16 | "algorithm", ["bruteforce-blas", "bruteforce", "kd-tree", "nn-descent"] 17 | ) 18 | @utils.parametrize_gpu( 19 | "algorithm", 20 | ["bruteforce-blas", "bruteforce", "bruteforce-sharemem", "nn-descent"], 21 | ) 22 | def track_time(size, dim, k, algorithm): 23 | device = utils.get_bench_device() 24 | features = np.random.RandomState(42).randn(size, dim) 25 | feat = torch.tensor(features, dtype=torch.float, device=device) 26 | # dry run 27 | for i in range(1): 28 | dgl.knn_graph(feat, k, algorithm=algorithm) 29 | # timing 30 | with utils.Timer() as t: 31 | for i in range(5): 32 | dgl.knn_graph(feat, k, algorithm=algorithm) 33 | 34 | return t.elapsed_secs / 5 35 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_metis_partition.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | import torch 7 | 8 | from .. import utils 9 | 10 | 11 | @utils.skip_if_gpu() 12 | @utils.benchmark("time", timeout=1200) 13 | @utils.parametrize("graph_name", ["reddit"]) 14 | @utils.parametrize("k", [2, 4, 8]) 15 | def track_time(graph_name, k): 16 | device = utils.get_bench_device() 17 | data = utils.process_data(graph_name) 18 | graph = data[0] 19 | # dry run 20 | gg = dgl.transforms.metis_partition(graph, k) 21 | 22 | # timing 23 | with utils.Timer() as t: 24 | for i in range(3): 25 | gg = dgl.transforms.metis_partition(graph, k) 26 | 27 | return t.elapsed_secs / 3 28 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_node_subgraph.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | import dgl.function as fn 5 | 6 | import numpy as np 7 | import torch 8 | 9 | from .. import utils 10 | 11 | 12 | @utils.benchmark("time") 13 | @utils.parametrize("graph_name", ["livejournal", "reddit"]) 14 | @utils.parametrize("format", ["coo", "csc"]) 15 | @utils.parametrize("seed_nodes_num", [200, 5000, 20000]) 16 | def track_time(graph_name, format, seed_nodes_num): 17 | device = utils.get_bench_device() 18 | graph = utils.get_graph(graph_name, format) 19 | graph = graph.to(device) 20 | 21 | seed_nodes = np.random.randint(0, graph.num_nodes(), seed_nodes_num) 22 | seed_nodes = torch.from_numpy(seed_nodes).to(device) 23 | 24 | # dry run 25 | for i in range(3): 26 | dgl.node_subgraph(graph, seed_nodes) 27 | 28 | # timing 29 | num_iters = 50 30 | with utils.Timer() as t: 31 | for i in range(num_iters): 32 | dgl.node_subgraph(graph, seed_nodes) 33 | 34 | return t.elapsed_secs / num_iters 35 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_reverse.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | import torch 7 | 8 | from .. import utils 9 | 10 | 11 | @utils.benchmark("time", timeout=1200) 12 | @utils.parametrize_cpu("graph_name", ["cora", "livejournal", "friendster"]) 13 | @utils.parametrize_gpu("graph_name", ["cora", "livejournal"]) 14 | @utils.parametrize("format", ["coo", "csc", "csr"]) 15 | def track_time(graph_name, format): 16 | device = utils.get_bench_device() 17 | graph = utils.get_graph(graph_name, format) 18 | graph = graph.to(device) 19 | graph = graph.formats([format]) 20 | # dry run 21 | dgl.reverse(graph) 22 | 23 | # timing 24 | with utils.Timer() as t: 25 | for i in range(100): 26 | gg = dgl.reverse(graph) 27 | 28 | return t.elapsed_secs / 100 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/api/bench_unbatch.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import torch 6 | 7 | from .. import utils 8 | 9 | 10 | @utils.benchmark("time") 11 | @utils.parametrize("batch_size", [4, 32, 256, 1024]) 12 | def track_time(batch_size): 13 | device = utils.get_bench_device() 14 | ds = dgl.data.QM7bDataset() 15 | # prepare graph 16 | graphs = ds[0:batch_size][0] 17 | bg = dgl.batch(graphs).to(device) 18 | 19 | # dry run 20 | for i in range(10): 21 | glist = dgl.unbatch(bg) 22 | 23 | # timing 24 | with utils.Timer() as t: 25 | for i in range(100): 26 | glist = dgl.unbatch(bg) 27 | 28 | return t.elapsed_secs / 100 29 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/kernel/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/kernel/__init__.py -------------------------------------------------------------------------------- /benchmarks/benchmarks/kernel/bench_edgesoftmax.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import dgl 4 | 5 | import torch 6 | 7 | from .. import utils 8 | 9 | 10 | # The benchmarks for ops edge_softmax 11 | @utils.benchmark("time", timeout=600) 12 | @utils.parametrize("graph", ["ogbn-arxiv", "reddit", "cora", "pubmed"]) 13 | @utils.parametrize("num_heads", [1, 4, 8]) 14 | def track_time(graph, num_heads): 15 | device = utils.get_bench_device() 16 | graph = utils.get_graph(graph).to(device) 17 | score = ( 18 | torch.randn((graph.num_edges(), num_heads)) 19 | .requires_grad_(True) 20 | .float() 21 | .to(device) 22 | ) 23 | 24 | # dry run 25 | for i in range(3): 26 | y = dgl.ops.edge_softmax(graph, score) 27 | 28 | # timing 29 | with utils.Timer(device) as t: 30 | for i in range(100): 31 | y = dgl.ops.edge_softmax(graph, score) 32 | 33 | return t.elapsed_secs / 100 34 | -------------------------------------------------------------------------------- /benchmarks/benchmarks/model_acc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/model_acc/__init__.py -------------------------------------------------------------------------------- /benchmarks/benchmarks/model_speed/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/model_speed/__init__.py -------------------------------------------------------------------------------- /benchmarks/benchmarks/multigpu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/benchmarks/benchmarks/multigpu/__init__.py -------------------------------------------------------------------------------- /benchmarks/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | DEVICE=$1 6 | ROOT=/asv/dgl 7 | 8 | . /opt/conda/etc/profile.d/conda.sh 9 | 10 | conda activate base 11 | pip install --upgrade pip 12 | # Newer asv version like 0.5.1 has different result format, 13 | # so we fix the version here. Or `generate_excel.py` has to be changed. 14 | pip install asv==0.4.2 15 | pip uninstall -y dgl 16 | 17 | export DGL_BENCH_DEVICE=$DEVICE 18 | echo "DGL_BENCH_DEVICE=$DGL_BENCH_DEVICE" 19 | pushd $ROOT/benchmarks 20 | cat asv.conf.json 21 | asv machine --yes 22 | # If --launch-method is specified as 'spawn', multigpu tests will crash with 23 | # "No module named 'benchmarks' is found". 24 | asv run -e -v 25 | asv publish 26 | popd 27 | -------------------------------------------------------------------------------- /benchmarks/scripts/build_dgl_asv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Default building only with cpu 6 | DEVICE=${DGL_BENCH_DEVICE:-cpu} 7 | 8 | pip install -r /asv/torch_gpu_pip.txt 9 | 10 | # build 11 | # 'CUDA_TOOLKIT_ROOT_DIR' is always required for sparse build as torch1.13.1+cu116 is installed. 12 | CMAKE_VARS="-DUSE_OPENMP=ON -DBUILD_TORCH=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda" 13 | if [[ $DEVICE == "gpu" ]]; then 14 | CMAKE_VARS="-DUSE_CUDA=ON $CMAKE_VARS" 15 | fi 16 | mkdir -p build 17 | pushd build 18 | cmake $CMAKE_VARS .. 19 | make -j8 20 | popd 21 | -------------------------------------------------------------------------------- /benchmarks/scripts/install_dgl_asv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # install 6 | pushd python 7 | rm -rf build *.egg-info dist 8 | pip uninstall -y dgl 9 | python3 setup.py install 10 | popd 11 | -------------------------------------------------------------------------------- /benchmarks/scripts/torch_gpu_pip.txt: -------------------------------------------------------------------------------- 1 | --find-links https://download.pytorch.org/whl/torch_stable.html 2 | torch==1.13.1+cu116 3 | torchvision==0.14.1+cu116 4 | torchmetrics 5 | pytest 6 | nose 7 | numpy 8 | cython 9 | scipy 10 | networkx 11 | matplotlib 12 | nltk 13 | requests[security] 14 | tqdm 15 | awscli 16 | torchtext 17 | pandas 18 | rdflib 19 | ogb 20 | -------------------------------------------------------------------------------- /benchmarks/task.json: -------------------------------------------------------------------------------- 1 | { 2 | "r5.16xlarge": { 3 | "tests": [ 4 | "api.", "kernel.", "model_acc.", "model_speed." 5 | ], 6 | "env": { 7 | "DEVICE": "cpu" 8 | } 9 | }, 10 | "g4dn.2xlarge": { 11 | "tests": [ 12 | "api.", "kernel.", "model_acc.", "model_speed." 13 | ], 14 | "env": { 15 | "DEVICE": "gpu" 16 | } 17 | }, 18 | "g4dn.12xlarge": { 19 | "tests": [ 20 | "multigpu." 21 | ], 22 | "env": { 23 | "DEVICE": "gpu" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /conda/dgl/README.md: -------------------------------------------------------------------------------- 1 | conda recipe 2 | === 3 | 4 | Build the package with `conda build .` 5 | -------------------------------------------------------------------------------- /conda/dgl/bld.bat: -------------------------------------------------------------------------------- 1 | REM Needs vcvars64.bat to be called 2 | git submodule init 3 | git submodule update --recursive 4 | md build 5 | cd build 6 | COPY %TEMP%\dgl.dll . 7 | cd ..\python 8 | "%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt || EXIT /B 1 9 | EXIT /B 10 | -------------------------------------------------------------------------------- /conda/dgl/build.sh: -------------------------------------------------------------------------------- 1 | git submodule init 2 | git submodule update --recursive 3 | mkdir build 4 | cd build 5 | cmake -DUSE_CUDA=$USE_CUDA -DUSE_OPENMP=ON -DCUDA_ARCH_NAME=All .. 6 | make 7 | cd ../python 8 | $PYTHON setup.py install --single-version-externally-managed --record=record.txt 9 | -------------------------------------------------------------------------------- /conda/dgl/conda_build_config.yaml: -------------------------------------------------------------------------------- 1 | python: 2 | - 3.6 3 | - 3.7 4 | - 3.8 5 | - 3.9 6 | - 3.10 7 | -------------------------------------------------------------------------------- /conda/dgl/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: dgl{{ environ.get('DGL_PACKAGE_SUFFIX', '') }} 3 | version: 1.2{{ environ.get('DGL_VERSION_SUFFIX', '') }} 4 | 5 | source: 6 | git_rev: {{ environ.get('DGL_RELEASE_BRANCH', 'master') }} 7 | git_url: https://github.com/dmlc/dgl.git 8 | 9 | requirements: 10 | build: 11 | - python {{ python }} 12 | - setuptools 13 | - cmake 14 | - git 15 | - cython 16 | run: 17 | - python 18 | - numpy 19 | - scipy 20 | - networkx 21 | - requests 22 | - tqdm 23 | - psutil 24 | 25 | build: 26 | script_env: 27 | - USE_CUDA 28 | - CUDA_VER 29 | - CACHEDIR 30 | - DGL_VERSION_SUFFIX 31 | 32 | about: 33 | home: https://github.com/dmlc/dgl.git 34 | license_file: {{ environ.get('SRC_DIR') }}/LICENSE 35 | license: Apache 36 | -------------------------------------------------------------------------------- /conda/dgl/run_test.bat: -------------------------------------------------------------------------------- 1 | set DGLBACKEND=numpy 2 | %PYTHON% -c "import dgl" 3 | -------------------------------------------------------------------------------- /conda/dgl/run_test.sh: -------------------------------------------------------------------------------- 1 | DGLBACKEND=numpy $PYTHON -c 'import dgl' 2 | -------------------------------------------------------------------------------- /dgl_sparse/find_cmake.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import torch 4 | 5 | cmake_prefix_path = getattr( 6 | torch.utils, 7 | "cmake_prefix_path", 8 | os.path.join(os.path.dirname(torch.__file__), "share", "cmake"), 9 | ) 10 | version = torch.__version__.split("+")[0] 11 | print(";".join([cmake_prefix_path, version])) 12 | -------------------------------------------------------------------------------- /dgl_sparse/include/sparse/matrix_ops.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023 by Contributors 3 | * @file sparse/matrix_ops.h 4 | * @brief DGL C++ sparse matrix operators. 5 | */ 6 | #ifndef SPARSE_MATRIX_OPS_H_ 7 | #define SPARSE_MATRIX_OPS_H_ 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace dgl { 14 | namespace sparse { 15 | 16 | /** 17 | * @brief Compute the intersection of two COO matrices. Return the intersection 18 | * matrix, and the indices of the intersection in the left-hand-side and 19 | * right-hand-side matrices. 20 | * 21 | * @param lhs The left-hand-side COO matrix. 22 | * @param rhs The right-hand-side COO matrix. 23 | * 24 | * @return A tuple of COO matrix, lhs indices, and rhs indices. 25 | */ 26 | std::tuple, torch::Tensor, torch::Tensor> COOIntersection( 27 | const std::shared_ptr& lhs, const std::shared_ptr& rhs); 28 | 29 | } // namespace sparse 30 | } // namespace dgl 31 | 32 | #endif // SPARSE_MATRIX_OPS_H_ 33 | -------------------------------------------------------------------------------- /dgl_sparse/include/sparse/softmax.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 by Contributors 3 | * @file sparse/softmax.h 4 | * @brief DGL C++ Softmax operator 5 | */ 6 | #ifndef SPARSE_SOFTMAX_H_ 7 | #define SPARSE_SOFTMAX_H_ 8 | 9 | #include 10 | 11 | namespace dgl { 12 | namespace sparse { 13 | 14 | /** 15 | * @brief Apply softmax to the non-zero entries of the sparse matrix on the 16 | * dimension dim. dim = 0 or 1 indicates column-wise or row-wise softmax 17 | * respectively. 18 | * 19 | * This function supports autograd for the sparse matrix, but it does not 20 | * support higher order gradient. 21 | * 22 | * @param sparse_mat The sparse matrix 23 | * @param dim The dimension to apply softmax 24 | * 25 | * @return Sparse matrix 26 | */ 27 | c10::intrusive_ptr Softmax( 28 | const c10::intrusive_ptr& sparse_mat, int64_t dim); 29 | 30 | } // namespace sparse 31 | } // namespace dgl 32 | 33 | #endif // SPARSE_SOFTMAX_H_ 34 | -------------------------------------------------------------------------------- /dglgo/dglgo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/dglgo/dglgo.png -------------------------------------------------------------------------------- /dglgo/dglgo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/dglgo/dglgo/__init__.py -------------------------------------------------------------------------------- /dglgo/dglgo/apply_pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | from .graphpred import ApplyGraphpredPipeline 2 | from .nodepred import ApplyNodepredPipeline 3 | from .nodepred_sample import ApplyNodepredNsPipeline 4 | -------------------------------------------------------------------------------- /dglgo/dglgo/apply_pipeline/graphpred/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/apply_pipeline/nodepred/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/apply_pipeline/nodepred_sample/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/__init__.py: -------------------------------------------------------------------------------- 1 | from .cli import app 2 | 3 | if __name__ == "__main__": 4 | app() 5 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/apply_cli.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import autopep8 4 | import isort 5 | import typer 6 | import yaml 7 | 8 | from ..utils.factory import ApplyPipelineFactory 9 | 10 | 11 | def apply(cfg: str = typer.Option(..., help="config yaml file name")): 12 | user_cfg = yaml.safe_load(Path(cfg).open("r")) 13 | pipeline_name = user_cfg["pipeline_name"] 14 | output_file_content = ApplyPipelineFactory.registry[ 15 | pipeline_name 16 | ].gen_script(user_cfg) 17 | 18 | f_code = autopep8.fix_code(output_file_content, options={"aggressive": 1}) 19 | f_code = isort.code(f_code) 20 | code = compile(f_code, "dglgo_tmp.py", "exec") 21 | exec(code, {"__name__": "__main__"}) 22 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/cli.py: -------------------------------------------------------------------------------- 1 | import typer 2 | from ..pipeline import * 3 | from ..model import * 4 | from .apply_cli import apply 5 | from .config_apply_cli import config_apply_app 6 | from .config_cli import config_app 7 | from .export_cli import export 8 | from .recipe_cli import recipe_app 9 | from .train_cli import train 10 | 11 | no_args_is_help = False 12 | app = typer.Typer(no_args_is_help=True, add_completion=False) 13 | app.add_typer(config_app, name="configure", no_args_is_help=no_args_is_help) 14 | app.add_typer(recipe_app, name="recipe", no_args_is_help=True) 15 | app.command(help="Launch training", no_args_is_help=no_args_is_help)(train) 16 | app.command( 17 | help="Export a runnable python script", no_args_is_help=no_args_is_help 18 | )(export) 19 | app.add_typer( 20 | config_apply_app, name="configure-apply", no_args_is_help=no_args_is_help 21 | ) 22 | app.command(help="Launch inference", no_args_is_help=no_args_is_help)(apply) 23 | 24 | 25 | def main(): 26 | app() 27 | 28 | 29 | if __name__ == "__main__": 30 | app() 31 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/config_apply_cli.py: -------------------------------------------------------------------------------- 1 | from ..apply_pipeline import * 2 | import typer 3 | 4 | from ..utils.factory import ApplyPipelineFactory 5 | 6 | config_apply_app = typer.Typer( 7 | help="Generate a configuration file for inference" 8 | ) 9 | for key, pipeline in ApplyPipelineFactory.registry.items(): 10 | config_apply_app.command(key, help=pipeline.get_description())( 11 | pipeline.get_cfg_func() 12 | ) 13 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/config_cli.py: -------------------------------------------------------------------------------- 1 | from ..pipeline import * 2 | import typing 3 | from enum import Enum 4 | from pathlib import Path 5 | 6 | import typer 7 | import yaml 8 | 9 | from ..utils.factory import ModelFactory, PipelineFactory 10 | 11 | config_app = typer.Typer(help="Generate a configuration file") 12 | for key, pipeline in PipelineFactory.registry.items(): 13 | config_app.command(key, help=pipeline.get_description())( 14 | pipeline.get_cfg_func() 15 | ) 16 | 17 | if __name__ == "__main__": 18 | config_app() 19 | -------------------------------------------------------------------------------- /dglgo/dglgo/cli/train_cli.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from enum import Enum 3 | from pathlib import Path 4 | 5 | import autopep8 6 | import isort 7 | import typer 8 | import yaml 9 | 10 | from ..utils.factory import ModelFactory, PipelineFactory 11 | 12 | 13 | def train( 14 | cfg: str = typer.Option("cfg.yaml", help="config yaml file name"), 15 | ): 16 | user_cfg = yaml.safe_load(Path(cfg).open("r")) 17 | pipeline_name = user_cfg["pipeline_name"] 18 | output_file_content = PipelineFactory.registry[pipeline_name].gen_script( 19 | user_cfg 20 | ) 21 | 22 | f_code = autopep8.fix_code(output_file_content, options={"aggressive": 1}) 23 | f_code = isort.code(f_code) 24 | code = compile(f_code, "dglgo_tmp.py", "exec") 25 | exec(code, {"__name__": "__main__"}) 26 | 27 | 28 | if __name__ == "__main__": 29 | train_app = typer.Typer() 30 | train_app.command()(train) 31 | train_app() 32 | -------------------------------------------------------------------------------- /dglgo/dglgo/model/__init__.py: -------------------------------------------------------------------------------- 1 | from .node_encoder import * 2 | from .edge_encoder import * 3 | from .graph_encoder import * 4 | -------------------------------------------------------------------------------- /dglgo/dglgo/model/edge_encoder/__init__.py: -------------------------------------------------------------------------------- 1 | from ...utils.factory import EdgeModelFactory 2 | from .bilinear import BilinearPredictor 3 | from .ele import ElementWiseProductPredictor 4 | 5 | EdgeModelFactory.register("ele")(ElementWiseProductPredictor) 6 | EdgeModelFactory.register("bilinear")(BilinearPredictor) 7 | -------------------------------------------------------------------------------- /dglgo/dglgo/model/edge_encoder/dot.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | 5 | 6 | class DotPredictor(nn.Module): 7 | def __init__( 8 | self, 9 | in_size: int = -1, 10 | out_size: int = 1, 11 | hidden_size: int = 256, 12 | num_layers: int = 3, 13 | bias: bool = False, 14 | ): 15 | super(DotPredictor, self).__init__() 16 | lins_list = [] 17 | for _ in range(num_layers - 2): 18 | lins_list.append(nn.Linear(in_size, hidden_size, bias=bias)) 19 | lins_list.append(nn.ReLU()) 20 | lins_list.append(nn.Linear(hidden_size, out_size, bias=bias)) 21 | self.linear = nn.Sequential(*lins_list) 22 | 23 | def forward(self, h_src, h_dst): 24 | h = h_src * h_dst 25 | h = self.linear(h) 26 | h = torch.sigmoid(h) 27 | return h 28 | -------------------------------------------------------------------------------- /dglgo/dglgo/model/graph_encoder/__init__.py: -------------------------------------------------------------------------------- 1 | from ...utils.factory import GraphModelFactory 2 | from .gin_ogbg import OGBGGIN 3 | from .pna import PNA 4 | 5 | GraphModelFactory.register("gin")(OGBGGIN) 6 | GraphModelFactory.register("pna")(PNA) 7 | -------------------------------------------------------------------------------- /dglgo/dglgo/model/node_encoder/__init__.py: -------------------------------------------------------------------------------- 1 | from ...utils.factory import NodeModelFactory 2 | from .gat import GAT 3 | from .gcn import GCN 4 | from .gin import GIN 5 | from .sage import GraphSAGE 6 | from .sgc import SGC 7 | 8 | NodeModelFactory.register("gcn")(GCN) 9 | NodeModelFactory.register("gat")(GAT) 10 | NodeModelFactory.register("sage")(GraphSAGE) 11 | NodeModelFactory.register("sgc")(SGC) 12 | NodeModelFactory.register("gin")(GIN) 13 | -------------------------------------------------------------------------------- /dglgo/dglgo/pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | from .graphpred import GraphpredPipeline 2 | from .linkpred import LinkpredPipeline 3 | from .nodepred import NodepredPipeline 4 | from .nodepred_sample import NodepredNsPipeline 5 | -------------------------------------------------------------------------------- /dglgo/dglgo/pipeline/graphpred/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/pipeline/linkpred/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/pipeline/nodepred/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/pipeline/nodepred_sample/__init__.py: -------------------------------------------------------------------------------- 1 | from .gen import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .factory import * 2 | -------------------------------------------------------------------------------- /dglgo/dglgo/utils/enter_config.py: -------------------------------------------------------------------------------- 1 | import copy 2 | from enum import Enum, IntEnum 3 | from typing import Optional 4 | 5 | import jinja2 6 | import yaml 7 | from jinja2 import Template 8 | from pydantic import BaseModel as PydanticBaseModel, create_model, Field 9 | 10 | from .base_model import DGLBaseModel 11 | 12 | # from ..pipeline import nodepred, nodepred_sample 13 | from .factory import DataFactory, ModelFactory, PipelineFactory 14 | 15 | 16 | class PipelineConfig(DGLBaseModel): 17 | node_embed_size: Optional[int] = -1 18 | early_stop: Optional[dict] 19 | num_epochs: int = 200 20 | eval_period: int = 5 21 | optimizer: dict = {"name": "Adam", "lr": 0.005} 22 | loss: str = "CrossEntropyLoss" 23 | 24 | 25 | class UserConfig(DGLBaseModel): 26 | version: Optional[str] = "0.0.2" 27 | pipeline_name: PipelineFactory.get_pipeline_enum() 28 | pipeline_mode: str 29 | device: str = "cpu" 30 | -------------------------------------------------------------------------------- /dglgo/dglgo/utils/optimizer_config.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/dglgo/dglgo/utils/optimizer_config.py -------------------------------------------------------------------------------- /dglgo/dglgo/utils/yaml_dump.py: -------------------------------------------------------------------------------- 1 | from ruamel.yaml.comments import CommentedMap 2 | 3 | 4 | def deep_convert_dict(layer): 5 | to_ret = layer 6 | if isinstance(layer, dict): 7 | to_ret = CommentedMap(layer) 8 | try: 9 | for key, value in to_ret.items(): 10 | to_ret[key] = deep_convert_dict(value) 11 | except AttributeError: 12 | pass 13 | 14 | return to_ret 15 | 16 | 17 | import collections.abc 18 | 19 | 20 | def merge_comment(d, comment_dict, column=30): 21 | for k, v in comment_dict.items(): 22 | if isinstance(v, collections.abc.Mapping): 23 | d[k] = merge_comment(d.get(k, CommentedMap()), v) 24 | else: 25 | d.yaml_add_eol_comment(v, key=k, column=column) 26 | return d 27 | -------------------------------------------------------------------------------- /dglgo/recipes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/dglgo/recipes/__init__.py -------------------------------------------------------------------------------- /dglgo/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup 4 | 5 | from setuptools import find_packages 6 | 7 | setup( 8 | name="dglgo", 9 | version="0.0.2", 10 | description="DGL", 11 | author="DGL Team", 12 | author_email="wmjlyjemaine@gmail.com", 13 | packages=find_packages(), 14 | install_requires=[ 15 | "typer>=0.4.0", 16 | "isort>=5.10.1", 17 | "autopep8>=1.6.0", 18 | "numpydoc>=1.1.0", 19 | "pydantic>=1.9.0", 20 | "ruamel.yaml>=0.17.20", 21 | "PyYAML>=5.1", 22 | "ogb>=1.3.3", 23 | "rdkit-pypi", 24 | "scikit-learn>=0.20.0", 25 | ], 26 | package_data={"": ["./*"]}, 27 | include_package_data=True, 28 | license="APACHE", 29 | entry_points={"console_scripts": ["dgl = dglgo.cli.cli:main"]}, 30 | url="https://github.com/dmlc/dgl", 31 | ) 32 | -------------------------------------------------------------------------------- /dglgo/tests/run_test.sh: -------------------------------------------------------------------------------- 1 | python -m pytest --pdb -vv --capture=tee-sys test_pipeline.py::test_recipe -------------------------------------------------------------------------------- /docker/Dockerfile.awscli: -------------------------------------------------------------------------------- 1 | # Using the Ubuntu image (our OS) 2 | FROM ubuntu:latest 3 | # Update package manager (apt-get) 4 | # and install (with the yes flag `-y`) 5 | # Python and Pip 6 | RUN apt-get update && apt-get install -y \ 7 | python3.8 \ 8 | python3-pip 9 | 10 | RUN apt-get install -y \ 11 | unzip \ 12 | curl \ 13 | && apt-get clean \ 14 | && curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ 15 | && unzip awscliv2.zip \ 16 | && ./aws/install \ 17 | && rm -rf \ 18 | awscliv2.zip 19 | 20 | RUN pip install pytest pytest-html requests 21 | -------------------------------------------------------------------------------- /docker/Dockerfile.ci_cpu_torch_1.2.0: -------------------------------------------------------------------------------- 1 | # CI docker CPU env 2 | # Adapted from github.com/dmlc/tvm/docker/Dockerfile.ci_cpu 3 | FROM ubuntu:16.04 4 | 5 | RUN apt-get update --fix-missing 6 | 7 | COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh 8 | RUN bash /install/ubuntu_install_core.sh 9 | 10 | COPY install/ubuntu_install_build.sh /install/ubuntu_install_build.sh 11 | RUN bash /install/ubuntu_install_build.sh 12 | 13 | # python 14 | COPY install/ubuntu_install_conda.sh /install/ubuntu_install_conda.sh 15 | RUN bash /install/ubuntu_install_conda.sh 16 | 17 | ENV CONDA_ALWAYS_YES="true" 18 | 19 | COPY install/conda_env/kg_cpu.yml /install/conda_env/kg_cpu.yml 20 | RUN ["/bin/bash", "-i", "-c", "conda env create -f /install/conda_env/kg_cpu.yml"] 21 | 22 | ENV CONDA_ALWAYS_YES= -------------------------------------------------------------------------------- /docker/Dockerfile.ci_lint: -------------------------------------------------------------------------------- 1 | # CI docker for lint 2 | # Adapted from github.com/dmlc/tvm/docker/Dockerfile.ci_lint 3 | 4 | FROM ubuntu:18.04 5 | 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | 8 | COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh 9 | RUN bash /install/ubuntu_install_core.sh 10 | 11 | COPY install/ubuntu_install_python.sh /install/ubuntu_install_python.sh 12 | RUN bash /install/ubuntu_install_python.sh 13 | 14 | RUN apt-get install -y doxygen graphviz 15 | 16 | RUN pip3 install cpplint==1.3.0 pylint==2.7.0 mypy 17 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | ## Build docker image for CI 2 | 3 | ### CPU image 4 | ```bash 5 | docker build -t dgl-cpu -f Dockerfile.ci_cpu . 6 | ``` 7 | 8 | ### GPU image 9 | ```bash 10 | docker build -t dgl-gpu -f Dockerfile.ci_gpu . 11 | ``` 12 | 13 | ### Lint image 14 | ```bash 15 | docker build -t dgl-lint -f Dockerfile.ci_lint . 16 | ``` 17 | 18 | ### CPU image for kg 19 | ```bash 20 | wget https://data.dgl.ai/dataset/FB15k.zip -P install/ 21 | docker build -t dgl-cpu:torch-1.2.0 -f Dockerfile.ci_cpu_torch_1.2.0 . 22 | ``` 23 | 24 | ### GPU image for kg 25 | ```bash 26 | wget https://data.dgl.ai/dataset/FB15k.zip -P install/ 27 | docker build -t dgl-gpu:torch-1.2.0 -f Dockerfile.ci_gpu_torch_1.2.0 . 28 | ``` 29 | -------------------------------------------------------------------------------- /docker/install/conda_env/kg_cpu.yml: -------------------------------------------------------------------------------- 1 | name: kg-ci 2 | dependencies: 3 | - python=3.6.9 4 | - pip 5 | - pip: 6 | - torch 7 | - torchvision 8 | - mxnet 9 | - pytest 10 | - nose 11 | - numpy 12 | - cython 13 | - scipy 14 | - networkx 15 | - matplotlib 16 | - nltk 17 | - requests[security] 18 | - tqdm -------------------------------------------------------------------------------- /docker/install/conda_env/kg_gpu.yml: -------------------------------------------------------------------------------- 1 | name: kg-ci 2 | dependencies: 3 | - python=3.6.9 4 | - pip 5 | - pip: 6 | - torch 7 | - torchvision 8 | - mxnet-cu101 9 | - pytest 10 | - nose 11 | - numpy 12 | - cython 13 | - scipy 14 | - networkx 15 | - matplotlib 16 | - nltk 17 | - requests[security] 18 | - tqdm -------------------------------------------------------------------------------- /docker/install/conda_env/mxnet_cpu.yml: -------------------------------------------------------------------------------- 1 | name: mxnet-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - mxnet==1.6.0 7 | - pytest 8 | - nose 9 | - numpy 10 | - cython 11 | - scipy 12 | - networkx 13 | - matplotlib 14 | - nltk 15 | - requests[security] 16 | - tqdm 17 | - psutil 18 | - pyyaml 19 | - pydantic 20 | - pandas 21 | - rdflib 22 | - ogb 23 | -------------------------------------------------------------------------------- /docker/install/conda_env/mxnet_gpu.yml: -------------------------------------------------------------------------------- 1 | name: mxnet-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - mxnet-cu101==1.7.0 7 | - pytest 8 | - nose 9 | - numpy 10 | - cython 11 | - scipy 12 | - networkx 13 | - matplotlib 14 | - nltk 15 | - requests[security] 16 | - tqdm 17 | - psutil 18 | - pyyaml 19 | - pydantic 20 | - pandas 21 | - rdflib 22 | - ogb 23 | -------------------------------------------------------------------------------- /docker/install/conda_env/tensorflow_cpu.yml: -------------------------------------------------------------------------------- 1 | name: tensorflow-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - tensorflow==2.3.0 7 | - pytest 8 | - nose 9 | - numpy 10 | - cython 11 | - scipy 12 | - networkx 13 | - matplotlib 14 | - nltk 15 | - requests[security] 16 | - tqdm 17 | - psutil 18 | - pyyaml 19 | - pydantic 20 | - pandas 21 | - rdflib 22 | - ogb 23 | -------------------------------------------------------------------------------- /docker/install/conda_env/tensorflow_gpu.yml: -------------------------------------------------------------------------------- 1 | name: tensorflow-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - tensorflow==2.3.0 7 | - pytest 8 | - nose 9 | - numpy 10 | - cython 11 | - scipy 12 | - networkx 13 | - matplotlib 14 | - nltk 15 | - requests[security] 16 | - tqdm 17 | - psutil 18 | - pyyaml 19 | - pydantic 20 | - pandas 21 | - rdflib 22 | - ogb 23 | -------------------------------------------------------------------------------- /docker/install/conda_env/torch_cpu.yml: -------------------------------------------------------------------------------- 1 | name: pytorch-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - --find-links https://download.pytorch.org/whl/torch_stable.html 7 | - --requirement torch_cpu_pip.txt -------------------------------------------------------------------------------- /docker/install/conda_env/torch_cpu_pip.txt: -------------------------------------------------------------------------------- 1 | --find-links https://download.pytorch.org/whl/torch_stable.html 2 | cython 3 | filelock 4 | matplotlib 5 | networkx 6 | nltk 7 | nose 8 | numpy 9 | ogb 10 | pandas 11 | psutil 12 | pyarrow 13 | pydantic 14 | pytest 15 | pyyaml 16 | rdflib 17 | requests[security] 18 | scikit-learn 19 | scipy 20 | torch==1.12.0+cpu 21 | torchmetrics 22 | tqdm 23 | -------------------------------------------------------------------------------- /docker/install/conda_env/torch_gpu.yml: -------------------------------------------------------------------------------- 1 | name: pytorch-ci 2 | dependencies: 3 | - python=3.7.0 4 | - pip 5 | - pip: 6 | - --find-links https://download.pytorch.org/whl/torch_stable.html 7 | - --requirement torch_gpu_pip.txt -------------------------------------------------------------------------------- /docker/install/conda_env/torch_gpu_pip.txt: -------------------------------------------------------------------------------- 1 | --find-links https://download.pytorch.org/whl/torch_stable.html 2 | cython 3 | matplotlib 4 | networkx 5 | nltk 6 | nose 7 | numpy 8 | ogb 9 | pandas 10 | psutil 11 | pydantic 12 | pytest 13 | pyyaml 14 | rdflib 15 | requests[security] 16 | scikit-learn 17 | scipy 18 | torch==1.12.0+cu102 19 | torchmetrics 20 | tqdm 21 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_antlr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -u 5 | set -o pipefail 6 | 7 | cd /usr/local/lib 8 | wget -q https://www.antlr.org/download/antlr-4.7.1-complete.jar 9 | cd - 10 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_build.sh: -------------------------------------------------------------------------------- 1 | # install cmake 3.15, cmake>=3.12 is required for CUDA 10.1 2 | version=3.15 3 | build=5 4 | mkdir ~/temp 5 | cd ~/temp 6 | wget https://cmake.org/files/v$version/cmake-$version.$build-Linux-x86_64.sh 7 | sudo mkdir /opt/cmake 8 | sudo sh cmake-$version.$build-Linux-x86_64.sh --prefix=/opt/cmake --skip-license 9 | sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake 10 | cd ~ 11 | rm -rf ~/temp -------------------------------------------------------------------------------- /docker/install/ubuntu_install_conda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export LANG=C.UTF-8 LC_ALL=C.UTF-8 3 | export PATH=/opt/conda/bin:$PATH 4 | 5 | apt-get update --fix-missing && \ 6 | apt-get install -y wget bzip2 ca-certificates curl git && \ 7 | apt-get clean && \ 8 | rm -rf /var/lib/apt/lists/* 9 | 10 | wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \ 11 | /bin/bash ~/miniconda.sh -b -p /opt/conda && \ 12 | rm ~/miniconda.sh && \ 13 | /opt/conda/bin/conda clean -tipy && \ 14 | ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ 15 | echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ 16 | echo "conda activate base" >> ~/.bashrc 17 | 18 | export TINI_VERSION=v0.16.1 19 | source ~/.bashrc 20 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_core.sh: -------------------------------------------------------------------------------- 1 | # install libraries for building c++ core on ubuntu 2 | apt update && apt install -y --no-install-recommends --force-yes \ 3 | apt-utils git build-essential make wget unzip sudo \ 4 | libz-dev libxml2-dev libopenblas-dev libopencv-dev \ 5 | graphviz graphviz-dev libgraphviz-dev ca-certificates \ 6 | systemd vim openssh-client openssh-server 7 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_java.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit -o nounset 4 | set -o pipefail 5 | 6 | apt-get update && apt-get install -y openjdk-8-jdk maven 7 | test -d "/usr/lib/jvm/java-8-openjdk-amd64/jre" 8 | echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre" >> /etc/profile 9 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_mxnet_cpu.sh: -------------------------------------------------------------------------------- 1 | pip3 install mxnet 2 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_mxnet_gpu.sh: -------------------------------------------------------------------------------- 1 | pip3 install mxnet-cu90 2 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_python.sh: -------------------------------------------------------------------------------- 1 | # install python and pip, don't modify this, modify install_python_package.sh 2 | apt-get update 3 | apt-get install -y python-dev python3-dev 4 | 5 | # install pip 6 | cd /tmp && wget https://bootstrap.pypa.io/get-pip.py 7 | python2 get-pip.py 8 | python3 get-pip.py 9 | 10 | # santiy check 11 | python2 --version 12 | python3 --version 13 | pip2 --version 14 | pip3 --version 15 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_python_package.sh: -------------------------------------------------------------------------------- 1 | # install libraries for python package on ubuntu 2 | #pip2 install nose numpy cython scipy networkx matplotlib nltk requests[security] tqdm 3 | pip3 install nose numpy cython scipy networkx matplotlib nltk requests[security] tqdm 4 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_torch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # install torch 3 | pip2 install torch==1.0.1 torchvision==0.2.2 4 | pip3 install torch==1.0.1 torchvision==0.2.2 5 | -------------------------------------------------------------------------------- /docker/install/ubuntu_install_torch_1.2.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # install torch 3 | pip3 install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html 4 | -------------------------------------------------------------------------------- /docker/pods/ci-compile-cpu.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | securityContext: 5 | runAsUser: 0 6 | containers: 7 | - name: dgl-ci-cpu-compile 8 | image: dgllib/dgl-ci-cpu:cu101_v220123 9 | imagePullPolicy: Always 10 | tty: true 11 | resources: 12 | requests: 13 | cpu: 16 14 | # affinity: 15 | # nodeAffinity: 16 | # requiredDuringSchedulingIgnoredDuringExecution: 17 | # nodeSelectorTerms: 18 | # - matchExpressions: 19 | # - key: beta.kubernetes.io/instance-type 20 | # operator: In 21 | # values: 22 | # - c5.9xlarge -------------------------------------------------------------------------------- /docker/pods/ci-compile-gpu.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | securityContext: 5 | runAsUser: 0 6 | containers: 7 | - name: dgl-ci-gpu-compile 8 | image: dgllib/dgl-ci-gpu:cu101_v220123 9 | imagePullPolicy: Always 10 | tty: true 11 | resources: 12 | requests: 13 | cpu: 32 14 | # affinity: 15 | # nodeAffinity: 16 | # requiredDuringSchedulingIgnoredDuringExecution: 17 | # nodeSelectorTerms: 18 | # - matchExpressions: 19 | # - key: beta.kubernetes.io/instance-type 20 | # operator: In 21 | # values: 22 | # - c5.9xlarge -------------------------------------------------------------------------------- /docker/pods/ci-cpu.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | securityContext: 5 | runAsUser: 0 6 | containers: 7 | - name: dgl-ci-cpu 8 | image: dgllib/dgl-ci-cpu:cu101_v220217 9 | imagePullPolicy: Always 10 | tty: true 11 | resources: 12 | requests: 13 | cpu: 16 14 | volumeMounts: 15 | # - name: persistent-storage 16 | # mountPath: /tmp/dataset 17 | - name: dshm 18 | mountPath: /dev/shm 19 | volumes: 20 | # - name: persistent-storage 21 | # persistentVolumeClaim: 22 | # claimName: ogb-efs-claim 23 | - name: dshm 24 | emptyDir: 25 | medium: Memory 26 | -------------------------------------------------------------------------------- /docker/pods/ci-gpu.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | securityContext: 5 | runAsUser: 0 6 | containers: 7 | - name: dgl-ci-gpu 8 | image: dgllib/dgl-ci-gpu:cu101_v220217 9 | imagePullPolicy: Always 10 | tty: true 11 | resources: 12 | limits: 13 | nvidia.com/gpu: 1 # requesting 1 GPU 14 | volumeMounts: 15 | - name: dshm 16 | mountPath: /dev/shm 17 | volumes: 18 | - name: dshm 19 | emptyDir: 20 | medium: Memory 21 | affinity: 22 | nodeAffinity: 23 | requiredDuringSchedulingIgnoredDuringExecution: 24 | nodeSelectorTerms: 25 | - matchExpressions: 26 | - key: beta.kubernetes.io/instance-type 27 | operator: In 28 | values: 29 | - g4dn.2xlarge -------------------------------------------------------------------------------- /docker/pods/ci-lint.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | securityContext: 5 | runAsUser: 0 6 | containers: 7 | - name: dgl-ci-lint 8 | image: dgllib/dgl-ci-lint 9 | imagePullPolicy: Always 10 | tty: true 11 | resources: 12 | requests: 13 | cpu: 1 14 | serviceAccountName: dglciuser -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | # tutorials are auto-generated 4 | source/tutorials 5 | source/new-tutorial 6 | source/generated 7 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | DGL document and tutorial folder 2 | ================================ 3 | 4 | 5 | To build the doc: 6 | 7 | - Create the developer conda environment using the script [here](../script/create_dev_conda_env.sh). 8 | - Activate the developer conda environment. 9 | - Build DGL from source using the script [here](../script/build_dgl.sh). 10 | - Build the doc using the script [here](../script/build_doc.sh). 11 | 12 | To render locally: 13 | ``` 14 | cd build/html 15 | python3 -m http.server 8000 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make clean 4 | rm -rf build 5 | rm -rf source/tutorials 6 | rm -rf source/generated 7 | -------------------------------------------------------------------------------- /docs/source/_static/blitz_1_introduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_1_introduction.png -------------------------------------------------------------------------------- /docs/source/_static/blitz_2_dglgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_2_dglgraph.png -------------------------------------------------------------------------------- /docs/source/_static/blitz_3_message_passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_3_message_passing.png -------------------------------------------------------------------------------- /docs/source/_static/blitz_4_link_predict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_4_link_predict.png -------------------------------------------------------------------------------- /docs/source/_static/blitz_5_graph_classification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_5_graph_classification.png -------------------------------------------------------------------------------- /docs/source/_static/blitz_6_load_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/blitz_6_load_data.png -------------------------------------------------------------------------------- /docs/source/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | .wy-table-responsive table td, 2 | .wy-table-responsive table th { 3 | white-space: normal; 4 | } 5 | 6 | .wy-table-bordered-all, 7 | .rst-content table.docutils { 8 | border: none; 9 | } 10 | 11 | .wy-table-bordered-all td, 12 | .rst-content table.docutils td { 13 | border: none; 14 | } 15 | 16 | .wy-table td, 17 | .rst-content table.docutils td, 18 | .rst-content table.field-list td, 19 | .wy-table th, 20 | .rst-content table.docutils th, 21 | .rst-content table.field-list th { 22 | padding: 14px; 23 | } -------------------------------------------------------------------------------- /docs/source/_static/large_L0_neighbor_sampling_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/docs/source/_static/large_L0_neighbor_sampling_overview.png -------------------------------------------------------------------------------- /docs/source/_templates/classtemplate.rst: -------------------------------------------------------------------------------- 1 | .. role:: hidden 2 | :class: hidden-section 3 | .. currentmodule:: {{ module }} 4 | 5 | 6 | {{ name | underline}} 7 | 8 | .. autoclass:: {{ name }} 9 | :show-inheritance: 10 | :members: __getitem__, __len__, collate_fn, forward, reset_parameters, rel_emb, rel_project, explain_node, explain_graph, train_step 11 | -------------------------------------------------------------------------------- /docs/source/api/python/dgl.geometry.rst: -------------------------------------------------------------------------------- 1 | .. _api-geometry: 2 | 3 | dgl.geometry 4 | ================================= 5 | 6 | .. automodule:: dgl.geometry 7 | 8 | .. _api-geometry-farthest-point-sampler: 9 | 10 | Farthest Point Sampler 11 | ----------- 12 | 13 | Farthest point sampling is a greedy algorithm that samples from a point cloud 14 | data iteratively. It starts from a random single sample of point. In each iteration, 15 | it samples from the rest points that is the farthest from the set of sampled points. 16 | 17 | .. autoclass:: farthest_point_sampler 18 | 19 | .. _api-geometry-neighbor-matching: 20 | 21 | Neighbor Matching 22 | ----------------------------- 23 | 24 | Neighbor matching is an important module in the Graclus clustering algorithm. 25 | 26 | .. autoclass:: neighbor_matching 27 | -------------------------------------------------------------------------------- /docs/source/api/python/dgl.multiprocessing.rst: -------------------------------------------------------------------------------- 1 | .. _apimultiprocessing: 2 | 3 | dgl.multiprocessing 4 | =================== 5 | 6 | This is a minimal wrapper of Python's native :mod:`multiprocessing` module. 7 | It modifies the :class:`multiprocessing.Process` class to make forking 8 | work with OpenMP in the DGL core library. 9 | 10 | The API usage is exactly the same as the native module, so DGL does not provide 11 | additional documentation. 12 | 13 | In addition, if your backend is PyTorch, this module will also be compatible with 14 | :mod:`torch.multiprocessing` module. 15 | 16 | .. currentmodule:: dgl.multiprocessing.pytorch 17 | .. autosummary:: 18 | :toctree: ../../generated/ 19 | 20 | call_once_and_share 21 | shared_tensor 22 | -------------------------------------------------------------------------------- /docs/source/api/python/dgl.optim.rst: -------------------------------------------------------------------------------- 1 | .. _apioptim: 2 | 3 | dgl.optim 4 | ========= 5 | 6 | .. automodule:: dgl.optim 7 | 8 | Node embedding optimizer 9 | ------------------------- 10 | .. currentmodule:: dgl.optim.pytorch 11 | 12 | .. autoclass:: SparseAdagrad 13 | .. autoclass:: SparseAdam -------------------------------------------------------------------------------- /docs/source/api/python/dgl.sampling.rst: -------------------------------------------------------------------------------- 1 | .. _api-sampling: 2 | 3 | dgl.sampling 4 | ================================= 5 | 6 | .. automodule:: dgl.sampling 7 | 8 | Random walk 9 | ------------------------------ 10 | 11 | .. autosummary:: 12 | :toctree: ../../generated/ 13 | 14 | random_walk 15 | node2vec_random_walk 16 | pack_traces 17 | 18 | Neighbor sampling 19 | --------------------------- 20 | 21 | .. autosummary:: 22 | :toctree: ../../generated/ 23 | 24 | sample_neighbors 25 | sample_labors 26 | sample_neighbors_biased 27 | select_topk 28 | PinSAGESampler 29 | 30 | Negative sampling 31 | ----------------- 32 | 33 | .. autosummary:: 34 | :toctree: ../../generated/ 35 | 36 | global_uniform_negative_sampling 37 | -------------------------------------------------------------------------------- /docs/source/api/python/index.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | dgl 8 | dgl.data 9 | dgl.dataloading 10 | dgl.DGLGraph 11 | dgl.distributed 12 | dgl.function 13 | nn-pytorch 14 | nn-tensorflow 15 | nn-mxnet 16 | dgl.ops 17 | dgl.sampling 18 | udf 19 | transforms 20 | -------------------------------------------------------------------------------- /docs/source/api/python/nn.functional.rst: -------------------------------------------------------------------------------- 1 | .. _apinn-functional: 2 | 3 | dgl.nn.functional 4 | ================= 5 | 6 | .. automodule:: dgl.nn.functional 7 | 8 | .. autosummary:: 9 | :toctree: ../../generated/ 10 | 11 | edge_softmax 12 | -------------------------------------------------------------------------------- /docs/source/api/python/transforms.rst: -------------------------------------------------------------------------------- 1 | .. _apitransform-namespace: 2 | 3 | dgl.transforms 4 | ============== 5 | 6 | .. currentmodule:: dgl.transforms 7 | .. automodule:: dgl.transforms 8 | 9 | .. autosummary:: 10 | :toctree: ../../generated/ 11 | :nosignatures: 12 | :template: classtemplate.rst 13 | 14 | BaseTransform 15 | Compose 16 | AddSelfLoop 17 | RemoveSelfLoop 18 | AddReverse 19 | ToSimple 20 | LineGraph 21 | KHopGraph 22 | AddMetaPaths 23 | GCNNorm 24 | PPR 25 | HeatKernel 26 | GDC 27 | NodeShuffle 28 | DropNode 29 | DropEdge 30 | AddEdge 31 | RandomWalkPE 32 | LapPE 33 | FeatMask 34 | RowFeatNormalizer 35 | SIGNDiffusion 36 | ToLevi 37 | SVDPE 38 | -------------------------------------------------------------------------------- /docs/source/faq.rst: -------------------------------------------------------------------------------- 1 | Frequently Asked Questions (FAQ) 2 | ================================ 3 | 4 | For frequently asked questions, refer to `this post `__. 5 | -------------------------------------------------------------------------------- /docs/source/guide/index.rst: -------------------------------------------------------------------------------- 1 | User Guide 2 | ========== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :titlesonly: 7 | 8 | graph 9 | message 10 | nn 11 | data 12 | training 13 | minibatch 14 | distributed 15 | mixed_precision 16 | -------------------------------------------------------------------------------- /docs/source/guide/message-part.rst: -------------------------------------------------------------------------------- 1 | .. _guide-message-passing-part: 2 | 3 | 2.3 Apply Message Passing On Part Of The Graph 4 | ---------------------------------------------- 5 | 6 | :ref:`(中文版) ` 7 | 8 | If one only wants to update part of the nodes in the graph, the practice 9 | is to create a subgraph by providing the IDs for the nodes to 10 | include in the update, then call :meth:`~dgl.DGLGraph.update_all` on the 11 | subgraph. For example: 12 | 13 | .. code:: 14 | 15 | nid = [0, 2, 3, 6, 7, 9] 16 | sg = g.subgraph(nid) 17 | sg.update_all(message_func, reduce_func, apply_node_func) 18 | 19 | This is a common usage in mini-batch training. Check :ref:`guide-minibatch` for more detailed 20 | usages. -------------------------------------------------------------------------------- /docs/source/guide_cn/data.rst: -------------------------------------------------------------------------------- 1 | .. _guide_cn-data-pipeline: 2 | 3 | 第4章:图数据处理管道 4 | ============================== 5 | 6 | :ref:`(English Version) ` 7 | 8 | DGL在 :ref:`apidata` 里实现了很多常用的图数据集。它们遵循了由 :class:`dgl.data.DGLDataset` 类定义的标准的数据处理管道。 9 | DGL推荐用户将图数据处理为 :class:`dgl.data.DGLDataset` 的子类。该类为导入、处理和保存图数据提供了简单而干净的解决方案。 10 | 11 | 本章路线图 12 | ----------- 13 | 14 | 本章介绍了如何为用户自己的图数据创建一个DGL数据集。以下内容说明了管道的工作方式,并展示了如何实现管道的每个组件。 15 | 16 | * :ref:`guide_cn-data-pipeline-dataset` 17 | * :ref:`guide_cn-data-pipeline-download` 18 | * :ref:`guide_cn-data-pipeline-process` 19 | * :ref:`guide_cn-data-pipeline-savenload` 20 | * :ref:`guide_cn-data-pipeline-loadogb` 21 | 22 | .. toctree:: 23 | :maxdepth: 1 24 | :hidden: 25 | :glob: 26 | 27 | data-dataset 28 | data-download 29 | data-process 30 | data-savenload 31 | data-loadogb -------------------------------------------------------------------------------- /docs/source/guide_cn/graph-basic.rst: -------------------------------------------------------------------------------- 1 | .. _guide_cn-graph-basic: 2 | 3 | 1.1 关于图的基本概念 4 | ----------------- 5 | 6 | :ref:`(English Version) ` 7 | 8 | 图是用以表示实体及其关系的结构,记为 :math:`G=(V, E)` 。图由两个集合组成,一是节点的集合 :math:`V` ,一个是边的集合 :math:`E` 。 9 | 在边集 :math:`E` 中,一条边 :math:`(u, v)` 连接一对节点 :math:`u` 和 :math:`v` ,表明两节点间存在关系。关系可以是无向的, 10 | 如描述节点之间的对称关系;也可以是有向的,如描述非对称关系。例如,若用图对社交网络中人们的友谊关系进行建模,因为友谊是相互的,则边是无向的; 11 | 若用图对Twitter用户的关注行为进行建模,则边是有向的。图可以是 *有向的* 或 *无向的* ,这取决于图中边的方向性。 12 | 13 | 图可以是 *加权的* 或 *未加权的* 。在加权图中,每条边都与一个标量权重值相关联。例如,该权重可以表示长度或连接的强度。 14 | 15 | 图可以是 *同构的* 或是 *异构的* 。在同构图中,所有节点表示同一类型的实体,所有边表示同一类型的关系。 16 | 例如,社交网络的图由表示同一实体类型的人及其相互之间的社交关系组成。 17 | 18 | 相对地,在异构图中,节点和边的类型可以是不同的。例如,编码市场的图可以有表示"顾客"、"商家"和"商品"的节点, 19 | 它们通过“想购买”、“已经购买”、“是顾客”和“正在销售”的边互相连接。二分图是一类特殊的、常用的异构图, 20 | 其中的边连接两类不同类型的节点。例如,在推荐系统中,可以使用二分图表示"用户"和"物品"之间的关系。想了解更多信息,读者可参考 :ref:`guide_cn-graph-heterogeneous`。 21 | 22 | 在多重图中,同一对节点之间可以有多条(有向)边,包括自循环的边。例如,两名作者可以在不同年份共同署名文章, 23 | 这就带来了具有不同特征的多条边。 24 | -------------------------------------------------------------------------------- /docs/source/guide_cn/graph.rst: -------------------------------------------------------------------------------- 1 | .. _guide_cn-graph: 2 | 3 | 第1章:图 4 | ============= 5 | 6 | :ref:`(English Version)` 7 | 8 | 图表示实体(节点)和它们的关系(边),其中节点和边可以是有类型的 (例如,``"用户"`` 和 ``"物品"`` 是两种不同类型的节点)。 9 | DGL通过其核心数据结构 :class:`~dgl.DGLGraph` 提供了一个以图为中心的编程抽象。 :class:`~dgl.DGLGraph` 提供了接口以处理图的结构、节点/边 10 | 的特征,以及使用这些组件可以执行的计算。 11 | 12 | 13 | 本章路线图 14 | -------------- 15 | 16 | 本章首先简要介绍了图的定义(见1.1节),然后介绍了一些 :class:`~dgl.DGLGraph` 相关的核心概念: 17 | 18 | * :ref:`guide_cn-graph-basic` 19 | * :ref:`guide_cn-graph-graphs-nodes-edges` 20 | * :ref:`guide_cn-graph-feature` 21 | * :ref:`guide_cn-graph-external` 22 | * :ref:`guide_cn-graph-heterogeneous` 23 | * :ref:`guide_cn-graph-gpu` 24 | 25 | .. toctree:: 26 | :maxdepth: 1 27 | :hidden: 28 | :glob: 29 | 30 | graph-basic 31 | graph-graphs-nodes-edges 32 | graph-feature 33 | graph-external 34 | graph-heterogeneous 35 | graph-gpu 36 | -------------------------------------------------------------------------------- /docs/source/guide_cn/message-part.rst: -------------------------------------------------------------------------------- 1 | .. _guide_cn-message-passing-part: 2 | 3 | 2.3 在图的一部分上进行消息传递 4 | ------------------------- 5 | 6 | :ref:`(English Version) ` 7 | 8 | 如果用户只想更新图中的部分节点,可以先通过想要囊括的节点编号创建一个子图, 9 | 然后在子图上调用 :meth:`~dgl.DGLGraph.update_all` 方法。例如: 10 | 11 | .. code:: 12 | 13 | nid = [0, 2, 3, 6, 7, 9] 14 | sg = g.subgraph(nid) 15 | sg.update_all(message_func, reduce_func, apply_node_func) 16 | 17 | 这是小批量训练中的常见用法。更多详细用法请参考用户指南 :ref:`guide_cn-minibatch`。 -------------------------------------------------------------------------------- /docs/source/guide_ko/data.rst: -------------------------------------------------------------------------------- 1 | .. _guide_ko-data-pipeline: 2 | 3 | 4장: 그래프 데이터 파이프라인 4 | ====================== 5 | 6 | :ref:`(English Version) ` 7 | 8 | DGL은 :ref:`apidata` 에서 일반적으로 많이 사용되는 그래프 데이터셋을 구현하고 있다. 이것들은 :class:`dgl.data.DGLDataset` 클래스에서 정의하고 있는 표준 파이프라인을 따른다. DGL은 :class:`dgl.data.DGLDataset` 의 서브클래스로 그래프 데이터 프로세싱하는 것을 강하게 권장한다. 이는 파이프라인이 그래프 데이터를 로딩하고, 처리하고, 저장하는데 대한 간단하고 깔끔한 방법을 제공하기 때문이다. 9 | 10 | 로드맵 11 | ---- 12 | 13 | 이 장은 커스텀 DGL-Dataset를 만드는 방법을 소개한다. 이를 위해 다음 절들에서 파이프라인이 어떻게 동작하는지 설명하고, 각 파이프라인의 컴포넌트를 구현하는 방법을 보여준다. 14 | 15 | * :ref:`guide_ko-data-pipeline-dataset` 16 | * :ref:`guide_ko-data-pipeline-download` 17 | * :ref:`guide_ko-data-pipeline-process` 18 | * :ref:`guide_ko-data-pipeline-savenload` 19 | * :ref:`guide_ko-data-pipeline-loadogb` 20 | 21 | .. toctree:: 22 | :maxdepth: 1 23 | :hidden: 24 | :glob: 25 | 26 | data-dataset 27 | data-download 28 | data-process 29 | data-savenload 30 | data-loadogb -------------------------------------------------------------------------------- /docs/source/guide_ko/graph.rst: -------------------------------------------------------------------------------- 1 | .. _guide_ko-graph: 2 | 3 | 1장: 그래프 4 | ========= 5 | 6 | :ref:`(English version)` 7 | 8 | 그래프는 앤티티들(entity 또는 노드들)과 노드들간의 관계(에지)로 표현되며, 노드와 에지들을 타입을 갖을 수 있다. (예를 들어, ``"user"`` 와 ``"item"`` 은 서로 다른 타입의 노드들이다.) DGL은 :class:`~dgl.DGLGraph` 를 핵심 자료 구조로 갖는 그래프-중심의 프로그래밍 추상화를 제공한다. :class:`~dgl.DGLGraph` 그래프의 구조, 그 그래프의 노드 및 에지 피처들과 이 컴포넌트들을 사용해서 수행된 연산 결과를 다루는데 필요한 인터페이스를 제공한다. 9 | 10 | 로드맵 11 | ------- 12 | 13 | 이 장은 1.1절의 그래프 정의에 대한 간단한 소개를 시작으로 :class:`~dgl.DGLGraph`: 의 몇가지 핵심 개념을 소개한다. 14 | 15 | * :ref:`guide_ko-graph-basic` 16 | * :ref:`guide_ko-graph-graphs-nodes-edges` 17 | * :ref:`guide_ko-graph-feature` 18 | * :ref:`guide_ko-graph-external` 19 | * :ref:`guide_ko-graph-heterogeneous` 20 | * :ref:`guide_ko-graph-gpu` 21 | 22 | .. toctree:: 23 | :maxdepth: 1 24 | :hidden: 25 | :glob: 26 | 27 | graph-basic 28 | graph-graphs-nodes-edges 29 | graph-feature 30 | graph-external 31 | graph-heterogeneous 32 | graph-gpu 33 | -------------------------------------------------------------------------------- /docs/source/guide_ko/index.rst: -------------------------------------------------------------------------------- 1 | 사용자 가이드 2 | ========== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :titlesonly: 7 | 8 | graph 9 | message 10 | nn 11 | data 12 | training 13 | minibatch 14 | distributed 15 | mixed_precision 16 | 17 | 18 | 이 한글 버전 DGL 사용자 가이드 2021년 11월 기준의 영문 :ref:`(User Guide) ` 을 Amazon Machine Learning Solutions Lab의 김무현 Principal Data Scientist가 번역한 것입니다. 오류 및 질문은 `muhyun@amazon.com` 으로 보내주세요. -------------------------------------------------------------------------------- /docs/source/guide_ko/message-edge.rst: -------------------------------------------------------------------------------- 1 | .. _guide_ko-message-passing-edge: 2 | 3 | 2.4 메시지 전달에 에지 가중치 적용하기 4 | ----------------------------- 5 | 6 | :ref:`(English Version) ` 7 | 8 | `GAT `__ 또는 일부 `GCN 변형 `__ 에서 사용되는 것처럼 메시지 병합이전에 에지의 가중치를 적용하는 것은 GNN 모델링에서 흔하게 사용되는 기법이다. DGL은 이를 다음과 같은 밥벙으로 지원하고 있다. 9 | 10 | - 가중치를 에지 피쳐로 저장 11 | - 메시지 함수에서 에지 피쳐를 소스 노드의 피쳐와 곱하기 12 | 13 | 예를 들면, 14 | 15 | .. code:: 16 | 17 | import dgl.function as fn 18 | 19 | # Suppose eweight is a tensor of shape (E, *), where E is the number of edges. 20 | graph.edata['a'] = eweight 21 | graph.update_all(fn.u_mul_e('ft', 'a', 'm'), 22 | fn.sum('m', 'ft')) 23 | 24 | 이 예제는 eweight를 이제 가중치고 사용하고 있다. 에지 가중치는 보통은 스칼라 값을 갖는다. -------------------------------------------------------------------------------- /docs/source/guide_ko/message-part.rst: -------------------------------------------------------------------------------- 1 | .. _guide_ko-message-passing-part: 2 | 3 | 2.3 그래프 일부에 메지시 전달 적용하기 4 | ------------------------------ 5 | 6 | :ref:`(English Version) ` 7 | 8 | 그래프 노드의 일부만 업데이트를 하기 원하는 경우, 업데이트를 하고 싶은 노드들의 ID를 사용해서 서브그래프를 만든 후, 그 서브그래프에 :meth:`~dgl.DGLGraph.update_all` 를 호출하는 방법으로 가능하다. 9 | 10 | .. code:: 11 | 12 | nid = [0, 2, 3, 6, 7, 9] 13 | sg = g.subgraph(nid) 14 | sg.update_all(message_func, reduce_func, apply_node_func) 15 | 16 | 이는 미니-배치 학습에서 흔히 사용되는 방법이다. 자세한 사용법은 :ref:`guide_ko-minibatch` 참고하자. -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/gcn.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../../notebooks/sparse/gcn.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/graph_diffusion.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../../notebooks/sparse/graph_diffusion.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/graph_transformer.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../../notebooks/sparse/graph_transformer.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/hgnn.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../../notebooks/sparse/hgnn.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/index.rst: -------------------------------------------------------------------------------- 1 | 🆕 Tutorials: dgl.sparse 2 | ========================= 3 | 4 | The tutorial set cover the basic usage of DGL's sparse matrix class and operators. You can begin with "Quickstart" and "Building a Graph Convolutional Network Using Sparse Matrices". The rest of the tutorials demonstrate the usage by end-to-end examples. All the tutorials are written in Jupyter Notebook and can be played on Google Colab. 5 | 6 | .. toctree:: 7 | :maxdepth: 3 8 | :titlesonly: 9 | 10 | quickstart.nblink 11 | gcn.nblink 12 | graph_diffusion.nblink 13 | hgnn.nblink 14 | graph_transformer.nblink 15 | -------------------------------------------------------------------------------- /docs/source/notebooks/sparse/quickstart.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../../notebooks/sparse/quickstart.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/resources.rst: -------------------------------------------------------------------------------- 1 | Resources 2 | ========= 3 | * If you are new to deep learning, `Dive into Deep Learning `__ 4 | is a nice book to start with. 5 | * `Pytorch tutorials `__ 6 | * Thomas Kipf's `blog on Graph Convolutional Networks `__ 7 | -------------------------------------------------------------------------------- /examples/core/gat/README.md: -------------------------------------------------------------------------------- 1 | Graph Attention Networks (GAT) 2 | ============ 3 | 4 | - Paper link: [https://arxiv.org/abs/1710.10903](https://arxiv.org/abs/1710.10903) 5 | - Author's code repo (tensorflow implementation): 6 | [https://github.com/PetarV-/GAT](https://github.com/PetarV-/GAT). 7 | - Popular pytorch implementation: 8 | [https://github.com/Diego999/pyGAT](https://github.com/Diego999/pyGAT). 9 | 10 | How to run 11 | ------- 12 | 13 | Run with the following for multiclass node classification (available datasets: "cora", "citeseer", "pubmed") 14 | ```bash 15 | python3 train.py --dataset cora 16 | ``` 17 | 18 | > **_NOTE:_** Users may occasionally run into low accuracy issue (e.g., test accuracy < 0.8) due to overfitting. This can be resolved by adding Early Stopping or reducing maximum number of training epochs. 19 | 20 | Summary 21 | ------- 22 | * cora: ~0.821 23 | * citeseer: ~0.710 24 | * pubmed: ~0.780 25 | -------------------------------------------------------------------------------- /examples/core/gated_gcn/README.md: -------------------------------------------------------------------------------- 1 | Gated Graph ConvNet (GatedGCN) 2 | ============================== 3 | 4 | * paper link: [https://arxiv.org/abs/2003.00982.pdf](https://arxiv.org/abs/2003.00982.pdf) 5 | 6 | ## Dataset 7 | 8 | Task: Graph Property Prediction 9 | 10 | | Dataset | #Graphs | #Node Feats | #Edge Feats | Metric | 11 | | :---------: | :-----: | :---------: | :---------: | :-----: | 12 | | ogbg-molhiv | 41,127 | 9 | 3 | ROC-AUC | 13 | 14 | How to run 15 | ---------- 16 | 17 | ```bash 18 | python train.py 19 | ``` 20 | 21 | ## Summary 22 | 23 | * ogbg-molhiv: ~0.781 24 | -------------------------------------------------------------------------------- /examples/multigpu/README.md: -------------------------------------------------------------------------------- 1 | # Multiple GPU Training 2 | 3 | ## Requirements 4 | 5 | ```bash 6 | pip install torchmetrics==0.11.4 7 | ``` 8 | 9 | ## How to run 10 | 11 | ### Node classification 12 | 13 | Run with following (available dataset: "ogbn-products", "ogbn-arxiv") 14 | 15 | ```bash 16 | python3 node_classification_sage.py --dataset_name ogbn-products 17 | ``` 18 | 19 | #### __Results__ with default arguments 20 | ``` 21 | * Test Accuracy of "ogbn-products": ~0.7716 22 | * Test Accuracy of "ogbn-arxiv": ~0.6994 23 | ``` 24 | -------------------------------------------------------------------------------- /examples/mxnet/README.md: -------------------------------------------------------------------------------- 1 | # Model Examples using DGL (w/ MXNet backend) 2 | 3 | use `DGLBACKEND=mxnet` to use MXNet as DGL's backend 4 | 5 | ## Examples: 6 | 7 | ``` 8 | DGLBACKEND=mxnet python gcn_batch.py --dataset cora 9 | DGLBACKEND=mxnet python gat_batch.py --dataset cora 10 | ``` 11 | 12 | Each model is hosted in their own folders. Please read their README.md to see how to 13 | run them. 14 | 15 | To understand step-by-step how these models are implemented in DGL. Check out our 16 | [tutorials](https://docs.dgl.ai/tutorials/models/index.html) 17 | -------------------------------------------------------------------------------- /examples/mxnet/appnp/README.md: -------------------------------------------------------------------------------- 1 | Predict then Propagate: Graph Neural Networks meet Personalized PageRank (APPNP) 2 | ============ 3 | 4 | - Paper link: [Predict then Propagate: Graph Neural Networks meet Personalized PageRank](https://arxiv.org/abs/1810.05997) 5 | - Author's code repo: [https://github.com/klicperajo/ppnp](https://github.com/klicperajo/ppnp). 6 | 7 | Dependencies 8 | ------------ 9 | - MXNET 1.5+ 10 | - requests 11 | 12 | ``bash 13 | pip install torch requests 14 | `` 15 | 16 | Code 17 | ----- 18 | The folder contains an implementation of APPNP (`appnp.py`). 19 | 20 | Results 21 | ------- 22 | 23 | Run with following (available dataset: "cora", "citeseer", "pubmed") 24 | ```bash 25 | DGLBACKEND=mxnet python3 appnp.py --dataset cora --gpu 0 26 | ``` 27 | 28 | * cora: 0.8370 (paper: 0.850) 29 | * citeseer: 0.713 (paper: 0.757) 30 | * pubmed: 0.798 (paper: 0.797) 31 | 32 | Experiments were done on dgl datasets (GCN settings) which are different from those used in the original implementation. (discrepancies are detailed in experimental section of the original paper) 33 | -------------------------------------------------------------------------------- /examples/mxnet/gat/README.md: -------------------------------------------------------------------------------- 1 | Graph Attention Networks (GAT) 2 | ============ 3 | 4 | - Paper link: [https://arxiv.org/abs/1710.10903](https://arxiv.org/abs/1710.10903) 5 | - Author's code repo: 6 | [https://github.com/PetarV-/GAT](https://github.com/PetarV-/GAT). 7 | 8 | Note that the original code is implemented with Tensorflow for the paper. 9 | 10 | ### Dependencies 11 | * MXNet nightly build 12 | * requests 13 | 14 | ```bash 15 | pip install mxnet --pre 16 | pip install requests 17 | ``` 18 | 19 | 20 | ### Usage (make sure that DGLBACKEND is changed into mxnet) 21 | ```bash 22 | DGLBACKEND=mxnet python3 train.py --dataset cora --gpu 0 23 | DGLBACKEND=mxnet python3 train.py --dataset citeseer --gpu 0 --early-stop 24 | DGLBACKEND=mxnet python3 train.py --dataset pubmed --gpu 0 --early-stop 25 | ``` 26 | -------------------------------------------------------------------------------- /examples/mxnet/gat/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class EarlyStopping: 5 | def __init__(self, patience=10): 6 | self.patience = patience 7 | self.counter = 0 8 | self.best_score = None 9 | self.early_stop = False 10 | 11 | def step(self, acc, model): 12 | score = acc 13 | if self.best_score is None: 14 | self.best_score = score 15 | self.save_checkpoint(model) 16 | elif score < self.best_score: 17 | self.counter += 1 18 | print( 19 | f"EarlyStopping counter: {self.counter} out of {self.patience}" 20 | ) 21 | if self.counter >= self.patience: 22 | self.early_stop = True 23 | else: 24 | self.best_score = score 25 | self.save_checkpoint(model) 26 | self.counter = 0 27 | return self.early_stop 28 | 29 | def save_checkpoint(self, model): 30 | """Saves model when validation loss decrease.""" 31 | model.save_parameters("model.param") 32 | -------------------------------------------------------------------------------- /examples/mxnet/graphsage/README.md: -------------------------------------------------------------------------------- 1 | Inductive Representation Learning on Large Graphs (GraphSAGE) 2 | ============ 3 | 4 | - Paper link: [http://papers.nips.cc/paper/6703-inductive-representation-learning-on-large-graphs.pdf](http://papers.nips.cc/paper/6703-inductive-representation-learning-on-large-graphs.pdf) 5 | - Author's code repo: [https://github.com/williamleif/graphsage-simple](https://github.com/williamleif/graphsage-simple). Note that the original code is 6 | simple reference implementation of GraphSAGE. 7 | 8 | Requirements 9 | ------------ 10 | - requests 11 | 12 | ``bash 13 | pip install requests 14 | `` 15 | 16 | 17 | Results 18 | ------- 19 | 20 | Run with following (available dataset: "cora", "citeseer", "pubmed") 21 | ```bash 22 | python3 main.py --dataset cora --gpu 0 23 | ``` 24 | 25 | * cora: ~0.817 26 | * citeseer: ~0.699 27 | * pubmed: ~0.790 -------------------------------------------------------------------------------- /examples/mxnet/monet/README.md: -------------------------------------------------------------------------------- 1 | MoNet 2 | ===== 3 | 4 | - paper link: [Geometric deep learning on graphs and manifolds using mixture model CNNs](https://arxiv.org/pdf/1611.08402.pdf) 5 | 6 | Dependencies 7 | ============ 8 | 9 | - MXNet 1.5+ 10 | 11 | Results 12 | ======= 13 | 14 | ## Citation networks 15 | Run with following (available dataset: "cora", "citeseer", "pubmed") 16 | ```bash 17 | python3 citation.py --dataset cora --gpu 0 18 | ``` 19 | 20 | - Cora: ~0.814 21 | - Pubmed: ~0.748 22 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .dataloader import * 2 | from .object import * 3 | from .relation import * 4 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/data/dataloader.py: -------------------------------------------------------------------------------- 1 | """DataLoader utils.""" 2 | import dgl 3 | from gluoncv.data.batchify import Pad 4 | from mxnet import nd 5 | 6 | 7 | def dgl_mp_batchify_fn(data): 8 | if isinstance(data[0], tuple): 9 | data = zip(*data) 10 | return [dgl_mp_batchify_fn(i) for i in data] 11 | 12 | for dt in data: 13 | if dt is not None: 14 | if isinstance(dt, dgl.DGLGraph): 15 | return [d for d in data if isinstance(d, dgl.DGLGraph)] 16 | elif isinstance(dt, nd.NDArray): 17 | pad = Pad(axis=(1, 2), num_shards=1, ret_length=False) 18 | data_list = [dt for dt in data if dt is not None] 19 | return pad(data_list) 20 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/model/__init__.py: -------------------------------------------------------------------------------- 1 | from .faster_rcnn import * 2 | from .reldn import * 3 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/train_faster_rcnn.sh: -------------------------------------------------------------------------------- 1 | MXNET_CUDNN_AUTOTUNE_DEFAULT=0 CUDNN_AUTOTUNE_DEFAULT=0 MXNET_GPU_MEM_POOL_TYPE=Round MXNET_GPU_MEM_POOL_ROUND_LINEAR_CUTOFF=28 python train_faster_rcnn.py \ 2 | --gpus 0,1,2,3,4,5,6,7 --dataset visualgenome -j 60 --batch-size 8 --val-interval 20 --save-prefix faster_rcnn_resnet101_v1d_visualgenome/ 3 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/train_reldn.sh: -------------------------------------------------------------------------------- 1 | MXNET_CUDNN_AUTOTUNE_DEFAULT=0 python train_reldn.py \ 2 | --pretrained-faster-rcnn-params faster_rcnn_resnet101_v1d_visualgenome/faster_rcnn_resnet101_v1d_custom_best.params 3 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .build_graph import * 2 | from .metric import * 3 | from .sampling import * 4 | from .viz import * 5 | -------------------------------------------------------------------------------- /examples/mxnet/scenegraph/validate_reldn.sh: -------------------------------------------------------------------------------- 1 | MXNET_CUDNN_AUTOTUNE_DEFAULT=0 python validate_reldn.py \ 2 | --pretrained-faster-rcnn-params faster_rcnn_resnet101_v1d_visualgenome/faster_rcnn_resnet101_v1d_custom_best.params \ 3 | --reldn-params params_resnet101_v1d_reldn/model-8.params \ 4 | --faster-rcnn-params params_resnet101_v1d_reldn/detector_feat.features-8.params 5 | -------------------------------------------------------------------------------- /examples/mxnet/sgc/README.md: -------------------------------------------------------------------------------- 1 | Simple Graph Convolution (SGC) 2 | ============ 3 | 4 | - Paper link: [Simplifying Graph Convolutional Networks](https://arxiv.org/abs/1902.07153) 5 | - Author's code repo: [https://github.com/Tiiiger/SGC](https://github.com/Tiiiger/SGC). 6 | 7 | Dependencies 8 | ------------ 9 | - MXNET 1.5+ 10 | - requests 11 | 12 | ``bash 13 | pip install torch requests 14 | `` 15 | 16 | Codes 17 | ----- 18 | The folder contains an implementation of SGC (`sgc.py`). 19 | 20 | Results 21 | ------- 22 | 23 | Run with following (available dataset: "cora", "citeseer", "pubmed") 24 | ```bash 25 | DGLBACKEND=mxnet python3 sgc.py --dataset cora --gpu 0 26 | DGLBACKEND=mxnet python3 sgc.py --dataset citeseer --weight-decay 5e-5 --n-epochs 150 --bias --gpu 0 27 | DGLBACKEND=mxnet python3 sgc.py --dataset pubmed --weight-decay 5e-5 --bias --gpu 0 28 | ``` 29 | 30 | On NVIDIA V100 31 | 32 | * cora: 0.818 (paper: 0.810) 33 | * citeseer: 0.725 (paper: 0.719) 34 | * pubmed: 0.788 (paper: 0.789) 35 | -------------------------------------------------------------------------------- /examples/mxnet/tagcn/README.md: -------------------------------------------------------------------------------- 1 | Topology Adaptive Graph Convolutional networks (TAGCN) 2 | ============ 3 | 4 | - Paper link: [https://arxiv.org/abs/1710.10370](https://arxiv.org/abs/1710.10370) 5 | 6 | Dependencies 7 | ------------ 8 | - MXNet nightly build 9 | - requests 10 | 11 | ``bash 12 | pip install mxnet --pre 13 | pip install requests 14 | `` 15 | 16 | Results 17 | ------- 18 | Run with following (available dataset: "cora", "citeseer", "pubmed") 19 | ```bash 20 | DGLBACKEND=mxnet python3 train.py --dataset cora --gpu 0 --self-loop 21 | ``` 22 | 23 | * cora: ~0.820 (paper: 0.833) 24 | * citeseer: ~0.702 (paper: 0.714) 25 | * pubmed: ~0.798 (paper: 0.811) -------------------------------------------------------------------------------- /examples/mxnet/util.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/mxnet/util.py -------------------------------------------------------------------------------- /examples/pytorch/GATNE-T/requirements.txt: -------------------------------------------------------------------------------- 1 | tqdm 2 | numpy 3 | sklearn 4 | networkx 5 | gensim 6 | requests 7 | --pre dgl-cu101 -------------------------------------------------------------------------------- /examples/pytorch/GATNE-T/scripts/run_example.sh: -------------------------------------------------------------------------------- 1 | python src/main.py --input data/example --gpu 0 2 | -------------------------------------------------------------------------------- /examples/pytorch/GATNE-T/scripts/run_example_sparse.sh: -------------------------------------------------------------------------------- 1 | python src/main_sparse.py --input data/example --gpu 0 2 | -------------------------------------------------------------------------------- /examples/pytorch/GATNE-T/scripts/run_example_sparse_multi_gpus.sh: -------------------------------------------------------------------------------- 1 | python src/main_sparse_multi_gpus.py --input data/example 2 | -------------------------------------------------------------------------------- /examples/pytorch/GNN-FiLM/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from sklearn.metrics import f1_score 3 | 4 | 5 | # function to compute f1 score 6 | def evaluate_f1_score(pred, label): 7 | pred = np.round(pred, 0).astype(np.int16) 8 | pred = pred.flatten() 9 | label = label.flatten() 10 | return f1_score(y_pred=pred, y_true=label) 11 | -------------------------------------------------------------------------------- /examples/pytorch/NGCF/Data/load_amazon-book.sh: -------------------------------------------------------------------------------- 1 | wget https://s3.us-west-2.amazonaws.com/dgl-data/dataset/amazon-book.zip 2 | unzip amazon-book.zip -------------------------------------------------------------------------------- /examples/pytorch/NGCF/Data/load_gowalla.sh: -------------------------------------------------------------------------------- 1 | wget https://s3.us-west-2.amazonaws.com/dgl-data/dataset/gowalla.zip 2 | unzip gowalla.zip -------------------------------------------------------------------------------- /examples/pytorch/TAHIN/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from sklearn.metrics import ( 4 | accuracy_score, 5 | average_precision_score, 6 | f1_score, 7 | log_loss, 8 | ndcg_score, 9 | roc_auc_score, 10 | ) 11 | 12 | 13 | def evaluate_auc(pred, label): 14 | res = roc_auc_score(y_score=pred, y_true=label) 15 | return res 16 | 17 | 18 | def evaluate_acc(pred, label): 19 | res = [] 20 | for _value in pred: 21 | if _value >= 0.5: 22 | res.append(1) 23 | else: 24 | res.append(0) 25 | return accuracy_score(y_pred=res, y_true=label) 26 | 27 | 28 | def evaluate_f1_score(pred, label): 29 | res = [] 30 | for _value in pred: 31 | if _value >= 0.5: 32 | res.append(1) 33 | else: 34 | res.append(0) 35 | return f1_score(y_pred=res, y_true=label) 36 | 37 | 38 | def evaluate_logloss(pred, label): 39 | res = log_loss(y_true=label, y_pred=pred, eps=1e-7, normalize=True) 40 | return res 41 | -------------------------------------------------------------------------------- /examples/pytorch/appnp/README.md: -------------------------------------------------------------------------------- 1 | Predict then Propagate: Graph Neural Networks meet Personalized PageRank (APPNP) 2 | ============ 3 | 4 | - Paper link: [Predict then Propagate: Graph Neural Networks meet Personalized PageRank](https://arxiv.org/abs/1810.05997) 5 | - Author's code repo: [https://github.com/klicperajo/ppnp](https://github.com/klicperajo/ppnp). 6 | 7 | Dependencies 8 | ------------ 9 | - PyTorch 0.4.1+ 10 | - requests 11 | 12 | ``bash 13 | pip install torch requests 14 | `` 15 | 16 | Code 17 | ----- 18 | The folder contains an implementation of APPNP (`appnp.py`). 19 | 20 | Results 21 | ------- 22 | 23 | Run with following (available dataset: "cora", "citeseer", "pubmed") 24 | ```bash 25 | python3 train.py --dataset cora --gpu 0 26 | ``` 27 | 28 | * cora: 0.8370 (paper: 0.850) 29 | * citeseer: 0.715 (paper: 0.757) 30 | * pubmed: 0.793 (paper: 0.797) 31 | 32 | Experiments were done on dgl datasets (GCN settings) which are different from those used in the original implementation. (discrepancies are detailed in experimental section of the original paper) 33 | -------------------------------------------------------------------------------- /examples/pytorch/capsule/README.md: -------------------------------------------------------------------------------- 1 | DGL implementation of Capsule Network 2 | ===================================== 3 | 4 | This repo implements Hinton and his team's [Capsule Network](https://arxiv.org/abs/1710.09829). 5 | Only margin loss is implemented, for simplicity to understand the DGL. 6 | 7 | Dependencies 8 | -------------- 9 | * PyTorch 0.4.1+ 10 | * torchvision 11 | 12 | ```bash 13 | pip install torch torchvision 14 | ``` 15 | 16 | Training & Evaluation 17 | ---------------------- 18 | ```bash 19 | # Run with default config 20 | python3 main.py 21 | # Run with train and test batch size 128, and for 50 epochs 22 | python3 main.py --batch-size 128 --test-batch-size 128 --epochs 50 23 | ``` 24 | -------------------------------------------------------------------------------- /examples/pytorch/cluster_gcn/README.md: -------------------------------------------------------------------------------- 1 | Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks 2 | ============ 3 | - Paper link: [Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks](https://arxiv.org/abs/1905.07953) 4 | - Author's code repo: [https://github.com/google-research/google-research/blob/master/cluster_gcn/](https://github.com/google-research/google-research/blob/master/cluster_gcn/). 5 | 6 | This repo reproduce the reported speed and performance maximally on Reddit and PPI. However, the diag enhancement is not covered, as the GraphSage aggregator already achieves satisfying F1 score. 7 | 8 | Dependencies 9 | ------------ 10 | - Python 3.7+(for string formatting features) 11 | - PyTorch 1.9.0+ 12 | - sklearn 13 | - TorchMetrics 0.11.4 14 | 15 | ## Run Experiments 16 | 17 | ```bash 18 | python cluster_gcn.py 19 | ``` 20 | -------------------------------------------------------------------------------- /examples/pytorch/compGCN/get_fb15k-237.sh: -------------------------------------------------------------------------------- 1 | wget https://dgl-data.s3.cn-north-1.amazonaws.com.cn/dataset/FB15k-237.zip 2 | unzip FB15k-237.zip 3 | -------------------------------------------------------------------------------- /examples/pytorch/compGCN/get_wn18rr.sh: -------------------------------------------------------------------------------- 1 | wget https://dgl-data.s3.cn-north-1.amazonaws.com.cn/dataset/wn18rr.zip 2 | unzip wn18rr.zip 3 | -------------------------------------------------------------------------------- /examples/pytorch/dagnn/utils.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | import numpy as np 4 | import torch 5 | from torch.nn import functional as F 6 | 7 | 8 | def evaluate(model, graph, feats, labels, idxs): 9 | model.eval() 10 | with torch.no_grad(): 11 | logits = model(graph, feats) 12 | results = () 13 | for idx in idxs: 14 | loss = F.cross_entropy(logits[idx], labels[idx]) 15 | acc = torch.sum( 16 | logits[idx].argmax(dim=1) == labels[idx] 17 | ).item() / len(idx) 18 | results += (loss, acc) 19 | return results 20 | 21 | 22 | def generate_random_seeds(seed, nums): 23 | random.seed(seed) 24 | return [random.randint(1, 999999999) for _ in range(nums)] 25 | 26 | 27 | def set_random_state(seed): 28 | random.seed(seed) 29 | np.random.seed(seed) 30 | torch.manual_seed(seed) 31 | if torch.cuda.is_available(): 32 | torch.cuda.manual_seed_all(seed) 33 | torch.backends.cudnn.deterministic = True 34 | -------------------------------------------------------------------------------- /examples/pytorch/deepwalk/README.md: -------------------------------------------------------------------------------- 1 | # DeepWalk 2 | 3 | - Paper link: [here](https://arxiv.org/pdf/1403.6652.pdf) 4 | 5 | The example code was moved to examples/pytorch/ogb/deepwalk. 6 | -------------------------------------------------------------------------------- /examples/pytorch/dgi/README.md: -------------------------------------------------------------------------------- 1 | Deep Graph Infomax (DGI) 2 | ======================== 3 | 4 | - Paper link: [https://arxiv.org/abs/1809.10341](https://arxiv.org/abs/1809.10341) 5 | - Author's code repo (in Pytorch): 6 | [https://github.com/PetarV-/DGI](https://github.com/PetarV-/DGI) 7 | 8 | Dependencies 9 | ------------ 10 | - PyTorch 0.4.1+ 11 | - requests 12 | 13 | ```bash 14 | pip install torch requests 15 | ``` 16 | 17 | How to run 18 | ---------- 19 | 20 | Run with following: 21 | 22 | ```bash 23 | python3 train.py --dataset=cora --gpu=0 --self-loop 24 | ``` 25 | 26 | ```bash 27 | python3 train.py --dataset=citeseer --gpu=0 28 | ``` 29 | 30 | ```bash 31 | python3 train.py --dataset=pubmed --gpu=0 32 | ``` 33 | 34 | Results 35 | ------- 36 | * cora: ~81.6 (81.2-82.1) (paper: 82.3) 37 | * citeseer: ~69.4 (paper: 71.8) 38 | * pubmed: ~76.1 (paper: 76.8) 39 | -------------------------------------------------------------------------------- /examples/pytorch/dgmg/README.md: -------------------------------------------------------------------------------- 1 | # Learning Deep Generative Models of Graphs 2 | 3 | This is an implementation of [Learning Deep Generative Models of Graphs](https://arxiv.org/pdf/1803.03324.pdf) by 4 | Yujia Li, Oriol Vinyals, Chris Dyer, Razvan Pascanu, Peter Battaglia. 5 | 6 | For molecule generation, see 7 | [DGL-LifeSci](https://github.com/awslabs/dgl-lifesci/tree/master/examples/generative_models/dgmg). 8 | 9 | ## Dependencies 10 | - Python 3.5.2 11 | - [Pytorch 0.4.1](https://pytorch.org/) 12 | - [Matplotlib 2.2.2](https://matplotlib.org/) 13 | 14 | ## Usage 15 | 16 | `python3 main.py` 17 | 18 | ## Performance 19 | 20 | 90% accuracy for cycles compared with 84% accuracy reported in the original paper. 21 | 22 | ## Speed 23 | 24 | On AWS p3.2x instance (w/ V100), one epoch takes ~526s. 25 | 26 | ## Acknowledgement 27 | 28 | We would like to thank Yujia Li for providing details on the implementation. 29 | -------------------------------------------------------------------------------- /examples/pytorch/dgmg/configure.py: -------------------------------------------------------------------------------- 1 | """We intend to make our reproduction as close as possible to the original paper. 2 | The configuration in the file is mostly from the description in the original paper 3 | and will be loaded when setting up.""" 4 | 5 | 6 | def dataset_based_configure(opts): 7 | if opts["dataset"] == "cycles": 8 | ds_configure = cycles_configure 9 | else: 10 | raise ValueError("Unsupported dataset: {}".format(opts["dataset"])) 11 | 12 | opts = {**opts, **ds_configure} 13 | 14 | return opts 15 | 16 | 17 | synthetic_dataset_configure = { 18 | "node_hidden_size": 16, 19 | "num_propagation_rounds": 2, 20 | "optimizer": "Adam", 21 | "nepochs": 25, 22 | "ds_size": 4000, 23 | "num_generated_samples": 10000, 24 | } 25 | 26 | cycles_configure = { 27 | **synthetic_dataset_configure, 28 | **{ 29 | "min_size": 10, 30 | "max_size": 20, 31 | "lr": 5e-4, 32 | }, 33 | } 34 | -------------------------------------------------------------------------------- /examples/pytorch/diffpool/model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/diffpool/model/__init__.py -------------------------------------------------------------------------------- /examples/pytorch/diffpool/model/dgl_layers/__init__.py: -------------------------------------------------------------------------------- 1 | from .gnn import DiffPoolBatchedGraphLayer, GraphSage, GraphSageLayer 2 | -------------------------------------------------------------------------------- /examples/pytorch/diffpool/model/loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class EntropyLoss(nn.Module): 6 | # Return Scalar 7 | def forward(self, adj, anext, s_l): 8 | entropy = ( 9 | (torch.distributions.Categorical(probs=s_l).entropy()) 10 | .sum(-1) 11 | .mean(-1) 12 | ) 13 | assert not torch.isnan(entropy) 14 | return entropy 15 | 16 | 17 | class LinkPredLoss(nn.Module): 18 | def forward(self, adj, anext, s_l): 19 | link_pred_loss = (adj - s_l.matmul(s_l.transpose(-1, -2))).norm( 20 | dim=(1, 2) 21 | ) 22 | link_pred_loss = link_pred_loss / (adj.size(1) * adj.size(2)) 23 | return link_pred_loss.mean() 24 | -------------------------------------------------------------------------------- /examples/pytorch/diffpool/model/tensorized_layers/__init__.py: -------------------------------------------------------------------------------- 1 | from .diffpool import BatchedDiffPool 2 | from .graphsage import BatchedGraphSAGE 3 | -------------------------------------------------------------------------------- /examples/pytorch/diffpool/model/tensorized_layers/assignment.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn as nn 3 | from torch.autograd import Variable 4 | from torch.nn import functional as F 5 | 6 | from model.tensorized_layers.graphsage import BatchedGraphSAGE 7 | 8 | 9 | class DiffPoolAssignment(nn.Module): 10 | def __init__(self, nfeat, nnext): 11 | super().__init__() 12 | self.assign_mat = BatchedGraphSAGE(nfeat, nnext, use_bn=True) 13 | 14 | def forward(self, x, adj, log=False): 15 | s_l_init = self.assign_mat(x, adj) 16 | s_l = F.softmax(s_l_init, dim=-1) 17 | return s_l 18 | -------------------------------------------------------------------------------- /examples/pytorch/dimenet/config/convert.yaml: -------------------------------------------------------------------------------- 1 | tf: 2 | ckpt_path: 'pretrained/dimenet_pp/mu' 3 | torch: 4 | dump_path: 'pretrained/converted' -------------------------------------------------------------------------------- /examples/pytorch/dimenet/config/dimenet.yaml: -------------------------------------------------------------------------------- 1 | name: "dimenet" 2 | 3 | model: 4 | emb_size: 128 5 | num_blocks: 6 6 | num_bilinear: 8 7 | num_spherical: 7 8 | num_radial: 6 9 | envelope_exponent: 5 10 | cutoff: 5.0 11 | num_before_skip: 1 12 | num_after_skip: 2 13 | num_dense_output: 3 14 | # ['mu', 'alpha', 'homo', 'lumo', 'gap', 'r2', 'zpve', 'U0', 'U', 'H', 'G', 'Cv'] 15 | targets: ['U0'] 16 | 17 | train: 18 | num_train: 110000 19 | num_valid: 10000 20 | data_seed: 42 21 | lr: 0.001 22 | weight_decay: 0.0001 23 | ema_decay: 0 24 | batch_size: 45 25 | epochs: 300 26 | early_stopping: 20 27 | num_workers: 18 28 | gpu: 0 29 | interval: 50 30 | step_size: 100 31 | gamma: 0.3 32 | 33 | pretrain: 34 | flag: False 35 | path: 'pretrained/converted/' -------------------------------------------------------------------------------- /examples/pytorch/dimenet/config/dimenet_pp.yaml: -------------------------------------------------------------------------------- 1 | name: "dimenet++" 2 | 3 | model: 4 | emb_size: 128 5 | out_emb_size: 256 6 | int_emb_size: 64 7 | basis_emb_size: 8 8 | num_blocks: 4 9 | num_spherical: 7 10 | num_radial: 6 11 | envelope_exponent: 5 12 | cutoff: 5.0 13 | extensive: True 14 | num_before_skip: 1 15 | num_after_skip: 2 16 | num_dense_output: 3 17 | # ['mu', 'alpha', 'homo', 'lumo', 'gap', 'r2', 'zpve', 'U0', 'U', 'H', 'G', 'Cv'] 18 | targets: ['mu'] 19 | 20 | train: 21 | num_train: 110000 22 | num_valid: 10000 23 | data_seed: 42 24 | lr: 0.001 25 | weight_decay: 0.0001 26 | ema_decay: 0 27 | batch_size: 100 28 | epochs: 300 29 | early_stopping: 20 30 | num_workers: 18 31 | gpu: 0 32 | interval: 50 33 | step_size: 100 34 | gamma: 0.3 35 | 36 | pretrain: 37 | flag: False 38 | path: 'pretrained/converted/' -------------------------------------------------------------------------------- /examples/pytorch/dimenet/modules/activations.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def swish(x): 5 | """ 6 | Swish activation function, 7 | from Ramachandran, Zopf, Le 2017. "Searching for Activation Functions" 8 | """ 9 | return x * torch.sigmoid(x) 10 | -------------------------------------------------------------------------------- /examples/pytorch/dimenet/modules/envelope.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | class Envelope(nn.Module): 5 | """ 6 | Envelope function that ensures a smooth cutoff 7 | """ 8 | 9 | def __init__(self, exponent): 10 | super(Envelope, self).__init__() 11 | 12 | self.p = exponent + 1 13 | self.a = -(self.p + 1) * (self.p + 2) / 2 14 | self.b = self.p * (self.p + 2) 15 | self.c = -self.p * (self.p + 1) / 2 16 | 17 | def forward(self, x): 18 | # Envelope function divided by r 19 | x_p_0 = x.pow(self.p - 1) 20 | x_p_1 = x_p_0 * x 21 | x_p_2 = x_p_1 * x 22 | env_val = 1 / x + self.a * x_p_0 + self.b * x_p_1 + self.c * x_p_2 23 | return env_val 24 | -------------------------------------------------------------------------------- /examples/pytorch/dimenet/modules/initializers.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | def GlorotOrthogonal(tensor, scale=2.0): 5 | if tensor is not None: 6 | nn.init.orthogonal_(tensor.data) 7 | scale /= (tensor.size(-2) + tensor.size(-1)) * tensor.var() 8 | tensor.data *= scale.sqrt() 9 | -------------------------------------------------------------------------------- /examples/pytorch/dimenet/modules/residual_layer.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | from modules.initializers import GlorotOrthogonal 3 | 4 | 5 | class ResidualLayer(nn.Module): 6 | def __init__(self, units, activation=None): 7 | super(ResidualLayer, self).__init__() 8 | 9 | self.activation = activation 10 | self.dense_1 = nn.Linear(units, units) 11 | self.dense_2 = nn.Linear(units, units) 12 | 13 | self.reset_params() 14 | 15 | def reset_params(self): 16 | GlorotOrthogonal(self.dense_1.weight) 17 | nn.init.zeros_(self.dense_1.bias) 18 | GlorotOrthogonal(self.dense_2.weight) 19 | nn.init.zeros_(self.dense_2.bias) 20 | 21 | def forward(self, inputs): 22 | x = self.dense_1(inputs) 23 | if self.activation is not None: 24 | x = self.activation(x) 25 | x = self.dense_2(x) 26 | if self.activation is not None: 27 | x = self.activation(x) 28 | return inputs + x 29 | -------------------------------------------------------------------------------- /examples/pytorch/dtgrnn/utils.py: -------------------------------------------------------------------------------- 1 | import dgl 2 | import numpy as np 3 | import scipy.sparse as sparse 4 | import torch 5 | import torch.nn as nn 6 | 7 | 8 | class NormalizationLayer(nn.Module): 9 | def __init__(self, mean, std): 10 | self.mean = mean 11 | self.std = std 12 | 13 | # Here we shall expect mean and std be scaler 14 | def normalize(self, x): 15 | return (x - self.mean) / self.std 16 | 17 | def denormalize(self, x): 18 | return x * self.std + self.mean 19 | 20 | 21 | def masked_mae_loss(y_pred, y_true): 22 | mask = (y_true != 0).float() 23 | mask /= mask.mean() 24 | loss = torch.abs(y_pred - y_true) 25 | loss = loss * mask 26 | # trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3 27 | loss[loss != loss] = 0 28 | return loss.mean() 29 | 30 | 31 | def get_learning_rate(optimizer): 32 | for param in optimizer.param_groups: 33 | return param["lr"] 34 | -------------------------------------------------------------------------------- /examples/pytorch/eges/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | 3 | -------------------------------------------------------------------------------- /examples/pytorch/eges/README.md: -------------------------------------------------------------------------------- 1 | # DGL & Pytorch implementation of Enhanced Graph Embedding with Side information (EGES) 2 | Paper link: https://arxiv.org/pdf/1803.02349.pdf 3 | Reference code repo: (https://github.com/wangzhegeek/EGES.git) 4 | 5 | ## How to run 6 | 7 | - Create a folder named `data`. 8 | `mkdir data` 9 | - Download csv data 10 | `wget https://raw.githubusercontent.com/Wang-Yu-Qing/dgl_data/master/eges_data/action_head.csv -P data/` 11 | `wget https://raw.githubusercontent.com/Wang-Yu-Qing/dgl_data/master/eges_data/jdata_product.csv -P data/` 12 | - Run with the following command (with default configuration) 13 | `python main.py` 14 | 15 | ## Result 16 | ``` 17 | Evaluate link prediction AUC: 0.7084 18 | ``` 19 | -------------------------------------------------------------------------------- /examples/pytorch/gas/variant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/gas/variant.png -------------------------------------------------------------------------------- /examples/pytorch/gatv2/README.md: -------------------------------------------------------------------------------- 1 | Graph Attention Networks v2 (GATv2) 2 | ============ 3 | 4 | - Paper link: [How Attentive are Graph Attention Networks?](https://arxiv.org/pdf/2105.14491.pdf) 5 | - Author's code repo: [https://github.com/tech-srl/how_attentive_are_gats](https://github.com/tech-srl/how_attentive_are_gats). 6 | - Annotated implemetnation: [https://nn.labml.ai/graphs/gatv2/index.html] 7 | 8 | Dependencies 9 | ------------ 10 | - torch 11 | - requests 12 | - sklearn 13 | 14 | How to run 15 | ---------- 16 | 17 | Run with following: 18 | 19 | ```bash 20 | python3 train.py --dataset=cora 21 | ``` 22 | 23 | ```bash 24 | python3 train.py --dataset=citeseer 25 | ``` 26 | 27 | ```bash 28 | python3 train.py --dataset=pubmed 29 | ``` 30 | 31 | Results 32 | ------- 33 | 34 | | Dataset | Test Accuracy | 35 | | -------- | ------------- | 36 | | Cora | 82.10 | 37 | | Citeseer | 70.00 | 38 | | Pubmed | 77.2 | 39 | 40 | * All the accuracy numbers are obtained after 200 epochs. -------------------------------------------------------------------------------- /examples/pytorch/gcn/README.md: -------------------------------------------------------------------------------- 1 | Graph Convolutional Networks (GCN) 2 | ============ 3 | 4 | - Paper link: [https://arxiv.org/abs/1609.02907](https://arxiv.org/abs/1609.02907) 5 | - Author's code repo: [https://github.com/tkipf/gcn](https://github.com/tkipf/gcn). 6 | 7 | How to run 8 | ------- 9 | 10 | ### DGL built-in GraphConv module 11 | 12 | Run with the following (available dataset: "cora", "citeseer", "pubmed") 13 | ```bash 14 | python3 train.py --dataset cora 15 | ``` 16 | 17 | Summary 18 | ------- 19 | * cora: ~0.810 (paper: 0.815) 20 | * citeseer: ~0.707 (paper: 0.703) 21 | * pubmed: ~0.792 (paper: 0.790) 22 | 23 | -------------------------------------------------------------------------------- /examples/pytorch/gnn_explainer/gnn_subgraph/1/model_list.json: -------------------------------------------------------------------------------- 1 | {"models": [], "success": true} -------------------------------------------------------------------------------- /examples/pytorch/gnn_explainer/gnn_subgraph/1/subgraph_list.json: -------------------------------------------------------------------------------- 1 | {"subgraphs": [{"id": 1, "name": "GNNExplainer"}], "success": true} -------------------------------------------------------------------------------- /examples/pytorch/gnn_explainer/gnn_subgraph/dataset_list.json: -------------------------------------------------------------------------------- 1 | {"datasets": [{"id": 1, "name": "BAShape"}], "success": true} -------------------------------------------------------------------------------- /examples/pytorch/grace/dataset.py: -------------------------------------------------------------------------------- 1 | from dgl.data import CiteseerGraphDataset, CoraGraphDataset, PubmedGraphDataset 2 | 3 | 4 | def load(name): 5 | if name == "cora": 6 | dataset = CoraGraphDataset() 7 | elif name == "citeseer": 8 | dataset = CiteseerGraphDataset() 9 | elif name == "pubmed": 10 | dataset = PubmedGraphDataset() 11 | 12 | graph = dataset[0] 13 | 14 | train_mask = graph.ndata.pop("train_mask") 15 | test_mask = graph.ndata.pop("test_mask") 16 | 17 | feat = graph.ndata.pop("feat") 18 | labels = graph.ndata.pop("label") 19 | 20 | return graph, feat, labels, train_mask, test_mask 21 | -------------------------------------------------------------------------------- /examples/pytorch/graphsage/advanced/README.md: -------------------------------------------------------------------------------- 1 | More Examples for Training GraphSAGE 2 | ============================ 3 | 4 | ### Training with PyTorch Lightning 5 | 6 | We provide minibatch training scripts with PyTorch Lightning in `train_lightning_unsupervised.py`. 7 | 8 | Requires `pytorch_lightning` and `torchmetrics`. 9 | 10 | ```bash 11 | python3 train_lightning_unsupervised.py 12 | ``` 13 | -------------------------------------------------------------------------------- /examples/pytorch/graphsage/advanced/negative_sampler.py: -------------------------------------------------------------------------------- 1 | import dgl 2 | import torch as th 3 | 4 | 5 | class NegativeSampler(object): 6 | def __init__(self, g, k, neg_share=False, device=None): 7 | if device is None: 8 | device = g.device 9 | self.weights = g.in_degrees().float().to(device) ** 0.75 10 | self.k = k 11 | self.neg_share = neg_share 12 | 13 | def __call__(self, g, eids): 14 | src, _ = g.find_edges(eids) 15 | n = len(src) 16 | if self.neg_share and n % self.k == 0: 17 | dst = self.weights.multinomial(n, replacement=True) 18 | dst = dst.view(-1, 1, self.k).expand(-1, self.k, -1).flatten() 19 | else: 20 | dst = self.weights.multinomial(n * self.k, replacement=True) 21 | src = src.repeat_interleave(self.k) 22 | return src, dst 23 | -------------------------------------------------------------------------------- /examples/pytorch/graphsage/dist/ip_config.txt: -------------------------------------------------------------------------------- 1 | 172.31.2.66 2 | 172.31.1.191 3 | -------------------------------------------------------------------------------- /examples/pytorch/graphsim/utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import cv2 as cv 4 | import matplotlib 5 | import matplotlib.animation as manimation 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | 9 | matplotlib.use("agg") 10 | 11 | # Make video can be used to visualize test data 12 | 13 | 14 | def make_video(xy, filename): 15 | os.system("rm -rf pics/*") 16 | FFMpegWriter = manimation.writers["ffmpeg"] 17 | metadata = dict( 18 | title="Movie Test", artist="Matplotlib", comment="Movie support!" 19 | ) 20 | writer = FFMpegWriter(fps=15, metadata=metadata) 21 | fig = plt.figure() 22 | plt.xlim(-200, 200) 23 | plt.ylim(-200, 200) 24 | fig_num = len(xy) 25 | color = ["ro", "bo", "go", "ko", "yo", "mo", "co"] 26 | with writer.saving(fig, filename, len(xy)): 27 | for i in range(len(xy)): 28 | for j in range(len(xy[0])): 29 | plt.plot(xy[i, j, 1], xy[i, j, 0], color[j % len(color)]) 30 | writer.grab_frame() 31 | -------------------------------------------------------------------------------- /examples/pytorch/graphwriter/prepare_data.sh: -------------------------------------------------------------------------------- 1 | wget https://data.dgl.ai/dataset/AGENDA.tar.gz 2 | mkdir data 3 | tar -C data/ -xvzf AGENDA.tar.gz 4 | -------------------------------------------------------------------------------- /examples/pytorch/graphwriter/run.sh: -------------------------------------------------------------------------------- 1 | nohup env CUDA_VISIBLE_DEVICES=0 python -u train.py --prop 6 --save_model tmp_model.pt --title > train_1.log 2>&1 & 2 | #nohup env CUDA_VISIBLE_DEVICES=2 python -u train.py --prop 6 --save_model tmp_model1.pt --title > train_2.log 2>&1 & 3 | #nohup env CUDA_VISIBLE_DEVICES=3 python -u train.py --prop 6 --save_model tmp_model2.pt --title > train_3.log 2>&1 & 4 | #nohup env CUDA_VISIBLE_DEVICES=4 python -u train.py --prop 6 --save_model tmp_model3.pt --title > train_4.log 2>&1 & 5 | #nohup env CUDA_VISIBLE_DEVICES=5 python -u train.py --prop 2 --save_model tmp_model4.pt --title > train_5.log 2>&1 & 6 | #nohup env CUDA_VISIBLE_DEVICES=6 python -u train.py --prop 2 --save_model tmp_model5.pt --title > train_6.log 2>&1 & 7 | -------------------------------------------------------------------------------- /examples/pytorch/graphwriter/test.sh: -------------------------------------------------------------------------------- 1 | env CUDA_VISIBLE_DEVICES=0 python -u train.py --save_model tmp_model.ptbest --test --title --lp 1.0 --beam_size 1 2 | if [ ! detokenizer.perl ]; then 3 | wget https://raw.githubusercontent.com/moses-smt/mosesdecoder/8c5eaa1a122236bbf927bde4ec610906fea599e6/scripts/tokenizer/detokenizer.perl 4 | fi 5 | if [ ! multi-bleu.perl ]; then 6 | wget https://raw.githubusercontent.com/moses-smt/mosesdecoder/8c5eaa1a122236bbf927bde4ec610906fea599e6/scripts/generic/multi-bleu.perl 7 | fi 8 | perl detokenizer.perl -l en < tmp_gold.txt > tmp_gold.txt.a 9 | perl detokenizer.perl -l en < tmp_pred.txt > tmp_pred.txt.a 10 | perl multi-bleu.perl tmp_gold.txt < tmp_pred.txt 11 | perl multi-bleu-detok.perl tmp_gold.txt.a < tmp_pred.txt.a 12 | -------------------------------------------------------------------------------- /examples/pytorch/hgt/README.md: -------------------------------------------------------------------------------- 1 | # Heterogeneous Graph Transformer (HGT) 2 | 3 | [Alternative PyTorch-Geometric implementation](https://github.com/acbull/pyHGT) 4 | 5 | [“**Heterogeneous Graph Transformer**”](https://arxiv.org/abs/2003.01332) is a graph neural network architecture that can deal with large-scale heterogeneous and dynamic graphs. 6 | 7 | 8 | This toy experiment is based on DGL's official [tutorial](https://docs.dgl.ai/en/0.4.x/generated/dgl.heterograph.html). As the ACM datasets doesn't have input feature, we simply randomly assign features for each node. Such process can be simply replaced by any prepared features. 9 | 10 | 11 | The reference performance against R-GCN and MLP running 5 times: 12 | 13 | 14 | | Model | Test Accuracy | # Parameter | 15 | | --------- | --------------- | -------------| 16 | | 2-layer HGT | 0.465 ± 0.007 | 2,176,324 | 17 | | 2-layer RGCN | 0.392 ± 0.013 | 416,340 | 18 | | MLP | 0.132 ± 0.003 | 200,974 | 19 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/PSS/Smooth_AP/README.md: -------------------------------------------------------------------------------- 1 | # Smooth_AP 2 | 3 | Referenced from the ECCV '20 paper ["Smooth-AP: Smoothing the Path Towards Large-Scale Image Retrieval"](https://www.robots.ox.ac.uk/~vgg/research/smooth-ap/), reference code is from https://github.com/Andrew-Brown1/Smooth_AP. 4 | 5 | 6 | ![teaser](https://github.com/Andrew-Brown1/Smooth_AP/blob/master/ims/teaser.png) 7 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/PSS/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/hilander/PSS/__init__.py -------------------------------------------------------------------------------- /examples/pytorch/hilander/PSS/test.sh: -------------------------------------------------------------------------------- 1 | python Smooth_AP/src/evaluate_model.py \ 2 | --dataset Inaturalist \ 3 | --bs 384 \ 4 | --source_path ~/code/Smooth_AP/data/ --embed_dim 128 \ 5 | --resume $CHECKPOINT_PATH \ 6 | --class_num 948 --loss smoothap \ 7 | --trainset lin_train_set1.txt \ 8 | --testset Inaturalist_test_set1.txt \ 9 | --linsize 29011 --uinsize 18403 -------------------------------------------------------------------------------- /examples/pytorch/hilander/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/hilander/__init__.py -------------------------------------------------------------------------------- /examples/pytorch/hilander/checkpoint/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/hilander/checkpoint/.gitkeep -------------------------------------------------------------------------------- /examples/pytorch/hilander/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/hilander/data/.gitkeep -------------------------------------------------------------------------------- /examples/pytorch/hilander/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | from .dataset import LanderDataset 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .graphconv import GraphConv 2 | from .lander import LANDER 3 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/test_deepglint_hannah.sh: -------------------------------------------------------------------------------- 1 | python test_subg.py --data_path data/subcenter_arcface_deepglint_hannah_features.pkl --model_filename checkpoint/deepglint_sampler.pth --knn_k 10 --tau 0.8 --level 10 --threshold prob --faiss_gpu --hidden 512 --num_conv 1 --batch_size 4096 --early_stop --use_cluster_feat 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/test_deepglint_imdb.sh: -------------------------------------------------------------------------------- 1 | python test_subg.py --data_path data/subcenter_arcface_deepglint_imdb_features.pkl --model_filename checkpoint/deepglint_sampler.pth --knn_k 10 --tau 0.8 --level 10 --threshold prob --faiss_gpu --hidden 512 --num_conv 1 --batch_size 4096 --early_stop --use_cluster_feat 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/test_deepglint_imdb_sampled_as_deepglint.sh: -------------------------------------------------------------------------------- 1 | python test_subg.py --data_path data/subcenter_arcface_deepglint_imdb_features_sampled_as_deepglint_1_in_10.pkl --model_filename checkpoint/deepglint_sampler.pth --knn_k 10 --tau 0.8 --level 10 --threshold prob --faiss_gpu --hidden 512 --num_conv 1 --batch_size 4096 --early_stop --use_cluster_feat 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/test_inat.sh: -------------------------------------------------------------------------------- 1 | python test_subg.py --data_path data/inat2018_test.pkl --model_filename checkpoint/inat.ckpt --knn_k 10 --tau 0.1 --level 10 --threshold prob --faiss_gpu --hidden 512 --num_conv 1 --gat --batch_size 4096 --early_stop 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/test_inat_train_on_resampled_1_in_6_per_class.sh: -------------------------------------------------------------------------------- 1 | python test_subg.py --data_path data/inat2018_test.pkl --model_filename checkpoint/inat_resampled_1_in_6_per_class.ckpt --knn_k 10 --tau 0.1 --level 10 --threshold prob --faiss_gpu --hidden 512 --num_conv 1 --gat --batch_size 4096 --early_stop 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/train_deepglint.sh: -------------------------------------------------------------------------------- 1 | python train_subg.py --data_path data/subcenter_arcface_deepglint_train_1_in_10_recreated.pkl --model_filename checkpoint/deepglint_sampler.pth --knn_k 10,5,3 --levels 2,3,4 --faiss_gpu --hidden 512 --epochs 250 --lr 0.01 --batch_size 4096 --num_conv 1 --balance --use_cluster_feat 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/train_inat.sh: -------------------------------------------------------------------------------- 1 | python train_subg.py --data_path data/inat2018_train_dedup_inter_intra.pkl --model_filename checkpoint/inat.ckpt --knn_k 10,5,3 --levels 2,3,4 --faiss_gpu --hidden 512 --epochs 250 --lr 0.01 --batch_size 4096 --num_conv 1 --gat --balance 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/scripts/train_inat_resampled_1_in_6_per_class.sh: -------------------------------------------------------------------------------- 1 | python train_subg.py --data_path data/inat2018_train_dedup_inter_intra_1_in_6_per_class.pkl --model_filename checkpoint/inat_resampled_1_in_6_per_class.ckpt --knn_k 10,5,3 --levels 2,3,4 --faiss_gpu --hidden 512 --epochs 250 --lr 0.01 --batch_size 4096 --num_conv 1 --gat --balance 2 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from .adjacency import * 5 | from .deduce import * 6 | from .density import * 7 | from .evaluate import * 8 | from .faiss_gpu import faiss_search_approx_knn 9 | from .faiss_search import faiss_search_knn 10 | from .knn import * 11 | from .metrics import * 12 | from .misc import * 13 | -------------------------------------------------------------------------------- /examples/pytorch/hilander/utils/adjacency.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | This file re-uses implementation from https://github.com/yl-1993/learn-to-cluster 5 | """ 6 | 7 | import numpy as np 8 | import scipy.sparse as sp 9 | from scipy.sparse import coo_matrix 10 | 11 | 12 | def row_normalize(mx): 13 | """Row-normalize sparse matrix""" 14 | rowsum = np.array(mx.sum(1)) 15 | # if rowsum <= 0, keep its previous value 16 | rowsum[rowsum <= 0] = 1 17 | r_inv = np.power(rowsum, -1).flatten() 18 | r_inv[np.isinf(r_inv)] = 0.0 19 | r_mat_inv = sp.diags(r_inv) 20 | mx = r_mat_inv.dot(mx) 21 | return mx, r_inv 22 | 23 | 24 | def sparse_mx_to_indices_values(sparse_mx): 25 | sparse_mx = sparse_mx.tocoo().astype(np.float32) 26 | indices = np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64) 27 | values = sparse_mx.data 28 | shape = np.array(sparse_mx.shape) 29 | return indices, values, shape 30 | -------------------------------------------------------------------------------- /examples/pytorch/jtnn/README.md: -------------------------------------------------------------------------------- 1 | Junction Tree VAE - example for training 2 | ========================================== 3 | 4 | This is a direct modification from https://github.com/wengong-jin/icml18-jtnn 5 | 6 | Dependencies 7 | -------------- 8 | * PyTorch 0.4.1+ 9 | * RDKit=2018.09.3.0 10 | * requests 11 | 12 | How to run 13 | ----------- 14 | 15 | To run the model, use 16 | ``` 17 | python3 vaetrain_dgl.py 18 | ``` 19 | The script will automatically download the data, which is the same as the one in the 20 | original repository. 21 | 22 | To disable CUDA, run with `NOCUDA` variable set: 23 | ``` 24 | NOCUDA=1 python3 vaetrain_dgl.py 25 | ``` 26 | 27 | To decode for new molecules, run 28 | ``` 29 | python3 vaetrain_dgl.py -T 30 | ``` 31 | 32 | Currently, decoding involves encoding a training example, sampling from the posterior 33 | distribution, and decoding a molecule from that. 34 | -------------------------------------------------------------------------------- /examples/pytorch/jtnn/jtnn/__init__.py: -------------------------------------------------------------------------------- 1 | from .chemutils import decode_stereo 2 | from .datautils import JTNNCollator, JTNNDataset 3 | from .jtnn_vae import DGLJTNNVAE 4 | from .mol_tree import Vocab 5 | from .mpn import DGLMPN 6 | from .nnutils import cuda 7 | -------------------------------------------------------------------------------- /examples/pytorch/jtnn/jtnn/line_profiler_integration.py: -------------------------------------------------------------------------------- 1 | """ 2 | line_profiler integration 3 | """ 4 | import os 5 | 6 | if os.getenv("PROFILE", 0): 7 | import atexit 8 | 9 | import line_profiler 10 | 11 | profile = line_profiler.LineProfiler() 12 | 13 | profile_output = os.getenv("PROFILE_OUTPUT", None) 14 | if profile_output: 15 | from functools import partial 16 | 17 | atexit.register(partial(profile.dump_stats, profile_output)) 18 | else: 19 | atexit.register(profile.print_stats) 20 | else: 21 | 22 | def profile(f): 23 | return f 24 | -------------------------------------------------------------------------------- /examples/pytorch/jtnn/jtnn/mol_tree.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | import rdkit.Chem as Chem 4 | 5 | 6 | def get_slots(smiles): 7 | mol = Chem.MolFromSmiles(smiles) 8 | return [ 9 | (atom.GetSymbol(), atom.GetFormalCharge(), atom.GetTotalNumHs()) 10 | for atom in mol.GetAtoms() 11 | ] 12 | 13 | 14 | class Vocab(object): 15 | def __init__(self, smiles_list): 16 | self.vocab = smiles_list 17 | self.vmap = {x: i for i, x in enumerate(self.vocab)} 18 | self.slots = [get_slots(smiles) for smiles in self.vocab] 19 | 20 | def get_index(self, smiles): 21 | return self.vmap[smiles] 22 | 23 | def get_smiles(self, idx): 24 | return self.vocab[idx] 25 | 26 | def get_slots(self, idx): 27 | return copy.deepcopy(self.slots[idx]) 28 | 29 | def size(self): 30 | return len(self.vocab) 31 | -------------------------------------------------------------------------------- /examples/pytorch/model_zoo/README.md: -------------------------------------------------------------------------------- 1 | Model Zoo 2 | ========== 3 | 4 | Here are examples of using the model zoo. 5 | -------------------------------------------------------------------------------- /examples/pytorch/model_zoo/geometric/.gitignore: -------------------------------------------------------------------------------- 1 | MNIST/ 2 | -------------------------------------------------------------------------------- /examples/pytorch/model_zoo/geometric/README.md: -------------------------------------------------------------------------------- 1 | Geometric Deep Learning models 2 | ========= 3 | 4 | This example shows how to use geometric deep learning models defined in `dgl.nn.pytorch.conv` for 5 | graph classification. 6 | 7 | Currently we support following models: 8 | - [ChebNet](https://arxiv.org/pdf/1606.09375.pdf) 9 | - [MoNet](https://arxiv.org/pdf/1611.08402.pdf) 10 | 11 | ## Image Classification on MNIST 12 | 13 | By transforming images to graphs, graph classifcation algorithms could 14 | be applied to image classification problems. 15 | 16 | ### Usage 17 | ```bash 18 | python mnist.py --model cheb --gpu 0 19 | python mnist.py --model monet --gpu 0 20 | ``` 21 | 22 | ### Acknowledgement 23 | We thank [Xavier Bresson](https://github.com/xbresson) for providing 24 | code for graph coarsening algorithm and grid graph building in 25 | [CE7454_2019 Labs](https://github.com/xbresson/CE7454_2019/tree/master/codes/labs_lecture14/lab01_ChebGCNs). 26 | -------------------------------------------------------------------------------- /examples/pytorch/monet/README.md: -------------------------------------------------------------------------------- 1 | MoNet 2 | ===== 3 | 4 | - paper link: [Geometric deep learning on graphs and manifolds using mixture model CNNs](https://arxiv.org/pdf/1611.08402.pdf) 5 | 6 | Dependencies 7 | ============ 8 | 9 | - pytorch 1.1+ 10 | 11 | Results 12 | ======= 13 | 14 | ## Citation networks 15 | Run with following (available dataset: "cora", "citeseer", "pubmed") 16 | ```bash 17 | python3 citation.py --dataset cora --gpu 0 18 | ``` 19 | 20 | - Cora: ~0.816 21 | - Pubmed: ~0.763 22 | 23 | ## Image classification: 24 | - please refer to [model_zoo/geometric](../model_zoo/geometric). -------------------------------------------------------------------------------- /examples/pytorch/ogb/README.md: -------------------------------------------------------------------------------- 1 | # OGB Submissions 2 | 3 | This directory lists the submissions made from DGL Team to the OGB Leaderboard. 4 | 5 | Currently it contains: 6 | 7 | * OGBN-Products 8 | * GraphSAGE with Neighbor Sampling 9 | * SIGN 10 | * OGBN-Proteins 11 | * MWE-GCN and MWE-DGCN ([GCN models for graphs with multi-dimensionally weighted edges](https://cims.nyu.edu/~chenzh/files/GCN_with_edge_weights.pdf)) 12 | * OGBN-Arxiv 13 | * SIGN 14 | * OGBN-Mag 15 | * SIGN 16 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/cluster-gat/README.md: -------------------------------------------------------------------------------- 1 | # ClusterGAT 2 | Params: 1540848 3 | 4 | ## OGB Products 5 | Run `main.py` and you should directly see the result. 6 | 7 | Valid over 10 runs: 0.8985 ± 0.00224 8 | Accuracy over 10 runs: 0.79232 ± 0.007786 9 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/cluster-gat/partition_utils.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | from dgl import backend as F 7 | from dgl.transforms import metis_partition 8 | 9 | 10 | def get_partition_list(g, psize): 11 | p_gs = metis_partition(g, psize) 12 | graphs = [] 13 | for k, val in p_gs.items(): 14 | nids = val.ndata[dgl.NID] 15 | nids = F.asnumpy(nids) 16 | graphs.append(nids) 17 | return graphs 18 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/cluster-sage/README.md: -------------------------------------------------------------------------------- 1 | # Cluster-SAGE on OGB Dataset 2 | 3 | Requires DGL 0.4.3post2 or later versions. 4 | We use builtin metis to do the graph partition. 5 | 6 | ## OGB-Product 7 | 8 | Run `main.py` and you should directly see the result. 9 | 10 | Accuracy over 10 runs: 0.7830701 ± 0.0035093208 11 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/cluster-sage/partition_utils.py: -------------------------------------------------------------------------------- 1 | from time import time 2 | 3 | import dgl 4 | 5 | import numpy as np 6 | from dgl import backend as F 7 | from dgl.transforms import metis_partition 8 | 9 | 10 | def get_partition_list(g, psize): 11 | p_gs = metis_partition(g, psize) 12 | graphs = [] 13 | for k, val in p_gs.items(): 14 | nids = val.ndata[dgl.NID] 15 | nids = F.asnumpy(nids) 16 | graphs.append(nids) 17 | return graphs 18 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/deepwalk/utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def shuffle_walks(walks): 5 | seeds = torch.randperm(walks.size()[0]) 6 | return walks[seeds] 7 | 8 | 9 | def sum_up_params(model): 10 | """Count the model parameters""" 11 | n = [] 12 | n.append(model.u_embeddings.weight.cpu().data.numel() * 2) 13 | n.append(model.lookup_table.cpu().numel()) 14 | n.append(model.index_emb_posu.cpu().numel() * 2) 15 | n.append(model.grad_u.cpu().numel() * 2) 16 | 17 | try: 18 | n.append(model.index_emb_negu.cpu().numel() * 2) 19 | except: 20 | pass 21 | try: 22 | n.append(model.state_sum_u.cpu().numel() * 2) 23 | except: 24 | pass 25 | try: 26 | n.append(model.grad_avg.cpu().numel()) 27 | except: 28 | pass 29 | try: 30 | n.append(model.context_weight.cpu().numel()) 31 | except: 32 | pass 33 | 34 | print("#params " + str(sum(n))) 35 | exit() 36 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/ogbn-products/graphsage/README.md: -------------------------------------------------------------------------------- 1 | # GraphSAGE on OGB Products 2 | 3 | Requires DGL 0.4.3post2 or later versions. 4 | 5 | Run `main.py` and you should directly see the result. 6 | 7 | Accuracy over 10 runs: 0.7828772 ± 0.001568163 8 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/ogbn-products/mlp/README.md: -------------------------------------------------------------------------------- 1 | # DGL examples for ogbn-products 2 | 3 | Requires DGL 0.5 or later versions. 4 | 5 | For the score of `MLP`, run the following command and you should directly see the result. 6 | 7 | ```bash 8 | python3 mlp.py --eval-last 9 | ``` 10 | 11 | ## Results 12 | 13 | Here are the results over 10 runs. 14 | 15 | | Method | Validation Accuracy | Test Accuracy | #Parameters | 16 | |:------:|:-------------------:|:---------------:|:-----------:| 17 | | MLP | 0.7841 ± 0.0014 | 0.6320 ± 0.0013 | 535,727 | 18 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/ogbn-proteins/configure.py: -------------------------------------------------------------------------------- 1 | """Best hyperparameters found.""" 2 | import torch 3 | 4 | MWE_GCN_proteins = { 5 | "num_ew_channels": 8, 6 | "num_epochs": 2000, 7 | "in_feats": 1, 8 | "hidden_feats": 10, 9 | "out_feats": 112, 10 | "n_layers": 3, 11 | "lr": 2e-2, 12 | "weight_decay": 0, 13 | "patience": 1000, 14 | "dropout": 0.2, 15 | "aggr_mode": "sum", ## 'sum' or 'concat' for the aggregation across channels 16 | "ewnorm": "both", 17 | } 18 | 19 | MWE_DGCN_proteins = { 20 | "num_ew_channels": 8, 21 | "num_epochs": 2000, 22 | "in_feats": 1, 23 | "hidden_feats": 10, 24 | "out_feats": 112, 25 | "n_layers": 2, 26 | "lr": 1e-2, 27 | "weight_decay": 0, 28 | "patience": 300, 29 | "dropout": 0.5, 30 | "aggr_mode": "sum", 31 | "residual": True, 32 | "ewnorm": "none", 33 | } 34 | 35 | 36 | def get_exp_configure(args): 37 | if args["model"] == "MWE-GCN": 38 | return MWE_GCN_proteins 39 | elif args["model"] == "MWE-DGCN": 40 | return MWE_DGCN_proteins 41 | -------------------------------------------------------------------------------- /examples/pytorch/ogb/sign/.gitignore: -------------------------------------------------------------------------------- 1 | dataset 2 | -------------------------------------------------------------------------------- /examples/pytorch/ogb_lsc/README.md: -------------------------------------------------------------------------------- 1 | # Baselines for OGB Large-Scale Challenge (LSC) at KDD Cup 2021 2 | 3 | **Please upgrade your OGB to 1.3.1 to enable faster downloads**: 4 | 5 | - [Node Classification with MAG240M](https://dgl-data.s3-accelerate.amazonaws.com/dataset/OGB-LSC/mag240m_kddcup2021.zip) 6 | - [Link Prediction with WikiKG90M](https://dgl-data.s3-accelerate.amazonaws.com/dataset/OGB-LSC/wikikg90m_kddcup2021.zip) 7 | - [Graph Classification with PCQM4M](https://dgl-data.s3-accelerate.amazonaws.com/dataset/OGB-LSC/pcqm4m_kddcup2021.zip) 8 | 9 | 10 | # checksum md5sum of the files 11 | mag240m_kddcup2021.zip : ```bd61c9446f557fbe4430d9a7ce108b34``` 12 | 13 | wikikg90m_kddcup2021.zip : ```73d4f5dde29d78669330b4db4c12fc9c``` 14 | 15 | pcqm4m_kddcup2021.zip. : ```5144ebaa7c67d24da1a2acbe41f57f6a``` 16 | -------------------------------------------------------------------------------- /examples/pytorch/pagerank.py: -------------------------------------------------------------------------------- 1 | import dgl 2 | import dgl.function as fn 3 | import networkx as nx 4 | import torch 5 | 6 | N = 100 7 | g = nx.erdos_renyi_graph(N, 0.05) 8 | g = dgl.DGLGraph(g) 9 | 10 | DAMP = 0.85 11 | K = 10 12 | 13 | 14 | def compute_pagerank(g): 15 | g.ndata["pv"] = torch.ones(N) / N 16 | degrees = g.out_degrees(g.nodes()).type(torch.float32) 17 | for k in range(K): 18 | g.ndata["pv"] = g.ndata["pv"] / degrees 19 | g.update_all( 20 | message_func=fn.copy_u(u="pv", out="m"), 21 | reduce_func=fn.sum(msg="m", out="pv"), 22 | ) 23 | g.ndata["pv"] = (1 - DAMP) / N + DAMP * g.ndata["pv"] 24 | return g.ndata["pv"] 25 | 26 | 27 | pv = compute_pagerank(g) 28 | print(pv) 29 | -------------------------------------------------------------------------------- /examples/pytorch/pointcloud/edgeconv/README.md: -------------------------------------------------------------------------------- 1 | Dynamic EdgeConv 2 | ==== 3 | 4 | This is a reproduction of the paper [Dynamic Graph CNN for Learning on Point 5 | Clouds](https://arxiv.org/pdf/1801.07829.pdf). 6 | 7 | The reproduced experiment is the 40-class classification on the ModelNet40 8 | dataset. The sampled point clouds are identical to that of 9 | [PointNet](https://github.com/charlesq34/pointnet). 10 | 11 | To train and test the model, simply run 12 | 13 | ```python 14 | python main.py 15 | ``` 16 | 17 | The model currently takes 3 minutes to train an epoch on Tesla V100, and an 18 | additional 17 seconds to run a validation and 20 seconds to run a test. 19 | 20 | The best validation performance is 93.5% with a test performance of 91.8%. 21 | 22 | ## Dependencies 23 | 24 | * `h5py` 25 | * `tqdm` 26 | -------------------------------------------------------------------------------- /examples/pytorch/pointcloud/pointnet/vis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/examples/pytorch/pointcloud/pointnet/vis.png -------------------------------------------------------------------------------- /examples/pytorch/rgat/README.md: -------------------------------------------------------------------------------- 1 | Relational Graph Attention Networks (RGAT) 2 | ============== 3 | This is an adaptation of RGCN where graph convolution is replaced with graph attention. 4 | 5 | Dependencies 6 | ------------ 7 | - torchmetrics 0.11.4 8 | 9 | Install as follows: 10 | ```bash 11 | pip install torchmetrics==0.11.4 12 | ``` 13 | 14 | How to Run 15 | ------- 16 | 17 | Run with the following for node classification on ogbn-mag dataset 18 | ```bash 19 | python train.py 20 | ``` 21 | 22 | 23 | Summary 24 | ------- 25 | * ogbn-mag (test acc.): ~0.3647 26 | -------------------------------------------------------------------------------- /examples/pytorch/rgcn-hetero/.gitignore: -------------------------------------------------------------------------------- 1 | *.pth 2 | *.pt 3 | -------------------------------------------------------------------------------- /examples/pytorch/rgcn/experimental/preprocessing_dist_training/edges/identity1/sample.csv: -------------------------------------------------------------------------------- 1 | identity1,0,0,1 2 | identity1,1,0,2 3 | 4 | -------------------------------------------------------------------------------- /examples/pytorch/rgcn/experimental/preprocessing_dist_training/edges/identity2/sample.csv: -------------------------------------------------------------------------------- 1 | identity2,0,1,2 2 | identity2,1,0,2 3 | 4 | -------------------------------------------------------------------------------- /examples/pytorch/rgcn/experimental/preprocessing_dist_training/edges/identity3/sample.csv: -------------------------------------------------------------------------------- 1 | identity3,0,0,2 2 | -------------------------------------------------------------------------------- /examples/pytorch/rgcn/experimental/preprocessing_dist_training/nodes/order/sample.csv: -------------------------------------------------------------------------------- 1 | 171-0000102-1785122,0,2021-06-01 21:15:33,18604601535 2 | 171-0000550-1206725,1,2021-06-08 12:53:53,19613747325 3 | 171-0000784-4201160,2,2021-06-05 16:27:42,8348611025 4 | -------------------------------------------------------------------------------- /examples/pytorch/sagpool/grid_search_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "arch": ["hierarchical", "global"], 3 | "hidden": [16, 32, 64, 128], 4 | "pool_ratio": [0.25, 0.5], 5 | "lr": [1e-2, 5e-2, 1e-3, 5e-3, 1e-4, 5e-4], 6 | "weight_decay": [1e-2, 1e-3, 1e-4, 1e-5], 7 | "dataset": ["DD", "PROTEINS", "NCI1", "NCI109", "Mutagenicity"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/pytorch/sign/README.md: -------------------------------------------------------------------------------- 1 | SIGN: Scalable Inception Graph Neural Networks 2 | =============== 3 | 4 | - paper link: [https://arxiv.org/pdf/2004.11198.pdf](https://arxiv.org/pdf/2004.11198.pdf) 5 | 6 | Requirements 7 | ---------------- 8 | 9 | ```bash 10 | pip install requests ogb 11 | ``` 12 | 13 | Results 14 | --------------- 15 | ### [Ogbn-products](https://ogb.stanford.edu/docs/nodeprop/#ogbn-products) (Amazon co-purchase dataset) 16 | 17 | ```bash 18 | python sign.py --dataset amazon 19 | ``` 20 | 21 | Test accuracy: mean 0.78672, std 0.00059 22 | 23 | ### Reddit 24 | ```bash 25 | python sign.py --dataset reddit 26 | ``` 27 | 28 | Test accuracy: mean 0.96326, std 0.00010 29 | -------------------------------------------------------------------------------- /examples/pytorch/stgcn_wave/load_data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import torch 4 | 5 | 6 | def load_data(file_path, len_train, len_val): 7 | df = pd.read_csv(file_path, header=None).values.astype(float) 8 | train = df[:len_train] 9 | val = df[len_train : len_train + len_val] 10 | test = df[len_train + len_val :] 11 | return train, val, test 12 | 13 | 14 | def data_transform(data, n_his, n_pred, device): 15 | # produce data slices for training and testing 16 | n_route = data.shape[1] 17 | l = len(data) 18 | num = l - n_his - n_pred 19 | x = np.zeros([num, 1, n_his, n_route]) 20 | y = np.zeros([num, n_route]) 21 | 22 | cnt = 0 23 | for i in range(l - n_his - n_pred): 24 | head = i 25 | tail = i + n_his 26 | x[cnt, :, :, :] = data[head:tail].reshape(1, n_his, n_route) 27 | y[cnt] = data[tail + n_pred - 1] 28 | cnt += 1 29 | return torch.Tensor(x).to(device), torch.Tensor(y).to(device) 30 | -------------------------------------------------------------------------------- /examples/pytorch/tagcn/README.md: -------------------------------------------------------------------------------- 1 | Topology Adaptive Graph Convolutional networks (TAGCN) 2 | ============ 3 | 4 | - Paper link: [https://arxiv.org/abs/1710.10370](https://arxiv.org/abs/1710.10370) 5 | 6 | Dependencies 7 | ------------ 8 | - PyTorch 0.4.1+ 9 | - requests 10 | 11 | ``bash 12 | pip install torch requests 13 | `` 14 | 15 | Results 16 | ------- 17 | Run with following (available dataset: "cora", "citeseer", "pubmed") 18 | ```bash 19 | python3 train.py --dataset cora --gpu 0 --self-loop 20 | ``` 21 | 22 | * cora: ~0.812 (0.804-0.823) (paper: 0.833) 23 | * citeseer: ~0.715 (paper: 0.714) 24 | * pubmed: ~0.794 (paper: 0.811) -------------------------------------------------------------------------------- /examples/pytorch/tgn/README.md: -------------------------------------------------------------------------------- 1 | Temporal Graph Neural Network (TGN) 2 | === 3 | 4 | The example was temporarily removed due to the change in the `DataLoader` 5 | interface in DGL 1.0. Please refer to the v0.9 example 6 | [here](https://github.com/dmlc/dgl/tree/0.9.x/examples/pytorch/tgn). 7 | -------------------------------------------------------------------------------- /examples/pytorch/transformer/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | data/ 3 | scripts/ 4 | checkpoints/ 5 | log/ 6 | *__pycache__* 7 | *.pdf 8 | *.tar.gz 9 | *.zip 10 | *.pyc 11 | *.lprof 12 | *.swp 13 | -------------------------------------------------------------------------------- /examples/pytorch/transformer/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from .models import * 2 | -------------------------------------------------------------------------------- /examples/pytorch/transformer/modules/config.py: -------------------------------------------------------------------------------- 1 | # Define some global constants/variables 2 | VIZ_IDX = 3 3 | -------------------------------------------------------------------------------- /examples/pytorch/transformer/modules/functions.py: -------------------------------------------------------------------------------- 1 | import torch as th 2 | 3 | 4 | def src_dot_dst(src_field, dst_field, out_field): 5 | """ 6 | This function serves as a surrogate for `src_dot_dst` built-in apply_edge function. 7 | """ 8 | 9 | def func(edges): 10 | return { 11 | out_field: (edges.src[src_field] * edges.dst[dst_field]).sum( 12 | -1, keepdim=True 13 | ) 14 | } 15 | 16 | return func 17 | 18 | 19 | def scaled_exp(field, c): 20 | """ 21 | This function applies $exp(x / c)$ for input $x$, which is required by *Scaled Dot-Product Attention* mentioned in the paper. 22 | """ 23 | 24 | def func(edges): 25 | return {field: th.exp((edges.data[field] / c).clamp(-10, 10))} 26 | 27 | return func 28 | -------------------------------------------------------------------------------- /examples/pytorch/transformer/optims/__init__.py: -------------------------------------------------------------------------------- 1 | from .noamopt import * 2 | -------------------------------------------------------------------------------- /examples/pytorch/vrgcn/README.md: -------------------------------------------------------------------------------- 1 | VRGCN (control variate sampling) 2 | ================================ 3 | 4 | Paper: https://arxiv.org/abs/1710.10568 5 | 6 | Run with 7 | 8 | ```bash 9 | python3 train_cv.py --num-epochs 30 10 | python3 train_cv_multi_gpu.py --num-epochs 30 --gpu 0,1,2,3 # multi-GPU 11 | ``` 12 | -------------------------------------------------------------------------------- /examples/tensorflow/dgi/README.md: -------------------------------------------------------------------------------- 1 | Deep Graph Infomax (DGI) 2 | ======================== 3 | 4 | - Paper link: [https://arxiv.org/abs/1809.10341](https://arxiv.org/abs/1809.10341) 5 | - Author's code repo (in Pytorch): 6 | [https://github.com/PetarV-/DGI](https://github.com/PetarV-/DGI) 7 | 8 | Dependencies 9 | ------------ 10 | - tensorflow 2.1+ 11 | - requests 12 | 13 | ```bash 14 | pip install tensorflow requests 15 | ``` 16 | 17 | How to run 18 | ---------- 19 | 20 | Run with following: 21 | 22 | ```bash 23 | python3 train.py --dataset=cora --gpu=0 --self-loop 24 | ``` 25 | 26 | ```bash 27 | python3 train.py --dataset=citeseer --gpu=0 28 | ``` 29 | 30 | ```bash 31 | python3 train.py --dataset=pubmed --gpu=0 32 | ``` 33 | 34 | Results 35 | ------- 36 | * cora: ~81.6 (80.9-82.9) (paper: 82.3) 37 | * citeseer: ~70.2 (paper: 71.8) 38 | * pubmed: ~77.2 (paper: 76.8) 39 | -------------------------------------------------------------------------------- /examples/tensorflow/gat/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class EarlyStopping: 5 | def __init__(self, patience=10): 6 | self.patience = patience 7 | self.counter = 0 8 | self.best_score = None 9 | self.early_stop = False 10 | 11 | def step(self, acc, model): 12 | score = acc 13 | if self.best_score is None: 14 | self.best_score = score 15 | self.save_checkpoint(model) 16 | elif score < self.best_score: 17 | self.counter += 1 18 | print( 19 | f"EarlyStopping counter: {self.counter} out of {self.patience}" 20 | ) 21 | if self.counter >= self.patience: 22 | self.early_stop = True 23 | else: 24 | self.best_score = score 25 | self.save_checkpoint(model) 26 | self.counter = 0 27 | return self.early_stop 28 | 29 | def save_checkpoint(self, model): 30 | """Saves model when validation loss decrease.""" 31 | model.save_weights("es_checkpoint.pb") 32 | -------------------------------------------------------------------------------- /featgraph/README.md: -------------------------------------------------------------------------------- 1 | # FeatGraph-DGL 2 | 3 | FeatGraph is an efficient backend for Graph Neural Networks based on TVM. 4 | 5 | - Original repo: https://github.com/amazon-research/FeatGraph 6 | - SC2020 Paper: https://www.csl.cornell.edu/~zhiruz/pdfs/featgraph-sc2020.pdf 7 | 8 | This folder contains the code for integrating featgraph kernels to DGL. 9 | 10 | ## Usage 11 | 12 | After building DGL with `USE_TVM=ON`, you should be able to run: 13 | ```bash 14 | python test.py 15 | ``` 16 | to verify correctness. 17 | 18 | ## Reference 19 | 20 | - [TVM Tutorial on Deploy TVM Module using C++ API](https://tvm.apache.org/docs/deploy/cpp_deploy.html). 21 | 22 | -------------------------------------------------------------------------------- /featgraph/include/featgraph.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 by Contributors 3 | * @file featgraph/include/featgraph.h 4 | * @brief FeatGraph kernel headers. 5 | */ 6 | #ifndef FEATGRAPH_H_ 7 | #define FEATGRAPH_H_ 8 | 9 | #include 10 | 11 | namespace dgl { 12 | namespace featgraph { 13 | 14 | /* @brief Load Featgraph module from given path. */ 15 | void LoadFeatGraphModule(const std::string& path); 16 | 17 | /* @brief Call Featgraph's SDDMM kernel. */ 18 | void SDDMMTreeReduction( 19 | DLManagedTensor* row, DLManagedTensor* col, DLManagedTensor* lhs, 20 | DLManagedTensor* rhs, DLManagedTensor* out); 21 | 22 | } // namespace featgraph 23 | } // namespace dgl 24 | 25 | #endif // FEATGRAPH_H_ 26 | -------------------------------------------------------------------------------- /featgraph/test.py: -------------------------------------------------------------------------------- 1 | import dgl 2 | import dgl.backend as F 3 | import torch 4 | 5 | g = dgl.rand_graph(10, 15).int().to(torch.device(0)) 6 | gidx = g._graph 7 | u = torch.rand((10, 2, 8), device=torch.device(0)) 8 | v = torch.rand((10, 2, 8), device=torch.device(0)) 9 | e = dgl.ops.gsddmm(g, "dot", u, v) 10 | print(e) 11 | e = torch.zeros((15, 2, 1), device=torch.device(0)) 12 | u = F.zerocopy_to_dgl_ndarray(u) 13 | v = F.zerocopy_to_dgl_ndarray(v) 14 | e = F.zerocopy_to_dgl_ndarray_for_write(e) 15 | dgl.sparse._CAPI_FG_LoadModule("../build/featgraph/libfeatgraph_kernels.so") 16 | dgl.sparse._CAPI_FG_SDDMMTreeReduction(gidx, u, v, e) 17 | print(e) 18 | -------------------------------------------------------------------------------- /graphbolt/build.bat: -------------------------------------------------------------------------------- 1 | REM Helper script to build Graphbolt libraries for PyTorch 2 | @ECHO OFF 3 | SETLOCAL EnableDelayedExpansion 4 | 5 | MD "%BINDIR%\graphbolt" 6 | DEL /S /Q build 7 | MD build 8 | PUSHD build 9 | 10 | IF x%1x == xx GOTO single 11 | 12 | FOR %%X IN (%*) DO ( 13 | DEL /S /Q * 14 | "%CMAKE_COMMAND%" -DCMAKE_CONFIGURATION_TYPES=Release -DPYTHON_INTERP=%%X .. -G "Visual Studio 16 2019" || EXIT /B 1 15 | msbuild graphbolt.sln /m /nr:false || EXIT /B 1 16 | COPY /Y Release\*.dll "%BINDIR%\graphbolt" || EXIT /B 1 17 | ) 18 | 19 | GOTO end 20 | 21 | :single 22 | 23 | DEL /S /Q * 24 | "%CMAKE_COMMAND%" -DCMAKE_CONFIGURATION_TYPES=Release .. -G "Visual Studio 16 2019" || EXIT /B 1 25 | msbuild graphbolt.sln /m /nr:false || EXIT /B 1 26 | COPY /Y Release\*.dll "%BINDIR%\graphbolt" || EXIT /B 1 27 | 28 | :end 29 | POPD 30 | 31 | ENDLOCAL 32 | -------------------------------------------------------------------------------- /graphbolt/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Helper script to build graphbolt libraries for PyTorch 3 | set -e 4 | 5 | mkdir -p build 6 | mkdir -p $BINDIR/graphbolt 7 | cd build 8 | 9 | if [ $(uname) = 'Darwin' ]; then 10 | CPSOURCE=*.dylib 11 | else 12 | CPSOURCE=*.so 13 | fi 14 | 15 | echo $CMAKE_FLAGS 16 | 17 | if [ $# -eq 0 ]; then 18 | $CMAKE_COMMAND $CMAKE_FLAGS .. 19 | make -j 20 | cp -v $CPSOURCE $BINDIR/graphbolt 21 | else 22 | for PYTHON_INTERP in $@; do 23 | TORCH_VER=$($PYTHON_INTERP -c 'import torch; print(torch.__version__.split("+")[0])') 24 | mkdir -p $TORCH_VER 25 | cd $TORCH_VER 26 | $CMAKE_COMMAND $CMAKE_FLAGS -DPYTHON_INTERP=$PYTHON_INTERP ../.. 27 | make -j 28 | cp -v $CPSOURCE $BINDIR/graphbolt 29 | cd .. 30 | done 31 | fi 32 | -------------------------------------------------------------------------------- /graphbolt/find_cmake.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import torch 4 | 5 | cmake_prefix_path = getattr( 6 | torch.utils, 7 | "cmake_prefix_path", 8 | os.path.join(os.path.dirname(torch.__file__), "share", "cmake"), 9 | ) 10 | version = torch.__version__.split("+")[0] 11 | print(";".join([cmake_prefix_path, version])) 12 | -------------------------------------------------------------------------------- /graphbolt/include/graphbolt/compact.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/graphbolt/include/graphbolt/compact.h -------------------------------------------------------------------------------- /graphbolt/include/graphbolt/neighbor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/graphbolt/include/graphbolt/neighbor.h -------------------------------------------------------------------------------- /graphbolt/src/compact.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/graphbolt/src/compact.cc -------------------------------------------------------------------------------- /graphbolt/src/neighbor.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/graphbolt/src/neighbor.cc -------------------------------------------------------------------------------- /include/dgl/array.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 by Contributors 3 | * @file dgl/array.h 4 | * @brief Common array operations required by DGL. 5 | * 6 | * Note that this is not meant for a full support of array library such as ATen. 7 | * Only a limited set of operators required by DGL are implemented. 8 | */ 9 | #ifndef DGL_ARRAY_H_ 10 | #define DGL_ARRAY_H_ 11 | #include "./aten/array_ops.h" 12 | #include "./aten/coo.h" 13 | #include "./aten/csr.h" 14 | #include "./aten/macro.h" 15 | #include "./aten/spmat.h" 16 | #include "./aten/types.h" 17 | #endif // DGL_ARRAY_H_ 18 | -------------------------------------------------------------------------------- /include/dgl/env_variable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023 by Contributors 3 | * @file dgl/env_variable.h 4 | * @brief Class about envrionment variables. 5 | */ 6 | #ifndef DGL_ENV_VARIABLE_H_ 7 | #define DGL_ENV_VARIABLE_H_ 8 | 9 | #include 10 | 11 | namespace dgl { 12 | 13 | static const char* kDGLParallelForGrainSize = 14 | std::getenv("DGL_PARALLEL_FOR_GRAIN_SIZE"); 15 | 16 | } // namespace dgl 17 | 18 | #endif // DGL_ENV_VARIABLE_H_ 19 | -------------------------------------------------------------------------------- /include/dgl/graph_serializer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2018 by Contributors 3 | * @file graph/graph_serializer.cc 4 | * @brief DGL serializer APIs 5 | */ 6 | 7 | #ifndef DGL_GRAPH_SERIALIZER_H_ 8 | #define DGL_GRAPH_SERIALIZER_H_ 9 | 10 | #include 11 | namespace dgl { 12 | 13 | // Util class to call the private/public empty constructor, which is needed for 14 | // serialization 15 | class Serializer { 16 | public: 17 | template 18 | static T* new_object() { 19 | return new T(); 20 | } 21 | 22 | template 23 | static std::shared_ptr make_shared() { 24 | return std::shared_ptr(new T()); 25 | } 26 | }; 27 | } // namespace dgl 28 | 29 | #endif // DGL_GRAPH_SERIALIZER_H_ 30 | -------------------------------------------------------------------------------- /include/dgl/runtime/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2019 by Contributors 3 | * @file runtime/config.h 4 | * @brief DGL runtime config 5 | */ 6 | 7 | #ifndef DGL_RUNTIME_CONFIG_H_ 8 | #define DGL_RUNTIME_CONFIG_H_ 9 | 10 | namespace dgl { 11 | namespace runtime { 12 | 13 | class Config { 14 | public: 15 | static Config* Global() { 16 | static Config config; 17 | return &config; 18 | } 19 | 20 | // Enabling or disable use libxsmm for Spmm 21 | void EnableLibxsmm(bool); 22 | bool IsLibxsmmAvailable() const; 23 | 24 | private: 25 | Config(); 26 | bool libxsmm_; 27 | }; 28 | 29 | } // namespace runtime 30 | } // namespace dgl 31 | 32 | #endif // DGL_RUNTIME_CONFIG_H_ 33 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.black] 2 | 3 | line-length = 80 4 | -------------------------------------------------------------------------------- /python/dgl/_api_internal.py: -------------------------------------------------------------------------------- 1 | """Namespace for internal apis.""" 2 | -------------------------------------------------------------------------------- /python/dgl/_ffi/README.md: -------------------------------------------------------------------------------- 1 | # C API and runtime 2 | 3 | Borrowed and adapted from TVM project. (commit: 2ce5277) 4 | -------------------------------------------------------------------------------- /python/dgl/_ffi/__init__.py: -------------------------------------------------------------------------------- 1 | """C interfacing code. 2 | 3 | This namespace contains everything that interacts with C code. 4 | Most C related object are ctypes compatible, which means 5 | they contains a handle field that is ctypes.c_void_p and can 6 | be used via ctypes function calls. 7 | 8 | Some performance critical functions are implemented by cython 9 | and have a ctypes fallback implementation. 10 | """ 11 | -------------------------------------------------------------------------------- /python/dgl/_ffi/_ctypes/__init__.py: -------------------------------------------------------------------------------- 1 | """ctypes specific implementation of FFI""" 2 | -------------------------------------------------------------------------------- /python/dgl/_ffi/_cy2/__init__.py: -------------------------------------------------------------------------------- 1 | """cython2 namespace""" 2 | -------------------------------------------------------------------------------- /python/dgl/_ffi/_cy3/__init__.py: -------------------------------------------------------------------------------- 1 | """cython3 namespace""" 2 | -------------------------------------------------------------------------------- /python/dgl/_ffi/_cython/.gitignore: -------------------------------------------------------------------------------- 1 | *.cpp 2 | -------------------------------------------------------------------------------- /python/dgl/_ffi/_cython/core.pyx: -------------------------------------------------------------------------------- 1 | include "./base.pxi" 2 | include "./object.pxi" 3 | include "./function.pxi" 4 | include "./ndarray.pxi" 5 | -------------------------------------------------------------------------------- /python/dgl/_ffi/capi.py: -------------------------------------------------------------------------------- 1 | """Init all C APIs in the default namespace.""" 2 | from .function import _init_api 3 | 4 | __all__ = _init_api("dgl.capi", __name__) 5 | -------------------------------------------------------------------------------- /python/dgl/backend/mxnet/__init__.py: -------------------------------------------------------------------------------- 1 | from .sparse import * 2 | from .tensor import * 3 | -------------------------------------------------------------------------------- /python/dgl/backend/mxnet/sparse_optim.py: -------------------------------------------------------------------------------- 1 | """Sparse optimizer is not supported for mxnet""" 2 | -------------------------------------------------------------------------------- /python/dgl/backend/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | from .sparse import * 2 | from .tensor import * 3 | -------------------------------------------------------------------------------- /python/dgl/backend/tensorflow/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true" 4 | 5 | from .sparse import * 6 | from .tensor import * 7 | -------------------------------------------------------------------------------- /python/dgl/backend/tensorflow/sparse_optim.py: -------------------------------------------------------------------------------- 1 | """Sparse optimizer is not supported for tensorflow""" 2 | -------------------------------------------------------------------------------- /python/dgl/cuda/__init__.py: -------------------------------------------------------------------------------- 1 | """ CUDA wrappers """ 2 | from .. import backend as F 3 | 4 | if F.get_preferred_backend() == "pytorch": 5 | from . import nccl 6 | -------------------------------------------------------------------------------- /python/dgl/dataloading/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for dataloaders and samplers.""" 2 | from .. import backend as F 3 | from . import negative_sampler 4 | from .base import * 5 | from .cluster_gcn import * 6 | from .graphsaint import * 7 | from .labor_sampler import * 8 | from .neighbor_sampler import * 9 | from .shadow import * 10 | 11 | if F.get_preferred_backend() == "pytorch": 12 | from .dataloader import * 13 | from .dist_dataloader import * 14 | -------------------------------------------------------------------------------- /python/dgl/distgnn/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This package contains DistGNN and Libra based graph partitioning tools. 3 | """ 4 | from . import partition, tools 5 | -------------------------------------------------------------------------------- /python/dgl/distgnn/partition/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This package contains Libra graph partitioner. 3 | """ 4 | from .libra_partition import partition_graph 5 | -------------------------------------------------------------------------------- /python/dgl/distgnn/tools/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This package contains extra routines related to Libra graph partitioner. 3 | """ 4 | from .tools import load_proteins 5 | -------------------------------------------------------------------------------- /python/dgl/distributed/__init__.py: -------------------------------------------------------------------------------- 1 | """DGL distributed module""" 2 | from . import optim 3 | from .dist_context import exit_client, initialize 4 | from .dist_dataloader import DistDataLoader 5 | from .dist_graph import DistGraph, DistGraphServer, edge_split, node_split 6 | from .dist_tensor import DistTensor 7 | from .graph_partition_book import GraphPartitionBook, PartitionPolicy 8 | from .graph_services import * 9 | from .kvstore import KVClient, KVServer 10 | from .nn import * 11 | from .partition import ( 12 | load_partition, 13 | load_partition_book, 14 | load_partition_feats, 15 | partition_graph, 16 | ) 17 | from .rpc import * 18 | from .rpc_client import connect_to_server, shutdown_servers 19 | from .rpc_server import start_server 20 | from .server_state import ServerState 21 | -------------------------------------------------------------------------------- /python/dgl/distributed/constants.py: -------------------------------------------------------------------------------- 1 | """Define all the constants used by DGL rpc""" 2 | 3 | # Maximum size of message queue in bytes 4 | MAX_QUEUE_SIZE = 20 * 1024 * 1024 * 1024 5 | 6 | SERVER_EXIT = "server_exit" 7 | SERVER_KEEP_ALIVE = "server_keep_alive" 8 | 9 | DEFAULT_NTYPE = "_N" 10 | DEFAULT_ETYPE = (DEFAULT_NTYPE, "_E", DEFAULT_NTYPE) 11 | -------------------------------------------------------------------------------- /python/dgl/distributed/nn/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl distributed.optims.""" 2 | import importlib 3 | import os 4 | import sys 5 | 6 | from ...backend import backend_name 7 | from ...utils import expand_as_pair 8 | 9 | 10 | def _load_backend(mod_name): 11 | mod = importlib.import_module(".%s" % mod_name, __name__) 12 | thismod = sys.modules[__name__] 13 | for api, obj in mod.__dict__.items(): 14 | setattr(thismod, api, obj) 15 | 16 | 17 | _load_backend(backend_name) 18 | -------------------------------------------------------------------------------- /python/dgl/distributed/nn/mxnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/distributed/nn/mxnet/__init__.py -------------------------------------------------------------------------------- /python/dgl/distributed/nn/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl distributed sparse optimizer for pytorch.""" 2 | from .sparse_emb import DistEmbedding 3 | -------------------------------------------------------------------------------- /python/dgl/distributed/nn/tensorflow/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/distributed/nn/tensorflow/__init__.py -------------------------------------------------------------------------------- /python/dgl/distributed/optim/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl distributed.optims.""" 2 | import importlib 3 | import os 4 | import sys 5 | 6 | from ...backend import backend_name 7 | from ...utils import expand_as_pair 8 | 9 | 10 | def _load_backend(mod_name): 11 | mod = importlib.import_module(".%s" % mod_name, __name__) 12 | thismod = sys.modules[__name__] 13 | for api, obj in mod.__dict__.items(): 14 | setattr(thismod, api, obj) 15 | 16 | 17 | _load_backend(backend_name) 18 | -------------------------------------------------------------------------------- /python/dgl/distributed/optim/mxnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/distributed/optim/mxnet/__init__.py -------------------------------------------------------------------------------- /python/dgl/distributed/optim/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl distributed sparse optimizer for pytorch.""" 2 | from .sparse_optim import SparseAdagrad, SparseAdam 3 | -------------------------------------------------------------------------------- /python/dgl/distributed/optim/tensorflow/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/distributed/optim/tensorflow/__init__.py -------------------------------------------------------------------------------- /python/dgl/distributed/shared_mem_utils.py: -------------------------------------------------------------------------------- 1 | """Define utility functions for shared memory.""" 2 | 3 | from .. import backend as F, ndarray as nd 4 | from .._ffi.ndarray import empty_shared_mem 5 | 6 | DTYPE_DICT = F.data_type_dict 7 | DTYPE_DICT = {DTYPE_DICT[key]: key for key in DTYPE_DICT} 8 | 9 | 10 | def _get_ndata_path(graph_name, ndata_name): 11 | return "/" + graph_name + "_node_" + ndata_name 12 | 13 | 14 | def _get_edata_path(graph_name, edata_name): 15 | return "/" + graph_name + "_edge_" + edata_name 16 | 17 | 18 | def _to_shared_mem(arr, name): 19 | dlpack = F.zerocopy_to_dlpack(arr) 20 | dgl_tensor = nd.from_dlpack(dlpack) 21 | new_arr = empty_shared_mem( 22 | name, True, F.shape(arr), DTYPE_DICT[F.dtype(arr)] 23 | ) 24 | dgl_tensor.copyto(new_arr) 25 | dlpack = new_arr.to_dlpack() 26 | return F.zerocopy_from_dlpack(dlpack) 27 | -------------------------------------------------------------------------------- /python/dgl/function/__init__.py: -------------------------------------------------------------------------------- 1 | """DGL builtin functors""" 2 | # pylint: disable=redefined-builtin 3 | from __future__ import absolute_import 4 | 5 | from .base import * 6 | from .message import * 7 | from .reducer import * 8 | -------------------------------------------------------------------------------- /python/dgl/function/base.py: -------------------------------------------------------------------------------- 1 | """Built-in function base class""" 2 | from __future__ import absolute_import 3 | 4 | __all__ = ["BuiltinFunction", "TargetCode"] 5 | 6 | 7 | class TargetCode(object): 8 | """Code for target 9 | 10 | Note: must be consistent with the target code definition in C++ side: 11 | src/kernel/binary_reduce_common.h 12 | """ 13 | 14 | SRC = 0 15 | DST = 1 16 | EDGE = 2 17 | 18 | CODE2STR = { 19 | 0: "u", 20 | 1: "v", 21 | 2: "e", 22 | } 23 | 24 | 25 | class BuiltinFunction(object): 26 | """Base builtin function class.""" 27 | 28 | @property 29 | def name(self): 30 | """Return the name of this builtin function.""" 31 | raise NotImplementedError 32 | -------------------------------------------------------------------------------- /python/dgl/geometry/__init__.py: -------------------------------------------------------------------------------- 1 | """The ``dgl.geometry`` package contains geometry operations: 2 | 3 | * Farthest point sampling for point cloud sampling 4 | 5 | * Neighbor matching module for graclus pooling 6 | 7 | .. note:: 8 | This package is experimental and the interfaces may be subject 9 | to changes in future releases. 10 | """ 11 | from .edge_coarsening import * 12 | from .fps import * 13 | -------------------------------------------------------------------------------- /python/dgl/global_config.py: -------------------------------------------------------------------------------- 1 | """Module for global configuration operators.""" 2 | from ._ffi.function import _init_api 3 | 4 | __all__ = ["is_libxsmm_enabled", "use_libxsmm"] 5 | 6 | 7 | def use_libxsmm(flag): 8 | r"""Set whether DGL uses libxsmm at runtime. 9 | 10 | Detailed information about libxsmm can be found here: 11 | https://github.com/libxsmm/libxsmm 12 | 13 | Parameters 14 | ---------- 15 | flag : boolean 16 | If True, use libxsmm, otherwise not. 17 | 18 | See Also 19 | -------- 20 | is_libxsmm_enabled 21 | """ 22 | _CAPI_DGLConfigSetLibxsmm(flag) 23 | 24 | 25 | def is_libxsmm_enabled(): 26 | r"""Get whether the use_libxsmm flag is turned on. 27 | 28 | Returns 29 | ---------- 30 | use_libxsmm_flag[boolean] 31 | True if the use_libxsmm flag is turned on. 32 | 33 | See Also 34 | ---------- 35 | use_libxsmm 36 | """ 37 | return _CAPI_DGLConfigGetLibxsmm() 38 | 39 | 40 | _init_api("dgl.global_config") 41 | -------------------------------------------------------------------------------- /python/dgl/graphbolt/__init__.py: -------------------------------------------------------------------------------- 1 | """GraphBolt""" 2 | 3 | from .itemset import * 4 | -------------------------------------------------------------------------------- /python/dgl/graphbolt/dataloader.py: -------------------------------------------------------------------------------- 1 | """Graph Bolt DataLoaders""" 2 | -------------------------------------------------------------------------------- /python/dgl/logging.py: -------------------------------------------------------------------------------- 1 | """logging module for DGL""" 2 | import logging 3 | import os 4 | 5 | 6 | def enable_verbose_logging(): 7 | """ 8 | Enable debug level logging for DGL 9 | """ 10 | os.environ["DMLC_LOG_DEBUG"] = "1" 11 | logger = logging.getLogger("dgl-core") 12 | logger.setLevel(logging.DEBUG) 13 | logging.info("DGL's logging level is set to DEBUG") 14 | 15 | 16 | def _setup_logger(): 17 | """setup logger""" 18 | logger = logging.getLogger("dgl-core") 19 | console = logging.StreamHandler() 20 | formatter = logging.Formatter( 21 | "%(asctime)s %(filename)s:%(lineno)s %(levelname)s p:%(processName)s \ 22 | t:%(threadName)s: %(message)s" 23 | ) 24 | console.setFormatter(formatter) 25 | console.setLevel(logging.DEBUG) 26 | logger.addHandler(console) 27 | logger.propagate = False 28 | logger.setLevel(logging.INFO) 29 | 30 | 31 | _setup_logger() 32 | 33 | if os.environ.get("DGL_LOG_DEBUG", None) == "1": 34 | enable_verbose_logging() 35 | -------------------------------------------------------------------------------- /python/dgl/mpops/__init__.py: -------------------------------------------------------------------------------- 1 | """Message passing operator sub-package""" 2 | 3 | from .edgewise import * 4 | from .nodewise import * 5 | from .fused import * 6 | -------------------------------------------------------------------------------- /python/dgl/mpops/fused.py: -------------------------------------------------------------------------------- 1 | """Operators that fuse the computation and aggregation of edge data.""" 2 | -------------------------------------------------------------------------------- /python/dgl/mpops/nodewise.py: -------------------------------------------------------------------------------- 1 | """Operators for aggregating/reducing edge data to node data.""" 2 | -------------------------------------------------------------------------------- /python/dgl/multiprocessing/__init__.py: -------------------------------------------------------------------------------- 1 | """Wrapper of the multiprocessing module for multi-GPU training.""" 2 | 3 | # To avoid duplicating the graph structure for node classification or link prediction 4 | # training we recommend using fork() rather than spawn() for multiple GPU training. 5 | # However, we need to work around https://github.com/pytorch/pytorch/issues/17199 to 6 | # make fork() and openmp work together. 7 | from .. import backend as F 8 | 9 | if F.get_preferred_backend() == "pytorch": 10 | # Wrap around torch.multiprocessing... 11 | from torch.multiprocessing import * 12 | 13 | # ... and override the Process initializer. 14 | from .pytorch import * 15 | else: 16 | # Just import multiprocessing module. 17 | from multiprocessing import * # pylint: disable=redefined-builtin 18 | -------------------------------------------------------------------------------- /python/dgl/nn/functional/__init__.py: -------------------------------------------------------------------------------- 1 | """Functions related to DGL NN Modules.""" 2 | 3 | from ...ops import edge_softmax 4 | -------------------------------------------------------------------------------- /python/dgl/nn/mxnet/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for mxnet-specific NN modules.""" 2 | from .conv import * 3 | from .glob import * 4 | from .hetero import * 5 | from .softmax import * 6 | from .utils import Sequential 7 | -------------------------------------------------------------------------------- /python/dgl/nn/mxnet/softmax.py: -------------------------------------------------------------------------------- 1 | """Gluon layer for graph related softmax.""" 2 | # pylint: disable= unused-import 3 | from ..functional import edge_softmax 4 | -------------------------------------------------------------------------------- /python/dgl/nn/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for pytorch-specific NN modules.""" 2 | from .conv import * 3 | from .explain import * 4 | from .link import * 5 | from .linear import * 6 | from .glob import * 7 | from .softmax import * 8 | from .factory import * 9 | from .hetero import * 10 | from .sparse_emb import NodeEmbedding 11 | from .utils import JumpingKnowledge, LabelPropagation, Sequential, WeightBasis 12 | from .network_emb import * 13 | from .gt import * 14 | -------------------------------------------------------------------------------- /python/dgl/nn/pytorch/explain/__init__.py: -------------------------------------------------------------------------------- 1 | """Torch modules for explanation models.""" 2 | # pylint: disable= no-member, arguments-differ, invalid-name 3 | 4 | from .gnnexplainer import * 5 | from .subgraphx import * 6 | from .pgexplainer import * 7 | -------------------------------------------------------------------------------- /python/dgl/nn/pytorch/gt/__init__.py: -------------------------------------------------------------------------------- 1 | """Torch modules for Graph Transformer.""" 2 | 3 | from .biased_mha import BiasedMHA 4 | from .degree_encoder import DegreeEncoder 5 | from .graphormer import GraphormerLayer 6 | from .lap_pos_encoder import LapPosEncoder 7 | from .path_encoder import PathEncoder 8 | from .spatial_encoder import SpatialEncoder, SpatialEncoder3d 9 | -------------------------------------------------------------------------------- /python/dgl/nn/pytorch/link/__init__.py: -------------------------------------------------------------------------------- 1 | """Torch modules for link prediction/knowledge graph completion.""" 2 | 3 | from .edgepred import EdgePredictor 4 | from .transe import TransE 5 | from .transr import TransR 6 | -------------------------------------------------------------------------------- /python/dgl/nn/pytorch/softmax.py: -------------------------------------------------------------------------------- 1 | """Torch modules for graph related softmax.""" 2 | # pylint: disable= unused-import 3 | from ..functional import edge_softmax 4 | -------------------------------------------------------------------------------- /python/dgl/nn/tensorflow/__init__.py: -------------------------------------------------------------------------------- 1 | """Package for Tensorflow-specific NN modules.""" 2 | from .conv import * 3 | from .glob import * 4 | from .hetero import * 5 | from .softmax import * 6 | from .utils import * 7 | -------------------------------------------------------------------------------- /python/dgl/nn/tensorflow/conv/__init__.py: -------------------------------------------------------------------------------- 1 | """TF NN conv module""" 2 | from .appnpconv import APPNPConv 3 | from .chebconv import ChebConv 4 | from .densechebconv import DenseChebConv 5 | from .edgeconv import EdgeConv 6 | from .gatconv import GATConv 7 | from .ginconv import GINConv 8 | from .graphconv import GraphConv 9 | from .relgraphconv import RelGraphConv 10 | from .sageconv import SAGEConv 11 | from .sgconv import SGConv 12 | -------------------------------------------------------------------------------- /python/dgl/nn/tensorflow/softmax.py: -------------------------------------------------------------------------------- 1 | """tf modules for graph related softmax.""" 2 | # pylint: disable= unused-import 3 | from ..functional import edge_softmax 4 | -------------------------------------------------------------------------------- /python/dgl/ops/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl operator module.""" 2 | from .edge_softmax import * 3 | from .gather_mm import * 4 | from .sddmm import * 5 | from .segment import * 6 | from .spmm import * 7 | -------------------------------------------------------------------------------- /python/dgl/optim/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl optims.""" 2 | import importlib 3 | import os 4 | import sys 5 | 6 | from ..backend import backend_name 7 | from ..utils import expand_as_pair 8 | 9 | 10 | def _load_backend(mod_name): 11 | mod = importlib.import_module(".%s" % mod_name, __name__) 12 | thismod = sys.modules[__name__] 13 | for api, obj in mod.__dict__.items(): 14 | setattr(thismod, api, obj) 15 | 16 | 17 | _load_backend(backend_name) 18 | -------------------------------------------------------------------------------- /python/dgl/optim/mxnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/optim/mxnet/__init__.py -------------------------------------------------------------------------------- /python/dgl/optim/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | """dgl sparse optimizer for pytorch.""" 2 | from .sparse_optim import SparseAdagrad, SparseAdam 3 | -------------------------------------------------------------------------------- /python/dgl/optim/tensorflow/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/python/dgl/optim/tensorflow/__init__.py -------------------------------------------------------------------------------- /python/dgl/sampling/__init__.py: -------------------------------------------------------------------------------- 1 | """The ``dgl.sampling`` package contains operators and utilities for 2 | sampling from a graph via random walks, neighbor sampling, etc. They 3 | are typically used together with the ``DataLoader`` s in the 4 | ``dgl.dataloading`` package. The user guide :ref:`guide-minibatch` 5 | gives a holistic explanation on how different components work together. 6 | """ 7 | 8 | from .randomwalks import * 9 | from .pinsage import * 10 | from .neighbor import * 11 | from .labor import * 12 | from .node2vec_randomwalk import * 13 | from .negative import * 14 | from . import utils 15 | -------------------------------------------------------------------------------- /python/dgl/sparse/utils.py: -------------------------------------------------------------------------------- 1 | """Utilities for DGL sparse module.""" 2 | from numbers import Number 3 | from typing import Union 4 | 5 | import torch 6 | 7 | 8 | def is_scalar(x): 9 | """Check if the input is a scalar.""" 10 | return isinstance(x, Number) or (torch.is_tensor(x) and x.dim() == 0) 11 | 12 | 13 | # Scalar type annotation 14 | Scalar = Union[Number, torch.Tensor] 15 | -------------------------------------------------------------------------------- /python/dgl/storages/__init__.py: -------------------------------------------------------------------------------- 1 | """Feature storage classes for DataLoading""" 2 | from .. import backend as F 3 | from .base import * 4 | from .numpy import * 5 | 6 | # Defines the name TensorStorage 7 | if F.get_preferred_backend() == "pytorch": 8 | from .pytorch_tensor import PyTorchTensorStorage as TensorStorage 9 | else: 10 | from .tensor import BaseTensorStorage as TensorStorage 11 | -------------------------------------------------------------------------------- /python/dgl/storages/numpy.py: -------------------------------------------------------------------------------- 1 | """Feature storage for ``numpy.memmap`` object.""" 2 | import numpy as np 3 | 4 | from .. import backend as F 5 | from .base import FeatureStorage, register_storage_wrapper, ThreadedFuture 6 | 7 | 8 | @register_storage_wrapper(np.memmap) 9 | class NumpyStorage(FeatureStorage): 10 | """FeatureStorage that asynchronously reads features from a ``numpy.memmap`` object.""" 11 | 12 | def __init__(self, arr): 13 | self.arr = arr 14 | 15 | # pylint: disable=unused-argument 16 | def _fetch(self, indices, device, pin_memory=False): 17 | result = F.zerocopy_from_numpy(self.arr[indices]) 18 | result = F.copy_to(result, device) 19 | return result 20 | 21 | # pylint: disable=unused-argument 22 | def fetch(self, indices, device, pin_memory=False, **kwargs): 23 | return ThreadedFuture( 24 | target=self._fetch, args=(indices, device, pin_memory) 25 | ) 26 | -------------------------------------------------------------------------------- /python/dgl/storages/tensor.py: -------------------------------------------------------------------------------- 1 | """Feature storages for tensors across different frameworks.""" 2 | from .. import backend as F 3 | from .base import FeatureStorage 4 | 5 | 6 | class BaseTensorStorage(FeatureStorage): 7 | """FeatureStorage that synchronously slices features from a tensor and transfers 8 | it to the given device. 9 | """ 10 | 11 | def __init__(self, tensor): 12 | self.storage = tensor 13 | 14 | def fetch( 15 | self, indices, device, pin_memory=False, **kwargs 16 | ): # pylint: disable=unused-argument 17 | return F.copy_to(F.gather_row(tensor, indices), device, **kwargs) 18 | -------------------------------------------------------------------------------- /python/dgl/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | """Transform for structures and features""" 2 | from .functional import * 3 | from .module import * 4 | from .to_block import * 5 | -------------------------------------------------------------------------------- /python/dgl/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """Internal utilities.""" 2 | from .checks import * 3 | from .data import * 4 | from .exception import * 5 | from .filter import * 6 | from .internal import * 7 | from .pin_memory import * 8 | from .shared_mem import * 9 | 10 | try: 11 | from packaging import version 12 | except ImportError: 13 | # If packaging isn't installed, try and use the vendored copy in setuptools 14 | from setuptools.extern.packaging import version 15 | -------------------------------------------------------------------------------- /python/dgl/utils/shared_mem.py: -------------------------------------------------------------------------------- 1 | """Shared memory utilities. 2 | 3 | For compatibility with older code that uses ``dgl.utils.shared_mem`` namespace; the 4 | content has been moved to ``dgl.ndarray`` module. 5 | """ 6 | from ..ndarray import ( # pylint: disable=unused-import 7 | create_shared_mem_array, 8 | get_shared_mem_array, 9 | ) 10 | -------------------------------------------------------------------------------- /readthedocs.yml: -------------------------------------------------------------------------------- 1 | build: 2 | image: latest 3 | 4 | formats: [] 5 | 6 | python: 7 | version: 3.6 8 | use_system_site_packages: true 9 | setup_py_install: false 10 | -------------------------------------------------------------------------------- /script/dgl_dev.yml.template: -------------------------------------------------------------------------------- 1 | name: __NAME__ 2 | dependencies: 3 | - python=__PYTHON_VERSION__ 4 | - pip 5 | - graphviz 6 | - pandoc 7 | - pygraphviz 8 | - pip: 9 | - --find-links https://download.pytorch.org/whl/torch_stable.html 10 | - cython 11 | - filelock 12 | - matplotlib 13 | - networkx 14 | - nltk 15 | - nose 16 | - numpy 17 | - ogb 18 | - pandas 19 | - psutil 20 | - pyarrow 21 | - pydantic 22 | - pytest 23 | - pyyaml 24 | - rdflib 25 | - requests[security] 26 | - scikit-learn 27 | - scipy 28 | - torch==__TORCH_VERSION__ 29 | - torchmetrics 30 | - tqdm 31 | - boto3 # AWS SDK for python 32 | - sphinx==4.2.0 33 | - sphinx-gallery 34 | - sphinx_rtd_theme 35 | - sphinx_copybutton 36 | - sphinxemoji 37 | - nbsphinx>=0.8.11 38 | - nbsphinx-link>=1.3.0 39 | - pillow 40 | - seaborn 41 | - jupyter_http_over_ws 42 | variables: 43 | DGL_HOME: __DGL_HOME__ 44 | -------------------------------------------------------------------------------- /src/array/cpu/array_nonzero.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 by Contributors 3 | * @file array/cpu/array_nonzero.cc 4 | * @brief Array nonzero CPU implementation 5 | */ 6 | #include 7 | 8 | namespace dgl { 9 | using runtime::NDArray; 10 | namespace aten { 11 | namespace impl { 12 | 13 | template 14 | IdArray NonZero(IdArray array) { 15 | std::vector ret; 16 | const IdType* data = array.Ptr(); 17 | for (int64_t i = 0; i < array->shape[0]; ++i) 18 | if (data[i] != 0) ret.push_back(i); 19 | return NDArray::FromVector(ret, array->ctx); 20 | } 21 | 22 | template IdArray NonZero(IdArray); 23 | template IdArray NonZero(IdArray); 24 | 25 | } // namespace impl 26 | } // namespace aten 27 | } // namespace dgl 28 | -------------------------------------------------------------------------------- /src/array/cuda/dgl_cub.cuh: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 by Contributors 3 | * @file cuda_common.h 4 | * @brief Wrapper to place cub in dgl namespace. 5 | */ 6 | 7 | #ifndef DGL_ARRAY_CUDA_DGL_CUB_CUH_ 8 | #define DGL_ARRAY_CUDA_DGL_CUB_CUH_ 9 | 10 | // This should be defined in CMakeLists.txt 11 | #ifndef THRUST_CUB_WRAPPED_NAMESPACE 12 | static_assert(false, "THRUST_CUB_WRAPPED_NAMESPACE must be defined for DGL."); 13 | #endif 14 | 15 | #include "cub/cub.cuh" 16 | 17 | #endif // DGL_ARRAY_CUDA_DGL_CUB_CUH_ 18 | -------------------------------------------------------------------------------- /src/array/uvm_array_op.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2019-2022 by Contributors 3 | * @file array/uvm_array_op.h 4 | * @brief Array operator templates 5 | */ 6 | #ifndef DGL_ARRAY_UVM_ARRAY_OP_H_ 7 | #define DGL_ARRAY_UVM_ARRAY_OP_H_ 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace dgl { 14 | namespace aten { 15 | namespace impl { 16 | 17 | // Take CPU array and GPU index, and then index with GPU. 18 | template 19 | NDArray IndexSelectCPUFromGPU(NDArray array, IdArray index); 20 | 21 | template 22 | void IndexScatterGPUToCPU(NDArray dest, IdArray index, NDArray source); 23 | 24 | } // namespace impl 25 | } // namespace aten 26 | } // namespace dgl 27 | 28 | #endif // DGL_ARRAY_UVM_ARRAY_OP_H_ 29 | -------------------------------------------------------------------------------- /src/runtime/meta_data.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 by Contributors 3 | * @file meta_data.h 4 | * @brief Meta data related utilities 5 | */ 6 | #ifndef DGL_RUNTIME_META_DATA_H_ 7 | #define DGL_RUNTIME_META_DATA_H_ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include "runtime_base.h" 17 | 18 | namespace dgl { 19 | namespace runtime { 20 | 21 | /** @brief function information needed by device */ 22 | struct FunctionInfo { 23 | std::string name; 24 | std::vector arg_types; 25 | std::vector thread_axis_tags; 26 | 27 | void Save(dmlc::JSONWriter *writer) const; 28 | void Load(dmlc::JSONReader *reader); 29 | void Save(dmlc::Stream *writer) const; 30 | bool Load(dmlc::Stream *reader); 31 | }; 32 | } // namespace runtime 33 | } // namespace dgl 34 | 35 | namespace dmlc { 36 | DMLC_DECLARE_TRAITS(has_saveload, ::dgl::runtime::FunctionInfo, true); 37 | } // namespace dmlc 38 | #endif // DGL_RUNTIME_META_DATA_H_ 39 | -------------------------------------------------------------------------------- /src/runtime/parallel_for.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 by Contributors 3 | * Implementation of C API (reference: tvm/src/api/c_api.cc) 4 | * @file c_api.cc 5 | */ 6 | 7 | namespace dgl { 8 | namespace runtime { 9 | DefaultGrainSizeT default_grain_size; 10 | } // namespace runtime 11 | } // namespace dgl 12 | -------------------------------------------------------------------------------- /tensoradapter/include/tensoradapter_exports.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 by Contributors 3 | * @file tensoradapter_exports.h 4 | * @brief Header file for functions exposed by the adapter library. 5 | */ 6 | 7 | #ifndef TENSORADAPTER_EXPORTS_H_ 8 | #define TENSORADAPTER_EXPORTS_H_ 9 | 10 | #if defined(WIN32) || defined(_WIN32) 11 | #define TA_EXPORTS __declspec(dllexport) 12 | #else 13 | #define TA_EXPORTS 14 | #endif 15 | 16 | #endif // TENSORADAPTER_EXPORTS_H_ 17 | -------------------------------------------------------------------------------- /tensoradapter/pytorch/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Helper script to build tensor adapter libraries for PyTorch 3 | set -e 4 | 5 | mkdir -p build 6 | mkdir -p $BINDIR/tensoradapter/pytorch 7 | cd build 8 | 9 | if [ $(uname) = 'Darwin' ]; then 10 | CPSOURCE=*.dylib 11 | else 12 | CPSOURCE=*.so 13 | fi 14 | 15 | CMAKE_FLAGS="-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_ROOT_DIR -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST -DUSE_CUDA=$USE_CUDA" 16 | 17 | if [ $# -eq 0 ]; then 18 | $CMAKE_COMMAND $CMAKE_FLAGS .. 19 | make -j 20 | cp -v $CPSOURCE $BINDIR/tensoradapter/pytorch 21 | else 22 | for PYTHON_INTERP in $@; do 23 | TORCH_VER=$($PYTHON_INTERP -c 'import torch; print(torch.__version__.split("+")[0])') 24 | mkdir -p $TORCH_VER 25 | cd $TORCH_VER 26 | $CMAKE_COMMAND $CMAKE_FLAGS -DPYTHON_INTERP=$PYTHON_INTERP ../.. 27 | make -j 28 | cp -v $CPSOURCE $BINDIR/tensoradapter/pytorch 29 | cd .. 30 | done 31 | fi 32 | -------------------------------------------------------------------------------- /tensoradapter/pytorch/find_cmake.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import torch 4 | 5 | cmake_prefix_path = getattr( 6 | torch.utils, 7 | "cmake_prefix_path", 8 | os.path.join(os.path.dirname(torch.__file__), "share", "cmake"), 9 | ) 10 | version = torch.__version__.split("+")[0] 11 | print(";".join([cmake_prefix_path, version])) 12 | -------------------------------------------------------------------------------- /tests/cpp/graph_index_test.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2019 by Contributors 3 | * @file graph_index_test.cc 4 | * @brief Test GraphIndex 5 | */ 6 | #include 7 | #include 8 | 9 | TEST(GraphTest, TestNumVertices) { 10 | dgl::Graph g; 11 | g.AddVertices(10); 12 | ASSERT_EQ(g.NumVertices(), 10); 13 | }; 14 | -------------------------------------------------------------------------------- /tests/dist/cpp/rpc_base.h: -------------------------------------------------------------------------------- 1 | #ifndef DIST_TEST_RPC_BASE_H_ 2 | #define DIST_TEST_RPC_BASE_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "../../../src/rpc/rpc_msg.h" 8 | #include "../../../src/rpc/tensorpipe/tp_communicator.h" 9 | #include "../../cpp/common.h" 10 | 11 | namespace { 12 | const int kNumSender = 30; 13 | const int kNumReceiver = 10; 14 | const int kNumMessage = 1024; 15 | const int kPort = 50090; 16 | const int kSizeTensor = 10 * 1024; 17 | const int kNumTensor = 30; 18 | 19 | std::shared_ptr InitTPContext() { 20 | auto context = std::make_shared(); 21 | auto transportContext = tensorpipe::transport::uv::create(); 22 | context->registerTransport(0 /* priority */, "tcp", transportContext); 23 | auto basicChannel = tensorpipe::channel::basic::create(); 24 | context->registerChannel(0 /* low priority */, "basic", basicChannel); 25 | return context; 26 | } 27 | } // namespace 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /tests/dist/test_cpp.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | from utils import execute_remote, get_ips 5 | 6 | 7 | @unittest.skipIf(os.name == "nt", reason="Do not support windows yet") 8 | def test_tensorpipe_comm(): 9 | base_dir = os.environ.get("DIST_DGL_TEST_CPP_BIN_DIR", ".") 10 | ip_config = os.environ.get("DIST_DGL_TEST_IP_CONFIG", "ip_config.txt") 11 | client_bin = os.path.join(base_dir, "rpc_client") 12 | server_bin = os.path.join(base_dir, "rpc_server") 13 | ips = get_ips(ip_config) 14 | num_machines = len(ips) 15 | procs = [] 16 | for ip in ips: 17 | procs.append( 18 | execute_remote(server_bin + " " + str(num_machines) + " " + ip, ip) 19 | ) 20 | for ip in ips: 21 | procs.append(execute_remote(client_bin + " " + ip_config, ip)) 22 | for p in procs: 23 | p.join() 24 | assert p.exitcode == 0 25 | -------------------------------------------------------------------------------- /tests/python/common/backend/test_set_default_backend.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | import backend as F 5 | 6 | 7 | def test_set_default_backend(): 8 | default_dir = os.path.join(os.path.expanduser("~"), ".dgl_unit_test") 9 | F.set_default_backend(default_dir, "pytorch") 10 | 11 | # make sure the config file was created 12 | assert os.path.exists(os.path.join(default_dir, "config.json")) 13 | -------------------------------------------------------------------------------- /tests/python/common/data/data/1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/1.bin -------------------------------------------------------------------------------- /tests/python/common/data/data/1.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/1.npy -------------------------------------------------------------------------------- /tests/python/common/data/data/2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/2.bin -------------------------------------------------------------------------------- /tests/python/common/data/data/2.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/2.npy -------------------------------------------------------------------------------- /tests/python/common/data/data/graph_0.9a220622.dgl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/graph_0.9a220622.dgl -------------------------------------------------------------------------------- /tests/python/common/data/data/hetero1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jermainewang/dgl/154b93c7bd08310a5390067e379b0271ade53bbf/tests/python/common/data/data/hetero1.bin -------------------------------------------------------------------------------- /tests/python/common/data/test_actor.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import backend as F 4 | 5 | import dgl 6 | 7 | 8 | @unittest.skipIf( 9 | F._default_context_str == "gpu", 10 | reason="Datasets don't need to be tested on GPU.", 11 | ) 12 | @unittest.skipIf( 13 | dgl.backend.backend_name != "pytorch", reason="only supports pytorch" 14 | ) 15 | def test_actor(): 16 | transform = dgl.AddSelfLoop(allow_duplicate=True) 17 | 18 | g = dgl.data.ActorDataset(force_reload=True)[0] 19 | assert g.num_nodes() == 7600 20 | assert g.num_edges() == 33391 21 | g2 = dgl.data.ActorDataset(force_reload=True, transform=transform)[0] 22 | assert g2.num_edges() - g.num_edges() == g.num_nodes() 23 | -------------------------------------------------------------------------------- /tests/python/common/test_generators.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import backend as F 4 | 5 | import dgl 6 | import numpy as np 7 | 8 | 9 | @unittest.skipIf( 10 | F._default_context_str == "gpu", reason="GPU random choice not implemented" 11 | ) 12 | def test_rand_graph(): 13 | g = dgl.rand_graph(10000, 100000) 14 | assert g.num_nodes() == 10000 15 | assert g.num_edges() == 100000 16 | # test random seed 17 | dgl.random.seed(42) 18 | g1 = dgl.rand_graph(100, 30) 19 | dgl.random.seed(42) 20 | g2 = dgl.rand_graph(100, 30) 21 | u1, v1 = g1.edges() 22 | u2, v2 = g2.edges() 23 | assert F.array_equal(u1, u2) 24 | assert F.array_equal(v1, v2) 25 | 26 | 27 | if __name__ == "__main__": 28 | test_rand_graph() 29 | -------------------------------------------------------------------------------- /tests/python/mxnet/ip_config.txt: -------------------------------------------------------------------------------- 1 | 0 127.0.0.1 50050 2 | 1 127.0.0.1 50051 3 | 2 127.0.0.1 50052 4 | 3 127.0.0.1 50053 -------------------------------------------------------------------------------- /tests/python/mxnet/test_geometry.py: -------------------------------------------------------------------------------- 1 | import backend as F 2 | import mxnet as mx 3 | import numpy as np 4 | 5 | from dgl.geometry import farthest_point_sampler 6 | 7 | 8 | def test_fps(): 9 | N = 1000 10 | batch_size = 5 11 | sample_points = 10 12 | x = mx.nd.array( 13 | np.random.uniform(size=(batch_size, int(N / batch_size), 3)) 14 | ) 15 | ctx = F.ctx() 16 | if F.gpu_ctx(): 17 | x = x.as_in_context(ctx) 18 | res = farthest_point_sampler(x, sample_points) 19 | assert res.shape[0] == batch_size 20 | assert res.shape[1] == sample_points 21 | assert res.sum() > 0 22 | 23 | 24 | if __name__ == "__main__": 25 | test_fps() 26 | -------------------------------------------------------------------------------- /tests/python/pytorch/ip_config.txt: -------------------------------------------------------------------------------- 1 | 0 127.0.0.1 40050 2 | 1 127.0.0.1 40051 3 | 2 127.0.0.1 40052 4 | 3 127.0.0.1 40053 -------------------------------------------------------------------------------- /tests/python/pytorch/nn/conv/test_gatedgcnconv.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | import backend as F 4 | 5 | import dgl.nn.pytorch as nn 6 | import pytest 7 | from utils import parametrize_idtype 8 | from utils.graph_cases import get_cases 9 | 10 | tmp_buffer = io.BytesIO() 11 | 12 | 13 | @parametrize_idtype 14 | @pytest.mark.parametrize("g", get_cases(["homo"], exclude=["zero-degree"])) 15 | def test_gatedgcn_conv(g, idtype): 16 | ctx = F.ctx() 17 | g = g.astype(idtype).to(ctx) 18 | gatedgcnconv = nn.GatedGCNConv(10, 10, 5) 19 | feat = F.randn((g.num_nodes(), 10)) 20 | efeat = F.randn((g.num_edges(), 10)) 21 | gatedgcnconv = gatedgcnconv.to(ctx) 22 | 23 | h, edge_h = gatedgcnconv(g, feat, efeat) 24 | # current we only do shape check 25 | assert h.shape == (g.number_of_dst_nodes(), 5) 26 | assert edge_h.shape == (g.number_of_edges(), 5) 27 | -------------------------------------------------------------------------------- /tests/python/pytorch/sparse/__init__.py: -------------------------------------------------------------------------------- 1 | """ DGL sparse tests""" 2 | -------------------------------------------------------------------------------- /tests/python/pytorch/test_heterograph-pickle.py: -------------------------------------------------------------------------------- 1 | import io 2 | import pickle 3 | 4 | import dgl 5 | 6 | import networkx as nx 7 | import torch 8 | 9 | 10 | def _reconstruct_pickle(obj): 11 | f = io.BytesIO() 12 | pickle.dump(obj, f) 13 | f.seek(0) 14 | obj = pickle.load(f) 15 | f.close() 16 | return obj 17 | 18 | 19 | def test_pickling_batched_graph(): 20 | # NOTE: this is a test for a wierd bug mentioned in 21 | # https://github.com/dmlc/dgl/issues/438 22 | glist = [nx.path_graph(i + 5) for i in range(5)] 23 | glist = [dgl.DGLGraph(g) for g in glist] 24 | bg = dgl.batch(glist) 25 | bg.ndata["x"] = torch.randn((35, 5)) 26 | bg.edata["y"] = torch.randn((60, 3)) 27 | new_bg = _reconstruct_pickle(bg) 28 | 29 | 30 | if __name__ == "__main__": 31 | test_pickling_batched_graph() 32 | -------------------------------------------------------------------------------- /tests/python/pytorch/test_multiprocessing-ipc.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | import dgl 5 | 6 | import torch as th 7 | import torch.multiprocessing as mp 8 | 9 | 10 | def sub_ipc(g): 11 | print(g) 12 | return g 13 | 14 | 15 | @unittest.skipIf(os.name == "nt", reason="Do not support windows yet") 16 | def test_torch_ipc(): 17 | g = dgl.graph(([0, 1, 2], [1, 2, 3])) 18 | ctx = mp.get_context("spawn") 19 | p = ctx.Process(target=sub_ipc, args=(g,)) 20 | 21 | p.start() 22 | p.join() 23 | 24 | 25 | if __name__ == "__main__": 26 | test_torch_ipc() 27 | -------------------------------------------------------------------------------- /tests/python/tensorflow/test_basic.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | 4 | 5 | if __name__ == "__main__": 6 | test() 7 | -------------------------------------------------------------------------------- /tests/scripts/build_dgl.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL EnableDelayedExpansion 3 | 4 | CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" 5 | CALL mkvirtualenv --system-site-packages %BUILD_TAG% 6 | DEL /S /Q build 7 | DEL /S /Q _download 8 | MD build 9 | 10 | SET _MSPDBSRV_ENDPOINT_=%BUILD_TAG% 11 | SET TMP=%WORKSPACE%\tmp 12 | SET TEMP=%WORKSPACE%\tmp 13 | SET TMPDIR=%WORKSPACE%\tmp 14 | 15 | PUSHD build 16 | cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DUSE_OPENMP=ON -DBUILD_TORCH=ON -DBUILD_GRAPHBOLT=ON -Dgtest_force_shared_crt=ON -DDMLC_FORCE_SHARED_CRT=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" -DTORCH_PYTHON_INTERPS=python -DBUILD_SPARSE=ON .. -G "Visual Studio 16 2019" || EXIT /B 1 17 | msbuild dgl.sln /m /nr:false || EXIT /B 1 18 | COPY /Y Release\runUnitTests.exe . 19 | POPD 20 | 21 | CALL workon %BUILD_TAG% 22 | 23 | PUSHD python 24 | DEL /S /Q build *.egg-info dist 25 | pip install -e . || EXIT /B 1 26 | POPD 27 | 28 | ENDLOCAL 29 | EXIT /B 30 | -------------------------------------------------------------------------------- /tests/scripts/cugraph_unit_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /opt/conda/etc/profile.d/conda.sh 4 | 5 | function fail { 6 | echo FAIL: $@ 7 | exit -1 8 | } 9 | 10 | export DGLBACKEND=$1 11 | export DGLTESTDEV=gpu 12 | export DGL_LIBRARY_PATH=${PWD}/build 13 | export PYTHONPATH=tests:${PWD}/python:$PYTHONPATH 14 | export DGL_DOWNLOAD_DIR=${PWD} 15 | export TF_FORCE_GPU_ALLOW_GROWTH=true 16 | 17 | export CUDA_VISIBLE_DEVICES=0 18 | 19 | python3 -m pip install pytest psutil pyyaml pydantic pandas rdflib ogb || fail "pip install" 20 | 21 | python3 -m pytest -v --junitxml=pytest_cugraph.xml --durations=20 tests/cugraph || fail "cugraph" 22 | -------------------------------------------------------------------------------- /tests/scripts/task_cpp_unit_test.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL EnableDelayedExpansion 3 | 4 | PUSHD build 5 | runUnitTests.exe || EXIT /B 1 6 | POPD 7 | -------------------------------------------------------------------------------- /tests/scripts/task_cpp_unit_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function fail { 3 | echo FAIL: $@ 4 | exit -1 5 | } 6 | echo $PWD 7 | pushd build 8 | ls -lh 9 | export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH 10 | ./runUnitTests || fail "CPP unit test" 11 | popd 12 | -------------------------------------------------------------------------------- /tests/scripts/task_example_test.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL EnableDelayedExpansion 3 | 4 | SET GCN_EXAMPLE_DIR=.\examples\pytorch 5 | 6 | IF x%1x==xx ( 7 | ECHO Must supply CPU or GPU 8 | GOTO :FAIL 9 | ) ELSE IF x%1x==xcpux ( 10 | SET DEV=-1 11 | ) ELSE IF x%1x==xgpux ( 12 | SET DEV=0 13 | SET CUDA_VISIBLE_DEVICES=0 14 | ) ELSE ( 15 | ECHO Must supply CPU or GPU 16 | GOTO :FAIL 17 | ) 18 | CALL workon %BUILD_TAG% 19 | 20 | SET DGLBACKEND=pytorch 21 | SET DGL_LIBRARY_PATH=!CD!\build 22 | SET PYTHONPATH=!CD!\python;!PYTHONPATH! 23 | SET DGL_DOWNLOAD_DIR=!CD! 24 | 25 | python -m pytest -v --junitxml=pytest_backend.xml --durations=100 tests\examples || GOTO :FAIL 26 | 27 | PUSHD !GCN_EXAMPLE_DIR! 28 | python pagerank.py || GOTO :FAIL 29 | python gcn\train.py --dataset cora || GOTO :FAIL 30 | POPD 31 | ENDLOCAL 32 | EXIT /B 33 | 34 | :FAIL 35 | ECHO Example test failed 36 | ENDLOCAL 37 | EXIT /B 1 38 | -------------------------------------------------------------------------------- /tests/scripts/task_go_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /opt/conda/etc/profile.d/conda.sh 4 | 5 | function fail { 6 | echo FAIL: $@ 7 | exit -1 8 | } 9 | 10 | export DGLBACKEND=pytorch 11 | export DGL_LIBRARY_PATH=${PWD}/build 12 | export PYTHONPATH=tests:${PWD}/python:$PYTHONPATH 13 | export DGL_DOWNLOAD_DIR=${PWD} 14 | 15 | conda activate pytorch-ci 16 | 17 | pushd dglgo 18 | rm -rf build *.egg-info dist 19 | pip uninstall -y dglgo 20 | python3 setup.py install 21 | popd 22 | 23 | export LC_ALL=C.UTF-8 24 | export LANG=C.UTF-8 25 | 26 | python3 -m pytest -v --junitxml=pytest_go.xml --durations=100 tests/go/test_model.py || fail "go" 27 | -------------------------------------------------------------------------------- /tests/scripts/task_lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # cpplint 4 | echo 'Checking code style of C++ codes...' 5 | python3 tests/lint/lint.py dgl cpp include src || exit 1 6 | python3 tests/lint/lint.py dgl_sparse cpp dgl_sparse/include dgl_sparse/src || exit 1 7 | 8 | # pylint 9 | echo 'Checking code style of python codes...' 10 | python3 -m pylint --reports=y -v --rcfile=tests/lint/pylintrc python/dgl || exit 1 11 | -------------------------------------------------------------------------------- /tests/scripts/task_pytorch_tutorial_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The working directory for this script will be "tests/scripts" 3 | 4 | . /opt/conda/etc/profile.d/conda.sh 5 | conda activate pytorch-ci 6 | TUTORIAL_ROOT="./tutorials" 7 | 8 | function fail { 9 | echo FAIL: $@ 10 | exit -1 11 | } 12 | 13 | export MPLBACKEND=Agg 14 | export DGLBACKEND=pytorch 15 | export DGL_LIBRARY_PATH=${PWD}/build 16 | export PYTHONPATH=${PWD}/python:$PYTHONPATH 17 | export DGL_DOWNLOAD_DIR=${PWD} 18 | 19 | pushd ${TUTORIAL_ROOT} > /dev/null 20 | # Install requirements 21 | pip install -r requirements.txt || fail "installing requirements" 22 | 23 | # Test 24 | for f in $(find . -path ./dist -prune -false -o -name "*.py" ! -name "*_mx.py") 25 | do 26 | echo "Running tutorial ${f} ..." 27 | python3 $f || fail "run ${f}" 28 | done 29 | 30 | popd > /dev/null 31 | -------------------------------------------------------------------------------- /tests/scripts/task_unit_test.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL EnableDelayedExpansion 3 | 4 | IF x%1x==xx ( 5 | ECHO Specify backend 6 | EXIT /B 1 7 | ) ELSE ( 8 | SET BACKEND=%1 9 | ) 10 | CALL workon %BUILD_TAG% 11 | 12 | SET PYTHONPATH=tests;!CD!\python;!PYTHONPATH! 13 | SET DGLBACKEND=!BACKEND! 14 | SET DGL_LIBRARY_PATH=!CD!\build 15 | SET DGL_DOWNLOAD_DIR=!CD! 16 | 17 | python -m pip install pytest psutil pandas pyyaml pydantic rdflib torchmetrics || EXIT /B 1 18 | python -m pytest -v --junitxml=pytest_backend.xml --durations=100 tests\python\!DGLBACKEND! || EXIT /B 1 19 | python -m pytest -v --junitxml=pytest_common.xml --durations=100 tests\python\common || EXIT /B 1 20 | ENDLOCAL 21 | EXIT /B 22 | -------------------------------------------------------------------------------- /tests/tools/test_array_readwriter.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | 4 | import numpy as np 5 | import pytest 6 | from distpartitioning import array_readwriter 7 | 8 | 9 | @pytest.mark.parametrize( 10 | "shape", [[500], [300, 10], [200, 5, 5], [100, 5, 5, 5]] 11 | ) 12 | @pytest.mark.parametrize("format", ["numpy", "parquet"]) 13 | def test_array_readwriter(format, shape): 14 | original_array = np.random.rand(*shape) 15 | fmt_meta = {"name": format} 16 | 17 | with tempfile.TemporaryDirectory() as test_dir: 18 | path = os.path.join(test_dir, f"nodes.{format}") 19 | array_readwriter.get_array_parser(**fmt_meta).write( 20 | path, original_array 21 | ) 22 | array = array_readwriter.get_array_parser(**fmt_meta).read(path) 23 | 24 | assert original_array.shape == array.shape 25 | assert np.array_equal(original_array, array) 26 | -------------------------------------------------------------------------------- /tests/utils/__init__.py: -------------------------------------------------------------------------------- 1 | import backend as F 2 | import pytest 3 | 4 | parametrize_idtype = pytest.mark.parametrize("idtype", [F.int32, F.int64]) 5 | 6 | from .checks import * 7 | from .graph_cases import get_cases 8 | -------------------------------------------------------------------------------- /tools/distpartitioning/array_readwriter/__init__.py: -------------------------------------------------------------------------------- 1 | from . import csv, numpy_array, parquet 2 | from .registry import get_array_parser, register_array_parser 3 | -------------------------------------------------------------------------------- /tools/distpartitioning/array_readwriter/numpy_array.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import numpy as np 4 | from numpy.lib.format import open_memmap 5 | 6 | from .registry import register_array_parser 7 | 8 | 9 | @register_array_parser("numpy") 10 | class NumpyArrayParser(object): 11 | def __init__(self): 12 | pass 13 | 14 | def read(self, path): 15 | logging.debug("Reading from %s using numpy format" % path) 16 | arr = np.load(path, mmap_mode="r") 17 | logging.debug("Done reading from %s" % path) 18 | return arr 19 | 20 | def write(self, path, arr): 21 | logging.debug("Writing to %s using numpy format" % path) 22 | # np.save would load the entire memmap array up into CPU. So we manually open 23 | # an empty npy file with memmap mode and manually flush it instead. 24 | new_arr = open_memmap(path, mode="w+", dtype=arr.dtype, shape=arr.shape) 25 | new_arr[:] = arr[:] 26 | logging.debug("Done writing to %s" % path) 27 | -------------------------------------------------------------------------------- /tools/distpartitioning/array_readwriter/registry.py: -------------------------------------------------------------------------------- 1 | REGISTRY = {} 2 | 3 | 4 | def register_array_parser(name): 5 | def _deco(cls): 6 | REGISTRY[name] = cls 7 | return cls 8 | 9 | return _deco 10 | 11 | 12 | def get_array_parser(**fmt_meta): 13 | cls = REGISTRY[fmt_meta.pop("name")] 14 | return cls(**fmt_meta) 15 | -------------------------------------------------------------------------------- /tools/files.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | from contextlib import contextmanager 4 | 5 | from numpy.lib.format import open_memmap 6 | 7 | 8 | @contextmanager 9 | def setdir(path): 10 | try: 11 | os.makedirs(path, exist_ok=True) 12 | cwd = os.getcwd() 13 | logging.info("Changing directory to %s" % path) 14 | logging.info("Previously: %s" % cwd) 15 | os.chdir(path) 16 | yield 17 | finally: 18 | logging.info("Restoring directory to %s" % cwd) 19 | os.chdir(cwd) 20 | -------------------------------------------------------------------------------- /tutorials/blitz/.gitignore: -------------------------------------------------------------------------------- 1 | *.dgl 2 | *.csv 3 | -------------------------------------------------------------------------------- /tutorials/blitz/README.txt: -------------------------------------------------------------------------------- 1 | A Blitz Introduction to DGL 2 | =========================== 3 | -------------------------------------------------------------------------------- /tutorials/cpu/README.txt: -------------------------------------------------------------------------------- 1 | Training on CPUs 2 | ========================= 3 | -------------------------------------------------------------------------------- /tutorials/dist/README.txt: -------------------------------------------------------------------------------- 1 | Distributed training 2 | ==================== 3 | -------------------------------------------------------------------------------- /tutorials/large/.gitignore: -------------------------------------------------------------------------------- 1 | dataset 2 | model.pt 3 | -------------------------------------------------------------------------------- /tutorials/large/README.txt: -------------------------------------------------------------------------------- 1 | Stochastic Training of GNNs 2 | =========================== 3 | -------------------------------------------------------------------------------- /tutorials/models/2_small_graph/README.txt: -------------------------------------------------------------------------------- 1 | .. _tutorials2-index: 2 | 3 | Batching many small graphs 4 | ------------------------------- 5 | 6 | * **Tree-LSTM** `[paper] `__ `[tutorial] 7 | <2_small_graph/3_tree-lstm.html>`__ `[PyTorch code] 8 | `__: 9 | Sentences have inherent structures that are thrown 10 | away by treating them simply as sequences. Tree-LSTM is a powerful model 11 | that learns the representation by using prior syntactic structures such as a parse-tree. 12 | The challenge in training is that simply by padding 13 | a sentence to the maximum length no longer works. Trees of different 14 | sentences have different sizes and topologies. DGL solves this problem by 15 | adding the trees to a bigger container graph, and then using message-passing 16 | to explore maximum parallelism. Batching is a key API for this. 17 | -------------------------------------------------------------------------------- /tutorials/models/3_generative_model/README.txt: -------------------------------------------------------------------------------- 1 | .. _tutorials3-index: 2 | 3 | Generative models 4 | -------------------- 5 | 6 | * **DGMG** `[paper] `__ `[tutorial] 7 | <3_generative_model/5_dgmg.html>`__ `[PyTorch code] 8 | `__: 9 | This model belongs to the family that deals with structural 10 | generation. Deep generative models of graphs (DGMG) uses a state-machine approach. 11 | It is also very challenging because, unlike Tree-LSTM, every 12 | sample has a dynamic, probability-driven structure that is not available 13 | before training. You can progressively leverage intra- and 14 | inter-graph parallelism to steadily improve the performance. 15 | -------------------------------------------------------------------------------- /tutorials/models/README.txt: -------------------------------------------------------------------------------- 1 | Paper Study with DGL 2 | ========================================= 3 | -------------------------------------------------------------------------------- /tutorials/multi/README.txt: -------------------------------------------------------------------------------- 1 | Training on Multiple GPUs 2 | ========================= 3 | -------------------------------------------------------------------------------- /tutorials/requirements.txt: -------------------------------------------------------------------------------- 1 | networkx>=2.1 2 | torch 3 | numpy 4 | seaborn 5 | matplotlib 6 | pygraphviz 7 | graphviz 8 | pandas 9 | rdflib 10 | --------------------------------------------------------------------------------