in graphlearn_torch/python/data/dataset.py [0:0]
def _build_features(feature_data, id2idx, split_ratio,
device_group_list, device, with_gpu, dtype):
r""" Build `Feature`s for node/edge feature data.
"""
if feature_data is not None:
if isinstance(feature_data, dict):
# heterogeneous.
if not isinstance(split_ratio, dict):
split_ratio = {
graph_type: float(split_ratio)
for graph_type in feature_data.keys()
}
if id2idx is not None:
assert isinstance(id2idx, dict)
else:
id2idx = {}
features = {}
for graph_type, feat in feature_data.items():
features[graph_type] = Feature(
feat, id2idx.get(graph_type, None),
split_ratio.get(graph_type, 0.0),
device_group_list, device, with_gpu,
dtype if dtype is not None else feat.dtype
)
else:
# homogeneous.
features = Feature(
feature_data, id2idx, float(split_ratio),
device_group_list, device, with_gpu,
dtype if dtype is not None else feature_data.dtype
)
else:
features = None
return features