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

Method _validate_chunk

caffe2/python/data_workers.py:208–230  ·  view source on GitHub ↗
(self, chunk)

Source from the content-addressed store, hash-verified

206 return None
207
208 def _validate_chunk(self, chunk):
209 if chunk is None:
210 log.warning("Fetcher function returned None")
211 return False
212
213 assert len(chunk) == len(self._input_blob_names), \
214 "Expecting data blob for each input"
215 for d in chunk:
216 assert isinstance(d, np.ndarray), \
217 "Fetcher function must return a numpy array"
218 if not self._dont_rebatch:
219 j = 1
220 for d in chunk[1:]:
221 assert d.shape[self._batch_columns[j]] == \
222 chunk[0].shape[self._batch_columns[0]], \
223 "Each returned input must have equal number of samples"
224 j += 1
225
226 if len(chunk) == 0:
227 log.warning("Worker provided zero length input")
228 return False
229
230 return True
231
232 def put(self, chunk, data_input_coordinator):
233 if not self._validate_chunk(chunk):

Callers 1

putMethod · 0.95

Calls 2

isinstanceFunction · 0.85
warningMethod · 0.80

Tested by

no test coverage detected