MCPcopy
hub / github.com/THUDM/CogDL / apply

Method apply

cogdl/data/data.py:104–115  ·  view source on GitHub ↗

r"""Applies the function :obj:`func` to all attributes :obj:`*keys`. If :obj:`*keys` is not given, :obj:`func` is applied to all present attributes.

(self, func, *keys)

Source from the content-addressed store, hash-verified

102 return self.cat_dim(key, value)
103
104 def apply(self, func, *keys):
105 r"""Applies the function :obj:`func` to all attributes :obj:`*keys`.
106 If :obj:`*keys` is not given, :obj:`func` is applied to all present
107 attributes.
108 """
109 for key, item in self(*keys):
110 if isinstance(item, Adjacency):
111 self[key] = func(item)
112 if not isinstance(item, torch.Tensor):
113 continue
114 self[key] = func(item)
115 return self
116
117 def contiguous(self, *keys):
118 r"""Ensures a contiguous memory layout for all attributes :obj:`*keys`.

Callers 15

contiguousMethod · 0.95
toMethod · 0.95
cudaMethod · 0.95
__init__Method · 0.80
__init__Method · 0.80
csrmhspmmFunction · 0.80
fused_gat_funcFunction · 0.80
csr_edge_softmaxFunction · 0.80
csrspmmFunction · 0.80
scatter_maxFunction · 0.80
train_stepMethod · 0.80
pre_stageMethod · 0.80

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected