From 9bcf27ba6d432e94a4a97fafac15d7a95dbbd085 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni <kaushikcfd@gmail.com> Date: Thu, 29 Mar 2018 18:27:28 -0500 Subject: [PATCH] TODO for replacing the inplace updates in a dictionary --- loopy/preprocess.py | 7 +++++-- loopy/type_inference.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/loopy/preprocess.py b/loopy/preprocess.py index f6bf6ab88..2ed004e07 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -2230,12 +2230,15 @@ class ArgDescriptionInferer(CombineMapper): assignee_id_to_descr[-i-1] = ValueArgDescriptor() # gathering all the descriptors - combined_arg_id_to_dtype = {**arg_id_to_descr, **assignee_id_to_descr} + # TODO: I dont like in place updates. Change this to somthing else. + # Perhaps make a function? + combined_arg_id_to_descr = arg_id_to_descr.copy() + combined_arg_id_to_descr.update(assignee_id_to_descr) # specializing the function according to the parameter description new_scoped_function = ( self.kernel.scoped_functions[expr.function.name].with_descrs( - combined_arg_id_to_dtype)) + combined_arg_id_to_descr)) # collecting the descriptors for args, kwargs, assignees return (frozenset(((expr, new_scoped_function), )) | diff --git a/loopy/type_inference.py b/loopy/type_inference.py index 9ffdb983e..861e59852 100644 --- a/loopy/type_inference.py +++ b/loopy/type_inference.py @@ -630,6 +630,9 @@ def infer_unknown_types(kernel, expect_completion=False): new_arg_dict[name] = item.copy(dtype=new_dtype) else: raise LoopyError("unexpected item type in type inference") + # TODO: I dont like in place updates. Change this to something + # else. Perhaps add a function for doing this, which does it + # using a bunch of copies? specialized_functions.update(new_specialized_functions) else: debug(" failure") -- GitLab