def test_fill_state(): with ExecutorFactory() as ex: N = ng.make_axis(3, name='N') x_np = np.ones((N.length)) * 4 x = ng.variable([N], initial_value=x_np).named('x') val = ng.sequential([ng.fill(x, -1), x]) f = ex.executor(val) x_val = f() assert np.allclose(-1, x_val)
def test_fill_slice(transformer_factory): axes = ng.make_axes([ng.make_axis(length=2), ng.make_axis(length=8)]) a = ng.placeholder(axes=axes) b = ng.sequential([ng.fill(a[:, 1], 0), ng.value_of(a)]) with ExecutorFactory() as ex: func = ex.executor(b, a) baseline = func( np.array([[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1]], dtype=np.float32)) expected = np.array([[1, 0, 3, 4, 5, 6, 7, 8], [8, 0, 6, 5, 4, 3, 2, 1]]) ng.testing.assert_allclose(baseline, expected)