(argType, ctx, **kwargs)
| 625 | |
| 626 | |
| 627 | def mlirTypeFromPyType(argType, ctx, **kwargs): |
| 628 | if argType in [int, np.int64]: |
| 629 | return IntegerType.get_signless(64, ctx) |
| 630 | if argType == np.int32: |
| 631 | return IntegerType.get_signless(32, ctx) |
| 632 | if argType == np.int16: |
| 633 | return IntegerType.get_signless(16, ctx) |
| 634 | if argType == np.int8: |
| 635 | return IntegerType.get_signless(8, ctx) |
| 636 | if argType in [float, np.float64]: |
| 637 | return F64Type.get(ctx) |
| 638 | if argType == np.float32: |
| 639 | return F32Type.get(ctx) |
| 640 | if argType == bool: |
| 641 | return IntegerType.get_signless(1, ctx) |
| 642 | if argType == complex: |
| 643 | return ComplexType.get(mlirTypeFromPyType(float, ctx)) |
| 644 | if argType == np.complex128: |
| 645 | return ComplexType.get(mlirTypeFromPyType(np.float64, ctx)) |
| 646 | if argType == np.complex64: |
| 647 | return ComplexType.get(mlirTypeFromPyType(np.float32, ctx)) |
| 648 | if argType == pauli_word: |
| 649 | return cc.CharspanType.get(ctx) |
| 650 | if argType == State: |
| 651 | return cc.PointerType.get(cc.StateType.get(ctx), ctx) |
| 652 | |
| 653 | if get_origin(argType) == list: |
| 654 | pyEleTy = get_args(argType) |
| 655 | if len(pyEleTy) == 1: |
| 656 | eleTy = mlirTypeFromPyType(pyEleTy[0], ctx) |
| 657 | return cc.StdvecType.get(eleTy, ctx) |
| 658 | argType = list |
| 659 | |
| 660 | if argType in [list, np.ndarray, List]: |
| 661 | if 'argInstance' not in kwargs: |
| 662 | return cc.StdvecType.get(mlirTypeFromPyType(float, ctx), ctx) |
| 663 | if argType != np.ndarray: |
| 664 | if kwargs['argInstance'] == None: |
| 665 | return cc.StdvecType.get(mlirTypeFromPyType(float, ctx), ctx) |
| 666 | |
| 667 | argInstance = kwargs['argInstance'] |
| 668 | argTypeToCompareTo = kwargs[ |
| 669 | 'argTypeToCompareTo'] if 'argTypeToCompareTo' in kwargs else None |
| 670 | |
| 671 | if len(argInstance) == 0: |
| 672 | if argTypeToCompareTo == None: |
| 673 | emitFatalError('Cannot infer runtime argument type') |
| 674 | |
| 675 | eleTy = cc.StdvecType.getElementType(argTypeToCompareTo) |
| 676 | return cc.StdvecType.get(eleTy, ctx) |
| 677 | |
| 678 | if isinstance(argInstance[0], list): |
| 679 | return cc.StdvecType.get( |
| 680 | mlirTypeFromPyType( |
| 681 | type(argInstance[0]), |
| 682 | ctx, |
| 683 | argInstance=argInstance[0], |
| 684 | argTypeToCompareTo=cc.StdvecType.getElementType( |
no test coverage detected