From d3858f8f56652d1f4ac3bd57bf0f0fdba12266bc Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 15 Nov 2017 18:43:31 -0600 Subject: [PATCH] Ignore all ISL keywords in domain parameter inference. --- loopy/kernel/creation.py | 7 ++++++- test/test_loopy.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index c6618d62f..e4cb17657 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -51,9 +51,14 @@ logger = logging.getLogger(__name__) _IDENTIFIER_RE = re.compile(r"\b([a-zA-Z_][a-zA-Z0-9_]*)\b") +# source: check_keywords() in isl_stream.c, ISL version 0.17 +_ISL_KEYWORDS = frozenset(""" + exists and or implies not infty infinity NaN min max rat true false ceild + floord mod ceil floor""".split()) + def _gather_isl_identifiers(s): - return set(_IDENTIFIER_RE.findall(s)) - set(["and", "or", "exists"]) + return set(_IDENTIFIER_RE.findall(s)) - _ISL_KEYWORDS class UniqueName: diff --git a/test/test_loopy.py b/test/test_loopy.py index 563964cf0..3a53202de 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2431,6 +2431,11 @@ def test_fixed_parameters(ctx_factory): knl(queue) +def test_parameter_inference(): + knl = lp.make_kernel("{[i]: 0 <= i < n and i mod 2 = 0}", "") + assert knl.all_params() == set(["n"]) + + def test_execution_backend_can_cache_dtypes(ctx_factory): # When the kernel is invoked, the execution backend uses it as a cache key # for the type inference and scheduling cache. This tests to make sure that -- GitLab