From 326e78d04fbbcb4fdd3c178e3d1dc75961d1815f Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 6 Nov 2020 14:27:58 +0300 Subject: [PATCH] Remove changes to CPUDispatcher New CPUDispatcher was created in 8e92a78 by @reazulhoque. Then it was reverted in 9666627 by @1e-to. Now it is the same as original CPUDispatcher and could be removed back. --- numba/core/cpu_dispatcher.py | 13 ------------- numba/core/inline_closurecall.py | 2 +- numba/core/ir_utils.py | 2 +- numba/core/registry.py | 5 +++++ numba/tests/test_inlining.py | 2 +- numba/tests/test_wrapper.py | 8 ++++---- 6 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 numba/core/cpu_dispatcher.py diff --git a/numba/core/cpu_dispatcher.py b/numba/core/cpu_dispatcher.py deleted file mode 100644 index 1b712ce2aff..00000000000 --- a/numba/core/cpu_dispatcher.py +++ /dev/null @@ -1,13 +0,0 @@ -from numba.core import dispatcher, compiler -from numba.core.registry import cpu_target, dispatcher_registry - - -class CPUDispatcher(dispatcher.Dispatcher): - targetdescr = cpu_target - - def __init__(self, py_func, locals={}, targetoptions={}, impl_kind='direct', pipeline_class=compiler.Compiler): - dispatcher.Dispatcher.__init__(self, py_func, locals=locals, - targetoptions=targetoptions, impl_kind=impl_kind, pipeline_class=pipeline_class) - - -dispatcher_registry['cpu'] = CPUDispatcher diff --git a/numba/core/inline_closurecall.py b/numba/core/inline_closurecall.py index 81634c9bec4..be56fe05162 100644 --- a/numba/core/inline_closurecall.py +++ b/numba/core/inline_closurecall.py @@ -256,7 +256,7 @@ def check_reduce_func(func_ir, func_var): analysis") if isinstance(reduce_func, (ir.FreeVar, ir.Global)): if not isinstance(reduce_func.value, - numba.core.cpu_dispatcher.CPUDispatcher): + numba.core.registry.CPUDispatcher): raise ValueError("Invalid reduction function") # pull out the python function for inlining reduce_func = reduce_func.value.py_func diff --git a/numba/core/ir_utils.py b/numba/core/ir_utils.py index 477cfbb3d9c..1d58c5c8b5b 100644 --- a/numba/core/ir_utils.py +++ b/numba/core/ir_utils.py @@ -679,7 +679,7 @@ def has_no_side_effect(rhs, lives, call_table): (call_list[0]._name == 'empty_inferred' or call_list[0]._name == 'unsafe_empty_inferred')): return True - from numba.core.cpu_dispatcher import CPUDispatcher + from numba.core.registry import CPUDispatcher from numba.np.linalg import dot_3_mv_check_args if isinstance(call_list[0], CPUDispatcher): py_func = call_list[0].py_func diff --git a/numba/core/registry.py b/numba/core/registry.py index a3396ecc5a6..01e492f91f4 100644 --- a/numba/core/registry.py +++ b/numba/core/registry.py @@ -75,6 +75,10 @@ def nested_context(self, typing_context, target_context): cpu_target = CPUTarget() +class CPUDispatcher(dispatcher.Dispatcher): + targetdescr = cpu_target + + class TargetRegistry(utils.UniqueDict): """ A registry of API implementations for various backends. @@ -99,3 +103,4 @@ def __getitem__(self, item): dispatcher_registry = TargetRegistry() +dispatcher_registry['cpu'] = CPUDispatcher diff --git a/numba/tests/test_inlining.py b/numba/tests/test_inlining.py index 5d13d1696db..76a7565fa4e 100644 --- a/numba/tests/test_inlining.py +++ b/numba/tests/test_inlining.py @@ -7,7 +7,7 @@ from numba.core import types, ir, postproc, compiler from numba.core.ir_utils import (guard, find_callname, find_const, get_definition, simplify_CFG) -from numba.core.cpu_dispatcher import CPUDispatcher +from numba.core.registry import CPUDispatcher from numba.core.inline_closurecall import inline_closure_call from numba.core.untyped_passes import (ExtractByteCode, TranslateByteCode, FixupArgs, diff --git a/numba/tests/test_wrapper.py b/numba/tests/test_wrapper.py index f5d0b9438cf..b26a804ac7d 100644 --- a/numba/tests/test_wrapper.py +++ b/numba/tests/test_wrapper.py @@ -1,7 +1,7 @@ import numpy as np import unittest -from numba.core import types, utils, compiler, registry, cpu_dispatcher +from numba.core import types, utils, compiler, registry def overhead(x): @@ -24,7 +24,7 @@ def test_overhead(self): """ cr = compiler.compile_isolated(overhead, [types.int32]) cfunc = cr.entry_point - disp = cpu_dispatcher.CPUDispatcher(overhead) + disp = registry.CPUDispatcher(overhead) disp.add_overload(cr) x = 321 @@ -50,7 +50,7 @@ def test_array_overhead(self): """ cr = compiler.compile_isolated(array_overhead, [types.int32[::1]]) cfunc = cr.entry_point - disp = cpu_dispatcher.CPUDispatcher(array_overhead) + disp = registry.CPUDispatcher(array_overhead) disp.add_overload(cr) self.assertEqual(cr.signature.args[0].layout, 'C') @@ -79,7 +79,7 @@ def test_add(self): """ cr = compiler.compile_isolated(add, [types.int32]) cfunc = cr.entry_point - disp = cpu_dispatcher.CPUDispatcher(add) + disp = registry.CPUDispatcher(add) disp.add_overload(cr) x = 321