(kind, type, op, np_op, shape, get_range, op_desc, eps)
| 529 | |
| 530 | |
| 531 | def 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 | |
| 549 | def test_math_function_ops(): |
nothing calls this directly
no test coverage detected