|
235 | 235 | lib.define( |
236 | 236 | "quantized_conv2d_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!)" |
237 | 237 | ) |
| 238 | +lib.define( |
| 239 | + "quantized_conv1d_nlc(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift) -> (Tensor Z)" |
| 240 | +) |
| 241 | +lib.define( |
| 242 | + "quantized_conv1d_nlc.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 243 | +) |
| 244 | +lib.define( |
| 245 | + "quantized_conv1d_ncl(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift) -> (Tensor Z)" |
| 246 | +) |
| 247 | +lib.define( |
| 248 | + "quantized_conv1d_ncl.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!)" |
| 249 | +) |
| 250 | +lib.define( |
| 251 | + "quantized_conv1d_ncl.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)" |
| 252 | +) |
| 253 | +lib.define( |
| 254 | + "quantized_conv1d_ncl.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!)" |
| 255 | +) |
| 256 | +lib.define( |
| 257 | + "quantized_conv1d_nlc.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)" |
| 258 | +) |
| 259 | +lib.define( |
| 260 | + "quantized_conv1d_nlc.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!)" |
| 261 | +) |
238 | 262 | lib.define( |
239 | 263 | "quantized_conv1d_ncl_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)" |
240 | 264 | ) |
@@ -934,6 +958,94 @@ def quantized_conv2d_nhwc_meta( |
934 | 958 | return input.new_empty(output_size, dtype=input.dtype) |
935 | 959 |
|
936 | 960 |
|
| 961 | +@register_fake("cadence::quantized_conv1d_nlc") |
| 962 | +def quantized_conv1d_nlc_meta( |
| 963 | + input: torch.Tensor, |
| 964 | + weight: torch.Tensor, |
| 965 | + bias: torch.Tensor, |
| 966 | + stride: Tuple[int], |
| 967 | + padding: Tuple[int], |
| 968 | + dilation: Tuple[int], |
| 969 | + groups: int, |
| 970 | + in_zero_point: int, |
| 971 | + weight_zero_point: torch.Tensor, |
| 972 | + bias_scale: torch.Tensor, |
| 973 | + output_scale: float, |
| 974 | + output_zero_point: int, |
| 975 | + out_multiplier: torch.Tensor, |
| 976 | + out_shift: torch.Tensor, |
| 977 | +) -> torch.Tensor: |
| 978 | + out_channels, *kernel_size, _ = weight.shape |
| 979 | + |
| 980 | + in_size = input.shape |
| 981 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 982 | + assert len(in_size) > 2 |
| 983 | + assert len(in_size) < 6 |
| 984 | + |
| 985 | + # Compute the output tensor size |
| 986 | + output_size = ( |
| 987 | + get_conv1d_output_size( |
| 988 | + in_size, |
| 989 | + out_channels, |
| 990 | + stride[1], |
| 991 | + padding[1], |
| 992 | + dilation[1], |
| 993 | + kernel_size[0], |
| 994 | + True, |
| 995 | + ) |
| 996 | + if len(in_size) == 3 |
| 997 | + else get_conv2d_output_size( |
| 998 | + in_size, out_channels, stride, padding, dilation, kernel_size, True |
| 999 | + ) |
| 1000 | + ) |
| 1001 | + |
| 1002 | + return input.new_empty(output_size, dtype=input.dtype) |
| 1003 | + |
| 1004 | + |
| 1005 | +@register_fake("cadence::quantized_conv1d_ncl") |
| 1006 | +def quantized_conv1d_ncl_meta( |
| 1007 | + input: torch.Tensor, |
| 1008 | + weight: torch.Tensor, |
| 1009 | + bias: torch.Tensor, |
| 1010 | + stride: Tuple[int], |
| 1011 | + padding: Tuple[int], |
| 1012 | + dilation: Tuple[int], |
| 1013 | + groups: int, |
| 1014 | + in_zero_point: int, |
| 1015 | + weight_zero_point: torch.Tensor, |
| 1016 | + bias_scale: torch.Tensor, |
| 1017 | + output_scale: float, |
| 1018 | + output_zero_point: int, |
| 1019 | + out_multiplier: torch.Tensor, |
| 1020 | + out_shift: torch.Tensor, |
| 1021 | +) -> torch.Tensor: |
| 1022 | + out_channels, _, *kernel_size = weight.shape |
| 1023 | + |
| 1024 | + in_size = input.shape |
| 1025 | + # Assert that the input tensor has at least 3 dimensions, and at most 6 |
| 1026 | + assert len(in_size) > 2 |
| 1027 | + assert len(in_size) < 6 |
| 1028 | + |
| 1029 | + # Compute the output tensor size |
| 1030 | + output_size = ( |
| 1031 | + get_conv1d_output_size( |
| 1032 | + in_size, |
| 1033 | + out_channels, |
| 1034 | + stride[1], |
| 1035 | + padding[1], |
| 1036 | + dilation[1], |
| 1037 | + kernel_size[0], |
| 1038 | + False, |
| 1039 | + ) |
| 1040 | + if len(in_size) == 3 |
| 1041 | + else get_conv2d_output_size( |
| 1042 | + in_size, out_channels, stride, padding, dilation, kernel_size, False |
| 1043 | + ) |
| 1044 | + ) |
| 1045 | + |
| 1046 | + return input.new_empty(output_size, dtype=input.dtype) |
| 1047 | + |
| 1048 | + |
937 | 1049 | @register_fake("cadence::quantized_conv2d_nchw") |
938 | 1050 | def quantized_conv2d_nchw_meta( |
939 | 1051 | input: torch.Tensor, |
@@ -2371,6 +2483,68 @@ def roi_align_box_processor_meta( |
2371 | 2483 | return rois.new_empty((rois.shape[0], 80), dtype=torch.uint8) |
2372 | 2484 |
|
2373 | 2485 |
|
| 2486 | +@register_fake("cadence::quantized_conv1d_ncl.per_tensor") |
| 2487 | +def quantized_conv1d_ncl_per_tensor_meta( |
| 2488 | + input: torch.Tensor, |
| 2489 | + weight: torch.Tensor, |
| 2490 | + bias: torch.Tensor, |
| 2491 | + stride: Tuple[int], |
| 2492 | + padding: Tuple[int], |
| 2493 | + dilation: Tuple[int], |
| 2494 | + groups: int, |
| 2495 | + in_zero_point: int, |
| 2496 | + weight_zero_point: int, |
| 2497 | + bias_scale: float, |
| 2498 | + output_scale: float, |
| 2499 | + output_zero_point: int, |
| 2500 | + out_multiplier: int, |
| 2501 | + out_shift: int, |
| 2502 | +) -> torch.Tensor: |
| 2503 | + assert input.dim() == 3 and weight.dim() == 3 |
| 2504 | + out_channels, _, kernel_size = weight.shape |
| 2505 | + output_size = get_conv1d_output_size( |
| 2506 | + input.shape, |
| 2507 | + out_channels, |
| 2508 | + stride[1], |
| 2509 | + padding[1], |
| 2510 | + dilation[1], |
| 2511 | + kernel_size, |
| 2512 | + False, |
| 2513 | + ) |
| 2514 | + return input.new_empty(output_size, dtype=input.dtype) |
| 2515 | + |
| 2516 | + |
| 2517 | +@register_fake("cadence::quantized_conv1d_nlc.per_tensor") |
| 2518 | +def quantized_conv1d_nlc_per_tensor_meta( |
| 2519 | + input: torch.Tensor, |
| 2520 | + weight: torch.Tensor, |
| 2521 | + bias: torch.Tensor, |
| 2522 | + stride: Tuple[int], |
| 2523 | + padding: Tuple[int], |
| 2524 | + dilation: Tuple[int], |
| 2525 | + groups: int, |
| 2526 | + in_zero_point: int, |
| 2527 | + weight_zero_point: int, |
| 2528 | + bias_scale: float, |
| 2529 | + output_scale: float, |
| 2530 | + output_zero_point: int, |
| 2531 | + out_multiplier: int, |
| 2532 | + out_shift: int, |
| 2533 | +) -> torch.Tensor: |
| 2534 | + assert input.dim() == 3 and weight.dim() == 3 |
| 2535 | + out_channels, _, kernel_size = weight.shape |
| 2536 | + output_size = get_conv1d_output_size( |
| 2537 | + input.shape, |
| 2538 | + out_channels, |
| 2539 | + stride[1], |
| 2540 | + padding[1], |
| 2541 | + dilation[1], |
| 2542 | + kernel_size, |
| 2543 | + True, |
| 2544 | + ) |
| 2545 | + return input.new_empty(output_size, dtype=input.dtype) |
| 2546 | + |
| 2547 | + |
2374 | 2548 | @register_fake("cadence::quantized_conv1d_ncl_asym8sxsym8s_asym8s.per_tensor") |
2375 | 2549 | def quantized_conv1d_ncl_asym8sxsym8s_asym8s_per_tensor_meta( |
2376 | 2550 | input: torch.Tensor, |
|
0 commit comments