What is the difference between two functions u_dot_v and u_mul_v

I have seen the doc, it says

dgl.function. u_mul_v ( lhs_field , rhs_field , out )
Builtin message function that computes a message on an edge by performing element-wise mul between features of src and dst if the features have the same shape; otherwise, it first broadcasts the features to a new shape and performs the element-wise operation.

dgl.function. u_dot_v ( lhs_field , rhs_field , out )
Builtin message function that computes a message on an edge by performing element-wise dot between features of src and dst if the features have the same shape; otherwise, it first broadcasts the features to a new shape and performs the element-wise operation.

I just want the element-wise scalar mul, it seems I should use u_mul_v, but what is u_dot_v’s element-wise dot?

1 Like

If what you need is element-wise mul, use u_mul_v.

u_dot_v will reduce the last dimension, for example, when the lhs_field has shape (N, D), and rhs_field has shape (N, D), the shape of result would be (E). This would useful in scenarios like attention and saves more GPU memory then u_mul_v.

1 Like