| 353 | |
| 354 | |
| 355 | def test_goptions(): |
| 356 | @trace(symbolic=True, opt_level=0, capture_as_const=True) |
| 357 | def f(x): |
| 358 | # directly return x / x will not trigger gopt |
| 359 | # since there's no way to tell the two x are the same |
| 360 | y = 2.0 * x |
| 361 | return y / y |
| 362 | |
| 363 | @trace(symbolic=True, opt_level=1, capture_as_const=True) |
| 364 | def g(x): |
| 365 | y = 2.0 * x |
| 366 | return y / y |
| 367 | |
| 368 | d = tensor(0.0) |
| 369 | assert not np.isfinite(f(d).numpy()) |
| 370 | np.testing.assert_equal(g(d).numpy().item(), 1.0) |
| 371 | |
| 372 | |
| 373 | def test_goptions_log_sum_exp(): |