MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / test_goptions

Function test_goptions

imperative/python/test/unit/jit/test_tracing.py:355–370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353
354
355def 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
373def test_goptions_log_sum_exp():

Callers

nothing calls this directly

Calls 6

assert_equalMethod · 0.80
fFunction · 0.70
gFunction · 0.70
isfiniteMethod · 0.45
numpyMethod · 0.45
itemMethod · 0.45

Tested by

no test coverage detected