MCPcopy Create free account
hub / github.com/NVIDIA/DALI / run_reduce_with_mean_input

Function run_reduce_with_mean_input

dali/test/python/operator_2/test_reduce.py:363–401  ·  view source on GitHub ↗
(
    keep_dims, reduction_name, batch_gen, input_type, output_type=None, layout=None
)

Source from the content-addressed store, hash-verified

361
362
363def run_reduce_with_mean_input(
364 keep_dims, reduction_name, batch_gen, input_type, output_type=None, layout=None
365):
366 batch_fn = batch_gen(input_type)
367 dali_reduce_fn, numpy_reduce_fn = reduce_fns[reduction_name]
368
369 for axes in batch_fn.valid_axes():
370 if axes == ():
371 valid_ddofs = [0]
372 elif axes is None:
373 valid_ddofs = [0, 1, 2, 3]
374 else:
375 valid_ddofs = [0, 1]
376 for ddof in valid_ddofs:
377 dali_res_cpu, dali_res_gpu = run_dali(
378 dali_reduce_fn,
379 batch_fn,
380 keep_dims=keep_dims,
381 axes=axes,
382 output_type=output_type,
383 add_mean_input=True,
384 ddof=ddof,
385 layout=layout,
386 )
387
388 batch_fn.reset()
389
390 np_res = run_numpy(
391 numpy_reduce_fn,
392 batch_fn,
393 keep_dims=keep_dims,
394 axes=axes,
395 output_type=output_type,
396 ddof=ddof,
397 )
398
399 for iteration in range(batch_fn.num_iter()):
400 compare(dali_res_cpu[iteration], np_res[iteration])
401 compare(dali_res_gpu[iteration], np_res[iteration])
402
403
404def test_reduce_with_mean_input():

Callers

nothing calls this directly

Calls 7

run_daliFunction · 0.85
run_numpyFunction · 0.85
num_iterMethod · 0.80
batch_genFunction · 0.70
compareFunction · 0.70
valid_axesMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected