FeatureStore

class dgl.graphbolt.FeatureStore[source]

Bases: object

A store to manage multiple features for access.

metadata(domain: str, type_name: str, feature_name: str)[source]

Get the metadata of the specified feature in the feature store.

Parameters
  • domain (str) – The domain of the feature such as “node”, “edge” or “graph”.

  • type_name (str) – The node or edge type name.

  • feature_name (str) – The feature name.

Returns

The metadata of the feature.

Return type

Dict

read(domain: str, type_name: str, feature_name: str, ids: Optional[torch.Tensor] = None)[source]

Read from the feature store.

Parameters
  • domain (str) – The domain of the feature such as “node”, “edge” or “graph”.

  • type_name (str) – The node or edge type name.

  • feature_name (str) – The feature name.

  • ids (torch.Tensor, optional) – The index of the feature. If specified, only the specified indices of the feature are read. If None, the entire feature is returned.

Returns

The read feature.

Return type

torch.Tensor

size(domain: str, type_name: str, feature_name: str)[source]

Get the size of the specified feature in the feature store.

Parameters
  • domain (str) – The domain of the feature such as “node”, “edge” or “graph”.

  • type_name (str) – The node or edge type name.

  • feature_name (str) – The feature name.

Returns

The size of the specified feature in the feature store.

Return type

torch.Size

update(domain: str, type_name: str, feature_name: str, value: torch.Tensor, ids: Optional[torch.Tensor] = None)[source]

Update the feature store.

Parameters
  • domain (str) – The domain of the feature such as “node”, “edge” or “graph”.

  • type_name (str) – The node or edge type name.

  • feature_name (str) – The feature name.

  • value (torch.Tensor) – The updated value of the feature.

  • ids (torch.Tensor, optional) – The indices of the feature to update. If specified, only the specified indices of the feature will be updated. For the feature, the ids[i] row is updated to value[i]. So the indices and value must have the same length. If None, the entire feature will be updated.