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

Method read_ex

caffe2/python/dataio.py:541–569  ·  view source on GitHub ↗

Stops when one of the reader finished

(self, local_init_net, local_finish_net)

Source from the content-addressed store, hash-verified

539 reader.setup_ex(init_net, finish_net)
540
541 def read_ex(self, local_init_net, local_finish_net):
542 """
543 Stops when one of the reader finished
544 """
545 # First, instantiate all the reader nets
546 fields = []
547 stop_blobs = []
548 all_sub_read_nets = []
549 for name, reader in zip(self._names, self._readers):
550 sub_read_nets, should_stop, record = reader.read_record_ex(
551 local_init_net, local_finish_net)
552 stop_blobs.append(should_stop)
553 all_sub_read_nets.append(sub_read_nets)
554 fields.extend(record.field_blobs())
555
556 read_nets = []
557 # Use the stop blob of the last reader as stop blob of composite reader.
558 local_should_stop = stop_blobs[-1]
559 for name, sub_read_nets, stop_blob in zip(self._names, all_sub_read_nets, stop_blobs):
560 read_nets.extend(sub_read_nets)
561 if stop_blob == local_should_stop:
562 # Skip adding stop net because Or([A, A], A) doesn't pass operator
563 # schema check
564 continue
565 stop_net = core.Net("{}_stop".format(name))
566 stop_net.Or([local_should_stop, stop_blob], local_should_stop)
567 read_nets.append(stop_net)
568
569 return read_nets, local_should_stop, fields
570
571 def reset(self, net):
572 for reader in self._readers:

Callers

nothing calls this directly

Calls 6

read_record_exMethod · 0.80
NetMethod · 0.80
appendMethod · 0.45
extendMethod · 0.45
field_blobsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected