(trace_mode, return_mode)
| 33 | @pytest.mark.parametrize("trace_mode", [False, True]) |
| 34 | @pytest.mark.parametrize("return_mode", ["Value", "Tuple", "List", "Dict"]) |
| 35 | def test_trace(trace_mode, return_mode): |
| 36 | @trace(symbolic=trace_mode) |
| 37 | def f(x): |
| 38 | if return_mode == "Tuple": |
| 39 | return (-x,) |
| 40 | elif return_mode == "List": |
| 41 | return [-x] |
| 42 | elif return_mode == "Dict": |
| 43 | return {"neg": -x} |
| 44 | else: |
| 45 | return -x |
| 46 | |
| 47 | def get_numpy(y): |
| 48 | if return_mode == "Tuple" or return_mode == "List": |
| 49 | return y[0].numpy() |
| 50 | elif return_mode == "Dict": |
| 51 | return y["neg"].numpy() |
| 52 | return y.numpy() |
| 53 | |
| 54 | x = tensor([1]) |
| 55 | y = get_numpy(f(x)) |
| 56 | |
| 57 | for i in range(3): |
| 58 | np.testing.assert_equal(get_numpy(f(x)), y) |
| 59 | |
| 60 | |
| 61 | def test_output_copy_trace(): |
nothing calls this directly
no test coverage detected