Operations on edges group by weight


#1

If each weight has a weight, we can regard the weight as the information. I want to pass messages group by the information. Does DGL have the API?

pass messages example:

def gcn_msg(edge):
    msg = edge.src['h'] * edge.src['norm']
    return {'m': msg}

By the way, does DGL pass messages on the whole edges at once? I want to batch the edges when passing the message.


#2

Hi, the message function you defined looks good to me so I’m not sure what’s the problem here. dgl performs message passing on a set of edges independently in parallel and the particular set of edges can be specified by the users.


#3

How can i do that? Would give me an example?


#4

This is similar to this question. Basically, how many edges and which set of edges will be processed in a batch cannot be specified by the user. It leaves space for system optimization. For example, if the number of edges are too large, the system might chop the edges into several small batches and process it one-by-one.

However in current implementation, all the edges given are batched for passing messages:

  • If it’s a update_all, then all the edges in the graph are batched.
  • If it’s a send_and_recv(edges), then all the given edges are batched.

But note that, relying on the above semantics in the code is unsafe because they could be changed in the future.


#5

I hope i can specific which set of edges will be processed in a batch in the future.


#6

Could you elaborate the use case?


#7

One thing that might help you is that if you want to pick a set of edges e to be processed in a batch, send_and_recv is always your friend:

edges = ... # the set of edges to be processed in a batch.
g.send_and_recv(edges, ...)