特征存储

class dgl.graphbolt.FeatureStore[source]

Bases: object

一个用于管理多个访问功能的存储。

keys()[source]

获取特征的键。

Returns:

The keys of the features. The tuples are in (domain, type_name, feat_name) format.

Return type:

List[tuple]

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

获取特征存储中指定特征的元数据。

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:

特征的元数据。

Return type:

字典

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

从特征存储中读取。

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:

读取功能。

Return type:

torch.Tensor

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

获取特征存储中指定特征的大小。

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:

特征存储中指定特征的大小。

Return type:

torch.Size

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

更新特征存储。

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.