Return the weights of A at the locations identical to the sparsity pattern of B. If a non-zero entry in B does not exist in A, DGL returns 0 for that location instead. Note that the edge weights of the graph must be scalar, i.e. :attr:`A_weights` must be a 1D vector. In sc
(A, A_weights, B)
| 858 | |
| 859 | |
| 860 | def _csrmask(A, A_weights, B): |
| 861 | """Return the weights of A at the locations identical to the sparsity pattern |
| 862 | of B. |
| 863 | |
| 864 | If a non-zero entry in B does not exist in A, DGL returns 0 for that location |
| 865 | instead. |
| 866 | |
| 867 | Note that the edge weights of the graph must be scalar, i.e. :attr:`A_weights` |
| 868 | must be a 1D vector. |
| 869 | |
| 870 | In scipy notation this is identical to ``A[B != 0]``. |
| 871 | |
| 872 | Parameters |
| 873 | ---------- |
| 874 | A : HeteroGraphIndex |
| 875 | The input graph index as left operand. |
| 876 | A_weights : Tensor |
| 877 | The edge weights of graph A as 1D tensor. |
| 878 | B : HeteroGraphIndex |
| 879 | The input graph index as right operand. |
| 880 | |
| 881 | Returns |
| 882 | ------- |
| 883 | B_weights : Tensor |
| 884 | The output weights. |
| 885 | """ |
| 886 | return F.from_dgl_nd(_CAPI_DGLCSRMask(A, F.to_dgl_nd(A_weights), B)) |
| 887 | |
| 888 | |
| 889 | ################################################################################################### |