(dali_datasets, iterations, to_stop_iter=False)
| 225 | |
| 226 | |
| 227 | def run_dataset_in_graph(dali_datasets, iterations, to_stop_iter=False): |
| 228 | if not isinstance(dali_datasets, list): |
| 229 | dali_datasets = [dali_datasets] |
| 230 | |
| 231 | dataset_results = [] |
| 232 | initializers = [tf.compat.v1.global_variables_initializer()] |
| 233 | ops_to_run = [] |
| 234 | |
| 235 | for dali_dataset in dali_datasets: |
| 236 | iterator = tf.compat.v1.data.make_initializable_iterator(dali_dataset) |
| 237 | initializers.append(iterator.initializer) |
| 238 | ops_to_run.append(iterator.get_next()) |
| 239 | |
| 240 | with tf.compat.v1.Session() as sess: |
| 241 | sess.run(initializers) |
| 242 | with expect_iter_end(not to_stop_iter, tf.errors.OutOfRangeError): |
| 243 | for _ in range(iterations): |
| 244 | dataset_results.append(sess.run(ops_to_run)) |
| 245 | return dataset_results |
| 246 | |
| 247 | |
| 248 | def run_dataset_eager_mode(dali_datasets, iterations, to_stop_iter=False): |
no test coverage detected