(kinds, types, op, shape, get_range, _)
| 781 | |
| 782 | |
| 783 | def check_arithm_binary_float(kinds, types, op, shape, get_range, _): |
| 784 | if isinstance(op, tuple): |
| 785 | dali_op, numpy_op = op |
| 786 | else: |
| 787 | dali_op = numpy_op = op |
| 788 | left_type, right_type = types |
| 789 | target_type = div_promote(left_type, right_type) |
| 790 | iterator = iter( |
| 791 | ExternalInputIterator( |
| 792 | batch_size, |
| 793 | shape, |
| 794 | types, |
| 795 | kinds, |
| 796 | (False, True), |
| 797 | limited_range=get_range(left_type, right_type), |
| 798 | ) |
| 799 | ) |
| 800 | pipe = ExprOpPipeline( |
| 801 | kinds, types, iterator, dali_op, batch_size=batch_size, num_threads=2, device_id=0 |
| 802 | ) |
| 803 | pipe_out = pipe.run() |
| 804 | for sample in range(batch_size): |
| 805 | l_np, r_np, out = extract_data(pipe_out, sample, kinds, target_type) |
| 806 | assert_equals(out.dtype, target_type) |
| 807 | np.testing.assert_allclose( |
| 808 | out, |
| 809 | numpy_op(l_np, r_np), |
| 810 | rtol=1e-06 if target_type != np.float16 else 0.005, |
| 811 | err_msg=f"{l_np} op\n{r_np} =\n{out}", |
| 812 | ) |
| 813 | |
| 814 | |
| 815 | def test_arithmetic_binary_float_big(): |
nothing calls this directly
no test coverage detected