MCPcopy Create free account
hub / github.com/pytorch/pytorch / split

Method split

caffe2/python/operator_test/segment_ops_test.py:172–186  ·  view source on GitHub ↗
(self, data, lengths, indices=None)

Source from the content-addressed store, hash-verified

170
171class LengthsTester(TesterBase):
172 def split(self, data, lengths, indices=None):
173 K = len(lengths)
174 outputs = [
175 np.zeros((lengths[seg_id], ) + data.shape[1:],
176 dtype=data.dtype) for seg_id in range(0, K)
177 ]
178 start = 0
179 for i in range(0, K):
180 for j in range(0, lengths[i]):
181 data_index = start + j
182 if indices is not None:
183 data_index = indices[data_index]
184 outputs[i][j] = data[data_index]
185 start += lengths[i]
186 return outputs
187
188 def unsplit(self, extra_shape, inputs, lengths):
189 N = sum(lengths)

Callers 15

parse_summaryFunction · 0.45
test_simple_cnnmodelMethod · 0.45
__getitem__Method · 0.45
__getitem__Method · 0.45
create_internalMethod · 0.45
from_column_listFunction · 0.45
renderFunction · 0.45
parse_kwargFunction · 0.45
mainFunction · 0.45
_GroupByDeviceFunction · 0.45

Calls 2

rangeFunction · 0.50
zerosMethod · 0.45

Tested by

no test coverage detected