def test_give_handle(): @myia(use_universe=True) def plus(h, y): i = y while i > 0: increment(h) i = i - 1 return handle_get(h) h1 = HandleInstance(0) h2 = HandleInstance(0) # handle is updated automatically assert plus(h1, 4) == 4 assert plus(h2, 9) == 9 assert plus(h1, 30) == 34
def test_give_handle(): @umyia def plus(h, y): i = y while i > 0: increment(h) i = i - 1 return cell_get(h) h1 = HandleInstance(0) h2 = HandleInstance(0) hb1 = plus.to_device(h1) hb2 = plus.to_device(h2) # handle is updated automatically assert plus(hb1, 4) == 4 assert plus(hb2, 9) == 9 assert plus(hb1, 30) == 34
def test_give_handle(): @myia(use_universe=True, backend='relay') def plus(h, y): i = y while i > 0: increment(h) i = i - 1 return handle_get(h) h1 = HandleInstance(0) h2 = HandleInstance(0) hb1 = plus.to_device(h1) hb2 = plus.to_device(h2) # handle is updated automatically assert plus(hb1, 4) == 4 assert plus(hb2, 9) == 9 assert plus(hb1, 30) == 34
def test_return_handle(): @myia(use_universe=True) def plus2(h): increment(h) increment(h) return h h = HandleInstance(0) h2 = plus2(h) assert h2.state == 2
def test_increment_recursion(): @myia(use_universe=True) def length(h, xs): if not isinstance(xs, Empty): increment(h) length(h, xs.tail) return handle_get(h) h = HandleInstance(0) assert length(h, [1, 2, 3, 4]) == 4
def test_increment_recursion(): @umyia def length(h, xs): if not isinstance(xs, Empty): increment(h) length(h, xs.tail) return cell_get(h) h = HandleInstance(0) hb = length.to_device(h) assert length(hb, [1, 2, 3, 4]) == 4
def test_increment_recursion(): @myia(use_universe=True, backend='relay') def length(h, xs): if not isinstance(xs, Empty): increment(h) length(h, xs.tail) return handle_get(h) h = HandleInstance(0) hb = length.to_device(h) assert length(hb, [1, 2, 3, 4]) == 4
def test_return_handle(): @umyia def plus2(h): increment(h) increment(h) return h h = HandleInstance(0) hb = plus2.to_device(h) # This might return a BackendValue later but it seems # to return the handle for now. h2 = plus2(hb) assert h2.state == 2
def test_handle_free_variable(): h = HandleInstance(0) @umyia def plus(y): i = y while i > 0: increment(h) i = i - 1 return cell_get(h) # handle is updated automatically assert plus(4) == 4 assert plus(30) == 34
def test_give_handle(): @myia( use_universe=True, backend="relay", backend_options={"exec_kind": "debug"}, pipeline=upipeline, ) def plus(h, y): i = y while i > 0: increment(h) i = i - 1 return handle_get(h) h1 = HandleInstance(0) h2 = HandleInstance(0) hb1 = plus.to_device(h1) hb2 = plus.to_device(h2) # handle is updated automatically assert plus(hb1, 4) == 4 assert plus(hb2, 9) == 9 assert plus(hb1, 30) == 34
def test_increment_recursion(): @myia( use_universe=True, backend="relay", backend_options={"exec_kind": "debug"}, pipeline=upipeline, ) def length(h, xs): if not isinstance(xs, Empty): increment(h) length(h, xs.tail) return handle_get(h) h = HandleInstance(0) hb = length.to_device(h) assert length(hb, [1, 2, 3, 4]) == 4
def test_return_handle(): @myia( use_universe=True, backend="relay", backend_options={"exec_kind": "debug"}, pipeline=upipeline, ) def plus2(h): increment(h) increment(h) return h h = HandleInstance(0) hb = plus2.to_device(h) # This might return a BackendValue later but it seems # to return the handle for now. h2 = plus2(hb) assert h2.state == 2
def __init__(self): self._count = HandleInstance(0)