From 35ddb010433e73bf5fdd93de277635213ac24739 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 27 Aug 2024 17:51:56 -0500 Subject: [PATCH] Numpy actx: warn (not error) on no user-provided transforms --- arraycontext/impl/numpy/__init__.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arraycontext/impl/numpy/__init__.py b/arraycontext/impl/numpy/__init__.py index 7d724b84..77b7b49f 100644 --- a/arraycontext/impl/numpy/__init__.py +++ b/arraycontext/impl/numpy/__init__.py @@ -43,6 +43,7 @@ ArrayOrContainerOrScalar, ArrayOrContainerOrScalarT, NumpyOrContainerOrScalar, + UntransformedCodeWarning, ) @@ -116,9 +117,21 @@ def _thaw(ary): # }}} def transform_loopy_program(self, t_unit): - raise ValueError("NumpyArrayContext does not implement " - "transform_loopy_program. Sub-classes are supposed " - "to implement it.") + from warnings import warn + warn("Using the base " + f"{type(self).__name__}.transform_loopy_program " + "to transform a translation unit. " + "This is a no-op and will result in unoptimized C code for" + "the requested optimization, all in a single statement." + "This will work, but is unlikely to be performant." + f"Instead, subclass {type(self).__name__} and implement " + "the specific transform logic required to transform the program " + "for your package or application. Check higher-level packages " + "(e.g. meshmode), which may already have subclasses you may want " + "to build on.", + UntransformedCodeWarning, stacklevel=2) + + return t_unit def tag(self, tags: ToTagSetConvertible,