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

Method testInputOrder

caffe2/python/data_workers_test.py:116–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

114
115 @unittest.skip("Test is flaky: https://github.com/pytorch/pytorch/issues/9064")
116 def testInputOrder(self):
117 #
118 # Create two models (train and validation) with same input blobs
119 # names and ensure that both will get the data in correct order
120 #
121 workspace.ResetWorkspace()
122 self.counters = {0: 0, 1: 1}
123
124 def dummy_fetcher_rnn_ordered1(fetcher_id, batch_size):
125 # Hardcoding some input blobs
126 T = 20
127 N = batch_size
128 D = 33
129 data = np.zeros((T, N, D))
130 data[0][0][0] = self.counters[fetcher_id]
131 label = np.random.randint(N, size=(T, N))
132 label[0][0] = self.counters[fetcher_id]
133 seq_lengths = np.random.randint(N, size=(N))
134 seq_lengths[0] = self.counters[fetcher_id]
135 self.counters[fetcher_id] += 1
136 return [data, label, seq_lengths]
137
138 workspace.ResetWorkspace()
139 model = model_helper.ModelHelper(name="rnn_test_order")
140
141 coordinator = data_workers.init_data_input_workers(
142 model,
143 input_blob_names=["data2", "label2", "seq_lengths2"],
144 fetch_fun=dummy_fetcher_rnn_ordered1,
145 batch_size=32,
146 max_buffered_batches=1000,
147 num_worker_threads=1,
148 dont_rebatch=True,
149 input_source_name='train'
150 )
151 coordinator.start()
152
153 val_model = model_helper.ModelHelper(name="rnn_test_order_val")
154 coordinator1 = data_workers.init_data_input_workers(
155 val_model,
156 input_blob_names=["data2", "label2", "seq_lengths2"],
157 fetch_fun=dummy_fetcher_rnn_ordered1,
158 batch_size=32,
159 max_buffered_batches=1000,
160 num_worker_threads=1,
161 dont_rebatch=True,
162 input_source_name='val'
163 )
164 coordinator1.start()
165
166 workspace.RunNetOnce(model.param_init_net)
167 workspace.CreateNet(model.net)
168 workspace.CreateNet(val_model.net)
169
170 while coordinator._coordinators[0]._state._inputs < 900:
171 time.sleep(0.01)
172
173 with timeout_guard.CompleteInTimeOrDie(5):

Callers

nothing calls this directly

Calls 5

rangeFunction · 0.50
startMethod · 0.45
ProtoMethod · 0.45
assertEqualMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected