3535from collections .abc import Mapping
3636from typing import TYPE_CHECKING , Any , cast
3737
38+ from pytato .analysis import get_num_call_sites
3839from pytato .array import (
3940 AbstractResultWithNamedArrays ,
4041 Array ,
4546 SizeParam ,
4647 make_placeholder ,
4748)
49+ from pytato .function import FunctionDefinition
4850from pytato .target .loopy import LoopyPyOpenCLTarget
4951from pytato .transform import ArrayOrNames , CopyMapper
5052from 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
99108def _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