(argType)
| 765 | |
| 766 | |
| 767 | def mlirTypeToPyType(argType): |
| 768 | |
| 769 | if IntegerType.isinstance(argType): |
| 770 | width = IntegerType(argType).width |
| 771 | if width == 1: |
| 772 | return bool |
| 773 | if width == 8: |
| 774 | return np.int8 |
| 775 | if width == 16: |
| 776 | return np.int16 |
| 777 | if width == 32: |
| 778 | return np.int32 |
| 779 | if width == 64: |
| 780 | return int |
| 781 | |
| 782 | if F64Type.isinstance(argType): |
| 783 | return float |
| 784 | |
| 785 | if F32Type.isinstance(argType): |
| 786 | return np.float32 |
| 787 | |
| 788 | if quake.VeqType.isinstance(argType): |
| 789 | return qvector |
| 790 | |
| 791 | if quake.RefType.isinstance(argType): |
| 792 | return qubit |
| 793 | |
| 794 | if cc.CallableType.isinstance(argType): |
| 795 | return Callable |
| 796 | |
| 797 | if ComplexType.isinstance(argType): |
| 798 | if F64Type.isinstance(ComplexType(argType).element_type): |
| 799 | return complex |
| 800 | return np.complex64 |
| 801 | |
| 802 | if cc.CharspanType.isinstance(argType): |
| 803 | return pauli_word |
| 804 | |
| 805 | if cc.MeasureHandleType.isinstance(argType): |
| 806 | return measure_handle |
| 807 | |
| 808 | if cc.StdvecType.isinstance(argType): |
| 809 | eleTy = cc.StdvecType.getElementType(argType) |
| 810 | if cc.CharspanType.isinstance(eleTy): |
| 811 | return list[pauli_word] |
| 812 | |
| 813 | pyEleTy = mlirTypeToPyType(eleTy) |
| 814 | return list[pyEleTy] |
| 815 | |
| 816 | if cc.PointerType.isinstance(argType): |
| 817 | valueTy = cc.PointerType.getElementType(argType) |
| 818 | if cc.StateType.isinstance(valueTy): |
| 819 | return State |
| 820 | |
| 821 | if cc.StructType.isinstance(argType): |
| 822 | if (cc.StructType.getName(argType) == "tuple"): |
| 823 | elements = [ |
| 824 | mlirTypeToPyType(v) for v in cc.StructType.getTypes(argType) |
no test coverage detected