|
144 | 144 | lib.define(
|
145 | 145 | "quantized_conv_nhwc_asym8uxsym8u_asym8u.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)"
|
146 | 146 | )
|
| 147 | +lib.define( |
| 148 | + "quantized_conv_nchw_dilated_asym8sxsym8s_asym8s.per_tensor(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift) -> (Tensor Z)" |
| 149 | +) |
| 150 | +lib.define( |
| 151 | + "quantized_conv_nchw_dilated_asym8sxsym8s_asym8s.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 152 | +) |
| 153 | +lib.define( |
| 154 | + "quantized_conv_nchw_dilated_asym8uxsym8u_asym8u.per_tensor(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift) -> (Tensor Z)" |
| 155 | +) |
| 156 | +lib.define( |
| 157 | + "quantized_conv_nchw_dilated_asym8uxsym8u_asym8u.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 158 | +) |
| 159 | +lib.define( |
| 160 | + "quantized_conv_nhwc_dilated_asym8sxsym8s_asym8s.per_tensor(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift) -> (Tensor Z)" |
| 161 | +) |
| 162 | +lib.define( |
| 163 | + "quantized_conv_nhwc_dilated_asym8sxsym8s_asym8s.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 164 | +) |
| 165 | +lib.define( |
| 166 | + "quantized_conv_nhwc_dilated_asym8uxsym8u_asym8u.per_tensor(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift) -> (Tensor Z)" |
| 167 | +) |
| 168 | +lib.define( |
| 169 | + "quantized_conv_nhwc_dilated_asym8uxsym8u_asym8u.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 170 | +) |
147 | 171 | lib.define(
|
148 | 172 | "quantized_matmul_asym8uxasym8u_asym8u(Tensor X, int X_zero_point, Tensor Y, int Y_zero_point, Tensor? bias, int out_multiplier, int out_shift, int out_zero_point, bool transposed=False) -> (Tensor Z)"
|
149 | 173 | )
|
@@ -919,6 +943,182 @@ def quantized_conv_nhwc_asym8uxsym8u_asym8u_per_tensor_meta(
|
919 | 943 | return input.new_empty(output_size, dtype=input.dtype)
|
920 | 944 |
|
921 | 945 |
|
| 946 | +@register_fake("cadence::quantized_conv_nchw_dilated_asym8sxsym8s_asym8s.per_tensor") |
| 947 | +def quantized_conv_nchw_dilated_asym8sxsym8s_asym8s_per_tensor_meta( |
| 948 | + input: torch.Tensor, |
| 949 | + weight: torch.Tensor, |
| 950 | + bias: torch.Tensor, |
| 951 | + stride: Tuple[int], |
| 952 | + padding: Tuple[int], |
| 953 | + dilation: Tuple[int], |
| 954 | + groups: int, |
| 955 | + in_zero_point: int, |
| 956 | + weight_zero_point: int, |
| 957 | + bias_scale: float, |
| 958 | + output_scale: float, |
| 959 | + output_zero_point: int, |
| 960 | + out_multiplier: int, |
| 961 | + out_shift: int, |
| 962 | +) -> torch.Tensor: |
| 963 | + out_channels, _, *kernel_size = weight.shape |
| 964 | + |
| 965 | + in_size = input.shape |
| 966 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 967 | + assert len(in_size) > 2 |
| 968 | + assert len(in_size) < 6 |
| 969 | + |
| 970 | + # Compute the output tensor size |
| 971 | + output_size = ( |
| 972 | + get_conv1d_output_size( |
| 973 | + in_size, |
| 974 | + out_channels, |
| 975 | + stride[1], |
| 976 | + padding[1], |
| 977 | + dilation[1], |
| 978 | + kernel_size[0], |
| 979 | + False, |
| 980 | + ) |
| 981 | + if len(in_size) == 3 |
| 982 | + else get_conv2d_output_size( |
| 983 | + in_size, out_channels, stride, padding, dilation, kernel_size, False |
| 984 | + ) |
| 985 | + ) |
| 986 | + |
| 987 | + return input.new_empty(output_size, dtype=input.dtype) |
| 988 | + |
| 989 | + |
| 990 | +@register_fake("cadence::quantized_conv_nchw_dilated_asym8uxsym8u_asym8u.per_tensor") |
| 991 | +def quantized_conv_nchw_dilated_asym8uxsym8u_asym8u_per_tensor_meta( |
| 992 | + input: torch.Tensor, |
| 993 | + weight: torch.Tensor, |
| 994 | + bias: torch.Tensor, |
| 995 | + stride: Tuple[int], |
| 996 | + padding: Tuple[int], |
| 997 | + dilation: Tuple[int], |
| 998 | + groups: int, |
| 999 | + in_zero_point: int, |
| 1000 | + weight_zero_point: int, |
| 1001 | + bias_scale: float, |
| 1002 | + output_scale: float, |
| 1003 | + output_zero_point: int, |
| 1004 | + out_multiplier: int, |
| 1005 | + out_shift: int, |
| 1006 | +) -> torch.Tensor: |
| 1007 | + out_channels, _, *kernel_size = weight.shape |
| 1008 | + |
| 1009 | + in_size = input.shape |
| 1010 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 1011 | + assert len(in_size) > 2 |
| 1012 | + assert len(in_size) < 6 |
| 1013 | + |
| 1014 | + # Compute the output tensor size |
| 1015 | + output_size = ( |
| 1016 | + get_conv1d_output_size( |
| 1017 | + in_size, |
| 1018 | + out_channels, |
| 1019 | + stride[1], |
| 1020 | + padding[1], |
| 1021 | + dilation[1], |
| 1022 | + kernel_size[0], |
| 1023 | + False, |
| 1024 | + ) |
| 1025 | + if len(in_size) == 3 |
| 1026 | + else get_conv2d_output_size( |
| 1027 | + in_size, out_channels, stride, padding, dilation, kernel_size, False |
| 1028 | + ) |
| 1029 | + ) |
| 1030 | + |
| 1031 | + return input.new_empty(output_size, dtype=input.dtype) |
| 1032 | + |
| 1033 | + |
| 1034 | +@register_fake("cadence::quantized_conv_nhwc_dilated_asym8sxsym8s_asym8s.per_tensor") |
| 1035 | +def quantized_conv_nhwc_dilated_asym8sxsym8s_asym8s_per_tensor_meta( |
| 1036 | + input: torch.Tensor, |
| 1037 | + weight: torch.Tensor, |
| 1038 | + bias: torch.Tensor, |
| 1039 | + stride: Tuple[int], |
| 1040 | + padding: Tuple[int], |
| 1041 | + dilation: Tuple[int], |
| 1042 | + groups: int, |
| 1043 | + in_zero_point: int, |
| 1044 | + weight_zero_point: int, |
| 1045 | + bias_scale: float, |
| 1046 | + output_scale: float, |
| 1047 | + output_zero_point: int, |
| 1048 | + out_multiplier: int, |
| 1049 | + out_shift: int, |
| 1050 | +) -> torch.Tensor: |
| 1051 | + out_channels, *kernel_size, _ = weight.shape |
| 1052 | + |
| 1053 | + in_size = input.shape |
| 1054 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 1055 | + assert len(in_size) > 2 |
| 1056 | + assert len(in_size) < 6 |
| 1057 | + |
| 1058 | + # Compute the output tensor size |
| 1059 | + output_size = ( |
| 1060 | + get_conv1d_output_size( |
| 1061 | + in_size, |
| 1062 | + out_channels, |
| 1063 | + stride[1], |
| 1064 | + padding[1], |
| 1065 | + dilation[1], |
| 1066 | + kernel_size[0], |
| 1067 | + True, |
| 1068 | + ) |
| 1069 | + if len(in_size) == 3 |
| 1070 | + else get_conv2d_output_size( |
| 1071 | + in_size, out_channels, stride, padding, dilation, kernel_size, True |
| 1072 | + ) |
| 1073 | + ) |
| 1074 | + |
| 1075 | + return input.new_empty(output_size, dtype=input.dtype) |
| 1076 | + |
| 1077 | + |
| 1078 | +@register_fake("cadence::quantized_conv_nhwc_dilated_asym8uxsym8u_asym8u.per_tensor") |
| 1079 | +def quantized_conv_nhwc_dilated_asym8uxsym8u_asym8u_per_tensor_meta( |
| 1080 | + input: torch.Tensor, |
| 1081 | + weight: torch.Tensor, |
| 1082 | + bias: torch.Tensor, |
| 1083 | + stride: Tuple[int], |
| 1084 | + padding: Tuple[int], |
| 1085 | + dilation: Tuple[int], |
| 1086 | + groups: int, |
| 1087 | + in_zero_point: int, |
| 1088 | + weight_zero_point: int, |
| 1089 | + bias_scale: float, |
| 1090 | + output_scale: float, |
| 1091 | + output_zero_point: int, |
| 1092 | + out_multiplier: int, |
| 1093 | + out_shift: int, |
| 1094 | +) -> torch.Tensor: |
| 1095 | + out_channels, *kernel_size, _ = weight.shape |
| 1096 | + |
| 1097 | + in_size = input.shape |
| 1098 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 1099 | + assert len(in_size) > 2 |
| 1100 | + assert len(in_size) < 6 |
| 1101 | + |
| 1102 | + # Compute the output tensor size |
| 1103 | + output_size = ( |
| 1104 | + get_conv1d_output_size( |
| 1105 | + in_size, |
| 1106 | + out_channels, |
| 1107 | + stride[1], |
| 1108 | + padding[1], |
| 1109 | + dilation[1], |
| 1110 | + kernel_size[0], |
| 1111 | + True, |
| 1112 | + ) |
| 1113 | + if len(in_size) == 3 |
| 1114 | + else get_conv2d_output_size( |
| 1115 | + in_size, out_channels, stride, padding, dilation, kernel_size, True |
| 1116 | + ) |
| 1117 | + ) |
| 1118 | + |
| 1119 | + return input.new_empty(output_size, dtype=input.dtype) |
| 1120 | + |
| 1121 | + |
922 | 1122 | @register_fake("cadence::quantized_layer_norm")
|
923 | 1123 | def quantized_layer_norm_meta(
|
924 | 1124 | input: torch.Tensor,
|
|
0 commit comments