MCPcopy Index your code
hub / github.com/pytorch/pytorch / ProcessingReader

Class ProcessingReader

caffe2/python/pipeline.py:353–394  ·  view source on GitHub ↗

Reader that reads from an upstream reader, calls the processor, and returns the processed record.

Source from the content-addressed store, hash-verified

351
352
353class ProcessingReader(Reader):
354 """
355 Reader that reads from an upstream reader, calls the processor, and returns
356 the processed record.
357 """
358 def __init__(self, reader, processor):
359 Reader.__init__(self)
360 self.reader = reader
361 self.processor = make_processor(processor, reader)
362
363 def schema(self):
364 return self.processor.schema()
365
366 def setup_ex(self, init_net, finish_net):
367 self.reader.setup_ex(init_net, finish_net)
368
369 def read_ex(self, init_net, exit_net):
370 read_nets, status, rec = self.reader.read_record_ex(init_net, exit_net)
371 # We don't use status as stop_blob of NetBuilder it's not guarantee that
372 # it would end up being the true stob_blob. For example,
373 # ReaderWithLimitBase doesn't pass the status through but rather copy
374 # from it.
375 with NetBuilder() as nb:
376 # Current NetBuilder is optionally used inside the processor,
377 # then its children are retrieved inside of
378 # normalize_processor_output.
379 # Once readers and writers also use NetBuilder,
380 # this logic will be more natural.
381 result = normalize_processor_output(self.processor(rec))
382 read_nets += result.nets
383 if result.should_stop or nb._stop_blob:
384 stop_net = core.Net('stop_net')
385 if result.should_stop:
386 stop_net.Or([status, result.should_stop], [status])
387 if nb._stop_blob:
388 stop_net.Or([status, nb._stop_blob], [status])
389 read_nets.append(stop_net)
390 if hasattr(self.processor, 'setup'):
391 init_net.add_attribute(TaskGroup.LOCAL_SETUP, self.processor)
392 self._set_schema(result.record)
393 fields = result.record.field_blobs() if result.record else None
394 return read_nets, status, fields
395
396
397class NetProcessor:

Callers 1

_pipe_stepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…