From 05073f0f9eac113f401ed4eb0560c47bb12afdea Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 7 May 2013 14:53:27 -0400
Subject: [PATCH] Expose argument type adding/inferring in UI.

---
 doc/reference.rst     |  9 +++++++++
 loopy/__init__.py     |  9 +++++++--
 loopy/kernel/tools.py | 13 +++++++++----
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/reference.rst b/doc/reference.rst
index bf3ddc864..8b1a4d6f9 100644
--- a/doc/reference.rst
+++ b/doc/reference.rst
@@ -203,6 +203,15 @@ Manipulating Instructions
 
 .. autofunction:: add_dependency
 
+Argument types
+--------------
+
+.. autofunction:: add_argument_dtypes
+
+.. autofunction:: infer_argument_dtypes
+
+.. autofunction:: add_and_infer_argument_dtypes
+
 Finishing up
 ------------
 
diff --git a/loopy/__init__.py b/loopy/__init__.py
index 354510691..668e4ddaa 100644
--- a/loopy/__init__.py
+++ b/loopy/__init__.py
@@ -60,7 +60,9 @@ from loopy.kernel.data import (
         Instruction)
 
 from loopy.kernel import LoopKernel
-from loopy.kernel.tools import get_dot_dependency_graph
+from loopy.kernel.tools import (
+        get_dot_dependency_graph, add_argument_dtypes,
+        infer_argument_dtypes, add_and_infer_argument_dtypes)
 from loopy.kernel.creation import make_kernel
 from loopy.reduction import register_reduction_parser
 from loopy.subst import extract_subst, expand_subst
@@ -83,7 +85,10 @@ __all__ = [
         "default_preamble_generator",
         "make_kernel",
         "register_reduction_parser",
-        "get_dot_dependency_graph",
+
+        "get_dot_dependency_graph", "add_argument_dtypes",
+        "infer_argument_dtypes", "add_and_infer_argument_dtypes",
+
         "preprocess_kernel", "realize_reduction",
         "generate_loop_schedules",
         "generate_code",
diff --git a/loopy/kernel/tools.py b/loopy/kernel/tools.py
index 02ce07245..2d0bbb401 100644
--- a/loopy/kernel/tools.py
+++ b/loopy/kernel/tools.py
@@ -28,18 +28,19 @@ THE SOFTWARE.
 
 
 import numpy as np
-from pytools import Record, memoize_method
-import islpy as isl
 from islpy import dim_type
 
-import re
-
 
 
 
 # {{{ add and infer argument dtypes
 
 def add_argument_dtypes(knl, dtype_dict):
+    """Specify remaining unspecified argument types.
+
+    :arg dtype_dict: a mapping from argument names to :class:`numpy.dtype`
+        instances
+    """
     dtype_dict = dtype_dict.copy()
     new_args = []
 
@@ -128,6 +129,10 @@ def infer_argument_dtypes(knl):
         else:
             return knl
 
+def add_and_infer_argument_dtypes(knl, dtype_dict):
+    knl = add_argument_dtypes(knl, dtype_dict)
+    return infer_argument_dtypes(knl)
+
 # }}}
 
 # {{{ find_all_insn_inames fixed point iteration
-- 
GitLab