A column is a compact store of features of multiple nodes/edges. It batches all the feature tensors together along the first dimension as one dense tensor. The column can optionally have an index tensor I. In this case, the i^th feature is stored in ``storage[index[i]]``. The c
| 165 | |
| 166 | |
| 167 | class Column(TensorStorage): |
| 168 | """A column is a compact store of features of multiple nodes/edges. |
| 169 | |
| 170 | It batches all the feature tensors together along the first dimension |
| 171 | as one dense tensor. |
| 172 | |
| 173 | The column can optionally have an index tensor I. |
| 174 | In this case, the i^th feature is stored in ``storage[index[i]]``. |
| 175 | The column class implements a Copy-On-Read semantics -- the index |
| 176 | select operation happens upon the first read of the feature data. |
| 177 | This is useful when one extracts a subset of the feature data |
| 178 | but wishes the actual index select happens on-demand. |
| 179 | |
| 180 | Parameters |
| 181 | ---------- |
| 182 | storage : Tensor |
| 183 | The feature data storage. |
| 184 | scheme : Scheme, optional |
| 185 | The scheme of the column. Will be inferred if not provided. |
| 186 | index : Tensor, optional |
| 187 | The row index to the feature data storage. None means an |
| 188 | identity mapping. |
| 189 | |
| 190 | Attributes |
| 191 | ---------- |
| 192 | storage : Tensor |
| 193 | The storage tensor. The storage tensor may not be the actual data |
| 194 | tensor of this column when the index tensor is not None. |
| 195 | This typically happens when the column is extracted from another |
| 196 | column using the `subcolumn` method. |
| 197 | |
| 198 | It can also be None, which may only happen when transmitting a |
| 199 | not-yet-materialized subcolumn from a subprocess to the main process. |
| 200 | In this case, the main process should already maintain the content of |
| 201 | the storage, and is responsible for restoring the subcolumn's storage pointer. |
| 202 | data : Tensor |
| 203 | The actual data tensor of this column. |
| 204 | scheme : Scheme |
| 205 | The scheme of the column. |
| 206 | index : Tensor |
| 207 | Index tensor |
| 208 | """ |
| 209 | |
| 210 | def __init__(self, storage, *args, **kwargs): |
| 211 | super().__init__(storage) |
| 212 | self._init(*args, **kwargs) |
| 213 | |
| 214 | def __len__(self): |
| 215 | """The number of features (number of rows) in this column.""" |
| 216 | if self.index is None: |
| 217 | return F.shape(self.storage)[0] |
| 218 | else: |
| 219 | return len(self.index) |
| 220 | |
| 221 | @property |
| 222 | def shape(self): |
| 223 | """Return the scheme shape (feature shape) of this column.""" |
| 224 | return self.scheme.shape |
no outgoing calls