Skip to content

Commit

Permalink
Numpy actx: warn (not error) on no user-provided transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Sep 4, 2024
1 parent 494becf commit 35ddb01
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions arraycontext/impl/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
ArrayOrContainerOrScalar,
ArrayOrContainerOrScalarT,
NumpyOrContainerOrScalar,
UntransformedCodeWarning,
)


Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 35ddb01

Please sign in to comment.