@@ -290,11 +290,9 @@ 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
293+ from numba .cuda .descriptor import cuda_target
295294
296- target_hw = get_local_target (self )
297- order = order_by_target_specificity (target_hw , templates , fnkey = attr )
295+ order = order_by_target_specificity (cuda_target , templates , fnkey = attr )
298296
299297 for template in order :
300298 return_type = template .resolve (typ , attr )
@@ -446,13 +444,6 @@ def install_registry(self, registry, external_defs_only=False):
446444 loader = templates .RegistryLoader (registry )
447445 self ._registries [registry ] = loader
448446
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-
456447 def is_for_this_target (ftcls ):
457448 metadata = getattr (ftcls , "metadata" , None )
458449 if metadata is None :
@@ -462,31 +453,11 @@ def is_for_this_target(ftcls):
462453 if target_str is None :
463454 return True
464455
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
456+ # Accept both "cuda" and "generic" targets
457+ if target_str in ("cuda" , "generic" ):
458+ return True
488459
489- return current_target . inherits_from ( ft_target )
460+ return False
490461
491462 def is_external (obj ):
492463 """Check if obj is from outside numba.* namespace."""
0 commit comments