Skip to main content

sparse_attention_message

Function sparse_attention_message 

Source
pub fn sparse_attention_message(
    adj_row_offsets: &[usize],
    adj_col_indices: &[usize],
    node_features: &[f64],
    attention_weights: &[f64],
    feature_dim: usize,
) -> Result<Vec<f64>, SparseError>
Expand description

Attention-weighted message passing.

For each node i, computes:

output[i, :] = sum_{j in N(i)} alpha_ij * features[j, :]

where attention_weights provides one scalar weight per edge.

§Arguments

  • adj_row_offsets – CSR row pointer (length num_nodes + 1).
  • adj_col_indices – CSR column indices (length num_edges).
  • node_features – Dense feature matrix, row-major (num_nodes x feature_dim).
  • attention_weights – One weight per edge (length num_edges).
  • feature_dim – Dimensionality of node features.

§Errors

Returns SparseError::DimensionMismatch on size mismatches.