From 6fb104ac7934af4120c2ed1632f43ad7682f2685 Mon Sep 17 00:00:00 2001 From: Emilien Bauer Date: Sun, 25 Feb 2024 10:48:05 +0000 Subject: [PATCH] Add inplace test. --- tests/test_xdsl_base.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_xdsl_base.py b/tests/test_xdsl_base.py index 0899fedd03..bfd70dd614 100644 --- a/tests/test_xdsl_base.py +++ b/tests/test_xdsl_base.py @@ -68,6 +68,28 @@ def test_xdsl_III(): assert type(ops[9] == Return) +def test_u_simple(): + value = 0.0001 + + # Define a simple Devito Operator + grid = Grid(shape=(3, 3)) + u = TimeFunction(name="u", grid=grid, time_order=0) + u.data[:] = value + + eq0 = Eq(u, u + 1) + op = Operator([eq0]) + op.apply(time_M=5) + norm_u = norm(u) + + u.data[:] = value + xdsl_op = Operator([eq0], opt="xdsl") + xdsl_op.apply(time_M=5) + norm_u2 = norm(u) + + assert np.isclose(norm_u, norm_u2, atol=1e-5, rtol=0) + assert np.isclose(norm_u, 18.0003, atol=1e-5, rtol=0) + + def test_diffusion_2D(): # Define a simple Devito Operator grid = Grid(shape=(3, 3))