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

Class CounterReader

caffe2/python/dataio.py:297–313  ·  view source on GitHub ↗

Reader that produces increasing integers.

Source from the content-addressed store, hash-verified

295
296
297class CounterReader(Reader):
298 """ Reader that produces increasing integers. """
299 def __init__(self):
300 Reader.__init__(self, schema=Struct(('iter', np.int64)))
301 self.counter = None
302 self.should_stop = None
303
304 def setup_ex(self, global_init_net, global_finish_net):
305 if self.counter is None:
306 self.counter = global_init_net.CreateCounter([], init_count=0)
307 self.should_stop = global_init_net.ConstantFill(
308 [], shape=[], dtype=core.DataType.BOOL, value=False)
309
310 def read_ex(self, local_init_net, local_finish_net):
311 count_net = core.Net('limited_reader_counter')
312 value = count_net.CountUp([self.counter], 1)
313 return [count_net], self.should_stop, [value]
314
315
316class ReaderWithLimitBase(Reader):

Callers 1

CountUntilFunction · 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…