(kind, type, op, shape, _)
| 492 | |
| 493 | |
| 494 | def check_unary_op(kind, type, op, shape, _): |
| 495 | # Regular arithmetic ops that can be validated as straight numpy |
| 496 | iterator = iter(ExternalInputIterator(batch_size, shape, type, kind)) |
| 497 | pipe = ExprOpPipeline( |
| 498 | kind, type, iterator, op, batch_size=batch_size, num_threads=2, device_id=0 |
| 499 | ) |
| 500 | pipe_out = pipe.run() |
| 501 | for sample in range(batch_size): |
| 502 | in_np, out = extract_un_data(pipe_out, sample, kind, type) |
| 503 | if "f" in np.dtype(type).kind: |
| 504 | np.testing.assert_allclose(out, op(in_np), rtol=1e-07 if type != np.float16 else 0.005) |
| 505 | else: |
| 506 | assert np.array_equal(out, op(in_np)) |
| 507 | |
| 508 | |
| 509 | def test_unary_arithmetic_ops(): |
no test coverage detected