Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions gigl/nn/graph_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

from gigl.src.common.types.graph_data import EdgeType, NodeType
from gigl.transforms.graph_transformer import (
PPR_RELATION_FEATURES_NAME,
PPR_WEIGHT_FEATURE_NAME,
SequenceAuxiliaryData,
TokenInputData,
_validate_reserved_anchor_feature_usage,
heterodata_to_graph_transformer_input,
)

Expand Down Expand Up @@ -1323,19 +1325,12 @@ def __init__(
anchor_bias_attr_names = anchor_based_attention_bias_attr_names
anchor_input_attr_names = anchor_based_input_attr_names
pairwise_bias_attr_names = pairwise_attention_bias_attr_names
if PPR_WEIGHT_FEATURE_NAME in pairwise_bias_attr_names:
raise ValueError(
f"'{PPR_WEIGHT_FEATURE_NAME}' is an anchor-relative feature and "
"cannot be used as pairwise attention bias."
)
if (
PPR_WEIGHT_FEATURE_NAME in anchor_bias_attr_names + anchor_input_attr_names
and sequence_construction_method != "ppr"
):
raise ValueError(
"The reserved anchor-relative feature 'ppr_weight' requires "
"sequence_construction_method='ppr'."
)
_validate_reserved_anchor_feature_usage(
pairwise_bias_attr_names=pairwise_bias_attr_names,
anchor_bias_attr_names=anchor_bias_attr_names,
anchor_input_attr_names=anchor_input_attr_names,
sequence_construction_method=sequence_construction_method,
)
self._sequence_construction_method = sequence_construction_method
self._sampling_direction = sampling_direction
self._sequence_positional_encoding_type = sequence_positional_encoding_type
Expand Down Expand Up @@ -1574,6 +1569,7 @@ def forward(
relative_pe_attr_names.update(self._anchor_based_input_attr_names or [])
relative_pe_attr_names.update(self._pairwise_attention_bias_attr_names or [])
relative_pe_attr_names.discard(PPR_WEIGHT_FEATURE_NAME)
relative_pe_attr_names.discard(PPR_RELATION_FEATURES_NAME)
if relative_pe_attr_names:
for attr_name in sorted(relative_pe_attr_names):
if hasattr(data, attr_name):
Expand Down
Loading