Skip to content

Commit 8e67030

Browse files
committed
forbid calling _normalize_pt_expr on a DAG with function calls for now
1 parent 6197a7a commit 8e67030

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

arraycontext/impl/pytato/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from collections.abc import Mapping
3636
from typing import TYPE_CHECKING, Any, cast
3737

38+
from pytato.analysis import get_num_call_sites
3839
from pytato.array import (
3940
AbstractResultWithNamedArrays,
4041
Array,
@@ -45,6 +46,7 @@
4546
SizeParam,
4647
make_placeholder,
4748
)
49+
from pytato.function import FunctionDefinition
4850
from pytato.target.loopy import LoopyPyOpenCLTarget
4951
from pytato.transform import ArrayOrNames, CopyMapper
5052
from pytools import UniqueNameGenerator, memoize_method
@@ -95,7 +97,14 @@ def map_placeholder(self, expr: Placeholder) -> Array:
9597
raise ValueError("Placeholders cannot appear in"
9698
" DatawrapperToBoundPlaceholderMapper.")
9799

100+
def map_function_definition(
101+
self, expr: FunctionDefinition) -> FunctionDefinition:
102+
raise ValueError("Function definitions cannot appear in"
103+
" DatawrapperToBoundPlaceholderMapper.")
104+
98105

106+
# FIXME: This strategy doesn't work if the DAG has functions, since function
107+
# definitions can't contain non-argument placeholders
99108
def _normalize_pt_expr(
100109
expr: DictOfNamedArrays
101110
) -> tuple[Array | AbstractResultWithNamedArrays, Mapping[str, Any]]:
@@ -108,6 +117,11 @@ def _normalize_pt_expr(
108117
Deterministic naming of placeholders permits more effective caching of
109118
equivalent graphs.
110119
"""
120+
if get_num_call_sites(expr):
121+
raise NotImplementedError(
122+
"_normalize_pt_expr is not compatible with expressions that "
123+
"contain function calls.")
124+
111125
normalize_mapper = _DatawrapperToBoundPlaceholderMapper()
112126
normalized_expr = normalize_mapper(expr)
113127
assert isinstance(normalized_expr, AbstractResultWithNamedArrays)

0 commit comments

Comments
 (0)