Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def main():
u = pt.make_placeholder(name="u", shape=(dg_ops.nelements, dg_ops.nnodes),
dtype=np.float64)
result = op.apply(u)
result = pt.transform.deduplicate(result)

prog = pt.generate_loopy(result, cl_device=queue.device)
print(prog.program)
Expand Down
12 changes: 6 additions & 6 deletions pytato/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,16 @@ def map_concatenate(self, expr: Concatenate) -> list[ArrayOrNames]:
def map_einsum(self, expr: Einsum) -> list[ArrayOrNames]:
return self._get_preds_from_shape(expr.shape) + list(expr.args)

def map_loopy_call(self, expr: LoopyCall) -> list[ArrayOrNames]:
return [ary for ary in expr.bindings.values() if isinstance(ary, Array)]

def map_loopy_call_result(self, expr: NamedArray) -> list[ArrayOrNames]:
from pytato.loopy import LoopyCall, LoopyCallResult
assert isinstance(expr, LoopyCallResult)
assert isinstance(expr._container, LoopyCall)
return (
self._get_preds_from_shape(expr.shape)
+ [
ary
for ary in expr._container.bindings.values()
if isinstance(ary, Array)])
return [
*self._get_preds_from_shape(expr.shape),
expr._container]

def _map_index_base(self, expr: IndexBase) -> list[ArrayOrNames]:
return (
Expand Down
2 changes: 1 addition & 1 deletion pytato/loopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"""


@array_dataclass()
@array_dataclass(hash=False)
class LoopyCall(AbstractResultWithNamedArrays):
"""
An array expression node representing a call to an entrypoint in a
Expand Down
14 changes: 7 additions & 7 deletions pytato/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class CachedMapper(Mapper[ResultT, FunctionResultT, P]):
"""
def __init__(
self,
err_on_collision: bool = False,
err_on_collision: bool = __debug__,
_cache:
CachedMapperCache[ArrayOrNames, ResultT, P] | None = None,
_function_cache:
Expand Down Expand Up @@ -661,8 +661,8 @@ class TransformMapper(CachedMapper[ArrayOrNames, FunctionDefinition, []]):
"""
def __init__(
self,
err_on_collision: bool = False,
err_on_created_duplicate: bool = False,
err_on_collision: bool = __debug__,
err_on_created_duplicate: bool = __debug__,
_cache: TransformMapperCache[ArrayOrNames, []] | None = None,
_function_cache: TransformMapperCache[FunctionDefinition, []] | None = None
) -> None:
Expand Down Expand Up @@ -756,8 +756,8 @@ class TransformMapperWithExtraArgs(
"""
def __init__(
self,
err_on_collision: bool = False,
err_on_created_duplicate: bool = False,
err_on_collision: bool = __debug__,
err_on_created_duplicate: bool = __debug__,
_cache: TransformMapperCache[ArrayOrNames, P] | None = None,
_function_cache:
TransformMapperCache[FunctionDefinition, P] | None = None
Expand Down Expand Up @@ -1931,8 +1931,8 @@ def __init__(
self,
nsuccessors: Mapping[Array, int],
_cache: MPMSMaterializerCache | None = None):
err_on_collision = False
err_on_created_duplicate = False
err_on_collision = __debug__
err_on_created_duplicate = __debug__

if _cache is None:
_cache = MPMSMaterializerCache(
Expand Down
4 changes: 3 additions & 1 deletion test/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,9 @@ def test_zeros_like(ctx_factory):
assert isinstance(zero, pt.Array)
assert isinstance(one, pt.Array)

prg = pt.generate_loopy({"zero": zero, "one": one})
prg = pt.generate_loopy(
pt.transform.deduplicate(
pt.make_dict_of_named_arrays({"zero": zero, "one": one})))
_, pt_out = prg(cq, x=x_in)
np.testing.assert_allclose(pt_out["zero"], 0)
np.testing.assert_allclose(pt_out["one"], 1)
Expand Down
Loading