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

Function check_math_function_op

dali/test/python/operator_1/test_arithmetic_ops.py:531–546  ·  view source on GitHub ↗
(kind, type, op, np_op, shape, get_range, op_desc, eps)

Source from the content-addressed store, hash-verified

529
530
531def check_math_function_op(kind, type, op, np_op, shape, get_range, op_desc, eps):
532 is_integer = type not in [np.float16, np.float32, np.float64]
533 limted_range = get_range(type)
534 iterator = iter(
535 ExternalInputIterator(batch_size, shape, type, kind, limited_range=limted_range)
536 )
537 pipe = ExprOpPipeline(
538 kind, type, iterator, op, batch_size=batch_size, num_threads=2, device_id=0
539 )
540 pipe_out = pipe.run()
541 out_type = np.float32 if is_integer else type
542 for sample in range(batch_size):
543 in_np, out = extract_un_data(pipe_out, sample, kind, out_type)
544 np.testing.assert_allclose(
545 out, np_op(in_np.astype(out_type)), rtol=eps if type != np.float16 else 0.005
546 )
547
548
549def test_math_function_ops():

Callers

nothing calls this directly

Calls 4

ExprOpPipelineClass · 0.85
extract_un_dataFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected