numba-cuda 0.21.1__cp313-cp313-win_amd64.whl → 0.23.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. numba_cuda/VERSION +1 -1
  2. numba_cuda/numba/cuda/api.py +4 -1
  3. numba_cuda/numba/cuda/cext/_dispatcher.cp313-win_amd64.pyd +0 -0
  4. numba_cuda/numba/cuda/cext/_dispatcher.cpp +0 -38
  5. numba_cuda/numba/cuda/cext/_helperlib.cp313-win_amd64.pyd +0 -0
  6. numba_cuda/numba/cuda/cext/_typeconv.cp313-win_amd64.pyd +0 -0
  7. numba_cuda/numba/cuda/cext/_typeof.cpp +0 -111
  8. numba_cuda/numba/cuda/cext/mviewbuf.cp313-win_amd64.pyd +0 -0
  9. numba_cuda/numba/cuda/codegen.py +42 -10
  10. numba_cuda/numba/cuda/compiler.py +10 -4
  11. numba_cuda/numba/cuda/core/analysis.py +29 -21
  12. numba_cuda/numba/cuda/core/annotations/type_annotations.py +4 -4
  13. numba_cuda/numba/cuda/core/base.py +6 -1
  14. numba_cuda/numba/cuda/core/consts.py +1 -1
  15. numba_cuda/numba/cuda/core/cuda_errors.py +917 -0
  16. numba_cuda/numba/cuda/core/errors.py +4 -912
  17. numba_cuda/numba/cuda/core/inline_closurecall.py +71 -57
  18. numba_cuda/numba/cuda/core/interpreter.py +79 -64
  19. numba_cuda/numba/cuda/core/ir.py +191 -119
  20. numba_cuda/numba/cuda/core/ir_utils.py +142 -112
  21. numba_cuda/numba/cuda/core/postproc.py +8 -8
  22. numba_cuda/numba/cuda/core/rewrites/ir_print.py +6 -3
  23. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +5 -5
  24. numba_cuda/numba/cuda/core/rewrites/static_raise.py +3 -3
  25. numba_cuda/numba/cuda/core/ssa.py +3 -3
  26. numba_cuda/numba/cuda/core/transforms.py +25 -10
  27. numba_cuda/numba/cuda/core/typed_passes.py +9 -9
  28. numba_cuda/numba/cuda/core/typeinfer.py +39 -24
  29. numba_cuda/numba/cuda/core/untyped_passes.py +71 -55
  30. numba_cuda/numba/cuda/cudadecl.py +0 -13
  31. numba_cuda/numba/cuda/cudadrv/devicearray.py +6 -5
  32. numba_cuda/numba/cuda/cudadrv/driver.py +132 -511
  33. numba_cuda/numba/cuda/cudadrv/dummyarray.py +4 -0
  34. numba_cuda/numba/cuda/cudadrv/nvrtc.py +16 -0
  35. numba_cuda/numba/cuda/cudaimpl.py +0 -12
  36. numba_cuda/numba/cuda/debuginfo.py +104 -10
  37. numba_cuda/numba/cuda/descriptor.py +1 -1
  38. numba_cuda/numba/cuda/device_init.py +4 -7
  39. numba_cuda/numba/cuda/dispatcher.py +36 -32
  40. numba_cuda/numba/cuda/intrinsics.py +150 -1
  41. numba_cuda/numba/cuda/lowering.py +64 -29
  42. numba_cuda/numba/cuda/memory_management/nrt.py +10 -14
  43. numba_cuda/numba/cuda/np/arrayobj.py +54 -0
  44. numba_cuda/numba/cuda/np/numpy_support.py +26 -0
  45. numba_cuda/numba/cuda/printimpl.py +20 -0
  46. numba_cuda/numba/cuda/serialize.py +10 -0
  47. numba_cuda/numba/cuda/stubs.py +0 -11
  48. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +21 -4
  49. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +1 -2
  50. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +130 -48
  51. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +6 -2
  52. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +3 -1
  53. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +5 -6
  54. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +11 -12
  55. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +27 -19
  56. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +47 -0
  57. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +10 -0
  58. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +89 -0
  59. numba_cuda/numba/cuda/tests/cudapy/test_device_array_capture.py +243 -0
  60. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +3 -3
  61. numba_cuda/numba/cuda/tests/cudapy/test_numba_interop.py +35 -0
  62. numba_cuda/numba/cuda/tests/cudapy/test_print.py +51 -0
  63. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +116 -1
  64. numba_cuda/numba/cuda/tests/doc_examples/test_globals.py +111 -0
  65. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +61 -0
  66. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +31 -0
  67. numba_cuda/numba/cuda/typing/context.py +3 -1
  68. numba_cuda/numba/cuda/typing/typeof.py +56 -0
  69. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/METADATA +1 -1
  70. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/RECORD +74 -74
  71. numba_cuda/numba/cuda/cext/_devicearray.cp313-win_amd64.pyd +0 -0
  72. numba_cuda/numba/cuda/cext/_devicearray.cpp +0 -159
  73. numba_cuda/numba/cuda/cext/_devicearray.h +0 -29
  74. numba_cuda/numba/cuda/intrinsic_wrapper.py +0 -41
  75. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/WHEEL +0 -0
  76. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/licenses/LICENSE +0 -0
  77. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/licenses/LICENSE.numba +0 -0
  78. {numba_cuda-0.21.1.dist-info → numba_cuda-0.23.0.dist-info}/top_level.txt +0 -0
@@ -337,9 +337,9 @@ class Inst(EqualityCheckMixin, AbstractRHS):
337
337
  """
338
338
  A recursive helper used to implement list_vars() in subclasses.
339
339
  """
340
- if isinstance(val, Var):
340
+ if isinstance(val, var_types):
341
341
  return [val]
342
- elif isinstance(val, Inst):
342
+ elif isinstance(val, inst_types):
343
343
  return val.list_vars()
344
344
  elif isinstance(val, (list, tuple)):
345
345
  lst = []
@@ -396,7 +396,7 @@ class Expr(Inst):
396
396
 
397
397
  def __init__(self, op, loc, **kws):
398
398
  assert isinstance(op, str)
399
- assert isinstance(loc, Loc)
399
+ assert isinstance(loc, loc_types)
400
400
  self.op = op
401
401
  self.loc = loc
402
402
  self._kws = kws
@@ -415,9 +415,9 @@ class Expr(Inst):
415
415
  @classmethod
416
416
  def binop(cls, fn, lhs, rhs, loc):
417
417
  assert isinstance(fn, BuiltinFunctionType)
418
- assert isinstance(lhs, Var)
419
- assert isinstance(rhs, Var)
420
- assert isinstance(loc, Loc)
418
+ assert isinstance(lhs, var_types)
419
+ assert isinstance(rhs, var_types)
420
+ assert isinstance(loc, loc_types)
421
421
  op = "binop"
422
422
  return cls(
423
423
  op=op,
@@ -433,9 +433,9 @@ class Expr(Inst):
433
433
  def inplace_binop(cls, fn, immutable_fn, lhs, rhs, loc):
434
434
  assert isinstance(fn, BuiltinFunctionType)
435
435
  assert isinstance(immutable_fn, BuiltinFunctionType)
436
- assert isinstance(lhs, Var)
437
- assert isinstance(rhs, Var)
438
- assert isinstance(loc, Loc)
436
+ assert isinstance(lhs, var_types)
437
+ assert isinstance(rhs, var_types)
438
+ assert isinstance(loc, loc_types)
439
439
  op = "inplace_binop"
440
440
  return cls(
441
441
  op=op,
@@ -450,8 +450,9 @@ class Expr(Inst):
450
450
 
451
451
  @classmethod
452
452
  def unary(cls, fn, value, loc):
453
- assert isinstance(value, (str, Var, FunctionType))
454
- assert isinstance(loc, Loc)
453
+ if not isinstance(value, (str, FunctionType)):
454
+ assert isinstance(value, var_types)
455
+ assert isinstance(loc, loc_types)
455
456
  op = "unary"
456
457
  fn = UNARY_BUILTINS_TO_OPERATORS.get(fn, fn)
457
458
  return cls(op=op, loc=loc, fn=fn, value=value)
@@ -460,8 +461,8 @@ class Expr(Inst):
460
461
  def call(
461
462
  cls, func, args, kws, loc, vararg=None, varkwarg=None, target=None
462
463
  ):
463
- assert isinstance(func, Var)
464
- assert isinstance(loc, Loc)
464
+ assert isinstance(func, var_types)
465
+ assert isinstance(loc, loc_types)
465
466
  op = "call"
466
467
  return cls(
467
468
  op=op,
@@ -476,25 +477,25 @@ class Expr(Inst):
476
477
 
477
478
  @classmethod
478
479
  def build_tuple(cls, items, loc):
479
- assert isinstance(loc, Loc)
480
+ assert isinstance(loc, loc_types)
480
481
  op = "build_tuple"
481
482
  return cls(op=op, loc=loc, items=items)
482
483
 
483
484
  @classmethod
484
485
  def build_list(cls, items, loc):
485
- assert isinstance(loc, Loc)
486
+ assert isinstance(loc, loc_types)
486
487
  op = "build_list"
487
488
  return cls(op=op, loc=loc, items=items)
488
489
 
489
490
  @classmethod
490
491
  def build_set(cls, items, loc):
491
- assert isinstance(loc, Loc)
492
+ assert isinstance(loc, loc_types)
492
493
  op = "build_set"
493
494
  return cls(op=op, loc=loc, items=items)
494
495
 
495
496
  @classmethod
496
497
  def build_map(cls, items, size, literal_value, value_indexes, loc):
497
- assert isinstance(loc, Loc)
498
+ assert isinstance(loc, loc_types)
498
499
  op = "build_map"
499
500
  return cls(
500
501
  op=op,
@@ -507,68 +508,68 @@ class Expr(Inst):
507
508
 
508
509
  @classmethod
509
510
  def pair_first(cls, value, loc):
510
- assert isinstance(value, Var)
511
+ assert isinstance(value, var_types)
511
512
  op = "pair_first"
512
513
  return cls(op=op, loc=loc, value=value)
513
514
 
514
515
  @classmethod
515
516
  def pair_second(cls, value, loc):
516
- assert isinstance(value, Var)
517
- assert isinstance(loc, Loc)
517
+ assert isinstance(value, var_types)
518
+ assert isinstance(loc, loc_types)
518
519
  op = "pair_second"
519
520
  return cls(op=op, loc=loc, value=value)
520
521
 
521
522
  @classmethod
522
523
  def getiter(cls, value, loc):
523
- assert isinstance(value, Var)
524
- assert isinstance(loc, Loc)
524
+ assert isinstance(value, var_types)
525
+ assert isinstance(loc, loc_types)
525
526
  op = "getiter"
526
527
  return cls(op=op, loc=loc, value=value)
527
528
 
528
529
  @classmethod
529
530
  def iternext(cls, value, loc):
530
- assert isinstance(value, Var)
531
- assert isinstance(loc, Loc)
531
+ assert isinstance(value, var_types)
532
+ assert isinstance(loc, loc_types)
532
533
  op = "iternext"
533
534
  return cls(op=op, loc=loc, value=value)
534
535
 
535
536
  @classmethod
536
537
  def exhaust_iter(cls, value, count, loc):
537
- assert isinstance(value, Var)
538
+ assert isinstance(value, var_types)
538
539
  assert isinstance(count, int)
539
- assert isinstance(loc, Loc)
540
+ assert isinstance(loc, loc_types)
540
541
  op = "exhaust_iter"
541
542
  return cls(op=op, loc=loc, value=value, count=count)
542
543
 
543
544
  @classmethod
544
545
  def getattr(cls, value, attr, loc):
545
- assert isinstance(value, Var)
546
+ assert isinstance(value, var_types)
546
547
  assert isinstance(attr, str)
547
- assert isinstance(loc, Loc)
548
+ assert isinstance(loc, loc_types)
548
549
  op = "getattr"
549
550
  return cls(op=op, loc=loc, value=value, attr=attr)
550
551
 
551
552
  @classmethod
552
553
  def getitem(cls, value, index, loc):
553
- assert isinstance(value, Var)
554
- assert isinstance(index, Var)
555
- assert isinstance(loc, Loc)
554
+ assert isinstance(value, var_types)
555
+ assert isinstance(index, var_types)
556
+ assert isinstance(loc, loc_types)
556
557
  op = "getitem"
557
558
  fn = operator.getitem
558
559
  return cls(op=op, loc=loc, value=value, index=index, fn=fn)
559
560
 
560
561
  @classmethod
561
562
  def typed_getitem(cls, value, dtype, index, loc):
562
- assert isinstance(value, Var)
563
- assert isinstance(loc, Loc)
563
+ assert isinstance(value, var_types)
564
+ assert isinstance(loc, loc_types)
564
565
  op = "typed_getitem"
565
566
  return cls(op=op, loc=loc, value=value, dtype=dtype, index=index)
566
567
 
567
568
  @classmethod
568
569
  def static_getitem(cls, value, index, index_var, loc):
569
- assert isinstance(value, Var)
570
- assert index_var is None or isinstance(index_var, Var)
571
- assert isinstance(loc, Loc)
570
+ assert isinstance(value, var_types)
571
+ assert index_var is None or isinstance(index_var, var_types)
572
+ assert isinstance(loc, loc_types)
572
573
  op = "static_getitem"
573
574
  fn = operator.getitem
574
575
  return cls(
@@ -580,15 +581,15 @@ class Expr(Inst):
580
581
  """
581
582
  A node for implicit casting at the return statement
582
583
  """
583
- assert isinstance(value, Var)
584
- assert isinstance(loc, Loc)
584
+ assert isinstance(value, var_types)
585
+ assert isinstance(loc, loc_types)
585
586
  op = "cast"
586
587
  return cls(op=op, value=value, loc=loc)
587
588
 
588
589
  @classmethod
589
590
  def phi(cls, loc):
590
591
  """Phi node"""
591
- assert isinstance(loc, Loc)
592
+ assert isinstance(loc, loc_types)
592
593
  return cls(op="phi", incoming_values=[], incoming_blocks=[], loc=loc)
593
594
 
594
595
  @classmethod
@@ -596,7 +597,7 @@ class Expr(Inst):
596
597
  """
597
598
  A node for making a function object.
598
599
  """
599
- assert isinstance(loc, Loc)
600
+ assert isinstance(loc, loc_types)
600
601
  op = "make_function"
601
602
  return cls(
602
603
  op=op,
@@ -615,7 +616,7 @@ class Expr(Inst):
615
616
  This node is not handled by type inference. It is only added by
616
617
  post-typing passes.
617
618
  """
618
- assert isinstance(loc, Loc)
619
+ assert isinstance(loc, loc_types)
619
620
  op = "null"
620
621
  return cls(op=op, loc=loc)
621
622
 
@@ -624,7 +625,7 @@ class Expr(Inst):
624
625
  """
625
626
  A node for undefined value specifically from LOAD_FAST_AND_CLEAR opcode.
626
627
  """
627
- assert isinstance(loc, Loc)
628
+ assert isinstance(loc, loc_types)
628
629
  op = "undef"
629
630
  return cls(op=op, loc=loc)
630
631
 
@@ -638,7 +639,7 @@ class Expr(Inst):
638
639
  by type inference or lowering. It's presence outside of the interpreter
639
640
  renders IR as illegal.
640
641
  """
641
- assert isinstance(loc, Loc)
642
+ assert isinstance(loc, loc_types)
642
643
  assert isinstance(op, str)
643
644
  return cls(op=op, info=info, loc=loc)
644
645
 
@@ -682,10 +683,10 @@ class SetItem(Stmt):
682
683
  """
683
684
 
684
685
  def __init__(self, target, index, value, loc):
685
- assert isinstance(target, Var)
686
- assert isinstance(index, Var)
687
- assert isinstance(value, Var)
688
- assert isinstance(loc, Loc)
686
+ assert isinstance(target, var_types)
687
+ assert isinstance(index, var_types)
688
+ assert isinstance(value, var_types)
689
+ assert isinstance(loc, loc_types)
689
690
  self.target = target
690
691
  self.index = index
691
692
  self.value = value
@@ -701,11 +702,11 @@ class StaticSetItem(Stmt):
701
702
  """
702
703
 
703
704
  def __init__(self, target, index, index_var, value, loc):
704
- assert isinstance(target, Var)
705
- assert not isinstance(index, Var)
706
- assert isinstance(index_var, Var)
707
- assert isinstance(value, Var)
708
- assert isinstance(loc, Loc)
705
+ assert isinstance(target, var_types)
706
+ assert not isinstance(index, var_types)
707
+ assert isinstance(index_var, var_types)
708
+ assert isinstance(value, var_types)
709
+ assert isinstance(loc, loc_types)
709
710
  self.target = target
710
711
  self.index = index
711
712
  self.index_var = index_var
@@ -722,9 +723,9 @@ class DelItem(Stmt):
722
723
  """
723
724
 
724
725
  def __init__(self, target, index, loc):
725
- assert isinstance(target, Var)
726
- assert isinstance(index, Var)
727
- assert isinstance(loc, Loc)
726
+ assert isinstance(target, var_types)
727
+ assert isinstance(index, var_types)
728
+ assert isinstance(loc, loc_types)
728
729
  self.target = target
729
730
  self.index = index
730
731
  self.loc = loc
@@ -735,10 +736,10 @@ class DelItem(Stmt):
735
736
 
736
737
  class SetAttr(Stmt):
737
738
  def __init__(self, target, attr, value, loc):
738
- assert isinstance(target, Var)
739
+ assert isinstance(target, var_types)
739
740
  assert isinstance(attr, str)
740
- assert isinstance(value, Var)
741
- assert isinstance(loc, Loc)
741
+ assert isinstance(value, var_types)
742
+ assert isinstance(loc, loc_types)
742
743
  self.target = target
743
744
  self.attr = attr
744
745
  self.value = value
@@ -750,9 +751,9 @@ class SetAttr(Stmt):
750
751
 
751
752
  class DelAttr(Stmt):
752
753
  def __init__(self, target, attr, loc):
753
- assert isinstance(target, Var)
754
+ assert isinstance(target, var_types)
754
755
  assert isinstance(attr, str)
755
- assert isinstance(loc, Loc)
756
+ assert isinstance(loc, loc_types)
756
757
  self.target = target
757
758
  self.attr = attr
758
759
  self.loc = loc
@@ -763,10 +764,10 @@ class DelAttr(Stmt):
763
764
 
764
765
  class StoreMap(Stmt):
765
766
  def __init__(self, dct, key, value, loc):
766
- assert isinstance(dct, Var)
767
- assert isinstance(key, Var)
768
- assert isinstance(value, Var)
769
- assert isinstance(loc, Loc)
767
+ assert isinstance(dct, var_types)
768
+ assert isinstance(key, var_types)
769
+ assert isinstance(value, var_types)
770
+ assert isinstance(loc, loc_types)
770
771
  self.dct = dct
771
772
  self.key = key
772
773
  self.value = value
@@ -779,10 +780,7 @@ class StoreMap(Stmt):
779
780
  class Del(Stmt):
780
781
  def __init__(self, value, loc):
781
782
  assert isinstance(value, str)
782
- if HAS_NUMBA:
783
- assert isinstance(loc, (Loc, numba.core.ir.Loc))
784
- else:
785
- assert isinstance(loc, (Loc))
783
+ assert isinstance(loc, loc_types)
786
784
  self.value = value
787
785
  self.loc = loc
788
786
 
@@ -794,8 +792,8 @@ class Raise(Terminator):
794
792
  is_exit = True
795
793
 
796
794
  def __init__(self, exception, loc):
797
- assert exception is None or isinstance(exception, Var)
798
- assert isinstance(loc, Loc)
795
+ assert exception is None or isinstance(exception, var_types)
796
+ assert isinstance(loc, loc_types)
799
797
  self.exception = exception
800
798
  self.loc = loc
801
799
 
@@ -817,7 +815,7 @@ class StaticRaise(Terminator):
817
815
 
818
816
  def __init__(self, exc_class, exc_args, loc):
819
817
  assert exc_class is None or isinstance(exc_class, type)
820
- assert isinstance(loc, Loc)
818
+ assert isinstance(loc, loc_types)
821
819
  assert exc_args is None or isinstance(exc_args, tuple)
822
820
  self.exc_class = exc_class
823
821
  self.exc_args = exc_args
@@ -849,7 +847,7 @@ class DynamicRaise(Terminator):
849
847
 
850
848
  def __init__(self, exc_class, exc_args, loc):
851
849
  assert exc_class is None or isinstance(exc_class, type)
852
- assert isinstance(loc, Loc)
850
+ assert isinstance(loc, loc_types)
853
851
  assert exc_args is None or isinstance(exc_args, tuple)
854
852
  self.exc_class = exc_class
855
853
  self.exc_args = exc_args
@@ -876,8 +874,8 @@ class TryRaise(Stmt):
876
874
  """
877
875
 
878
876
  def __init__(self, exception, loc):
879
- assert exception is None or isinstance(exception, Var)
880
- assert isinstance(loc, Loc)
877
+ assert exception is None or isinstance(exception, var_types)
878
+ assert isinstance(loc, loc_types)
881
879
  self.exception = exception
882
880
  self.loc = loc
883
881
 
@@ -892,7 +890,7 @@ class StaticTryRaise(Stmt):
892
890
 
893
891
  def __init__(self, exc_class, exc_args, loc):
894
892
  assert exc_class is None or isinstance(exc_class, type)
895
- assert isinstance(loc, Loc)
893
+ assert isinstance(loc, loc_types)
896
894
  assert exc_args is None or isinstance(exc_args, tuple)
897
895
  self.exc_class = exc_class
898
896
  self.exc_args = exc_args
@@ -915,7 +913,7 @@ class DynamicTryRaise(Stmt):
915
913
 
916
914
  def __init__(self, exc_class, exc_args, loc):
917
915
  assert exc_class is None or isinstance(exc_class, type)
918
- assert isinstance(loc, Loc)
916
+ assert isinstance(loc, loc_types)
919
917
  assert exc_args is None or isinstance(exc_args, tuple)
920
918
  self.exc_class = exc_class
921
919
  self.exc_args = exc_args
@@ -939,8 +937,8 @@ class Return(Terminator):
939
937
  is_exit = True
940
938
 
941
939
  def __init__(self, value, loc):
942
- assert isinstance(value, Var), type(value)
943
- assert isinstance(loc, Loc)
940
+ assert isinstance(value, var_types), type(value)
941
+ assert isinstance(loc, loc_types)
944
942
  self.value = value
945
943
  self.loc = loc
946
944
 
@@ -957,7 +955,7 @@ class Jump(Terminator):
957
955
  """
958
956
 
959
957
  def __init__(self, target, loc):
960
- assert isinstance(loc, Loc)
958
+ assert isinstance(loc, loc_types)
961
959
  self.target = target
962
960
  self.loc = loc
963
961
 
@@ -974,8 +972,8 @@ class Branch(Terminator):
974
972
  """
975
973
 
976
974
  def __init__(self, cond, truebr, falsebr, loc):
977
- assert isinstance(cond, Var)
978
- assert isinstance(loc, Loc)
975
+ assert isinstance(cond, var_types)
976
+ assert isinstance(loc, loc_types)
979
977
  self.cond = cond
980
978
  self.truebr = truebr
981
979
  self.falsebr = falsebr
@@ -994,9 +992,9 @@ class Assign(Stmt):
994
992
  """
995
993
 
996
994
  def __init__(self, value, target, loc):
997
- assert isinstance(value, AbstractRHS)
998
- assert isinstance(target, Var)
999
- assert isinstance(loc, Loc)
995
+ assert isinstance(value, abstractrhs_types)
996
+ assert isinstance(target, var_types)
997
+ assert isinstance(loc, loc_types)
1000
998
  self.value = value
1001
999
  self.target = target
1002
1000
  self.loc = loc
@@ -1011,9 +1009,10 @@ class Print(Stmt):
1011
1009
  """
1012
1010
 
1013
1011
  def __init__(self, args, vararg, loc):
1014
- assert all(isinstance(x, Var) for x in args)
1015
- assert vararg is None or isinstance(vararg, Var)
1016
- assert isinstance(loc, Loc)
1012
+ assert all(isinstance(x, var_types) for x in args)
1013
+ if vararg is not None:
1014
+ assert isinstance(vararg, var_types)
1015
+ assert isinstance(loc, loc_types)
1017
1016
  self.args = tuple(args)
1018
1017
  self.vararg = vararg
1019
1018
  # Constant-inferred arguments
@@ -1026,8 +1025,8 @@ class Print(Stmt):
1026
1025
 
1027
1026
  class Yield(Inst):
1028
1027
  def __init__(self, value, loc, index):
1029
- assert isinstance(value, Var)
1030
- assert isinstance(loc, Loc)
1028
+ assert isinstance(value, var_types)
1029
+ assert isinstance(loc, loc_types)
1031
1030
  self.value = value
1032
1031
  self.loc = loc
1033
1032
  self.index = index
@@ -1052,8 +1051,8 @@ class EnterWith(Stmt):
1052
1051
  loc : ir.Loc instance
1053
1052
  Source location
1054
1053
  """
1055
- assert isinstance(contextmanager, Var)
1056
- assert isinstance(loc, Loc)
1054
+ assert isinstance(contextmanager, var_types)
1055
+ assert isinstance(loc, loc_types)
1057
1056
  self.contextmanager = contextmanager
1058
1057
  self.begin = begin
1059
1058
  self.end = end
@@ -1070,7 +1069,7 @@ class PopBlock(Stmt):
1070
1069
  """Marker statement for a pop block op code"""
1071
1070
 
1072
1071
  def __init__(self, loc):
1073
- assert isinstance(loc, Loc)
1072
+ assert isinstance(loc, loc_types)
1074
1073
  self.loc = loc
1075
1074
 
1076
1075
  def __str__(self):
@@ -1081,7 +1080,7 @@ class Arg(EqualityCheckMixin, AbstractRHS):
1081
1080
  def __init__(self, name, index, loc):
1082
1081
  assert isinstance(name, str)
1083
1082
  assert isinstance(index, int)
1084
- assert isinstance(loc, Loc)
1083
+ assert isinstance(loc, loc_types)
1085
1084
  self.name = name
1086
1085
  self.index = index
1087
1086
  self.loc = loc
@@ -1095,7 +1094,7 @@ class Arg(EqualityCheckMixin, AbstractRHS):
1095
1094
 
1096
1095
  class Const(EqualityCheckMixin, AbstractRHS):
1097
1096
  def __init__(self, value, loc, use_literal_type=True):
1098
- assert isinstance(loc, Loc)
1097
+ assert isinstance(loc, loc_types)
1099
1098
  self.value = value
1100
1099
  self.loc = loc
1101
1100
  # Note: need better way to tell if this is a literal or not.
@@ -1118,7 +1117,7 @@ class Const(EqualityCheckMixin, AbstractRHS):
1118
1117
 
1119
1118
  class Global(EqualityCheckMixin, AbstractRHS):
1120
1119
  def __init__(self, name, value, loc):
1121
- assert isinstance(loc, Loc)
1120
+ assert isinstance(loc, loc_types)
1122
1121
  self.name = name
1123
1122
  self.value = value
1124
1123
  self.loc = loc
@@ -1144,7 +1143,7 @@ class FreeVar(EqualityCheckMixin, AbstractRHS):
1144
1143
  def __init__(self, index, name, value, loc):
1145
1144
  assert isinstance(index, int)
1146
1145
  assert isinstance(name, str)
1147
- assert isinstance(loc, Loc)
1146
+ assert isinstance(loc, loc_types)
1148
1147
  # index inside __code__.co_freevars
1149
1148
  self.index = index
1150
1149
  # variable name
@@ -1180,9 +1179,10 @@ class Var(EqualityCheckMixin, AbstractRHS):
1180
1179
 
1181
1180
  def __init__(self, scope, name, loc):
1182
1181
  # NOTE: Use of scope=None should be removed.
1183
- assert scope is None or isinstance(scope, Scope)
1182
+ if scope is not None:
1183
+ assert isinstance(scope, scope_types)
1184
1184
  assert isinstance(name, str)
1185
- assert isinstance(loc, Loc)
1185
+ assert isinstance(loc, loc_types)
1186
1186
  self.scope = scope
1187
1187
  self.name = name
1188
1188
  self.loc = loc
@@ -1241,8 +1241,9 @@ class Scope(EqualityCheckMixin):
1241
1241
  """
1242
1242
 
1243
1243
  def __init__(self, parent, loc):
1244
- assert parent is None or isinstance(parent, Scope)
1245
- assert isinstance(loc, Loc)
1244
+ if parent is not None:
1245
+ assert isinstance(parent, scope_types)
1246
+ assert isinstance(loc, loc_types)
1246
1247
  self.parent = parent
1247
1248
  self.localvars = VarMap()
1248
1249
  self.loc = loc
@@ -1348,12 +1349,8 @@ class Block(EqualityCheckMixin):
1348
1349
  """A code block"""
1349
1350
 
1350
1351
  def __init__(self, scope, loc):
1351
- if HAS_NUMBA:
1352
- assert isinstance(scope, (Scope, numba.core.ir.Scope))
1353
- assert isinstance(loc, (Loc, numba.core.ir.Loc))
1354
- else:
1355
- assert isinstance(scope, Scope)
1356
- assert isinstance(loc, Loc)
1352
+ assert isinstance(scope, scope_types)
1353
+ assert isinstance(loc, loc_types)
1357
1354
  self.scope = scope
1358
1355
  self.body = []
1359
1356
  self.loc = loc
@@ -1368,9 +1365,9 @@ class Block(EqualityCheckMixin):
1368
1365
  Iterate over exprs of the given *op* in this block.
1369
1366
  """
1370
1367
  for inst in self.body:
1371
- if isinstance(inst, Assign):
1368
+ if isinstance(inst, assign_types):
1372
1369
  expr = inst.value
1373
- if isinstance(expr, Expr):
1370
+ if isinstance(expr, expr_types):
1374
1371
  if op is None or expr.op == op:
1375
1372
  yield expr
1376
1373
 
@@ -1387,21 +1384,21 @@ class Block(EqualityCheckMixin):
1387
1384
  Returns the assignment inst associated with variable "name", None if
1388
1385
  it cannot be found.
1389
1386
  """
1390
- for x in self.find_insts(cls=Assign):
1387
+ for x in self.find_insts(cls=assign_types):
1391
1388
  if x.target.name == name:
1392
1389
  return x
1393
1390
  return None
1394
1391
 
1395
1392
  def prepend(self, inst):
1396
- assert isinstance(inst, Stmt)
1393
+ assert isinstance(inst, stmt_types)
1397
1394
  self.body.insert(0, inst)
1398
1395
 
1399
1396
  def append(self, inst):
1400
- assert isinstance(inst, Stmt)
1397
+ assert isinstance(inst, stmt_types)
1401
1398
  self.body.append(inst)
1402
1399
 
1403
1400
  def remove(self, inst):
1404
- assert isinstance(inst, Stmt)
1401
+ assert isinstance(inst, stmt_types)
1405
1402
  del self.body[self.body.index(inst)]
1406
1403
 
1407
1404
  def clear(self):
@@ -1443,7 +1440,7 @@ class Block(EqualityCheckMixin):
1443
1440
  self.body.insert(index + 1, stmt)
1444
1441
 
1445
1442
  def insert_before_terminator(self, stmt):
1446
- assert isinstance(stmt, Stmt)
1443
+ assert isinstance(stmt, stmt_types)
1447
1444
  assert self.is_terminated
1448
1445
  self.body.insert(-1, stmt)
1449
1446
 
@@ -1527,8 +1524,12 @@ class FunctionIR(object):
1527
1524
  if block != other_blk:
1528
1525
  msg.append(("Block %s differs" % label).center(80, "-"))
1529
1526
  # see if the instructions are just a permutation
1530
- block_del = [x for x in block.body if isinstance(x, Del)]
1531
- oth_del = [x for x in other_blk.body if isinstance(x, Del)]
1527
+ block_del = [
1528
+ x for x in block.body if isinstance(x, del_types)
1529
+ ]
1530
+ oth_del = [
1531
+ x for x in other_blk.body if isinstance(x, del_types)
1532
+ ]
1532
1533
  if block_del != oth_del:
1533
1534
  # this is a common issue, dels are all present, but
1534
1535
  # order shuffled.
@@ -1653,7 +1654,7 @@ class FunctionIR(object):
1653
1654
  """
1654
1655
  Try to infer the constant value of a given variable.
1655
1656
  """
1656
- if isinstance(name, Var):
1657
+ if isinstance(name, var_types):
1657
1658
  name = name.name
1658
1659
  return self._consts.infer_constant(name)
1659
1660
 
@@ -1665,7 +1666,7 @@ class FunctionIR(object):
1665
1666
  """
1666
1667
  lhs = value
1667
1668
  while True:
1668
- if isinstance(value, Var):
1669
+ if isinstance(value, var_types):
1669
1670
  lhs = value
1670
1671
  name = value.name
1671
1672
  elif isinstance(value, str):
@@ -1692,10 +1693,10 @@ class FunctionIR(object):
1692
1693
  else:
1693
1694
  blocks = [self.blocks[blk] for blk in list(in_blocks)]
1694
1695
 
1695
- assert isinstance(rhs_value, AbstractRHS)
1696
+ assert isinstance(rhs_value, abstractrhs_types)
1696
1697
 
1697
1698
  for blk in blocks:
1698
- for assign in blk.find_insts(Assign):
1699
+ for assign in blk.find_insts(assign_types):
1699
1700
  if assign.value == rhs_value:
1700
1701
  return assign.target
1701
1702
 
@@ -1810,3 +1811,74 @@ class UndefinedType(EqualityCheckMixin):
1810
1811
 
1811
1812
 
1812
1813
  UNDEFINED = UndefinedType()
1814
+
1815
+ if HAS_NUMBA:
1816
+ abstractrhs_types = (AbstractRHS, numba.core.ir.AbstractRHS)
1817
+ arg_types = (Arg, numba.core.ir.Arg)
1818
+ assign_types = (Assign, numba.core.ir.Assign)
1819
+ block_types = (Block, numba.core.ir.Block)
1820
+ branch_types = (Branch, numba.core.ir.Branch)
1821
+ const_types = (Const, numba.core.ir.Const)
1822
+ del_types = (Del, numba.core.ir.Del)
1823
+ delattr_types = (DelAttr, numba.core.ir.DelAttr)
1824
+ delitem_types = (DelItem, numba.core.ir.DelItem)
1825
+ dynamicraise_types = (DynamicRaise, numba.core.ir.DynamicRaise)
1826
+ dynamictryraise_types = (DynamicTryRaise, numba.core.ir.DynamicTryRaise)
1827
+ enterwith_types = (EnterWith, numba.core.ir.EnterWith)
1828
+ expr_types = (Expr, numba.core.ir.Expr)
1829
+ freevar_types = (FreeVar, numba.core.ir.FreeVar)
1830
+ global_types = (Global, numba.core.ir.Global)
1831
+ inst_types = (Inst, numba.core.ir.Inst)
1832
+ jump_types = (Jump, numba.core.ir.Jump)
1833
+ loc_types = (Loc, numba.core.ir.Loc)
1834
+ popblock_types = (PopBlock, numba.core.ir.PopBlock)
1835
+ print_types = (Print, numba.core.ir.Print)
1836
+ raise_types = (Raise, numba.core.ir.Raise)
1837
+ return_types = (Return, numba.core.ir.Return)
1838
+ scope_types = (Scope, numba.core.ir.Scope)
1839
+ setattr_types = (SetAttr, numba.core.ir.SetAttr)
1840
+ setitem_types = (SetItem, numba.core.ir.SetItem)
1841
+ staticraise_types = (StaticRaise, numba.core.ir.StaticRaise)
1842
+ staticsetitem_types = (StaticSetItem, numba.core.ir.StaticSetItem)
1843
+ statictryraise_types = (StaticTryRaise, numba.core.ir.StaticTryRaise)
1844
+ stmt_types = (Stmt, numba.core.ir.Stmt)
1845
+ storemap_types = (StoreMap, numba.core.ir.StoreMap)
1846
+ tryraise_types = (TryRaise, numba.core.ir.TryRaise)
1847
+ var_types = (Var, numba.core.ir.Var)
1848
+ with_types = (With, numba.core.ir.With)
1849
+ yield_types = (Yield, numba.core.ir.Yield)
1850
+ else:
1851
+ abstractrhs_types = (AbstractRHS,)
1852
+ arg_types = (Arg,)
1853
+ assign_types = (Assign,)
1854
+ block_types = (Block,)
1855
+ branch_types = (Branch,)
1856
+ const_types = (Const,)
1857
+ del_types = (Del,)
1858
+ delattr_types = (DelAttr,)
1859
+ delitem_types = (DelItem,)
1860
+ dynamicraise_types = (DynamicRaise,)
1861
+ dynamictryraise_types = (DynamicTryRaise,)
1862
+ enterwith_types = (EnterWith,)
1863
+ expr_types = (Expr,)
1864
+ freevar_types = (FreeVar,)
1865
+ global_types = (Global,)
1866
+ inst_types = (Inst,)
1867
+ jump_types = (Jump,)
1868
+ loc_types = (Loc,)
1869
+ popblock_types = (PopBlock,)
1870
+ print_types = (Print,)
1871
+ raise_types = (Raise,)
1872
+ return_types = (Return,)
1873
+ scope_types = (Scope,)
1874
+ setattr_types = (SetAttr,)
1875
+ setitem_types = (SetItem,)
1876
+ staticraise_types = (StaticRaise,)
1877
+ staticsetitem_types = (StaticSetItem,)
1878
+ statictryraise_types = (StaticTryRaise,)
1879
+ stmt_types = (Stmt,)
1880
+ storemap_types = (StoreMap,)
1881
+ tryraise_types = (TryRaise,)
1882
+ var_types = (Var,)
1883
+ with_types = (With,)
1884
+ yield_types = (Yield,)