Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

A few operators on graphs stored as CSR #13290

Merged
merged 31 commits into from
Nov 24, 2018
Merged

Conversation

zheng-da
Copy link
Contributor

@zheng-da zheng-da commented Nov 15, 2018

Description

We can store a graph as an CSR matrix. In this case, the value in the matrix is the edge id starting from 0. These operators run on such special CSR matrices. This is joint work with @HyperZealot and @aksnzhy

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

HyperZealot and others added 13 commits November 16, 2018 05:02
* create DGLSubgraph.

* fix.

* return old eids in node_subgraph.
* add csr_neighborhood op

* update neighborhood sample

* Update csr_neighborhood_sample-inl.h

* Update csr_neighborhood_sample-inl.h

* Update csr_neighborhood_sample.cc
* add csr_neighborhood op

* update neighborhood sample

* Update csr_neighborhood_sample-inl.h

* Update csr_neighborhood_sample-inl.h

* Update csr_neighborhood_sample.cc

* Update csr_neighborhood_sample-inl.h

* Update csr_neighborhood_sample.cc

* Update csr_neighborhood_sample-inl.h
@zheng-da zheng-da reopened this Nov 15, 2018
@zheng-da
Copy link
Contributor Author

@eric-haibin-lin could you please review this PR?

@kalyc
Copy link
Contributor

kalyc commented Nov 16, 2018

@mxnet-label-bot add [pr-awaiting-review]

@marcoabreu marcoabreu added the pr-awaiting-review PR is waiting for code review label Nov 16, 2018
Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good. A few questions about details

src/operator/contrib/dgl_graph.cc Outdated Show resolved Hide resolved
src/operator/contrib/dgl_graph.cc Outdated Show resolved Hide resolved
.describe(R"code(This operator implements the edge_id function for csr arrays,
where output[i] = input[u[i], v[i]] if input[u[i], v[i]] is a non-zero element of input,
otherwise output[i] will be -1. Both u and v should be 1D vectors.
Example::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If csr.data contains zero values, would it be returned as 0 or -1? I don't see verification of "non-zero" when searching the value in csr.data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSR is a special CSR. Its value is edge Id, so it contains edge id 0. So when we search for edges, we only need to check if the location has a value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am aware of that. That's why I think it's not appropriate to put if input[u[i], v[i]] is a non-zero element of input since it also returns elements that are zeros and stored in csr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. i have updated the comment.

@eric-haibin-lin eric-haibin-lin merged commit 388a5f4 into apache:master Nov 24, 2018
@zheng-da zheng-da deleted the dgl_merge branch November 25, 2018 05:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants