MCPcopy
hub / github.com/dmlc/dgl / slice

Method slice

python/dgl/frame.py:24–32  ·  view source on GitHub ↗

Create a new _LazyIndex object sliced by the given index tensor.

(self, index)

Source from the content-addressed store, hash-verified

22 return len(self._indices[-1])
23
24 def slice(self, index):
25 """Create a new _LazyIndex object sliced by the given index tensor."""
26 # if our indices are in the same context, lets just slice now and free
27 # memory, otherwise do nothing until we have to
28 if F.context(self._indices[-1]) == F.context(index):
29 return _LazyIndex(
30 self._indices[:-1] + [F.gather_row(self._indices[-1], index)]
31 )
32 return _LazyIndex(self._indices + [index])
33
34 def flatten(self):
35 """Evaluate the chain of indices, and return a single index tensor."""

Callers 1

subcolumnMethod · 0.80

Calls 2

_LazyIndexClass · 0.85
contextMethod · 0.80

Tested by

no test coverage detected