Skip to content

Commit 8b1b795

Browse files
committed
Numpy actx: warn (not error) on no user-provided transforms
1 parent 9f1cad4 commit 8b1b795

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

arraycontext/impl/numpy/__init__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
ArrayOrContainerOrScalar,
4444
ArrayOrContainerOrScalarT,
4545
NumpyOrContainerOrScalar,
46+
UntransformedCodeWarning,
4647
)
4748

4849

@@ -116,9 +117,21 @@ def _thaw(ary):
116117
# }}}
117118

118119
def transform_loopy_program(self, t_unit):
119-
raise ValueError("NumpyArrayContext does not implement "
120-
"transform_loopy_program. Sub-classes are supposed "
121-
"to implement it.")
120+
from warnings import warn
121+
warn("Using the base "
122+
f"{type(self).__name__}.transform_loopy_program "
123+
"to transform a translation unit. "
124+
"This is a no-op and will result in unoptimized C code for"
125+
"the requested optimization, all in a single statement."
126+
"This will work, but is unlikely to be performant."
127+
f"Instead, subclass {type(self).__name__} and implement "
128+
"the specific transform logic required to transform the program "
129+
"for your package or application. Check higher-level packages "
130+
"(e.g. meshmode), which may already have subclasses you may want "
131+
"to build on.",
132+
UntransformedCodeWarning, stacklevel=2)
133+
134+
return t_unit
122135

123136
def tag(self,
124137
tags: ToTagSetConvertible,

0 commit comments

Comments
 (0)