@@ -290,11 +290,7 @@ def core(typ):
290290 def find_matching_getattr_template (self , typ , attr ):
291291 templates = list (self ._get_attribute_templates (typ ))
292292
293- # get the order in which to try templates
294- from numba .core .target_extension import get_local_target
295-
296- target_hw = get_local_target (self )
297- order = order_by_target_specificity (target_hw , templates , fnkey = attr )
293+ order = order_by_target_specificity (templates , fnkey = attr )
298294
299295 for template in order :
300296 return_type = template .resolve (typ , attr )
@@ -446,13 +442,6 @@ def install_registry(self, registry, external_defs_only=False):
446442 loader = templates .RegistryLoader (registry )
447443 self ._registries [registry ] = loader
448444
449- from numba .core .target_extension import (
450- get_local_target ,
451- resolve_target_str ,
452- )
453-
454- current_target = get_local_target (self )
455-
456445 def is_for_this_target (ftcls ):
457446 metadata = getattr (ftcls , "metadata" , None )
458447 if metadata is None :
@@ -462,31 +451,11 @@ def is_for_this_target(ftcls):
462451 if target_str is None :
463452 return True
464453
465- # There may be pending registrations for nonexistent targets.
466- # Ideally it would be impossible to leave a registration pending
467- # for an invalid target, but in practice this is exceedingly
468- # difficult to guard against - many things are registered at import
469- # time, and eagerly reporting an error when registering for invalid
470- # targets would require that all target registration code is
471- # executed prior to all typing registrations during the import
472- # process; attempting to enforce this would impose constraints on
473- # execution order during import that would be very difficult to
474- # resolve and maintain in the presence of typical code maintenance.
475- # Furthermore, these constraints would be imposed not only on
476- # Numba internals, but also on its dependents.
477- #
478- # Instead of that enforcement, we simply catch any occurrences of
479- # registrations for targets that don't exist, and report that
480- # they're not for this target. They will then not be encountered
481- # again during future typing context refreshes (because the
482- # loader's new registrations are a stream_list that doesn't yield
483- # previously-yielded items).
484- try :
485- ft_target = resolve_target_str (target_str )
486- except errors .NonexistentTargetError :
487- return False
454+ # Accept both "cuda" and "generic" targets
455+ if target_str in ("cuda" , "generic" ):
456+ return True
488457
489- return current_target . inherits_from ( ft_target )
458+ return False
490459
491460 def is_external (obj ):
492461 """Check if obj is from outside numba.* namespace."""
0 commit comments