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

Function check_arithm_binary_float

dali/test/python/operator_1/test_arithmetic_ops.py:783–812  ·  view source on GitHub ↗
(kinds, types, op, shape, get_range, _)

Source from the content-addressed store, hash-verified

781
782
783def 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
815def test_arithmetic_binary_float_big():

Callers

nothing calls this directly

Calls 6

assert_equalsFunction · 0.90
div_promoteFunction · 0.85
ExprOpPipelineClass · 0.85
extract_dataFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected