| 361 | |
| 362 | |
| 363 | def 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 | |
| 404 | def test_reduce_with_mean_input(): |