From dda0d05aac8f26eae2346199f7d83669331521ca Mon Sep 17 00:00:00 2001 From: David Schneller <12698011+davschneller@users.noreply.github.com> Date: Mon, 20 Oct 2025 18:15:21 +0200 Subject: [PATCH 1/2] Update node.py --- yateto/ast/node.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yateto/ast/node.py b/yateto/ast/node.py index 93da011..dfd65b7 100644 --- a/yateto/ast/node.py +++ b/yateto/ast/node.py @@ -104,8 +104,7 @@ def __radd__(self, other): return self.__add__(other) def __neg__(self): - self._checkMultipleScalarMults() - return ScalarMultiplication(-1.0, self) + return -1.0 * self def __sub__(self, other): return self._binOp(-other, Add) @@ -479,4 +478,4 @@ def nonZeroFlops(self): return nzFlops def is_empty(self): - return len(self._children) == 0 \ No newline at end of file + return len(self._children) == 0 From 6707b395db93a455b6eeebf11fd2c1a2be438288 Mon Sep 17 00:00:00 2001 From: David Schneller Date: Wed, 12 Nov 2025 18:43:48 +0100 Subject: [PATCH 2/2] Add expression test --- .github/workflows/yateto-ci.yml | 2 +- tests/code-gen/CMakeLists.txt | 2 +- tests/code-gen/expression.py | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/code-gen/expression.py diff --git a/.github/workflows/yateto-ci.yml b/.github/workflows/yateto-ci.yml index 040ef86..77cc6d7 100644 --- a/.github/workflows/yateto-ci.yml +++ b/.github/workflows/yateto-ci.yml @@ -73,7 +73,7 @@ jobs: - name: Codegen Tests run: | cd ./tests/code-gen - for example in matmul minimal; do + for example in matmul minimal expression; do for build_type in Debug Release; do for precision in single double; do echo " ====== Test Config: ======" diff --git a/tests/code-gen/CMakeLists.txt b/tests/code-gen/CMakeLists.txt index 5e03c24..e53c217 100644 --- a/tests/code-gen/CMakeLists.txt +++ b/tests/code-gen/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(EXAMPLES "matmul;minimal" CACHE STRING "a list of examples to run as tests") -set(SAMPLES hosvd matmul minimal seissol_eqspp stock tce) +set(SAMPLES hosvd matmul minimal seissol_eqspp stock tce expression) set_property(CACHE EXAMPLES PROPERTY STRINGS ${SAMPLES}) set(VARIANT "Eigen" CACHE STRING "example-specific variant") diff --git a/tests/code-gen/expression.py b/tests/code-gen/expression.py new file mode 100644 index 0000000..3464c83 --- /dev/null +++ b/tests/code-gen/expression.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +from yateto import * + +def add(g): + n = 32 + A = Tensor('A', (n, n)) + B = Tensor('B', (n, n)) + C = Tensor('C', (n, n)) + a = Scalar('a') + + g.add('axpy', C['ij'] <= A['ij'] + a * B['ij']) + g.add('axpyNeg', C['ij'] <= A['ij'] - a * B['ij']) + + # TODO: add some more simple expression tests here +