executorch 1.6.0__cp315-cp315-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.
- executorch/backends/__init__.py +0 -0
- executorch/backends/aoti/aoti_backend.py +493 -0
- executorch/backends/aoti/aoti_partitioner.py +141 -0
- executorch/backends/aoti/passes/replace_view_copy_with_view.py +137 -0
- executorch/backends/apple/__init__.py +0 -0
- executorch/backends/apple/coreai/__init__.py +52 -0
- executorch/backends/apple/coreai/compiler/__init__.py +5 -0
- executorch/backends/apple/coreai/compiler/constants.py +12 -0
- executorch/backends/apple/coreai/compiler/enumerated_shapes.py +246 -0
- executorch/backends/apple/coreai/compiler/io_compat.py +258 -0
- executorch/backends/apple/coreai/compiler/preprocess.py +550 -0
- executorch/backends/apple/coreai/palettizer/__init__.py +11 -0
- executorch/backends/apple/coreai/palettizer/palettizer.py +115 -0
- executorch/backends/apple/coreai/partition/__init__.py +5 -0
- executorch/backends/apple/coreai/partition/partitioner.py +324 -0
- executorch/backends/apple/coreai/passes/__init__.py +11 -0
- executorch/backends/apple/coreai/passes/narrow_dtypes.py +105 -0
- executorch/backends/apple/coreai/passes/replace_copy_ops.py +66 -0
- executorch/backends/apple/coreai/passes/test/__init__.py +5 -0
- executorch/backends/apple/coreai/quantizer/__init__.py +11 -0
- executorch/backends/apple/coreai/quantizer/quantizer.py +92 -0
- executorch/backends/apple/coreai/recipes/__init__.py +18 -0
- executorch/backends/apple/coreai/recipes/recipe_provider.py +97 -0
- executorch/backends/apple/coreai/recipes/recipe_types.py +26 -0
- executorch/backends/apple/coreai/test/__init__.py +5 -0
- executorch/backends/apple/coreml/compiler/__init__.py +9 -0
- executorch/backends/apple/coreml/compiler/coreml_preprocess.py +993 -0
- executorch/backends/apple/coreml/compiler/enumerated_shape_utils.py +244 -0
- executorch/backends/apple/coreml/compiler/torch_ops.py +240 -0
- executorch/backends/apple/coreml/executorchcoreml.pyi +10 -0
- executorch/backends/apple/coreml/logging.py +24 -0
- executorch/backends/apple/coreml/partition/__init__.py +9 -0
- executorch/backends/apple/coreml/partition/coreml_partitioner.py +477 -0
- executorch/backends/apple/coreml/quantizer/__init__.py +9 -0
- executorch/backends/apple/coreml/quantizer/_annotation_config.py +130 -0
- executorch/backends/apple/coreml/quantizer/_coreml_quantizer.py +628 -0
- executorch/backends/apple/coreml/quantizer/_coreml_quantizer_utils.py +800 -0
- executorch/backends/apple/coreml/quantizer/coreml_quantizer.py +7 -0
- executorch/backends/apple/coreml/recipes/__init__.py +17 -0
- executorch/backends/apple/coreml/recipes/coreml_recipe_provider.py +413 -0
- executorch/backends/apple/coreml/recipes/coreml_recipe_types.py +53 -0
- executorch/backends/apple/coreml/test/test_coreml_utils.py +19 -0
- executorch/backends/apple/coreml/test/tester.py +121 -0
- executorch/backends/apple/metal/metal_backend.py +127 -0
- executorch/backends/apple/metal/metal_partitioner.py +25 -0
- executorch/backends/apple/metal/ops/__init__.py +5 -0
- executorch/backends/apple/metal/ops/gated_delta_rule.py +92 -0
- executorch/backends/apple/metal/ops/gather_qmv.py +117 -0
- executorch/backends/apple/metal/passes/__init__.py +11 -0
- executorch/backends/apple/metal/passes/decompose_linear_pass.py +115 -0
- executorch/backends/apple/metal/tests/__init__.py +5 -0
- executorch/backends/arm/__init__.py +59 -0
- executorch/backends/arm/_passes/__init__.py +251 -0
- executorch/backends/arm/_passes/_debug_passes.py +59 -0
- executorch/backends/arm/_passes/accumulate_index_put_pass.py +65 -0
- executorch/backends/arm/_passes/arm_pass.py +305 -0
- executorch/backends/arm/_passes/arm_pass_manager.py +891 -0
- executorch/backends/arm/_passes/arm_pass_utils.py +830 -0
- executorch/backends/arm/_passes/aten_to_tosa_activation_functions.py +148 -0
- executorch/backends/arm/_passes/aten_to_tosa_comparison.py +27 -0
- executorch/backends/arm/_passes/aten_to_tosa_data_layout.py +98 -0
- executorch/backends/arm/_passes/aten_to_tosa_reduction.py +110 -0
- executorch/backends/arm/_passes/aten_to_tosa_tensor_operators.py +112 -0
- executorch/backends/arm/_passes/aten_to_tosa_ternary.py +25 -0
- executorch/backends/arm/_passes/broadcast_args_pass.py +90 -0
- executorch/backends/arm/_passes/canonicalize_gather_pass.py +203 -0
- executorch/backends/arm/_passes/canonicalize_view_copy_permute_pass.py +22 -0
- executorch/backends/arm/_passes/cast_int64_pass.py +100 -0
- executorch/backends/arm/_passes/cast_int_comparison_inputs_pass.py +61 -0
- executorch/backends/arm/_passes/cast_to_int32_pass.py +69 -0
- executorch/backends/arm/_passes/constant_folding_pass.py +70 -0
- executorch/backends/arm/_passes/control_flow_const_inline.py +78 -0
- executorch/backends/arm/_passes/convert_bool_sum_pass.py +81 -0
- executorch/backends/arm/_passes/convert_elu_params.py +88 -0
- executorch/backends/arm/_passes/convert_expand_copy_to_repeat.py +91 -0
- executorch/backends/arm/_passes/convert_full_like_to_full_pass.py +51 -0
- executorch/backends/arm/_passes/convert_int64_const_ops_to_int32.py +85 -0
- executorch/backends/arm/_passes/convert_int64_output_ops_to_int32.py +512 -0
- executorch/backends/arm/_passes/convert_minmax_pass.py +166 -0
- executorch/backends/arm/_passes/convert_split_to_slice.py +134 -0
- executorch/backends/arm/_passes/convert_squeezes_to_view.py +41 -0
- executorch/backends/arm/_passes/convert_to_clamp_pass.py +47 -0
- executorch/backends/arm/_passes/decompose_acosh_pass.py +75 -0
- executorch/backends/arm/_passes/decompose_adaptive_avg_pool2d_pass.py +457 -0
- executorch/backends/arm/_passes/decompose_adaptive_max_pool2d_pass.py +202 -0
- executorch/backends/arm/_passes/decompose_add_sub_alpha_pass.py +102 -0
- executorch/backends/arm/_passes/decompose_addmm_pass.py +75 -0
- executorch/backends/arm/_passes/decompose_any_pass.py +117 -0
- executorch/backends/arm/_passes/decompose_as_strided_copy_pass.py +116 -0
- executorch/backends/arm/_passes/decompose_asin_and_acos_pass.py +233 -0
- executorch/backends/arm/_passes/decompose_asinh_pass.py +72 -0
- executorch/backends/arm/_passes/decompose_atan_pass.py +149 -0
- executorch/backends/arm/_passes/decompose_atanh_pass.py +84 -0
- executorch/backends/arm/_passes/decompose_avg_pool2d_pass.py +178 -0
- executorch/backends/arm/_passes/decompose_batch_norm_no_stats.py +259 -0
- executorch/backends/arm/_passes/decompose_bool_equality_pass.py +31 -0
- executorch/backends/arm/_passes/decompose_choose_qparams_symmetric_pass.py +285 -0
- executorch/backends/arm/_passes/decompose_cosh_pass.py +69 -0
- executorch/backends/arm/_passes/decompose_cosine_similarity_pass.py +98 -0
- executorch/backends/arm/_passes/decompose_cumsum_pass.py +167 -0
- executorch/backends/arm/_passes/decompose_div_pass.py +59 -0
- executorch/backends/arm/_passes/decompose_div_tensor_mode.py +283 -0
- executorch/backends/arm/_passes/decompose_dynamic_adaptive_avg_pool2d_pass.py +57 -0
- executorch/backends/arm/_passes/decompose_dynamic_full_pass.py +56 -0
- executorch/backends/arm/_passes/decompose_einsum_pass.py +66 -0
- executorch/backends/arm/_passes/decompose_elu_pass.py +187 -0
- executorch/backends/arm/_passes/decompose_embedding_pass.py +132 -0
- executorch/backends/arm/_passes/decompose_erfinv_pass.py +374 -0
- executorch/backends/arm/_passes/decompose_expm1_pass.py +160 -0
- executorch/backends/arm/_passes/decompose_flip_pass.py +35 -0
- executorch/backends/arm/_passes/decompose_floor_divide_pass.py +76 -0
- executorch/backends/arm/_passes/decompose_gelu_pass.py +144 -0
- executorch/backends/arm/_passes/decompose_glu_pass.py +84 -0
- executorch/backends/arm/_passes/decompose_grouped_conv_pass.py +319 -0
- executorch/backends/arm/_passes/decompose_groupnorm_pass.py +223 -0
- executorch/backends/arm/_passes/decompose_gru_pass.py +337 -0
- executorch/backends/arm/_passes/decompose_index_copy_pass.py +33 -0
- executorch/backends/arm/_passes/decompose_index_select_to_gather_pass.py +237 -0
- executorch/backends/arm/_passes/decompose_index_tensor_to_gather_pass.py +553 -0
- executorch/backends/arm/_passes/decompose_int_pow_pass.py +87 -0
- executorch/backends/arm/_passes/decompose_isinf_isnan_pass.py +48 -0
- executorch/backends/arm/_passes/decompose_large_stride_maxpool2d_pass.py +207 -0
- executorch/backends/arm/_passes/decompose_layernorm_pass.py +214 -0
- executorch/backends/arm/_passes/decompose_leaky_relu_pass.py +80 -0
- executorch/backends/arm/_passes/decompose_linalg_vector_norm_pass.py +93 -0
- executorch/backends/arm/_passes/decompose_linear_pass.py +147 -0
- executorch/backends/arm/_passes/decompose_log1p_pass.py +110 -0
- executorch/backends/arm/_passes/decompose_logit_pass.py +119 -0
- executorch/backends/arm/_passes/decompose_lstm_pass.py +466 -0
- executorch/backends/arm/_passes/decompose_masked_fill_pass.py +60 -0
- executorch/backends/arm/_passes/decompose_matmul.py +47 -0
- executorch/backends/arm/_passes/decompose_max_pool1d_pass.py +106 -0
- executorch/backends/arm/_passes/decompose_maxpool2d_with_dilation_pass.py +241 -0
- executorch/backends/arm/_passes/decompose_meandim_pass.py +263 -0
- executorch/backends/arm/_passes/decompose_ne_pass.py +75 -0
- executorch/backends/arm/_passes/decompose_permute_for_u55_pass.py +370 -0
- executorch/backends/arm/_passes/decompose_pow_tensor_tensor_pass.py +186 -0
- executorch/backends/arm/_passes/decompose_prelu_pass.py +107 -0
- executorch/backends/arm/_passes/decompose_prod_pass.py +50 -0
- executorch/backends/arm/_passes/decompose_quant_nodes.py +184 -0
- executorch/backends/arm/_passes/decompose_remainder_pass.py +74 -0
- executorch/backends/arm/_passes/decompose_rnn_pass.py +300 -0
- executorch/backends/arm/_passes/decompose_roll_pass.py +131 -0
- executorch/backends/arm/_passes/decompose_round_pass.py +67 -0
- executorch/backends/arm/_passes/decompose_sdpa_pass.py +41 -0
- executorch/backends/arm/_passes/decompose_sdpa_with_regular_softmax_pass.py +111 -0
- executorch/backends/arm/_passes/decompose_select.py +88 -0
- executorch/backends/arm/_passes/decompose_select_scatter_pass.py +146 -0
- executorch/backends/arm/_passes/decompose_sign_pass.py +83 -0
- executorch/backends/arm/_passes/decompose_sinh_pass.py +74 -0
- executorch/backends/arm/_passes/decompose_slice_scatter_pass.py +201 -0
- executorch/backends/arm/_passes/decompose_softmax_pass.py +126 -0
- executorch/backends/arm/_passes/decompose_sqrt_pass.py +46 -0
- executorch/backends/arm/_passes/decompose_strided_slice_copy_pass.py +147 -0
- executorch/backends/arm/_passes/decompose_sum_pass.py +94 -0
- executorch/backends/arm/_passes/decompose_tan_pass.py +44 -0
- executorch/backends/arm/_passes/decompose_topk_pass.py +320 -0
- executorch/backends/arm/_passes/decompose_tosa_unsupported_clamp_pass.py +99 -0
- executorch/backends/arm/_passes/decompose_tril_pass.py +112 -0
- executorch/backends/arm/_passes/decompose_unfold_to_gather_pass.py +417 -0
- executorch/backends/arm/_passes/decompose_unsupported_bilinear_resize_pass.py +159 -0
- executorch/backends/arm/_passes/decompose_var_pass.py +107 -0
- executorch/backends/arm/_passes/decompose_where_scalar_other_pass.py +62 -0
- executorch/backends/arm/_passes/decorate_fp32_to_int32_casting_pass.py +90 -0
- executorch/backends/arm/_passes/deduplicate_const_shapes_pass.py +47 -0
- executorch/backends/arm/_passes/deduplicate_get_attr_pass.py +96 -0
- executorch/backends/arm/_passes/detect_dynamic_w8a8_linear_pass.py +588 -0
- executorch/backends/arm/_passes/ensure_unique_output_nodes_pass.py +82 -0
- executorch/backends/arm/_passes/exir_to_tosa_pass.py +176 -0
- executorch/backends/arm/_passes/fold_dyt_affine_into_conv_pass.py +890 -0
- executorch/backends/arm/_passes/fold_dyt_alpha_into_lut_pass.py +379 -0
- executorch/backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py +521 -0
- executorch/backends/arm/_passes/fold_scalar_mul_into_conv_pass.py +335 -0
- executorch/backends/arm/_passes/fuse_batch_norm2d_pass.py +341 -0
- executorch/backends/arm/_passes/fuse_consecutive_clamps_pass.py +185 -0
- executorch/backends/arm/_passes/fuse_consecutive_concat_shapes.py +64 -0
- executorch/backends/arm/_passes/fuse_consecutive_concats_pass.py +107 -0
- executorch/backends/arm/_passes/fuse_consecutive_rescales_pass.py +175 -0
- executorch/backends/arm/_passes/fuse_consecutive_slices_pass.py +112 -0
- executorch/backends/arm/_passes/fuse_constant_ops_pass.py +374 -0
- executorch/backends/arm/_passes/fuse_duplicate_users_pass.py +27 -0
- executorch/backends/arm/_passes/fuse_equal_placeholders_pass.py +137 -0
- executorch/backends/arm/_passes/fuse_identical_input_transforms_pass.py +28 -0
- executorch/backends/arm/_passes/fuse_quantized_activation_pass.py +93 -0
- executorch/backends/arm/_passes/fuse_view_copy_transform_pass.py +14 -0
- executorch/backends/arm/_passes/get_decomposition_pass.py +149 -0
- executorch/backends/arm/_passes/insert_const_shapes.py +78 -0
- executorch/backends/arm/_passes/insert_data_layout_casts_pass.py +134 -0
- executorch/backends/arm/_passes/insert_dynamic_padding.py +77 -0
- executorch/backends/arm/_passes/insert_int32_casts_after_int64_placeholders.py +133 -0
- executorch/backends/arm/_passes/insert_rescales_pass.py +682 -0
- executorch/backends/arm/_passes/insert_table_ops.py +430 -0
- executorch/backends/arm/_passes/int32_range_analysis.py +455 -0
- executorch/backends/arm/_passes/lower_dynamic_w8a8_linear_pass.py +353 -0
- executorch/backends/arm/_passes/match_arg_dtype_pass.py +105 -0
- executorch/backends/arm/_passes/match_arg_ranks_pass.py +133 -0
- executorch/backends/arm/_passes/mm_to_bmm_pass.py +114 -0
- executorch/backends/arm/_passes/move_data_movement_ops_to_smaller_dtype_pass.py +158 -0
- executorch/backends/arm/_passes/mutable_buffer_utils.py +231 -0
- executorch/backends/arm/_passes/normalize_delegate_io_layout_pass.py +138 -0
- executorch/backends/arm/_passes/normalize_index_put_bool_index_tensor_pass.py +102 -0
- executorch/backends/arm/_passes/normalize_index_put_none_indices_pass.py +144 -0
- executorch/backends/arm/_passes/normalize_max_pool2d_input_rank_pass.py +97 -0
- executorch/backends/arm/_passes/normalize_while_initial_args_pass.py +115 -0
- executorch/backends/arm/_passes/prepare_gather_indices_pass.py +174 -0
- executorch/backends/arm/_passes/promote_bool_operands_pass.py +84 -0
- executorch/backends/arm/_passes/propagate_view_copy_permute_pass.py +152 -0
- executorch/backends/arm/_passes/quant_args.py +131 -0
- executorch/backends/arm/_passes/remove_getitem_pass.py +25 -0
- executorch/backends/arm/_passes/remove_graph_asserts_pass.py +18 -0
- executorch/backends/arm/_passes/remove_noop_pass.py +260 -0
- executorch/backends/arm/_passes/remove_permutes_around_elementwise_tosa_ops.py +54 -0
- executorch/backends/arm/_passes/remove_redundant_type_as_pass.py +53 -0
- executorch/backends/arm/_passes/remove_safe_softmax_guard_pass.py +173 -0
- executorch/backends/arm/_passes/replace_inf_and_limit_values_pass.py +81 -0
- executorch/backends/arm/_passes/replace_scalar_with_tensor_pass.py +150 -0
- executorch/backends/arm/_passes/resolve_view_copy_inferred_dim_pass.py +76 -0
- executorch/backends/arm/_passes/rewrite_adaptive_avg_pool2d.py +170 -0
- executorch/backends/arm/_passes/rewrite_avg_pool2d_pass.py +106 -0
- executorch/backends/arm/_passes/rewrite_bool_bitwise_to_logical_pass.py +50 -0
- executorch/backends/arm/_passes/rewrite_bool_to_fp32_cast_via_int8_pass.py +77 -0
- executorch/backends/arm/_passes/rewrite_cat_slice_pass.py +304 -0
- executorch/backends/arm/_passes/rewrite_conv_pass.py +1285 -0
- executorch/backends/arm/_passes/rewrite_high_rank_singleton_permute_pass.py +114 -0
- executorch/backends/arm/_passes/rewrite_index_put_pass.py +198 -0
- executorch/backends/arm/_passes/rewrite_inplace_arithmetic_pass.py +41 -0
- executorch/backends/arm/_passes/rewrite_le_lt_to_ge_gt_pass.py +44 -0
- executorch/backends/arm/_passes/rewrite_matmul.py +125 -0
- executorch/backends/arm/_passes/rewrite_max_pool2d_pass.py +187 -0
- executorch/backends/arm/_passes/rewrite_mxfp_conv2d.py +407 -0
- executorch/backends/arm/_passes/rewrite_mxfp_linear.py +390 -0
- executorch/backends/arm/_passes/rewrite_pad.py +213 -0
- executorch/backends/arm/_passes/rewrite_slice.py +114 -0
- executorch/backends/arm/_passes/rewrite_upsample.py +306 -0
- executorch/backends/arm/_passes/scalars_to_attribute_pass.py +144 -0
- executorch/backends/arm/_passes/size_adjust_input_pass.py +409 -0
- executorch/backends/arm/_passes/symbolic_materialization_helper.py +109 -0
- executorch/backends/arm/_passes/symbolic_shape_utils.py +27 -0
- executorch/backends/arm/_passes/symbolic_to_tosa_shape_pass.py +239 -0
- executorch/backends/arm/_passes/symbolic_value_range.py +196 -0
- executorch/backends/arm/_passes/unsqueeze_before_repeat_pass.py +66 -0
- executorch/backends/arm/_passes/unsqueeze_scalar_placeholders_pass.py +101 -0
- executorch/backends/arm/ao_ext/__init__.py +12 -0
- executorch/backends/arm/ao_ext/mxfp.py +137 -0
- executorch/backends/arm/ao_ext/mxfp_tosa_lib.py +12 -0
- executorch/backends/arm/ao_ext/mxfp_transform.py +27 -0
- executorch/backends/arm/ao_ext/ops/__init__.py +12 -0
- executorch/backends/arm/ao_ext/ops/mxfp_conv2d_op.py +325 -0
- executorch/backends/arm/ao_ext/ops/mxfp_linear_op.py +236 -0
- executorch/backends/arm/arm_vela.py +331 -0
- executorch/backends/arm/cmsis_pack/scripts/generate_components.py +487 -0
- executorch/backends/arm/cmsis_pack/scripts/generate_register_all_kernels.py +485 -0
- executorch/backends/arm/cmsis_pack/scripts/op_guards.py +144 -0
- executorch/backends/arm/common/__init__.py +4 -0
- executorch/backends/arm/common/annotation_meta.py +39 -0
- executorch/backends/arm/common/arm_compile_spec.py +335 -0
- executorch/backends/arm/common/as_strided_utils.py +72 -0
- executorch/backends/arm/common/debug.py +79 -0
- executorch/backends/arm/common/pipeline_config.py +138 -0
- executorch/backends/arm/common/type.py +28 -0
- executorch/backends/arm/constants.py +54 -0
- executorch/backends/arm/debug/__init__.py +4 -0
- executorch/backends/arm/debug/schema.py +145 -0
- executorch/backends/arm/ethosu/__init__.py +16 -0
- executorch/backends/arm/ethosu/backend.py +150 -0
- executorch/backends/arm/ethosu/compile_spec.py +281 -0
- executorch/backends/arm/ethosu/partitioner.py +40 -0
- executorch/backends/arm/operator_support/__init__.py +32 -0
- executorch/backends/arm/operator_support/as_strided_copy_support.py +113 -0
- executorch/backends/arm/operator_support/bool_bitwise_support.py +45 -0
- executorch/backends/arm/operator_support/clone_dim_order_support.py +77 -0
- executorch/backends/arm/operator_support/control_flow_support.py +197 -0
- executorch/backends/arm/operator_support/convolution_support.py +326 -0
- executorch/backends/arm/operator_support/embedding_support.py +56 -0
- executorch/backends/arm/operator_support/ethos_u55_support.py +588 -0
- executorch/backends/arm/operator_support/gather_support.py +172 -0
- executorch/backends/arm/operator_support/index_put_support.py +86 -0
- executorch/backends/arm/operator_support/index_select_support.py +128 -0
- executorch/backends/arm/operator_support/index_tensor_support.py +235 -0
- executorch/backends/arm/operator_support/minmax_support.py +59 -0
- executorch/backends/arm/operator_support/pool_2d_support.py +289 -0
- executorch/backends/arm/operator_support/reduce_sum_support.py +71 -0
- executorch/backends/arm/operator_support/right_shift_support.py +47 -0
- executorch/backends/arm/operator_support/roll_support.py +59 -0
- executorch/backends/arm/operator_support/slice_copy_support.py +148 -0
- executorch/backends/arm/operator_support/symint_arithmetic_support.py +44 -0
- executorch/backends/arm/operator_support/to_dim_order_copy_support.py +124 -0
- executorch/backends/arm/operator_support/topk_support.py +40 -0
- executorch/backends/arm/operator_support/tosa_profile_supported_op_lists.py +373 -0
- executorch/backends/arm/operator_support/tosa_supported_operators.py +1738 -0
- executorch/backends/arm/operator_support/unfold_copy_support.py +146 -0
- executorch/backends/arm/operator_support/upsample_support.py +124 -0
- executorch/backends/arm/operator_support/where_support.py +76 -0
- executorch/backends/arm/operators/__init__.py +81 -0
- executorch/backends/arm/operators/node_visitor.py +259 -0
- executorch/backends/arm/operators/op_cond_if.py +67 -0
- executorch/backends/arm/operators/op_flip.py +76 -0
- executorch/backends/arm/operators/op_to_dim_order_copy.py +47 -0
- executorch/backends/arm/operators/op_tosa_abs.py +26 -0
- executorch/backends/arm/operators/op_tosa_add.py +26 -0
- executorch/backends/arm/operators/op_tosa_argmax.py +62 -0
- executorch/backends/arm/operators/op_tosa_avg_pool2d.py +73 -0
- executorch/backends/arm/operators/op_tosa_avg_pool2d_adaptive.py +69 -0
- executorch/backends/arm/operators/op_tosa_binary_ops.py +93 -0
- executorch/backends/arm/operators/op_tosa_bitwise_not.py +30 -0
- executorch/backends/arm/operators/op_tosa_cast_to_block_scaled.py +140 -0
- executorch/backends/arm/operators/op_tosa_ceil.py +30 -0
- executorch/backends/arm/operators/op_tosa_clamp.py +70 -0
- executorch/backends/arm/operators/op_tosa_clz.py +30 -0
- executorch/backends/arm/operators/op_tosa_concat.py +60 -0
- executorch/backends/arm/operators/op_tosa_conv2d.py +127 -0
- executorch/backends/arm/operators/op_tosa_conv2d_block_scaled.py +111 -0
- executorch/backends/arm/operators/op_tosa_conv3d.py +23 -0
- executorch/backends/arm/operators/op_tosa_cos.py +30 -0
- executorch/backends/arm/operators/op_tosa_custom.py +186 -0
- executorch/backends/arm/operators/op_tosa_depthwise_conv2d.py +25 -0
- executorch/backends/arm/operators/op_tosa_eq.py +29 -0
- executorch/backends/arm/operators/op_tosa_erf.py +30 -0
- executorch/backends/arm/operators/op_tosa_exp.py +30 -0
- executorch/backends/arm/operators/op_tosa_fft.py +76 -0
- executorch/backends/arm/operators/op_tosa_floor.py +30 -0
- executorch/backends/arm/operators/op_tosa_gather.py +72 -0
- executorch/backends/arm/operators/op_tosa_ge.py +31 -0
- executorch/backends/arm/operators/op_tosa_gt.py +31 -0
- executorch/backends/arm/operators/op_tosa_identity.py +38 -0
- executorch/backends/arm/operators/op_tosa_log.py +30 -0
- executorch/backends/arm/operators/op_tosa_logical_not.py +26 -0
- executorch/backends/arm/operators/op_tosa_matmul.py +108 -0
- executorch/backends/arm/operators/op_tosa_matmul_t_block_scaled.py +97 -0
- executorch/backends/arm/operators/op_tosa_max_pool2d.py +70 -0
- executorch/backends/arm/operators/op_tosa_max_pool2d_adaptive.py +58 -0
- executorch/backends/arm/operators/op_tosa_maximum.py +27 -0
- executorch/backends/arm/operators/op_tosa_minimum.py +27 -0
- executorch/backends/arm/operators/op_tosa_mul.py +59 -0
- executorch/backends/arm/operators/op_tosa_neg.py +79 -0
- executorch/backends/arm/operators/op_tosa_pad.py +68 -0
- executorch/backends/arm/operators/op_tosa_pow.py +30 -0
- executorch/backends/arm/operators/op_tosa_reciprocal.py +30 -0
- executorch/backends/arm/operators/op_tosa_reduce_all.py +47 -0
- executorch/backends/arm/operators/op_tosa_reduce_any.py +49 -0
- executorch/backends/arm/operators/op_tosa_reduce_max.py +68 -0
- executorch/backends/arm/operators/op_tosa_reduce_min.py +68 -0
- executorch/backends/arm/operators/op_tosa_reduce_product.py +51 -0
- executorch/backends/arm/operators/op_tosa_reduce_sum.py +55 -0
- executorch/backends/arm/operators/op_tosa_rescale.py +304 -0
- executorch/backends/arm/operators/op_tosa_reshape.py +59 -0
- executorch/backends/arm/operators/op_tosa_resize.py +57 -0
- executorch/backends/arm/operators/op_tosa_reverse.py +54 -0
- executorch/backends/arm/operators/op_tosa_rshift_tensor.py +56 -0
- executorch/backends/arm/operators/op_tosa_rsqrt.py +30 -0
- executorch/backends/arm/operators/op_tosa_scatter.py +59 -0
- executorch/backends/arm/operators/op_tosa_shapes.py +260 -0
- executorch/backends/arm/operators/op_tosa_sigmoid.py +30 -0
- executorch/backends/arm/operators/op_tosa_sin.py +30 -0
- executorch/backends/arm/operators/op_tosa_slice.py +56 -0
- executorch/backends/arm/operators/op_tosa_sub.py +26 -0
- executorch/backends/arm/operators/op_tosa_table.py +64 -0
- executorch/backends/arm/operators/op_tosa_tanh.py +30 -0
- executorch/backends/arm/operators/op_tosa_tile.py +55 -0
- executorch/backends/arm/operators/op_tosa_transpose.py +58 -0
- executorch/backends/arm/operators/op_tosa_transpose_conv2d.py +123 -0
- executorch/backends/arm/operators/op_where.py +68 -0
- executorch/backends/arm/operators/op_while.py +105 -0
- executorch/backends/arm/operators/operator_validation_utils.py +239 -0
- executorch/backends/arm/operators/ops_quant_utils.py +35 -0
- executorch/backends/arm/operators/simple_node_visitor.py +70 -0
- executorch/backends/arm/process_node.py +427 -0
- executorch/backends/arm/quantizer/__init__.py +38 -0
- executorch/backends/arm/quantizer/arm_quantizer.py +1545 -0
- executorch/backends/arm/quantizer/arm_quantizer_utils.py +806 -0
- executorch/backends/arm/quantizer/quantization_annotator.py +1072 -0
- executorch/backends/arm/quantizer/quantization_config.py +600 -0
- executorch/backends/arm/quantizer/quantizer_support.py +283 -0
- executorch/backends/arm/recipes/__init__.py +15 -0
- executorch/backends/arm/recipes/arm_recipe_provider.py +287 -0
- executorch/backends/arm/recipes/arm_recipe_types.py +52 -0
- executorch/backends/arm/scripts/aot_arm_compiler.py +1193 -0
- executorch/backends/arm/scripts/check_model_support.py +467 -0
- executorch/backends/arm/scripts/docgen/__init__.py +4 -0
- executorch/backends/arm/scripts/docgen/docgen.py +276 -0
- executorch/backends/arm/scripts/docgen/generate_op_support.py +3269 -0
- executorch/backends/arm/scripts/etdump_to_chrome_trace.py +109 -0
- executorch/backends/arm/scripts/evaluate_model.py +402 -0
- executorch/backends/arm/scripts/examples/fast_model_support_demo.py +26 -0
- executorch/backends/arm/scripts/generate_grid_sampler_spirv.py +81 -0
- executorch/backends/arm/scripts/generate_neural_graphics_test_data.py +738 -0
- executorch/backends/arm/scripts/get_ethosu_scratch_from_pte.py +77 -0
- executorch/backends/arm/scripts/neural_graphics_test_data.py +490 -0
- executorch/backends/arm/scripts/public_api_manifest/__init__.py +4 -0
- executorch/backends/arm/scripts/public_api_manifest/generate_public_api_manifest.py +209 -0
- executorch/backends/arm/scripts/public_api_manifest/validate_public_api_manifest.py +410 -0
- executorch/backends/arm/test/_custom_vgf_test_utils.py +999 -0
- executorch/backends/arm/test/common.py +487 -0
- executorch/backends/arm/test/conftest.py +265 -0
- executorch/backends/arm/test/misc/test_dw_convs_with_shared_weights.py +46 -0
- executorch/backends/arm/test/models/DeepSeek_R1_Distill_Qwen/deepseek_r1_distill_qwen_test_config.py +42 -0
- executorch/backends/arm/test/models/Gemma3n/gemma3n_test_config.py +37 -0
- executorch/backends/arm/test/models/Qwen3_VL/qwen3_vl_test_config.py +64 -0
- executorch/backends/arm/test/models/model_test_utils.py +73 -0
- executorch/backends/arm/test/models/phi3/phi3_module_test_configs.py +24 -0
- executorch/backends/arm/test/models/stable_diffusion/stable_diffusion_module_test_configs.py +113 -0
- executorch/backends/arm/test/models/stable_diffusion_3_5_large/test_configs_sd35_large.py +311 -0
- executorch/backends/arm/test/ops/mxfp/__init__.py +4 -0
- executorch/backends/arm/test/ops/mxfp/common.py +122 -0
- executorch/backends/arm/test/ops/test_conv1d.py +500 -0
- executorch/backends/arm/test/ops/test_conv2d.py +873 -0
- executorch/backends/arm/test/runner_utils.py +1332 -0
- executorch/backends/arm/test/runtime/_vgf_runtime_test_utils.py +364 -0
- executorch/backends/arm/test/tester/__init__.py +6 -0
- executorch/backends/arm/test/tester/analyze_output_utils.py +478 -0
- executorch/backends/arm/test/tester/arm_tester.py +1409 -0
- executorch/backends/arm/test/tester/pte_diff_utils.py +421 -0
- executorch/backends/arm/test/tester/quantize.py +67 -0
- executorch/backends/arm/test/tester/serialize.py +96 -0
- executorch/backends/arm/test/tester/test_pipeline.py +1539 -0
- executorch/backends/arm/tosa/__init__.py +16 -0
- executorch/backends/arm/tosa/backend.py +424 -0
- executorch/backends/arm/tosa/cast_support.py +175 -0
- executorch/backends/arm/tosa/compile_spec.py +35 -0
- executorch/backends/arm/tosa/constant_pool.py +59 -0
- executorch/backends/arm/tosa/dialect/__init__.py +35 -0
- executorch/backends/arm/tosa/dialect/lib.py +83 -0
- executorch/backends/arm/tosa/dialect/ops/_common.py +134 -0
- executorch/backends/arm/tosa/dialect/ops/activation.py +118 -0
- executorch/backends/arm/tosa/dialect/ops/argmax.py +65 -0
- executorch/backends/arm/tosa/dialect/ops/avg_pool2d.py +133 -0
- executorch/backends/arm/tosa/dialect/ops/avg_pool2d_adaptive.py +82 -0
- executorch/backends/arm/tosa/dialect/ops/binary_elementwise.py +296 -0
- executorch/backends/arm/tosa/dialect/ops/comparison.py +78 -0
- executorch/backends/arm/tosa/dialect/ops/conv2d.py +139 -0
- executorch/backends/arm/tosa/dialect/ops/conv2d_block_scaled.py +218 -0
- executorch/backends/arm/tosa/dialect/ops/conv3d.py +69 -0
- executorch/backends/arm/tosa/dialect/ops/conversion_ops.py +213 -0
- executorch/backends/arm/tosa/dialect/ops/custom.py +159 -0
- executorch/backends/arm/tosa/dialect/ops/data_layout_ops.py +284 -0
- executorch/backends/arm/tosa/dialect/ops/depthwise_conv2d.py +49 -0
- executorch/backends/arm/tosa/dialect/ops/fft.py +144 -0
- executorch/backends/arm/tosa/dialect/ops/gather.py +101 -0
- executorch/backends/arm/tosa/dialect/ops/identity.py +16 -0
- executorch/backends/arm/tosa/dialect/ops/matmul.py +76 -0
- executorch/backends/arm/tosa/dialect/ops/matmul_t_block_scaled.py +162 -0
- executorch/backends/arm/tosa/dialect/ops/max_pool2d.py +89 -0
- executorch/backends/arm/tosa/dialect/ops/max_pool2d_adaptive.py +70 -0
- executorch/backends/arm/tosa/dialect/ops/reduction_ops.py +186 -0
- executorch/backends/arm/tosa/dialect/ops/resize.py +118 -0
- executorch/backends/arm/tosa/dialect/ops/scatter.py +23 -0
- executorch/backends/arm/tosa/dialect/ops/shape_ops.py +506 -0
- executorch/backends/arm/tosa/dialect/ops/table.py +51 -0
- executorch/backends/arm/tosa/dialect/ops/ternary_elementwise.py +77 -0
- executorch/backends/arm/tosa/dialect/ops/transpose_conv2d.py +58 -0
- executorch/backends/arm/tosa/dialect/ops/unary_elementwise.py +187 -0
- executorch/backends/arm/tosa/dialect/ops_registration.py +92 -0
- executorch/backends/arm/tosa/dialect/real_impl.py +174 -0
- executorch/backends/arm/tosa/dialect/shape.py +21 -0
- executorch/backends/arm/tosa/mapping.py +336 -0
- executorch/backends/arm/tosa/partitioner.py +1050 -0
- executorch/backends/arm/tosa/resize_utils.py +341 -0
- executorch/backends/arm/tosa/schemas/__init__.py +4 -0
- executorch/backends/arm/tosa/schemas/tosa_1.0.fbs +559 -0
- executorch/backends/arm/tosa/schemas/tosa_1.1.fbs +701 -0
- executorch/backends/arm/tosa/specification.py +514 -0
- executorch/backends/arm/tosa/utils.py +173 -0
- executorch/backends/arm/util/_factory.py +59 -0
- executorch/backends/arm/util/arm_model_evaluator.py +277 -0
- executorch/backends/arm/vgf/__init__.py +11 -0
- executorch/backends/arm/vgf/_passes/__init__.py +13 -0
- executorch/backends/arm/vgf/_passes/fuse_grid_sampler_flow_offset.py +548 -0
- executorch/backends/arm/vgf/_passes/group_independent_custom_shaders.py +87 -0
- executorch/backends/arm/vgf/_passes/insert_grid_sampler_grid_dequant_pass.py +151 -0
- executorch/backends/arm/vgf/_passes/rewrite_grid_sampler_to_tosa_custom.py +488 -0
- executorch/backends/arm/vgf/backend.py +491 -0
- executorch/backends/arm/vgf/check_env.py +707 -0
- executorch/backends/arm/vgf/compile_spec.py +132 -0
- executorch/backends/arm/vgf/model_converter.py +420 -0
- executorch/backends/arm/vgf/partitioner.py +42 -0
- executorch/backends/arm/vgf/quantization_assessment.py +824 -0
- executorch/backends/arm/vgf/quantization_quality.py +170 -0
- executorch/backends/arm/vgf/quantization_sensitivity.py +847 -0
- executorch/backends/arm/vgf/quantization_visualization.py +320 -0
- executorch/backends/arm/vgf/shaders/__init__.py +4 -0
- executorch/backends/arm/vgf/shaders/flow_offset_grid_sampler_int8_align_corners.glsl +60 -0
- executorch/backends/arm/vgf/shaders/grid_sampler.glsl +41 -0
- executorch/backends/arm/vgf/shaders/grid_sampler.py +504 -0
- executorch/backends/arm/vgf/shaders/grid_sampler.spirv.b64 +1 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler.glsl +35 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler.spirv.b64 +1 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_align_corners.glsl +40 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_align_corners.spirv.b64 +1 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8.glsl +44 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8.spirv.b64 +1 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8_align_corners.glsl +49 -0
- executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8_align_corners.spirv.b64 +1 -0
- executorch/backends/cadence/aot/__init__.py +5 -0
- executorch/backends/cadence/aot/compiler.py +547 -0
- executorch/backends/cadence/aot/compiler_funcs.py +758 -0
- executorch/backends/cadence/aot/compiler_utils.py +271 -0
- executorch/backends/cadence/aot/decompose_ops.py +115 -0
- executorch/backends/cadence/aot/export_example.py +123 -0
- executorch/backends/cadence/aot/functions.yaml +510 -0
- executorch/backends/cadence/aot/functions_fusion_g3.yaml +191 -0
- executorch/backends/cadence/aot/functions_hifi.yaml +607 -0
- executorch/backends/cadence/aot/functions_vision.yaml +275 -0
- executorch/backends/cadence/aot/fuse_ops.py +1170 -0
- executorch/backends/cadence/aot/graph_builder.py +32 -0
- executorch/backends/cadence/aot/memory_constraints.py +759 -0
- executorch/backends/cadence/aot/memory_planning.py +562 -0
- executorch/backends/cadence/aot/memory_planning_algo.py +342 -0
- executorch/backends/cadence/aot/ops_registrations.py +3533 -0
- executorch/backends/cadence/aot/pass_utils.py +172 -0
- executorch/backends/cadence/aot/passes.py +226 -0
- executorch/backends/cadence/aot/program_builder.py +28 -0
- executorch/backends/cadence/aot/quantizer/fusion_pass.py +843 -0
- executorch/backends/cadence/aot/quantizer/passes/fuse_ops.py +391 -0
- executorch/backends/cadence/aot/quantizer/pattern_utils.py +460 -0
- executorch/backends/cadence/aot/quantizer/patterns.py +1567 -0
- executorch/backends/cadence/aot/quantizer/quantizer.py +555 -0
- executorch/backends/cadence/aot/quantizer/utils.py +286 -0
- executorch/backends/cadence/aot/ref_implementations.py +3126 -0
- executorch/backends/cadence/aot/remove_ops.py +1025 -0
- executorch/backends/cadence/aot/reorder_ops.py +1463 -0
- executorch/backends/cadence/aot/replace_ops.py +2657 -0
- executorch/backends/cadence/aot/simplify_ops.py +218 -0
- executorch/backends/cadence/aot/to_out_var_pass.py +24 -0
- executorch/backends/cadence/aot/type_dispatch.py +179 -0
- executorch/backends/cadence/aot/typing_stubs.py +22 -0
- executorch/backends/cadence/aot/utils.py +372 -0
- executorch/backends/cadence/aot/weight_packing.py +390 -0
- executorch/backends/cadence/runtime/__init__.py +13 -0
- executorch/backends/cadence/runtime/etdump.py +173 -0
- executorch/backends/cadence/runtime/executor.py +208 -0
- executorch/backends/cadence/runtime/runtime.py +167 -0
- executorch/backends/cadence/runtime/utils.py +100 -0
- executorch/backends/cadence/utils/facto_util.py +612 -0
- executorch/backends/cadence/utils/gen_header.py +49 -0
- executorch/backends/cadence/utils/post_compilation.py +173 -0
- executorch/backends/cortex_m/edge_compile_config.py +40 -0
- executorch/backends/cortex_m/library/__init__.py +4 -0
- executorch/backends/cortex_m/library/_cmsis_nn/cmsis_nn.cp315-win_amd64.pyd +0 -0
- executorch/backends/cortex_m/library/cmsis_nn.py +281 -0
- executorch/backends/cortex_m/ops/operators.py +1985 -0
- executorch/backends/cortex_m/ops/operators.yaml +145 -0
- executorch/backends/cortex_m/passes/__init__.py +15 -0
- executorch/backends/cortex_m/passes/activation_fusion_pass.py +210 -0
- executorch/backends/cortex_m/passes/aten_to_cortex_m_pass.py +1300 -0
- executorch/backends/cortex_m/passes/clamp_hardswish_pass.py +37 -0
- executorch/backends/cortex_m/passes/cortex_m_pass.py +35 -0
- executorch/backends/cortex_m/passes/cortex_m_pass_manager.py +221 -0
- executorch/backends/cortex_m/passes/decompose_hardswish_pass.py +128 -0
- executorch/backends/cortex_m/passes/decompose_mean_pass.py +104 -0
- executorch/backends/cortex_m/passes/decompose_sdpa_pass.py +92 -0
- executorch/backends/cortex_m/passes/explicit_layout_pass.py +157 -0
- executorch/backends/cortex_m/passes/fuse_conv_padding_pass.py +81 -0
- executorch/backends/cortex_m/passes/initialize_scratch_buffers_pass.py +37 -0
- executorch/backends/cortex_m/passes/matmul_to_bmm_pass.py +82 -0
- executorch/backends/cortex_m/passes/quantized_clamp_activation_pass.py +126 -0
- executorch/backends/cortex_m/passes/replace_quant_nodes_pass.py +76 -0
- executorch/backends/cortex_m/passes/scratch_buffer_sizes.py +328 -0
- executorch/backends/cortex_m/quantizer/__init__.py +19 -0
- executorch/backends/cortex_m/quantizer/node_finders.py +165 -0
- executorch/backends/cortex_m/quantizer/pattern_checkers.py +409 -0
- executorch/backends/cortex_m/quantizer/pattern_matcher.py +214 -0
- executorch/backends/cortex_m/quantizer/quantization_configs.py +226 -0
- executorch/backends/cortex_m/quantizer/quantizer.py +121 -0
- executorch/backends/cortex_m/quantizer/quantizer_support.py +260 -0
- executorch/backends/cortex_m/quantizer_reporter.py +443 -0
- executorch/backends/cortex_m/target_config.py +117 -0
- executorch/backends/cortex_m/test/models/__init__.py +4 -0
- executorch/backends/cortex_m/test/ops/__init__.py +4 -0
- executorch/backends/cortex_m/test/ops/nhwc_test_utils.py +42 -0
- executorch/backends/cortex_m/test/test_helpers_passes_utils.py +103 -0
- executorch/backends/cortex_m/test/tester.py +256 -0
- executorch/backends/cortex_m/utils.py +428 -0
- executorch/backends/cpu/__init__.py +5 -0
- executorch/backends/cpu/partitioner.py +110 -0
- executorch/backends/cpu/preprocess.py +89 -0
- executorch/backends/cpu/recipes/__init__.py +14 -0
- executorch/backends/cpu/recipes/cpu_recipe_provider.py +37 -0
- executorch/backends/cpu/recipes/cpu_recipe_types.py +15 -0
- executorch/backends/cpu/test/tester.py +43 -0
- executorch/backends/cuda/__init__.py +5 -0
- executorch/backends/cuda/aoti_packed_int4_tensor.py +178 -0
- executorch/backends/cuda/autotune/__init__.py +8 -0
- executorch/backends/cuda/autotune/cuda_graph_timing.py +367 -0
- executorch/backends/cuda/autotune/inputs.py +214 -0
- executorch/backends/cuda/autotune/launch_params.py +413 -0
- executorch/backends/cuda/batching/__init__.py +0 -0
- executorch/backends/cuda/batching/test/__init__.py +0 -0
- executorch/backends/cuda/batching/test/export_toy_decoder.py +346 -0
- executorch/backends/cuda/benchmarks/benchmark_moe.py +423 -0
- executorch/backends/cuda/benchmarks/benchmark_sdpa.py +308 -0
- executorch/backends/cuda/coalesced_int4_tensor.py +243 -0
- executorch/backends/cuda/cuda_backend.py +1578 -0
- executorch/backends/cuda/cuda_partitioner.py +53 -0
- executorch/backends/cuda/cuda_weight_collector.py +641 -0
- executorch/backends/cuda/dp4a_planar_int5_tensor.py +323 -0
- executorch/backends/cuda/dp4a_planar_int6_tensor.py +307 -0
- executorch/backends/cuda/merge_ptes.py +750 -0
- executorch/backends/cuda/passes/__init__.py +0 -0
- executorch/backends/cuda/passes/lower_offgraph_kv.py +689 -0
- executorch/backends/cuda/passes/move_cond_predicate_to_cpu.py +94 -0
- executorch/backends/cuda/passes/remove_assert_async.py +50 -0
- executorch/backends/cuda/passes/replace_complex_with_real.py +398 -0
- executorch/backends/cuda/passes/replace_fused_sdpa.py +136 -0
- executorch/backends/cuda/passes/replace_int64_floordiv.py +153 -0
- executorch/backends/cuda/passes/replace_masked_copy_with_where.py +220 -0
- executorch/backends/cuda/passes/tests/__init__.py +0 -0
- executorch/backends/cuda/passes/tests/test_replace_fused_sdpa.py +124 -0
- executorch/backends/cuda/quantize_op_dispatch/__init__.py +31 -0
- executorch/backends/cuda/quantize_op_dispatch/_gemm_family_dispatch.py +118 -0
- executorch/backends/cuda/quantize_op_dispatch/int4_dispatch.py +121 -0
- executorch/backends/cuda/quantize_op_dispatch/int5_dispatch.py +127 -0
- executorch/backends/cuda/quantize_op_dispatch/int6_dispatch.py +115 -0
- executorch/backends/cuda/quantize_op_dispatch/int8_dispatch.py +113 -0
- executorch/backends/cuda/target_smem.py +63 -0
- executorch/backends/cuda/tests/__init__.py +5 -0
- executorch/backends/cuda/tests/autotune_test_utils.py +236 -0
- executorch/backends/cuda/tests/test_int5_dispatch.py +432 -0
- executorch/backends/cuda/tests/test_int6_dispatch.py +462 -0
- executorch/backends/cuda/triton/__init__.py +17 -0
- executorch/backends/cuda/triton/kernels/__init__.py +64 -0
- executorch/backends/cuda/triton/kernels/chunk_gated_delta_rule.py +273 -0
- executorch/backends/cuda/triton/kernels/fused_deltanet_decode.py +358 -0
- executorch/backends/cuda/triton/kernels/fused_moe.py +1604 -0
- executorch/backends/cuda/triton/kernels/int4_matmul.py +558 -0
- executorch/backends/cuda/triton/kernels/int4_quantized_gemm.py +1964 -0
- executorch/backends/cuda/triton/kernels/int5_quantized_gemm.py +1675 -0
- executorch/backends/cuda/triton/kernels/int6_quantized_gemm.py +1501 -0
- executorch/backends/cuda/triton/kernels/int8_quantized_gemm.py +1275 -0
- executorch/backends/cuda/triton/kernels/quantized_gemm_family.py +579 -0
- executorch/backends/cuda/triton/kernels/quantized_gemm_utils.py +505 -0
- executorch/backends/cuda/triton/kernels/sdpa.py +2496 -0
- executorch/backends/cuda/triton/kernels/topk.py +220 -0
- executorch/backends/cuda/triton/kernels/tq4_sdpa.py +1216 -0
- executorch/backends/cuda/triton/kernels/triton_mutation_cache.py +131 -0
- executorch/backends/cuda/triton/replacement_pass.py +232 -0
- executorch/backends/example/example_backend.py +41 -0
- executorch/backends/example/example_backend_delegate_passes/merge_to_dim_pass.py +83 -0
- executorch/backends/example/example_backend_delegate_passes/permute_memory_formats_pass.py +143 -0
- executorch/backends/example/example_operators/adaptive_avg_pool2d.py +47 -0
- executorch/backends/example/example_operators/add.py +44 -0
- executorch/backends/example/example_operators/conv2d.py +52 -0
- executorch/backends/example/example_operators/conv_relu.py +49 -0
- executorch/backends/example/example_operators/dropout.py +44 -0
- executorch/backends/example/example_operators/flatten.py +40 -0
- executorch/backends/example/example_operators/linear.py +62 -0
- executorch/backends/example/example_operators/op_base.py +15 -0
- executorch/backends/example/example_operators/ops.py +32 -0
- executorch/backends/example/example_operators/utils.py +34 -0
- executorch/backends/example/example_partitioner.py +88 -0
- executorch/backends/example/example_quantizer.py +108 -0
- executorch/backends/example/test_example_delegate.py +112 -0
- executorch/backends/mediatek/__init__.py +5 -0
- executorch/backends/mediatek/_passes/__init__.py +0 -0
- executorch/backends/mediatek/_passes/decompose_scaled_dot_product_attention.py +79 -0
- executorch/backends/mediatek/partitioner.py +107 -0
- executorch/backends/mediatek/preprocess.py +214 -0
- executorch/backends/mediatek/quantizer/__init__.py +4 -0
- executorch/backends/mediatek/quantizer/annotator.py +263 -0
- executorch/backends/mediatek/quantizer/qconfig.py +174 -0
- executorch/backends/mediatek/quantizer/quantizer.py +45 -0
- executorch/backends/mlx/__init__.py +17 -0
- executorch/backends/mlx/_logging.py +40 -0
- executorch/backends/mlx/_memprofile.py +188 -0
- executorch/backends/mlx/builder/__init__.py +16 -0
- executorch/backends/mlx/builder/op_helpers.py +885 -0
- executorch/backends/mlx/builder/op_registry.py +223 -0
- executorch/backends/mlx/builder/pattern_matcher.py +64 -0
- executorch/backends/mlx/builder/program_builder.py +1281 -0
- executorch/backends/mlx/builder/slot_manager.py +252 -0
- executorch/backends/mlx/custom_kernel_ops/__init__.py +7 -0
- executorch/backends/mlx/custom_kernel_ops/gated_delta_rule.py +596 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/__init__.py +18 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/patterns.py +209 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/__init__.py +32 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/common.py +151 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/embedding.py +147 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/embedding_mlx_native.py +57 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/linear.py +500 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q4k/linear_mlx_native.py +85 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/__init__.py +37 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/common.py +167 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/embedding.py +144 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/embedding_mlx_native.py +57 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/linear.py +534 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q5k/linear_mlx_native.py +85 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/__init__.py +40 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/common.py +142 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/embedding.py +151 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/embedding_mlx_native.py +61 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/linear.py +511 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/q6k/linear_mlx_native.py +86 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/repack_mlx.py +132 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/test/__init__.py +5 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/test/test_embedding.py +270 -0
- executorch/backends/mlx/custom_kernel_ops/gguf/test/test_linear.py +647 -0
- executorch/backends/mlx/custom_kernel_ops/test/__init__.py +5 -0
- executorch/backends/mlx/custom_kernel_ops/test/test_gated_delta_rule.py +1037 -0
- executorch/backends/mlx/custom_kernel_ops/test/test_tq4_compress.py +183 -0
- executorch/backends/mlx/custom_kernel_ops/test/test_tq_dequant.py +166 -0
- executorch/backends/mlx/custom_kernel_ops/test/test_tq_norm.py +150 -0
- executorch/backends/mlx/custom_kernel_ops/tq4_compress.py +189 -0
- executorch/backends/mlx/custom_kernel_ops/tq_dequant.py +216 -0
- executorch/backends/mlx/custom_kernel_ops/tq_norm.py +170 -0
- executorch/backends/mlx/custom_ops.py +546 -0
- executorch/backends/mlx/examples/__init__.py +6 -0
- executorch/backends/mlx/examples/llm/__init__.py +6 -0
- executorch/backends/mlx/examples/llm/dflash/__init__.py +26 -0
- executorch/backends/mlx/examples/llm/dflash/adapters.py +71 -0
- executorch/backends/mlx/examples/llm/dflash/arch.py +109 -0
- executorch/backends/mlx/examples/llm/dflash/cache.py +60 -0
- executorch/backends/mlx/examples/llm/dflash/export.py +270 -0
- executorch/backends/mlx/examples/llm/dflash/model.py +368 -0
- executorch/backends/mlx/examples/llm/dflash/run.py +305 -0
- executorch/backends/mlx/examples/llm/export_llm_hf.py +758 -0
- executorch/backends/mlx/examples/llm/run_llm_hf.py +217 -0
- executorch/backends/mlx/examples/llm/runtime_meta.py +238 -0
- executorch/backends/mlx/examples/voxtral/__init__.py +5 -0
- executorch/backends/mlx/examples/voxtral/export_voxtral_hf.py +201 -0
- executorch/backends/mlx/examples/whisper/__init__.py +7 -0
- executorch/backends/mlx/examples/whisper/args.py +151 -0
- executorch/backends/mlx/examples/whisper/export_whisper.py +620 -0
- executorch/backends/mlx/examples/whisper/run_whisper.py +276 -0
- executorch/backends/mlx/llm/__init__.py +6 -0
- executorch/backends/mlx/llm/cache.py +721 -0
- executorch/backends/mlx/llm/et_attention.py +252 -0
- executorch/backends/mlx/llm/exportable.py +379 -0
- executorch/backends/mlx/llm/hf_attention.py +413 -0
- executorch/backends/mlx/llm/quantization.py +57 -0
- executorch/backends/mlx/llm/sampling.py +44 -0
- executorch/backends/mlx/llm/source_transformation.py +309 -0
- executorch/backends/mlx/llm/switch.py +329 -0
- executorch/backends/mlx/llm/turboquant_cache.py +244 -0
- executorch/backends/mlx/ops.py +5759 -0
- executorch/backends/mlx/partitioner.py +386 -0
- executorch/backends/mlx/passes.py +360 -0
- executorch/backends/mlx/pattern_utils.py +360 -0
- executorch/backends/mlx/patterns.py +1423 -0
- executorch/backends/mlx/preprocess.py +226 -0
- executorch/backends/mlx/pte_inspector.py +902 -0
- executorch/backends/mlx/serialization/__init__.py +32 -0
- executorch/backends/mlx/serialization/generate.py +1581 -0
- executorch/backends/mlx/serialization/mlx_graph_serialize.py +417 -0
- executorch/backends/mlx/serialization/schema.fbs +1314 -0
- executorch/backends/mlx/test/__init__.py +5 -0
- executorch/backends/mlx/test/run_all_tests.py +496 -0
- executorch/backends/mlx/test/test_ops.py +9052 -0
- executorch/backends/mlx/test/test_sample.py +295 -0
- executorch/backends/mlx/test/test_slot_recycling.py +198 -0
- executorch/backends/mlx/test/test_utils.py +1184 -0
- executorch/backends/mlx/test/tester.py +78 -0
- executorch/backends/native/__init__.py +23 -0
- executorch/backends/native/custom_ops.py +107 -0
- executorch/backends/native/examples/hf_llm/convert_meta_llama.py +93 -0
- executorch/backends/native/examples/hf_llm/export_hf_llm.py +316 -0
- executorch/backends/native/examples/hf_llm/gguf_hf.py +145 -0
- executorch/backends/native/examples/hf_llm/test_export_hf_llm.py +235 -0
- executorch/backends/native/partitioner.py +294 -0
- executorch/backends/native/passes/__init__.py +86 -0
- executorch/backends/native/passes/_utils.py +34 -0
- executorch/backends/native/passes/fuse_rope.py +488 -0
- executorch/backends/native/passes/reinplace.py +74 -0
- executorch/backends/native/passes/remove_runtime_asserts.py +114 -0
- executorch/backends/native/passes/replace_copy_with_alias.py +185 -0
- executorch/backends/native/preprocess.py +157 -0
- executorch/backends/native/serialization/__init__.py +27 -0
- executorch/backends/native/serialization/graph_serialize.py +1705 -0
- executorch/backends/native/serialization/native_graph.fbs +448 -0
- executorch/backends/native/serialization/schema.py +343 -0
- executorch/backends/native/test/__init__.py +0 -0
- executorch/backends/native/test/utils.py +44 -0
- executorch/backends/nxp/__init__.py +0 -0
- executorch/backends/nxp/aten_passes/add_batch_size_for_3d_input_pool_2d_ops.py +116 -0
- executorch/backends/nxp/aten_passes/convert_1d_conv_to_2d.py +489 -0
- executorch/backends/nxp/aten_passes/convert_div_to_mul.py +177 -0
- executorch/backends/nxp/aten_passes/convert_scalar_to_attr.py +119 -0
- executorch/backends/nxp/aten_passes/decompose_split_to_slices_pass.py +196 -0
- executorch/backends/nxp/aten_passes/fuse_batch_norm_with_conv_pass.py +145 -0
- executorch/backends/nxp/aten_passes/fuse_batch_norm_with_linear_pass.py +188 -0
- executorch/backends/nxp/aten_passes/fuse_linear_and_add_pass.py +202 -0
- executorch/backends/nxp/aten_passes/move_activation_before_concat.py +101 -0
- executorch/backends/nxp/aten_passes/neutron_aten_pass_manager.py +90 -0
- executorch/backends/nxp/aten_passes/remove_nodes_with_known_outputs.py +196 -0
- executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/__init__.py +16 -0
- executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/add_simulated_linear_bn_fusion_qat_pass.py +395 -0
- executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/remove_simulated_linear_bn_fusion_qat_pass.py +245 -0
- executorch/backends/nxp/aten_passes/split_group_convolution.py +300 -0
- executorch/backends/nxp/aten_passes/split_gru_based_on_num_layers.py +307 -0
- executorch/backends/nxp/backend/custom_delegation_options.py +17 -0
- executorch/backends/nxp/backend/data_format.py +49 -0
- executorch/backends/nxp/backend/edge_helper.py +527 -0
- executorch/backends/nxp/backend/edge_program_converter.py +363 -0
- executorch/backends/nxp/backend/graph_utils.py +129 -0
- executorch/backends/nxp/backend/ir/conversion_config.py +54 -0
- executorch/backends/nxp/backend/ir/conversion_context.py +43 -0
- executorch/backends/nxp/backend/ir/converter/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/converter/builder/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/converter/builder/aten_model_builder_director.py +156 -0
- executorch/backends/nxp/backend/ir/converter/builder/model_builder.py +1806 -0
- executorch/backends/nxp/backend/ir/converter/builder/quantization_verification.py +387 -0
- executorch/backends/nxp/backend/ir/converter/conversion/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/converter/conversion/aten_translator.py +71 -0
- executorch/backends/nxp/backend/ir/converter/conversion/common.py +177 -0
- executorch/backends/nxp/backend/ir/converter/conversion/translator.py +689 -0
- executorch/backends/nxp/backend/ir/converter/node_converter.py +538 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/__init__.py +4 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/__init__.py +179 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/abs_converter.py +53 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/adaptive_avg_pool_2d_converter.py +113 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/add_tensor_converter.py +67 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/addmm_converter.py +160 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/amax_converter.py +82 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/amin_converter.py +82 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/avg_pool_2d_converter.py +144 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/bmm_converter.py +102 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/cat_converter.py +123 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/clamp_converter.py +290 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/clone_converter.py +118 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/constant_pad_nd_converter.py +163 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/convolution_converter.py +548 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/exp_converter.py +60 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/getitem_converter.py +60 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardswish_converter.py +51 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardtanh_converter.py +37 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/leaky_relu_converter.py +64 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/log_converter.py +60 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/max_pool2d_with_indices_converter.py +183 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/maximum_converter.py +69 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mean_dim_converter.py +108 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/minimum_converter.py +69 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mm_converter.py +95 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py +64 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/neg_converter.py +77 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/pad_converter.py +118 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/permute_copy_converter.py +435 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/prelu_converter.py +67 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_dequantize_converter.py +127 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_quantize_converter.py +46 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/relu_converter.py +67 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/rsqrt_converter.py +63 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sigmoid_converter.py +63 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_copy_tensor_converter.py +116 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/softmax_converter.py +143 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sub_tensor_converter.py +72 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sum_dim_int_list_converter.py +84 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/tanh_converter.py +61 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/upsample_bilinear2d_converter.py +153 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/upsample_nearest2d_converter.py +137 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/view_copy_converter.py +99 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/conv_utils.py +123 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/recurrent_utils.py +64 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/reduce_utils.py +173 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/reshape_transposition.py +233 -0
- executorch/backends/nxp/backend/ir/converter/quantization_utils.py +161 -0
- executorch/backends/nxp/backend/ir/converter/tensor_utils.py +55 -0
- executorch/backends/nxp/backend/ir/lib/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ATan2Options.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/AbsOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ActivationFunctionType.py +12 -0
- executorch/backends/nxp/backend/ir/lib/tflite/AddNOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/AddOptions.py +82 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ArgMaxOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ArgMinOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/AssignVariableOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BatchMatMulOptions.py +101 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BatchToSpaceNDOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceLSTMOptions.py +160 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceRNNOptions.py +126 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BitcastOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BitwiseXorOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BroadcastToOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BucketizeOptions.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Buffer.py +132 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOperator.py +212 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions.py +133 -0
- executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions2.py +27 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CallOnceOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CallOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CastOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CombinerType.py +9 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ConcatEmbeddingsOptions.py +163 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ConcatenationOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Conv2DOptions.py +155 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Conv3DOptions.py +170 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CosOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CumsumOptions.py +84 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CustomOptionsFormat.py +7 -0
- executorch/backends/nxp/backend/ir/lib/tflite/CustomQuantization.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DensifyOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DepthToSpaceOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DepthwiseConv2DOptions.py +157 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DequantizeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DilateOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DimensionMetadata.py +152 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DimensionType.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DivOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/DynamicUpdateSliceOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/EmbeddingLookupSparseOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/EqualOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ExpOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ExpandDimsOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FakeQuantOptions.py +116 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FillOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FloorDivOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FloorModOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptions.py +129 -0
- executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptionsWeightsFormat.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/GatherNdOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/GatherOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/GeluOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/GreaterEqualOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/GreaterOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/HardSwishOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/HashtableFindOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/HashtableImportOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/HashtableOptions.py +95 -0
- executorch/backends/nxp/backend/ir/lib/tflite/HashtableSizeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/IfOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Int32Vector.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/L2NormOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionType.py +9 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LSTMKernelType.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LSTMOptions.py +131 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LeakyReluOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LessEqualOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LessOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LocalResponseNormalizationOptions.py +118 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LogSoftmaxOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LogicalAndOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LogicalNotOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/LogicalOrOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MatrixDiagOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MatrixSetDiagOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MaximumMinimumOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Metadata.py +84 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadMode.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Model.py +352 -0
- executorch/backends/nxp/backend/ir/lib/tflite/MulOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/NegOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV4Options.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV5Options.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/NotEqualOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/OneHotOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Operator.py +428 -0
- executorch/backends/nxp/backend/ir/lib/tflite/OperatorCode.py +112 -0
- executorch/backends/nxp/backend/ir/lib/tflite/PackOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/PadOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/PadV2Options.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Padding.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Pool2DOptions.py +140 -0
- executorch/backends/nxp/backend/ir/lib/tflite/PowOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/QuantizationDetails.py +8 -0
- executorch/backends/nxp/backend/ir/lib/tflite/QuantizationParameters.py +295 -0
- executorch/backends/nxp/backend/ir/lib/tflite/QuantizeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RNNOptions.py +82 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RandomOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RangeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RankOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReadVariableOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowFunction.py +13 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReducerOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReshapeOptions.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ResizeBilinearOptions.py +84 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ResizeNearestNeighborOptions.py +86 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReverseSequenceOptions.py +82 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ReverseV2Options.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Rfft2dOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RightShiftOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/RngAlgorithm.py +9 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SVDFOptions.py +97 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ScatterNdOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SegmentSumOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SelectOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SelectV2Options.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SequenceRNNOptions.py +99 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ShapeOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SignOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SignatureDef.py +172 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SkipGramOptions.py +97 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SliceOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SoftmaxOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SpaceToBatchNDOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SpaceToDepthOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SparseIndexVector.py +10 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SparseToDenseOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SparsityParameters.py +190 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SplitOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SplitVOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SquareOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SquaredDifferenceOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SqueezeOptions.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloBroadcastInDimOptions.py +102 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloCompareOptions.py +86 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonDirection.py +12 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonType.py +11 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloConcatenateOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloConvolutionOptions.py +634 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloCustomCallOptions.py +214 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloDotGeneralOptions.py +304 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloDynamicSliceOptions.py +100 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloGatherOptions.py +276 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloIotaOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloPadOptions.py +194 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloPrecisionConfig.py +9 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceOptions.py +115 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceWindowOptions.py +307 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloRngBitGeneratorOptions.py +67 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloScatterOptions.py +268 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloSliceOptions.py +194 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloSortOptions.py +97 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloTransposeOptions.py +100 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StablehloWhileOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/StridedSliceOptions.py +142 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SubGraph.py +251 -0
- executorch/backends/nxp/backend/ir/lib/tflite/SubOptions.py +82 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Tensor.py +317 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TensorMap.py +84 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TensorType.py +24 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TileOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TopKV2Options.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TransposeConvOptions.py +125 -0
- executorch/backends/nxp/backend/ir/lib/tflite/TransposeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Uint16Vector.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/Uint8Vector.py +98 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnidirectionalSequenceLSTMOptions.py +164 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UniqueOptions.py +65 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnpackOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMaxOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMinOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentProdOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentSumOptions.py +52 -0
- executorch/backends/nxp/backend/ir/lib/tflite/VarHandleOptions.py +84 -0
- executorch/backends/nxp/backend/ir/lib/tflite/VariantSubType.py +130 -0
- executorch/backends/nxp/backend/ir/lib/tflite/WhereOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/WhileOptions.py +80 -0
- executorch/backends/nxp/backend/ir/lib/tflite/ZerosLikeOptions.py +50 -0
- executorch/backends/nxp/backend/ir/lib/tflite/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/logger.py +341 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/graph_utils.py +115 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/operator_rules.py +102 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/base_optimization.py +41 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/permute_fully_connected_weights_after_reshape.py +121 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/prune_transpose_operators.py +177 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizer.py +127 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/pattern_matcher.py +925 -0
- executorch/backends/nxp/backend/ir/neutron_ir_post_processing/tensor_rules.py +710 -0
- executorch/backends/nxp/backend/ir/tflite_generator/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/abs_options.py +25 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_n_options.py +32 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_options.py +46 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_max_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_min_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/average_pool_2d_options.py +63 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/batch_mat_mul_options.py +45 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_lstm_options.py +65 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_rnn_options.py +53 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bitwise_xor_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/broadcast_to_options.py +25 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cast_options.py +32 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/concatenation_options.py +38 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_2d_options.py +59 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_3d_options.py +67 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cum_sum_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depth_to_space_options.py +29 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depthwise_conv_2d_options.py +69 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/dequantize_options.py +24 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/div_options.py +43 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/equal_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/exp_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/floor_mod_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/fully_connected_options.py +57 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_nd_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gelu_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_equal_options.py +25 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/hard_swish_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/leaky_relu_options.py +32 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_equal_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/log_softmax_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_and_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_not_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_or_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lrn_options.py +45 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lstm_options.py +60 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/max_pool_2d_options.py +63 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/maximum_options.py +21 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mean_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/minimum_options.py +21 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mirror_pad_options.py +60 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mul_options.py +36 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/multinomial_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/neg_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/not_equal_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/one_hot_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_v2_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pow_options.py +24 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/quantize_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/range_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_max_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_min_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_prod_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reshape_options.py +53 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_bilinear_options.py +34 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_nearest_neighbor_options.py +37 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reverse_sequence_options.py +32 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/scatter_nd_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/select_v2_options.py +24 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/shape_options.py +34 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sign_options.py +22 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/slice_options.py +29 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/softmax_options.py +36 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/space_to_depth_options.py +29 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_v_options.py +27 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/square_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squared_difference_options.py +25 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squeeze_options.py +42 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/strided_slice_options.py +35 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sub_options.py +46 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sum_options.py +28 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/tile_options.py +23 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_conv_options.py +50 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_options.py +30 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_lstm_options.py +67 -0
- executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_rnn_options.py +49 -0
- executorch/backends/nxp/backend/ir/tflite_generator/custom_options/flex_transpose_options.py +78 -0
- executorch/backends/nxp/backend/ir/tflite_generator/meta/__init__.py +0 -0
- executorch/backends/nxp/backend/ir/tflite_generator/meta/meta.py +255 -0
- executorch/backends/nxp/backend/ir/tflite_generator/meta/types.py +198 -0
- executorch/backends/nxp/backend/ir/tflite_generator/tflite_model.py +819 -0
- executorch/backends/nxp/backend/neutron_compiler_manager.py +213 -0
- executorch/backends/nxp/backend/neutron_map.py +877 -0
- executorch/backends/nxp/backend/neutron_operator_support.py +57 -0
- executorch/backends/nxp/backend/neutron_target_spec.py +161 -0
- executorch/backends/nxp/backend/node_format_inference.py +396 -0
- executorch/backends/nxp/backend/ops_aliases.py +83 -0
- executorch/backends/nxp/edge_passes/convert_reshaping_nodes_to_view.py +103 -0
- executorch/backends/nxp/edge_passes/move_auxiliary_operator_into_separate_qdq_cluster_pass.py +310 -0
- executorch/backends/nxp/edge_passes/neutron_edge_pass.py +55 -0
- executorch/backends/nxp/edge_passes/neutron_edge_pass_manager.py +38 -0
- executorch/backends/nxp/edge_passes/remove_additional_quantize_dequantize_nodes_pass.py +120 -0
- executorch/backends/nxp/edge_passes/remove_as_strided_copy_nodes.py +66 -0
- executorch/backends/nxp/edge_passes/remove_io_quant_ops_pass.py +76 -0
- executorch/backends/nxp/neutron_node_extraction.py +152 -0
- executorch/backends/nxp/neutron_partitioner.py +570 -0
- executorch/backends/nxp/nxp_backend.py +484 -0
- executorch/backends/nxp/quantizer/neutron_quantizer.py +406 -0
- executorch/backends/nxp/quantizer/patterns.py +1429 -0
- executorch/backends/nxp/quantizer/utils.py +300 -0
- executorch/backends/nxp/recipes/__init__.py +18 -0
- executorch/backends/nxp/recipes/nxp_recipe_provider.py +424 -0
- executorch/backends/nxp/recipes/nxp_recipe_types.py +40 -0
- executorch/backends/nxp/tests/__init__.py +0 -0
- executorch/backends/nxp/tests/calibration_dataset.py +77 -0
- executorch/backends/nxp/tests/config.py +56 -0
- executorch/backends/nxp/tests/config_importer.py +17 -0
- executorch/backends/nxp/tests/cortex_m_benchmarking.py +79 -0
- executorch/backends/nxp/tests/dataset_creator.py +432 -0
- executorch/backends/nxp/tests/executorch_pipeline.py +320 -0
- executorch/backends/nxp/tests/executors.py +433 -0
- executorch/backends/nxp/tests/generic_tests/__init__.py +0 -0
- executorch/backends/nxp/tests/graph_verifier.py +264 -0
- executorch/backends/nxp/tests/ir/__init__.py +0 -0
- executorch/backends/nxp/tests/ir/converter/__init__.py +0 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/__init__.py +0 -0
- executorch/backends/nxp/tests/ir/edge_passes/__init__.py +0 -0
- executorch/backends/nxp/tests/ir/edge_passes/test_remove_io_quant_ops_pass.py +128 -0
- executorch/backends/nxp/tests/model_output_comparator.py +576 -0
- executorch/backends/nxp/tests/models/__init__.py +0 -0
- executorch/backends/nxp/tests/nsys_testing.py +940 -0
- executorch/backends/nxp/tests/outputs_dir.py +10 -0
- executorch/backends/nxp/tests/outputs_dir_importer.py +17 -0
- executorch/backends/nxp/tests/profiling_utils.py +139 -0
- executorch/backends/nxp/tests/simple_models.py +1156 -0
- executorch/backends/nxp/tests/tester/__init__.py +8 -0
- executorch/backends/nxp/tests/tester/tester.py +637 -0
- executorch/backends/nxp/tests/use_qat.py +22 -0
- executorch/backends/nxp/tests/utils.py +232 -0
- executorch/backends/openvino/__init__.py +5 -0
- executorch/backends/openvino/_passes/__init__.py +15 -0
- executorch/backends/openvino/_passes/cast_reduction_input_pass.py +45 -0
- executorch/backends/openvino/_passes/decompose_floor_divide_pass.py +106 -0
- executorch/backends/openvino/_passes/fold_constant_cumsum_pass.py +161 -0
- executorch/backends/openvino/partitioner.py +334 -0
- executorch/backends/openvino/preprocess.py +174 -0
- executorch/backends/openvino/quantizer/__init__.py +9 -0
- executorch/backends/openvino/quantizer/llm_compression.py +133 -0
- executorch/backends/openvino/quantizer/observers.py +206 -0
- executorch/backends/openvino/quantizer/quantizer.py +675 -0
- executorch/backends/openvino/test/tester/__init__.py +19 -0
- executorch/backends/openvino/test/tester/tester.py +94 -0
- executorch/backends/openvino/tests/ops/base_openvino_op_test.py +109 -0
- executorch/backends/qualcomm/__init__.py +11 -0
- executorch/backends/qualcomm/_passes/__init__.py +153 -0
- executorch/backends/qualcomm/_passes/annotate_avg_pool1d.py +64 -0
- executorch/backends/qualcomm/_passes/annotate_get_attr.py +54 -0
- executorch/backends/qualcomm/_passes/annotate_quant_attrs.py +139 -0
- executorch/backends/qualcomm/_passes/annotate_stack.py +42 -0
- executorch/backends/qualcomm/_passes/annotate_unbind.py +40 -0
- executorch/backends/qualcomm/_passes/backends/__init__.py +5 -0
- executorch/backends/qualcomm/_passes/backends/gpu/__init__.py +11 -0
- executorch/backends/qualcomm/_passes/backends/gpu/qnn_gpu_pass_manager.py +46 -0
- executorch/backends/qualcomm/_passes/backends/htp/__init__.py +11 -0
- executorch/backends/qualcomm/_passes/backends/htp/qnn_htp_pass_manager.py +54 -0
- executorch/backends/qualcomm/_passes/backends/lpai/__init__.py +11 -0
- executorch/backends/qualcomm/_passes/backends/lpai/qnn_lpai_pass_manager.py +97 -0
- executorch/backends/qualcomm/_passes/build_quant_io.py +53 -0
- executorch/backends/qualcomm/_passes/canonicalize_conv.py +201 -0
- executorch/backends/qualcomm/_passes/convert_bmm_to_matmul.py +83 -0
- executorch/backends/qualcomm/_passes/convert_complex_stft.py +116 -0
- executorch/backends/qualcomm/_passes/convert_linear_to_conv2d.py +301 -0
- executorch/backends/qualcomm/_passes/convert_mha_to_sha.py +626 -0
- executorch/backends/qualcomm/_passes/convert_square_to_pow.py +38 -0
- executorch/backends/qualcomm/_passes/decompose_acos.py +75 -0
- executorch/backends/qualcomm/_passes/decompose_addmm.py +115 -0
- executorch/backends/qualcomm/_passes/decompose_any.py +69 -0
- executorch/backends/qualcomm/_passes/decompose_as_strided.py +226 -0
- executorch/backends/qualcomm/_passes/decompose_atan2.py +210 -0
- executorch/backends/qualcomm/_passes/decompose_binary_alpha.py +61 -0
- executorch/backends/qualcomm/_passes/decompose_cdist.py +86 -0
- executorch/backends/qualcomm/_passes/decompose_col_im.py +273 -0
- executorch/backends/qualcomm/_passes/decompose_diagonal.py +234 -0
- executorch/backends/qualcomm/_passes/decompose_div_mode.py +91 -0
- executorch/backends/qualcomm/_passes/decompose_einsum.py +51 -0
- executorch/backends/qualcomm/_passes/decompose_empty.py +128 -0
- executorch/backends/qualcomm/_passes/decompose_expm1.py +49 -0
- executorch/backends/qualcomm/_passes/decompose_fill.py +61 -0
- executorch/backends/qualcomm/_passes/decompose_floor_divide.py +62 -0
- executorch/backends/qualcomm/_passes/decompose_glu.py +55 -0
- executorch/backends/qualcomm/_passes/decompose_hardsigmoid.py +59 -0
- executorch/backends/qualcomm/_passes/decompose_hyperbolic_variants.py +202 -0
- executorch/backends/qualcomm/_passes/decompose_linalg_vector_norm.py +81 -0
- executorch/backends/qualcomm/_passes/decompose_log_variants.py +114 -0
- executorch/backends/qualcomm/_passes/decompose_maxpool3d.py +145 -0
- executorch/backends/qualcomm/_passes/decompose_minmaxdim.py +109 -0
- executorch/backends/qualcomm/_passes/decompose_pad.py +128 -0
- executorch/backends/qualcomm/_passes/decompose_pdist.py +123 -0
- executorch/backends/qualcomm/_passes/decompose_reciprocal.py +39 -0
- executorch/backends/qualcomm/_passes/decompose_remainder.py +118 -0
- executorch/backends/qualcomm/_passes/decompose_roll.py +78 -0
- executorch/backends/qualcomm/_passes/decompose_select_scatter.py +96 -0
- executorch/backends/qualcomm/_passes/decompose_silu.py +45 -0
- executorch/backends/qualcomm/_passes/decompose_tan.py +71 -0
- executorch/backends/qualcomm/_passes/decompose_threshold.py +61 -0
- executorch/backends/qualcomm/_passes/decompose_triu.py +71 -0
- executorch/backends/qualcomm/_passes/decompose_trunc.py +93 -0
- executorch/backends/qualcomm/_passes/decompose_var.py +139 -0
- executorch/backends/qualcomm/_passes/decompose_wrap_with_autocast.py +95 -0
- executorch/backends/qualcomm/_passes/expand_broadcast_tensor_shape.py +80 -0
- executorch/backends/qualcomm/_passes/fixed_linear_keep_dim.py +94 -0
- executorch/backends/qualcomm/_passes/fold_qdq.py +85 -0
- executorch/backends/qualcomm/_passes/fuse_batch_norm_with_conv.py +36 -0
- executorch/backends/qualcomm/_passes/fuse_consecutive_cast.py +115 -0
- executorch/backends/qualcomm/_passes/fuse_consecutive_reshape.py +53 -0
- executorch/backends/qualcomm/_passes/fuse_consecutive_transpose.py +108 -0
- executorch/backends/qualcomm/_passes/i64_to_i32.py +204 -0
- executorch/backends/qualcomm/_passes/insert_cast_for_fp_act_quantized_weight.py +141 -0
- executorch/backends/qualcomm/_passes/insert_io_qdq.py +85 -0
- executorch/backends/qualcomm/_passes/insert_requantize.py +111 -0
- executorch/backends/qualcomm/_passes/insert_reshape_for_reduce_ops.py +58 -0
- executorch/backends/qualcomm/_passes/layout_transform.py +373 -0
- executorch/backends/qualcomm/_passes/lift_constant_scalar_operands.py +202 -0
- executorch/backends/qualcomm/_passes/lpai_partition_fallback_support.py +336 -0
- executorch/backends/qualcomm/_passes/qnn_pass_manager.py +554 -0
- executorch/backends/qualcomm/_passes/recompose_hadamard.py +185 -0
- executorch/backends/qualcomm/_passes/recompose_pad_maxpool2d.py +144 -0
- executorch/backends/qualcomm/_passes/recompose_pixel_unshuffle.py +81 -0
- executorch/backends/qualcomm/_passes/recompose_rms_norm.py +170 -0
- executorch/backends/qualcomm/_passes/remove_0d_tensor.py +62 -0
- executorch/backends/qualcomm/_passes/remove_redundancy.py +72 -0
- executorch/backends/qualcomm/_passes/replace_arange_args.py +48 -0
- executorch/backends/qualcomm/_passes/resolve_debug_handle.py +47 -0
- executorch/backends/qualcomm/_passes/seq_mse.py +240 -0
- executorch/backends/qualcomm/_passes/tag_quant_io.py +45 -0
- executorch/backends/qualcomm/_passes/utils.py +407 -0
- executorch/backends/qualcomm/builders/__init__.py +243 -0
- executorch/backends/qualcomm/builders/custom_ops.py +69 -0
- executorch/backends/qualcomm/builders/node_visitor.py +612 -0
- executorch/backends/qualcomm/builders/node_visitor_manager.py +81 -0
- executorch/backends/qualcomm/builders/op_abs.py +57 -0
- executorch/backends/qualcomm/builders/op_adaptive_avg_pool2d.py +126 -0
- executorch/backends/qualcomm/builders/op_adaptive_max_pool2d.py +151 -0
- executorch/backends/qualcomm/builders/op_add.py +62 -0
- executorch/backends/qualcomm/builders/op_amax.py +90 -0
- executorch/backends/qualcomm/builders/op_amin.py +90 -0
- executorch/backends/qualcomm/builders/op_and.py +60 -0
- executorch/backends/qualcomm/builders/op_arange.py +41 -0
- executorch/backends/qualcomm/builders/op_argmax.py +78 -0
- executorch/backends/qualcomm/builders/op_argmin.py +78 -0
- executorch/backends/qualcomm/builders/op_asin.py +56 -0
- executorch/backends/qualcomm/builders/op_atan.py +55 -0
- executorch/backends/qualcomm/builders/op_avg_pool2d.py +151 -0
- executorch/backends/qualcomm/builders/op_avg_pool3d.py +293 -0
- executorch/backends/qualcomm/builders/op_batch_norm.py +156 -0
- executorch/backends/qualcomm/builders/op_binary.py +84 -0
- executorch/backends/qualcomm/builders/op_bmm.py +59 -0
- executorch/backends/qualcomm/builders/op_cat.py +89 -0
- executorch/backends/qualcomm/builders/op_ceil.py +56 -0
- executorch/backends/qualcomm/builders/op_channel_shuffle.py +73 -0
- executorch/backends/qualcomm/builders/op_clamp.py +80 -0
- executorch/backends/qualcomm/builders/op_conv.py +263 -0
- executorch/backends/qualcomm/builders/op_copy.py +112 -0
- executorch/backends/qualcomm/builders/op_cos.py +56 -0
- executorch/backends/qualcomm/builders/op_cum_sum.py +87 -0
- executorch/backends/qualcomm/builders/op_custom_op.py +138 -0
- executorch/backends/qualcomm/builders/op_depth_to_space.py +78 -0
- executorch/backends/qualcomm/builders/op_dequantize.py +72 -0
- executorch/backends/qualcomm/builders/op_div.py +62 -0
- executorch/backends/qualcomm/builders/op_elu.py +68 -0
- executorch/backends/qualcomm/builders/op_embedding.py +252 -0
- executorch/backends/qualcomm/builders/op_eq.py +62 -0
- executorch/backends/qualcomm/builders/op_exp.py +60 -0
- executorch/backends/qualcomm/builders/op_expand.py +84 -0
- executorch/backends/qualcomm/builders/op_flip.py +80 -0
- executorch/backends/qualcomm/builders/op_floor.py +56 -0
- executorch/backends/qualcomm/builders/op_full.py +42 -0
- executorch/backends/qualcomm/builders/op_full_like.py +41 -0
- executorch/backends/qualcomm/builders/op_gather.py +75 -0
- executorch/backends/qualcomm/builders/op_ge.py +62 -0
- executorch/backends/qualcomm/builders/op_gelu.py +57 -0
- executorch/backends/qualcomm/builders/op_grid_sampler_2d.py +162 -0
- executorch/backends/qualcomm/builders/op_group_norm.py +96 -0
- executorch/backends/qualcomm/builders/op_gt.py +62 -0
- executorch/backends/qualcomm/builders/op_hadamard_transform.py +66 -0
- executorch/backends/qualcomm/builders/op_hardsigmoid.py +78 -0
- executorch/backends/qualcomm/builders/op_hardswish.py +57 -0
- executorch/backends/qualcomm/builders/op_hardtanh.py +79 -0
- executorch/backends/qualcomm/builders/op_index.py +85 -0
- executorch/backends/qualcomm/builders/op_index_put.py +481 -0
- executorch/backends/qualcomm/builders/op_index_select.py +80 -0
- executorch/backends/qualcomm/builders/op_instance_norm.py +112 -0
- executorch/backends/qualcomm/builders/op_is_inf.py +71 -0
- executorch/backends/qualcomm/builders/op_is_nan.py +66 -0
- executorch/backends/qualcomm/builders/op_layer_norm.py +139 -0
- executorch/backends/qualcomm/builders/op_le.py +62 -0
- executorch/backends/qualcomm/builders/op_linear.py +98 -0
- executorch/backends/qualcomm/builders/op_log.py +58 -0
- executorch/backends/qualcomm/builders/op_log_softmax.py +81 -0
- executorch/backends/qualcomm/builders/op_logical_not.py +56 -0
- executorch/backends/qualcomm/builders/op_lt.py +62 -0
- executorch/backends/qualcomm/builders/op_matmul.py +59 -0
- executorch/backends/qualcomm/builders/op_max.py +62 -0
- executorch/backends/qualcomm/builders/op_max_dim.py +89 -0
- executorch/backends/qualcomm/builders/op_max_pool2d.py +145 -0
- executorch/backends/qualcomm/builders/op_mean_dim.py +100 -0
- executorch/backends/qualcomm/builders/op_min.py +62 -0
- executorch/backends/qualcomm/builders/op_min_dim.py +89 -0
- executorch/backends/qualcomm/builders/op_mul.py +62 -0
- executorch/backends/qualcomm/builders/op_ne.py +62 -0
- executorch/backends/qualcomm/builders/op_neg.py +54 -0
- executorch/backends/qualcomm/builders/op_or.py +60 -0
- executorch/backends/qualcomm/builders/op_pad.py +107 -0
- executorch/backends/qualcomm/builders/op_pow.py +75 -0
- executorch/backends/qualcomm/builders/op_prelu.py +69 -0
- executorch/backends/qualcomm/builders/op_quantize.py +73 -0
- executorch/backends/qualcomm/builders/op_rand.py +79 -0
- executorch/backends/qualcomm/builders/op_randn.py +79 -0
- executorch/backends/qualcomm/builders/op_relu.py +58 -0
- executorch/backends/qualcomm/builders/op_repeat.py +68 -0
- executorch/backends/qualcomm/builders/op_reshape.py +55 -0
- executorch/backends/qualcomm/builders/op_resize.py +85 -0
- executorch/backends/qualcomm/builders/op_rms_norm.py +149 -0
- executorch/backends/qualcomm/builders/op_round.py +58 -0
- executorch/backends/qualcomm/builders/op_rsqrt.py +58 -0
- executorch/backends/qualcomm/builders/op_scalar_tensor.py +51 -0
- executorch/backends/qualcomm/builders/op_scatter_elements.py +183 -0
- executorch/backends/qualcomm/builders/op_select_copy.py +89 -0
- executorch/backends/qualcomm/builders/op_sigmoid.py +58 -0
- executorch/backends/qualcomm/builders/op_sign.py +56 -0
- executorch/backends/qualcomm/builders/op_sin.py +56 -0
- executorch/backends/qualcomm/builders/op_skip_ops.py +55 -0
- executorch/backends/qualcomm/builders/op_slice_copy.py +95 -0
- executorch/backends/qualcomm/builders/op_slice_scatter.py +122 -0
- executorch/backends/qualcomm/builders/op_softmax.py +79 -0
- executorch/backends/qualcomm/builders/op_sort.py +124 -0
- executorch/backends/qualcomm/builders/op_space_to_depth.py +83 -0
- executorch/backends/qualcomm/builders/op_split_with_sizes.py +99 -0
- executorch/backends/qualcomm/builders/op_sqrt.py +60 -0
- executorch/backends/qualcomm/builders/op_squeeze.py +57 -0
- executorch/backends/qualcomm/builders/op_stack.py +71 -0
- executorch/backends/qualcomm/builders/op_stft.py +183 -0
- executorch/backends/qualcomm/builders/op_sub.py +62 -0
- executorch/backends/qualcomm/builders/op_sum_int_list.py +84 -0
- executorch/backends/qualcomm/builders/op_tanh.py +57 -0
- executorch/backends/qualcomm/builders/op_to.py +149 -0
- executorch/backends/qualcomm/builders/op_topk.py +112 -0
- executorch/backends/qualcomm/builders/op_transpose.py +76 -0
- executorch/backends/qualcomm/builders/op_unary.py +66 -0
- executorch/backends/qualcomm/builders/op_unbind.py +73 -0
- executorch/backends/qualcomm/builders/op_unsqueeze.py +57 -0
- executorch/backends/qualcomm/builders/op_upsample_bilinear2d.py +68 -0
- executorch/backends/qualcomm/builders/op_upsample_nearest2d.py +68 -0
- executorch/backends/qualcomm/builders/op_where.py +82 -0
- executorch/backends/qualcomm/builders/op_xor.py +60 -0
- executorch/backends/qualcomm/builders/qnn_constants.py +720 -0
- executorch/backends/qualcomm/builders/utils.py +196 -0
- executorch/backends/qualcomm/custom_op/annotator.py +137 -0
- executorch/backends/qualcomm/custom_op/interface.py +115 -0
- executorch/backends/qualcomm/debugger/format_outputs.py +235 -0
- executorch/backends/qualcomm/debugger/qcom_numerical_comparator_base.py +194 -0
- executorch/backends/qualcomm/debugger/qcom_numerical_comparator_sample.py +75 -0
- executorch/backends/qualcomm/debugger/qnn_intermediate_debugger.py +101 -0
- executorch/backends/qualcomm/debugger/utils.py +708 -0
- executorch/backends/qualcomm/export_utils.py +1053 -0
- executorch/backends/qualcomm/genai_pipeline/__init__.py +99 -0
- executorch/backends/qualcomm/genai_pipeline/artifact_keys.py +69 -0
- executorch/backends/qualcomm/genai_pipeline/compilation/__init__.py +17 -0
- executorch/backends/qualcomm/genai_pipeline/compilation/compile_spec_builder.py +311 -0
- executorch/backends/qualcomm/genai_pipeline/configs/__init__.py +41 -0
- executorch/backends/qualcomm/genai_pipeline/configs/compilation_input_config.py +71 -0
- executorch/backends/qualcomm/genai_pipeline/configs/compilation_output_config.py +32 -0
- executorch/backends/qualcomm/genai_pipeline/configs/inference_input_config.py +38 -0
- executorch/backends/qualcomm/genai_pipeline/configs/inference_output_config.py +35 -0
- executorch/backends/qualcomm/genai_pipeline/configs/model_preparation_input_config.py +23 -0
- executorch/backends/qualcomm/genai_pipeline/configs/model_preparation_output_config.py +48 -0
- executorch/backends/qualcomm/genai_pipeline/configs/quantization_input_config.py +65 -0
- executorch/backends/qualcomm/genai_pipeline/configs/quantization_output_config.py +19 -0
- executorch/backends/qualcomm/genai_pipeline/control_args.py +419 -0
- executorch/backends/qualcomm/genai_pipeline/datasets/__init__.py +34 -0
- executorch/backends/qualcomm/genai_pipeline/datasets/calibration_data_adapter.py +54 -0
- executorch/backends/qualcomm/genai_pipeline/datasets/default_calibration_data_adapter.py +89 -0
- executorch/backends/qualcomm/genai_pipeline/datasets/default_training_data_adapter.py +65 -0
- executorch/backends/qualcomm/genai_pipeline/datasets/training_data_adapter.py +44 -0
- executorch/backends/qualcomm/genai_pipeline/engine_proxy.py +77 -0
- executorch/backends/qualcomm/genai_pipeline/exceptions.py +52 -0
- executorch/backends/qualcomm/genai_pipeline/genai_pipeline.py +302 -0
- executorch/backends/qualcomm/genai_pipeline/graph_bundle.py +131 -0
- executorch/backends/qualcomm/genai_pipeline/graph_names.py +56 -0
- executorch/backends/qualcomm/genai_pipeline/pipeline_context.py +116 -0
- executorch/backends/qualcomm/genai_pipeline/pipeline_stage.py +33 -0
- executorch/backends/qualcomm/genai_pipeline/pipeline_types.py +29 -0
- executorch/backends/qualcomm/genai_pipeline/stages/__init__.py +25 -0
- executorch/backends/qualcomm/genai_pipeline/stages/compilation_stage.py +35 -0
- executorch/backends/qualcomm/genai_pipeline/stages/inference_stage.py +35 -0
- executorch/backends/qualcomm/genai_pipeline/stages/model_preparation_stage.py +37 -0
- executorch/backends/qualcomm/genai_pipeline/stages/quantization_stage.py +37 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/__init__.py +25 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/compilation/__init__.py +23 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/compilation/compilation_strategy.py +34 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/compilation/compiler_adapter.py +115 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/compilation/default_compiler_adapter.py +299 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/compilation/executorch_compilation_strategy.py +218 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/inference/__init__.py +23 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/inference/default_device_runner_adapter.py +154 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/inference/device_runner_adapter.py +88 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/inference/executorch_inference_strategy.py +159 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/inference/inference_strategy.py +34 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/__init__.py +21 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/default_model_loader_adapter.py +222 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/executorch_model_preparation_strategy.py +240 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/model_loader_adapter.py +130 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/model_preparation_strategy.py +34 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/quantization/__init__.py +21 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/quantization/default_quantizer_adapter.py +167 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/quantization/executorch_quantization_strategy.py +233 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/quantization/quantization_strategy.py +34 -0
- executorch/backends/qualcomm/genai_pipeline/strategies/quantization/quantizer_adapter.py +130 -0
- executorch/backends/qualcomm/genai_pipeline/tests/compilation/__init__.py +5 -0
- executorch/backends/qualcomm/genai_pipeline/tests/test_utils.py +44 -0
- executorch/backends/qualcomm/partition/common_defs.py +40 -0
- executorch/backends/qualcomm/partition/qnn_partitioner.py +402 -0
- executorch/backends/qualcomm/partition/utils.py +274 -0
- executorch/backends/qualcomm/qnn_preprocess.py +347 -0
- executorch/backends/qualcomm/quantizer/annotators/__init__.py +0 -0
- executorch/backends/qualcomm/quantizer/annotators/htp_rules.py +1929 -0
- executorch/backends/qualcomm/quantizer/annotators/lpai_rules.py +1088 -0
- executorch/backends/qualcomm/quantizer/backend_opinfo_adapter.py +184 -0
- executorch/backends/qualcomm/quantizer/conv_bn.py +222 -0
- executorch/backends/qualcomm/quantizer/custom_annotation.py +466 -0
- executorch/backends/qualcomm/quantizer/observers/concat_observer.py +76 -0
- executorch/backends/qualcomm/quantizer/observers/per_block_param_observer.py +146 -0
- executorch/backends/qualcomm/quantizer/observers/per_channel_param_observer.py +157 -0
- executorch/backends/qualcomm/quantizer/qconfig.py +1051 -0
- executorch/backends/qualcomm/quantizer/quant_recipe.py +514 -0
- executorch/backends/qualcomm/quantizer/quantizer.py +819 -0
- executorch/backends/qualcomm/quantizer/registry_loader.py +26 -0
- executorch/backends/qualcomm/quantizer/rules.py +258 -0
- executorch/backends/qualcomm/quantizer/validators.py +461 -0
- executorch/backends/qualcomm/recipes/__init__.py +16 -0
- executorch/backends/qualcomm/recipes/qnn_recipe_provider.py +198 -0
- executorch/backends/qualcomm/recipes/qnn_recipe_types.py +28 -0
- executorch/backends/qualcomm/scripts/download_qnn_sdk.py +863 -0
- executorch/backends/qualcomm/serialization/qc_compiler_spec.fbs +399 -0
- executorch/backends/qualcomm/serialization/qc_schema.py +337 -0
- executorch/backends/qualcomm/serialization/qc_schema_serialize.py +59 -0
- executorch/backends/qualcomm/tests/models.py +3244 -0
- executorch/backends/qualcomm/tests/rework/conftest.py +637 -0
- executorch/backends/qualcomm/tests/rework/gpu/conftest.py +42 -0
- executorch/backends/qualcomm/tests/rework/htp/conftest.py +102 -0
- executorch/backends/qualcomm/tests/rework/lpai/conftest.py +102 -0
- executorch/backends/qualcomm/tests/rework/passes/__init__.py +0 -0
- executorch/backends/qualcomm/tests/rework/passes/conftest.py +183 -0
- executorch/backends/qualcomm/tests/rework/passes/passes_helper.py +317 -0
- executorch/backends/qualcomm/tests/rework/src/fcb_utils.py +60 -0
- executorch/backends/qualcomm/tests/rework/src/feature.py +1048 -0
- executorch/backends/qualcomm/tests/rework/src/op.py +5757 -0
- executorch/backends/qualcomm/tests/rework/src/pattern.py +5207 -0
- executorch/backends/qualcomm/tests/rework/src/utils.py +831 -0
- executorch/backends/qualcomm/tests/test_qnn_delegate.py +12439 -0
- executorch/backends/qualcomm/tests/tester.py +117 -0
- executorch/backends/qualcomm/tests/utils.py +972 -0
- executorch/backends/qualcomm/utils/check_qnn_version.py +110 -0
- executorch/backends/qualcomm/utils/constants.py +64 -0
- executorch/backends/qualcomm/utils/qnn_manager_lifecycle.py +139 -0
- executorch/backends/qualcomm/utils/qnn_sdk_setup.py +199 -0
- executorch/backends/qualcomm/utils/utils.py +1585 -0
- executorch/backends/samsung/_passes/__init__.py +43 -0
- executorch/backends/samsung/_passes/annotate_qparams.py +394 -0
- executorch/backends/samsung/_passes/annotate_scalar_parameters.py +74 -0
- executorch/backends/samsung/_passes/compose_rms_norm.py +99 -0
- executorch/backends/samsung/_passes/compute_const_attrs.py +138 -0
- executorch/backends/samsung/_passes/conv1d_to_conv2d.py +110 -0
- executorch/backends/samsung/_passes/customized_constant_prop.py +113 -0
- executorch/backends/samsung/_passes/decompose_einsum.py +52 -0
- executorch/backends/samsung/_passes/decompose_glu.py +56 -0
- executorch/backends/samsung/_passes/decompose_linalg_vector_norm.py +83 -0
- executorch/backends/samsung/_passes/decompose_remainder.py +126 -0
- executorch/backends/samsung/_passes/decompose_roll.py +84 -0
- executorch/backends/samsung/_passes/enn_pass_manager.py +85 -0
- executorch/backends/samsung/_passes/fold_qdq.py +36 -0
- executorch/backends/samsung/_passes/fuse_activation.py +77 -0
- executorch/backends/samsung/_passes/insert_qdq.py +185 -0
- executorch/backends/samsung/_passes/remove_useless_ops.py +95 -0
- executorch/backends/samsung/_passes/replace_inf_values.py +67 -0
- executorch/backends/samsung/_passes/replace_scalar_ops.py +53 -0
- executorch/backends/samsung/_passes/utils.py +96 -0
- executorch/backends/samsung/builders/__init__.py +147 -0
- executorch/backends/samsung/builders/node_visitor.py +118 -0
- executorch/backends/samsung/builders/op_add.py +48 -0
- executorch/backends/samsung/builders/op_amax.py +49 -0
- executorch/backends/samsung/builders/op_avg_pool2d.py +68 -0
- executorch/backends/samsung/builders/op_batch_norm.py +70 -0
- executorch/backends/samsung/builders/op_bmm.py +45 -0
- executorch/backends/samsung/builders/op_cat.py +52 -0
- executorch/backends/samsung/builders/op_clamp.py +55 -0
- executorch/backends/samsung/builders/op_constant_pad_nd.py +58 -0
- executorch/backends/samsung/builders/op_conv2d.py +107 -0
- executorch/backends/samsung/builders/op_cos.py +33 -0
- executorch/backends/samsung/builders/op_dequantize.py +19 -0
- executorch/backends/samsung/builders/op_div.py +44 -0
- executorch/backends/samsung/builders/op_embedding.py +44 -0
- executorch/backends/samsung/builders/op_exp.py +33 -0
- executorch/backends/samsung/builders/op_expand_copy.py +86 -0
- executorch/backends/samsung/builders/op_flip.py +51 -0
- executorch/backends/samsung/builders/op_floor_divide.py +45 -0
- executorch/backends/samsung/builders/op_gather.py +46 -0
- executorch/backends/samsung/builders/op_gelu.py +42 -0
- executorch/backends/samsung/builders/op_getitem.py +32 -0
- executorch/backends/samsung/builders/op_group_norm.py +48 -0
- executorch/backends/samsung/builders/op_hardsigmoid.py +37 -0
- executorch/backends/samsung/builders/op_hardswish.py +37 -0
- executorch/backends/samsung/builders/op_hardtanh.py +44 -0
- executorch/backends/samsung/builders/op_index.py +47 -0
- executorch/backends/samsung/builders/op_layer_norm.py +55 -0
- executorch/backends/samsung/builders/op_leaky_relu.py +45 -0
- executorch/backends/samsung/builders/op_linear.py +53 -0
- executorch/backends/samsung/builders/op_log.py +34 -0
- executorch/backends/samsung/builders/op_log_softmax.py +41 -0
- executorch/backends/samsung/builders/op_max_dim.py +56 -0
- executorch/backends/samsung/builders/op_max_pool2d.py +94 -0
- executorch/backends/samsung/builders/op_maximum.py +39 -0
- executorch/backends/samsung/builders/op_mean_dim.py +60 -0
- executorch/backends/samsung/builders/op_minimum.py +41 -0
- executorch/backends/samsung/builders/op_mul.py +45 -0
- executorch/backends/samsung/builders/op_neg.py +34 -0
- executorch/backends/samsung/builders/op_pad.py +76 -0
- executorch/backends/samsung/builders/op_permute.py +41 -0
- executorch/backends/samsung/builders/op_pixel_shuffle.py +40 -0
- executorch/backends/samsung/builders/op_pixel_unshuffle.py +44 -0
- executorch/backends/samsung/builders/op_placeholder.py +39 -0
- executorch/backends/samsung/builders/op_pow.py +41 -0
- executorch/backends/samsung/builders/op_prelu.py +43 -0
- executorch/backends/samsung/builders/op_quantize.py +67 -0
- executorch/backends/samsung/builders/op_relu.py +39 -0
- executorch/backends/samsung/builders/op_reshape.py +50 -0
- executorch/backends/samsung/builders/op_rms_norm.py +63 -0
- executorch/backends/samsung/builders/op_rsqrt.py +37 -0
- executorch/backends/samsung/builders/op_select.py +55 -0
- executorch/backends/samsung/builders/op_sigmoid.py +37 -0
- executorch/backends/samsung/builders/op_silu.py +36 -0
- executorch/backends/samsung/builders/op_sin.py +33 -0
- executorch/backends/samsung/builders/op_skip.py +32 -0
- executorch/backends/samsung/builders/op_slice_copy.py +65 -0
- executorch/backends/samsung/builders/op_softmax.py +41 -0
- executorch/backends/samsung/builders/op_split_with_sizes_copy.py +78 -0
- executorch/backends/samsung/builders/op_sqrt.py +37 -0
- executorch/backends/samsung/builders/op_squeeze.py +39 -0
- executorch/backends/samsung/builders/op_sub.py +50 -0
- executorch/backends/samsung/builders/op_sum_int_list.py +42 -0
- executorch/backends/samsung/builders/op_tanh.py +34 -0
- executorch/backends/samsung/builders/op_to_copy.py +46 -0
- executorch/backends/samsung/builders/op_topk.py +96 -0
- executorch/backends/samsung/builders/op_unsqueeze.py +37 -0
- executorch/backends/samsung/builders/op_upsample_bilinear2d.py +60 -0
- executorch/backends/samsung/builders/op_upsample_nearest2d.py +54 -0
- executorch/backends/samsung/builders/utils.py +64 -0
- executorch/backends/samsung/enn_preprocess.py +178 -0
- executorch/backends/samsung/partition/enn_partitioner.py +206 -0
- executorch/backends/samsung/quantizer/__init__.py +10 -0
- executorch/backends/samsung/quantizer/annotator.py +920 -0
- executorch/backends/samsung/quantizer/qconfig.py +142 -0
- executorch/backends/samsung/quantizer/quantizer.py +64 -0
- executorch/backends/samsung/serialization/compile_options.py +231 -0
- executorch/backends/samsung/serialization/compile_options_def.fbs +37 -0
- executorch/backends/samsung/serialization/enn_graph_schema.py +145 -0
- executorch/backends/samsung/test/tester/__init__.py +11 -0
- executorch/backends/samsung/test/tester/samsung_tester.py +182 -0
- executorch/backends/samsung/test/utils/__init__.py +11 -0
- executorch/backends/samsung/test/utils/quant_checkers.py +241 -0
- executorch/backends/samsung/test/utils/run_tests.py +58 -0
- executorch/backends/samsung/test/utils/runtime_executor.py +186 -0
- executorch/backends/samsung/test/utils/utils.py +42 -0
- executorch/backends/samsung/utils/constants.py +45 -0
- executorch/backends/samsung/utils/export_utils.py +82 -0
- executorch/backends/samsung/utils/utils.py +125 -0
- executorch/backends/test/facto/__init__.py +0 -0
- executorch/backends/test/facto/facto_specs.py +59 -0
- executorch/backends/test/facto/test_facto.py +850 -0
- executorch/backends/test/graph_builder.py +158 -0
- executorch/backends/test/harness/__init__.py +3 -0
- executorch/backends/test/harness/error_statistics.py +99 -0
- executorch/backends/test/harness/stages/__init__.py +23 -0
- executorch/backends/test/harness/stages/export.py +32 -0
- executorch/backends/test/harness/stages/partition.py +26 -0
- executorch/backends/test/harness/stages/quantize.py +130 -0
- executorch/backends/test/harness/stages/run_passes.py +68 -0
- executorch/backends/test/harness/stages/serialize.py +59 -0
- executorch/backends/test/harness/stages/stage.py +91 -0
- executorch/backends/test/harness/stages/to_edge.py +27 -0
- executorch/backends/test/harness/stages/to_edge_transform_and_lower.py +50 -0
- executorch/backends/test/harness/stages/to_executorch.py +54 -0
- executorch/backends/test/harness/tester.py +548 -0
- executorch/backends/test/program_builder.py +138 -0
- executorch/backends/test/suite/__init__.py +74 -0
- executorch/backends/test/suite/buck_runner.py +66 -0
- executorch/backends/test/suite/conftest.py +228 -0
- executorch/backends/test/suite/context.py +34 -0
- executorch/backends/test/suite/discovery.py +100 -0
- executorch/backends/test/suite/flow.py +250 -0
- executorch/backends/test/suite/flows/__init__.py +7 -0
- executorch/backends/test/suite/flows/arm.py +98 -0
- executorch/backends/test/suite/flows/coreml.py +31 -0
- executorch/backends/test/suite/flows/cortex_m.py +127 -0
- executorch/backends/test/suite/flows/cpu.py +10 -0
- executorch/backends/test/suite/flows/mlx.py +14 -0
- executorch/backends/test/suite/flows/nxp.py +86 -0
- executorch/backends/test/suite/flows/openvino.py +60 -0
- executorch/backends/test/suite/flows/portable.py +19 -0
- executorch/backends/test/suite/flows/qualcomm.py +61 -0
- executorch/backends/test/suite/flows/samsung.py +43 -0
- executorch/backends/test/suite/flows/vulkan.py +44 -0
- executorch/backends/test/suite/flows/webgpu.py +26 -0
- executorch/backends/test/suite/flows/xnnpack.py +79 -0
- executorch/backends/test/suite/generate_markdown_summary.py +249 -0
- executorch/backends/test/suite/generate_markdown_summary_json.py +229 -0
- executorch/backends/test/suite/models/__init__.py +7 -0
- executorch/backends/test/suite/models/test_torchaudio.py +110 -0
- executorch/backends/test/suite/models/test_torchvision.py +194 -0
- executorch/backends/test/suite/operators/__init__.py +108 -0
- executorch/backends/test/suite/operators/test_abs.py +60 -0
- executorch/backends/test/suite/operators/test_adaptive_avgpool1d.py +102 -0
- executorch/backends/test/suite/operators/test_adaptive_avgpool2d.py +112 -0
- executorch/backends/test/suite/operators/test_adaptive_avgpool3d.py +112 -0
- executorch/backends/test/suite/operators/test_adaptive_maxpool1d.py +125 -0
- executorch/backends/test/suite/operators/test_adaptive_maxpool2d.py +135 -0
- executorch/backends/test/suite/operators/test_adaptive_maxpool3d.py +135 -0
- executorch/backends/test/suite/operators/test_add.py +76 -0
- executorch/backends/test/suite/operators/test_amax.py +257 -0
- executorch/backends/test/suite/operators/test_amin.py +259 -0
- executorch/backends/test/suite/operators/test_argmax.py +201 -0
- executorch/backends/test/suite/operators/test_argmin.py +201 -0
- executorch/backends/test/suite/operators/test_avgpool1d.py +155 -0
- executorch/backends/test/suite/operators/test_avgpool2d.py +168 -0
- executorch/backends/test/suite/operators/test_avgpool3d.py +163 -0
- executorch/backends/test/suite/operators/test_cat.py +176 -0
- executorch/backends/test/suite/operators/test_ceil.py +60 -0
- executorch/backends/test/suite/operators/test_clamp.py +86 -0
- executorch/backends/test/suite/operators/test_conv1d.py +144 -0
- executorch/backends/test/suite/operators/test_conv2d.py +167 -0
- executorch/backends/test/suite/operators/test_conv3d.py +162 -0
- executorch/backends/test/suite/operators/test_convtranspose1d.py +144 -0
- executorch/backends/test/suite/operators/test_convtranspose2d.py +171 -0
- executorch/backends/test/suite/operators/test_convtranspose3d.py +166 -0
- executorch/backends/test/suite/operators/test_div.py +110 -0
- executorch/backends/test/suite/operators/test_elu.py +49 -0
- executorch/backends/test/suite/operators/test_embedding.py +89 -0
- executorch/backends/test/suite/operators/test_embedding_bag.py +118 -0
- executorch/backends/test/suite/operators/test_exp.py +65 -0
- executorch/backends/test/suite/operators/test_expand.py +122 -0
- executorch/backends/test/suite/operators/test_floor.py +57 -0
- executorch/backends/test/suite/operators/test_floor_divide.py +216 -0
- executorch/backends/test/suite/operators/test_gelu.py +52 -0
- executorch/backends/test/suite/operators/test_glu.py +52 -0
- executorch/backends/test/suite/operators/test_hardsigmoid.py +50 -0
- executorch/backends/test/suite/operators/test_hardswish.py +50 -0
- executorch/backends/test/suite/operators/test_hardtanh.py +57 -0
- executorch/backends/test/suite/operators/test_index_put.py +455 -0
- executorch/backends/test/suite/operators/test_index_select.py +128 -0
- executorch/backends/test/suite/operators/test_leaky_relu.py +56 -0
- executorch/backends/test/suite/operators/test_linear.py +124 -0
- executorch/backends/test/suite/operators/test_log.py +80 -0
- executorch/backends/test/suite/operators/test_log10.py +60 -0
- executorch/backends/test/suite/operators/test_log1p.py +60 -0
- executorch/backends/test/suite/operators/test_log2.py +60 -0
- executorch/backends/test/suite/operators/test_logsigmoid.py +40 -0
- executorch/backends/test/suite/operators/test_lstm.py +247 -0
- executorch/backends/test/suite/operators/test_masked_fill.py +101 -0
- executorch/backends/test/suite/operators/test_maxpool1d.py +185 -0
- executorch/backends/test/suite/operators/test_maxpool2d.py +191 -0
- executorch/backends/test/suite/operators/test_maxpool3d.py +189 -0
- executorch/backends/test/suite/operators/test_mean.py +305 -0
- executorch/backends/test/suite/operators/test_median.py +188 -0
- executorch/backends/test/suite/operators/test_mul.py +66 -0
- executorch/backends/test/suite/operators/test_neg.py +70 -0
- executorch/backends/test/suite/operators/test_permute.py +109 -0
- executorch/backends/test/suite/operators/test_pow.py +149 -0
- executorch/backends/test/suite/operators/test_prelu.py +55 -0
- executorch/backends/test/suite/operators/test_relu.py +45 -0
- executorch/backends/test/suite/operators/test_reshape.py +82 -0
- executorch/backends/test/suite/operators/test_round.py +129 -0
- executorch/backends/test/suite/operators/test_rsqrt.py +76 -0
- executorch/backends/test/suite/operators/test_select.py +89 -0
- executorch/backends/test/suite/operators/test_sigmoid.py +40 -0
- executorch/backends/test/suite/operators/test_silu.py +50 -0
- executorch/backends/test/suite/operators/test_slice.py +146 -0
- executorch/backends/test/suite/operators/test_split.py +119 -0
- executorch/backends/test/suite/operators/test_sqrt.py +71 -0
- executorch/backends/test/suite/operators/test_square.py +67 -0
- executorch/backends/test/suite/operators/test_squeeze.py +86 -0
- executorch/backends/test/suite/operators/test_stack.py +114 -0
- executorch/backends/test/suite/operators/test_sub.py +84 -0
- executorch/backends/test/suite/operators/test_tanh.py +40 -0
- executorch/backends/test/suite/operators/test_threshold.py +72 -0
- executorch/backends/test/suite/operators/test_transpose.py +143 -0
- executorch/backends/test/suite/operators/test_trunc.py +73 -0
- executorch/backends/test/suite/operators/test_unsqueeze.py +110 -0
- executorch/backends/test/suite/operators/test_upsample_bilinear2d.py +273 -0
- executorch/backends/test/suite/operators/test_upsample_nearest2d.py +137 -0
- executorch/backends/test/suite/operators/test_view.py +82 -0
- executorch/backends/test/suite/reporting.py +427 -0
- executorch/backends/test/suite/runner.py +331 -0
- executorch/backends/test/suite/tests/__init__.py +0 -0
- executorch/backends/test/suite/tests/test_reporting.py +144 -0
- executorch/backends/transforms/__init__.py +12 -0
- executorch/backends/transforms/addmm_mm_to_linear.py +170 -0
- executorch/backends/transforms/aten_to_dialect_pass.py +121 -0
- executorch/backends/transforms/canonicalize_view_copy_permute_pass.py +443 -0
- executorch/backends/transforms/channels_last_layout.py +22 -0
- executorch/backends/transforms/channels_last_ops.py +187 -0
- executorch/backends/transforms/collapse_view_copy.py +74 -0
- executorch/backends/transforms/convert_conv1d_to_conv2d_pass.py +322 -0
- executorch/backends/transforms/convert_dtype_pass.py +139 -0
- executorch/backends/transforms/decompose_channels_last_pass.py +97 -0
- executorch/backends/transforms/decompose_sdpa.py +208 -0
- executorch/backends/transforms/dim_maps.py +1088 -0
- executorch/backends/transforms/duplicate_dynamic_quant_chain.py +195 -0
- executorch/backends/transforms/enforce_contiguous_dim_order.py +216 -0
- executorch/backends/transforms/fuse_batch_norm_with_conv.py +220 -0
- executorch/backends/transforms/fuse_cascaded_transpose_or_permute_ops.py +185 -0
- executorch/backends/transforms/fuse_cascaded_view_ops.py +43 -0
- executorch/backends/transforms/fuse_conv_with_clamp.py +78 -0
- executorch/backends/transforms/fuse_duplicate_users_pass.py +218 -0
- executorch/backends/transforms/fuse_gqa_with_sdpa.py +217 -0
- executorch/backends/transforms/fuse_identical_input_transforms_pass.py +461 -0
- executorch/backends/transforms/fuse_rms_norm.py +540 -0
- executorch/backends/transforms/fuse_transpose_or_permute_op_pairs_pass.py +111 -0
- executorch/backends/transforms/fuse_view_copy.py +209 -0
- executorch/backends/transforms/mean_to_sum_div.py +41 -0
- executorch/backends/transforms/merge_split_concat_chain.py +153 -0
- executorch/backends/transforms/normalize_sdpa_input_rank.py +100 -0
- executorch/backends/transforms/permute_pass_utils.py +282 -0
- executorch/backends/transforms/permute_view_meta.py +56 -0
- executorch/backends/transforms/postpone_permute_below_squeeze_view.py +208 -0
- executorch/backends/transforms/propagate_view_copy_permute_pass.py +1418 -0
- executorch/backends/transforms/quantize_fused_convbn_bias_pass.py +363 -0
- executorch/backends/transforms/rank_0_to_rank_1.py +18 -0
- executorch/backends/transforms/remove_clone_ops.py +109 -0
- executorch/backends/transforms/remove_getitem_op.py +109 -0
- executorch/backends/transforms/remove_permutes_around_elementwise_ops.py +1059 -0
- executorch/backends/transforms/remove_unused_constants_pass.py +79 -0
- executorch/backends/transforms/replace_channels_last_input_clones.py +133 -0
- executorch/backends/transforms/replace_nop_transpose_or_permute_with_view.py +91 -0
- executorch/backends/transforms/replace_ops_with_channels_last_variants.py +283 -0
- executorch/backends/transforms/replace_scalar_with_tensor.py +99 -0
- executorch/backends/transforms/replace_squeeze_unsqueeze_with_view.py +53 -0
- executorch/backends/transforms/test/common.py +69 -0
- executorch/backends/transforms/utils.py +474 -0
- executorch/backends/transforms/view_copy_to_squeeze_unsqueeze.py +135 -0
- executorch/backends/vulkan/__init__.py +14 -0
- executorch/backends/vulkan/_passes/__init__.py +43 -0
- executorch/backends/vulkan/_passes/conv1d_as_conv2d.py +169 -0
- executorch/backends/vulkan/_passes/fold_qdq.py +40 -0
- executorch/backends/vulkan/_passes/fuse_patterns.py +34 -0
- executorch/backends/vulkan/_passes/fuse_quantized_ops.py +236 -0
- executorch/backends/vulkan/_passes/insert_dtype_promotion.py +102 -0
- executorch/backends/vulkan/_passes/insert_prepack_nodes.py +105 -0
- executorch/backends/vulkan/_passes/remove_asserts.py +52 -0
- executorch/backends/vulkan/_passes/remove_redundant_ops.py +89 -0
- executorch/backends/vulkan/_passes/squeeze_unsqueeze_inputs.py +93 -0
- executorch/backends/vulkan/_passes/tag_memory_meta_pass.py +549 -0
- executorch/backends/vulkan/custom_ops_lib.py +1333 -0
- executorch/backends/vulkan/op_registry.py +2023 -0
- executorch/backends/vulkan/partitioner/vulkan_partitioner.py +515 -0
- executorch/backends/vulkan/patterns/__init__.py +153 -0
- executorch/backends/vulkan/patterns/pattern_registry.py +135 -0
- executorch/backends/vulkan/patterns/quantized_binary.py +161 -0
- executorch/backends/vulkan/patterns/quantized_convolution.py +347 -0
- executorch/backends/vulkan/patterns/quantized_embedding.py +342 -0
- executorch/backends/vulkan/patterns/quantized_linear.py +645 -0
- executorch/backends/vulkan/patterns/quantized_pixel_shuffle.py +180 -0
- executorch/backends/vulkan/patterns/quantized_unary.py +121 -0
- executorch/backends/vulkan/patterns/rms_norm.py +280 -0
- executorch/backends/vulkan/patterns/rope.py +173 -0
- executorch/backends/vulkan/patterns/rope_hf.py +188 -0
- executorch/backends/vulkan/patterns/sdpa.py +155 -0
- executorch/backends/vulkan/patterns/select_as_symint.py +104 -0
- executorch/backends/vulkan/patterns/swiglu.py +65 -0
- executorch/backends/vulkan/patterns/weight_packing_utils.py +51 -0
- executorch/backends/vulkan/quantizer/vulkan_quantizer.py +198 -0
- executorch/backends/vulkan/quantizer/vulkan_quantizer_utils.py +228 -0
- executorch/backends/vulkan/runtime/gen_vulkan_spv.py +1747 -0
- executorch/backends/vulkan/serialization/schema.fbs +162 -0
- executorch/backends/vulkan/serialization/vulkan_graph_builder.py +608 -0
- executorch/backends/vulkan/serialization/vulkan_graph_schema.py +165 -0
- executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +348 -0
- executorch/backends/vulkan/test/op_tests/cases.py +2444 -0
- executorch/backends/vulkan/test/op_tests/utils/aten_types.py +31 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_benchmark_vk.py +363 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_computegraph.py +836 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_correctness_base.py +427 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_correctness_vk.py +177 -0
- executorch/backends/vulkan/test/op_tests/utils/test_suite.py +53 -0
- executorch/backends/vulkan/test/tester.py +91 -0
- executorch/backends/vulkan/test/utils.py +1172 -0
- executorch/backends/vulkan/utils.py +2056 -0
- executorch/backends/vulkan/vulkan_preprocess.py +293 -0
- executorch/backends/webgpu/__init__.py +5 -0
- executorch/backends/webgpu/partitioner/__init__.py +9 -0
- executorch/backends/webgpu/partitioner/partitioner.py +66 -0
- executorch/backends/webgpu/scripts/gen_wgsl_headers.py +859 -0
- executorch/backends/webgpu/test/conftest.py +28 -0
- executorch/backends/webgpu/test/op_tests/__init__.py +5 -0
- executorch/backends/webgpu/test/op_tests/cases.py +2548 -0
- executorch/backends/webgpu/test/op_tests/generate_op_tests.py +278 -0
- executorch/backends/webgpu/test/op_tests/test_generator.py +248 -0
- executorch/backends/webgpu/test/op_tests/test_schema.py +84 -0
- executorch/backends/webgpu/test/op_tests/test_suite.py +101 -0
- executorch/backends/webgpu/test/ops/__init__.py +0 -0
- executorch/backends/webgpu/test/ops/dynamic_shape/test_dynamic_shape_export.py +1708 -0
- executorch/backends/webgpu/test/ops/index/__init__.py +0 -0
- executorch/backends/webgpu/test/ops/index/test_index.py +109 -0
- executorch/backends/webgpu/test/ops/test_adamw.py +142 -0
- executorch/backends/webgpu/test/ops/test_add.py +116 -0
- executorch/backends/webgpu/test/ops/test_addmm.py +28 -0
- executorch/backends/webgpu/test/ops/test_arange.py +103 -0
- executorch/backends/webgpu/test/ops/test_argmax.py +46 -0
- executorch/backends/webgpu/test/ops/test_avg_pool2d.py +98 -0
- executorch/backends/webgpu/test/ops/test_batch_norm.py +42 -0
- executorch/backends/webgpu/test/ops/test_bitwise.py +95 -0
- executorch/backends/webgpu/test/ops/test_bmm.py +104 -0
- executorch/backends/webgpu/test/ops/test_cat.py +82 -0
- executorch/backends/webgpu/test/ops/test_compare.py +169 -0
- executorch/backends/webgpu/test/ops/test_constant_pad_nd.py +23 -0
- executorch/backends/webgpu/test/ops/test_conv1d_dw.py +102 -0
- executorch/backends/webgpu/test/ops/test_conv1d_pw.py +162 -0
- executorch/backends/webgpu/test/ops/test_conv2d.py +95 -0
- executorch/backends/webgpu/test/ops/test_conv_with_clamp.py +106 -0
- executorch/backends/webgpu/test/ops/test_dim_order.py +95 -0
- executorch/backends/webgpu/test/ops/test_dispatch_order.py +119 -0
- executorch/backends/webgpu/test/ops/test_div.py +94 -0
- executorch/backends/webgpu/test/ops/test_embedding.py +103 -0
- executorch/backends/webgpu/test/ops/test_embedding_q4gsw.py +161 -0
- executorch/backends/webgpu/test/ops/test_et_vk_sdpa.py +131 -0
- executorch/backends/webgpu/test/ops/test_expand_copy.py +120 -0
- executorch/backends/webgpu/test/ops/test_fill.py +91 -0
- executorch/backends/webgpu/test/ops/test_flip.py +76 -0
- executorch/backends/webgpu/test/ops/test_floor_divide.py +21 -0
- executorch/backends/webgpu/test/ops/test_fused_ce.py +130 -0
- executorch/backends/webgpu/test/ops/test_gather.py +123 -0
- executorch/backends/webgpu/test/ops/test_gelu.py +59 -0
- executorch/backends/webgpu/test/ops/test_grid_priors.py +80 -0
- executorch/backends/webgpu/test/ops/test_grid_sampler_2d.py +76 -0
- executorch/backends/webgpu/test/ops/test_group_norm.py +83 -0
- executorch/backends/webgpu/test/ops/test_index_select.py +79 -0
- executorch/backends/webgpu/test/ops/test_layer_norm.py +78 -0
- executorch/backends/webgpu/test/ops/test_leaky_relu.py +21 -0
- executorch/backends/webgpu/test/ops/test_linear.py +116 -0
- executorch/backends/webgpu/test/ops/test_linear_dW.py +88 -0
- executorch/backends/webgpu/test/ops/test_linear_dq8ca_q4gsw.py +38 -0
- executorch/backends/webgpu/test/ops/test_linear_fp32.py +77 -0
- executorch/backends/webgpu/test/ops/test_linear_q8ta_q8csw.py +65 -0
- executorch/backends/webgpu/test/ops/test_linear_qcs4w.py +60 -0
- executorch/backends/webgpu/test/ops/test_log_softmax.py +97 -0
- executorch/backends/webgpu/test/ops/test_logical_and.py +79 -0
- executorch/backends/webgpu/test/ops/test_logical_not.py +116 -0
- executorch/backends/webgpu/test/ops/test_logical_or.py +67 -0
- executorch/backends/webgpu/test/ops/test_matmul.py +67 -0
- executorch/backends/webgpu/test/ops/test_max_pool2d.py +42 -0
- executorch/backends/webgpu/test/ops/test_minimum.py +18 -0
- executorch/backends/webgpu/test/ops/test_mul.py +69 -0
- executorch/backends/webgpu/test/ops/test_permute.py +76 -0
- executorch/backends/webgpu/test/ops/test_pixel_shuffle.py +76 -0
- executorch/backends/webgpu/test/ops/test_pow.py +18 -0
- executorch/backends/webgpu/test/ops/test_prepack.py +142 -0
- executorch/backends/webgpu/test/ops/test_q4gsw_requant.py +123 -0
- executorch/backends/webgpu/test/ops/test_q8ta_add.py +70 -0
- executorch/backends/webgpu/test/ops/test_q8ta_conv2d.py +62 -0
- executorch/backends/webgpu/test/ops/test_q8ta_conv2d_dw.py +63 -0
- executorch/backends/webgpu/test/ops/test_q8ta_conv2d_pw.py +58 -0
- executorch/backends/webgpu/test/ops/test_q8ta_conv2d_transposed.py +68 -0
- executorch/backends/webgpu/test/ops/test_q8ta_linear.py +61 -0
- executorch/backends/webgpu/test/ops/test_q8ta_pixel_shuffle.py +64 -0
- executorch/backends/webgpu/test/ops/test_q8ta_relu.py +60 -0
- executorch/backends/webgpu/test/ops/test_quant.py +70 -0
- executorch/backends/webgpu/test/ops/test_quantized_linear.py +406 -0
- executorch/backends/webgpu/test/ops/test_quantized_linear_backward.py +157 -0
- executorch/backends/webgpu/test/ops/test_reduce.py +249 -0
- executorch/backends/webgpu/test/ops/test_relu.py +27 -0
- executorch/backends/webgpu/test/ops/test_repeat.py +77 -0
- executorch/backends/webgpu/test/ops/test_rms_norm.py +192 -0
- executorch/backends/webgpu/test/ops/test_rope.py +129 -0
- executorch/backends/webgpu/test/ops/test_rope_hf.py +388 -0
- executorch/backends/webgpu/test/ops/test_rope_interleaved.py +77 -0
- executorch/backends/webgpu/test/ops/test_sdpa.py +637 -0
- executorch/backends/webgpu/test/ops/test_select.py +67 -0
- executorch/backends/webgpu/test/ops/test_sigmoid.py +80 -0
- executorch/backends/webgpu/test/ops/test_slice.py +66 -0
- executorch/backends/webgpu/test/ops/test_softmax.py +116 -0
- executorch/backends/webgpu/test/ops/test_split_with_sizes_copy.py +39 -0
- executorch/backends/webgpu/test/ops/test_squeeze.py +75 -0
- executorch/backends/webgpu/test/ops/test_sub.py +114 -0
- executorch/backends/webgpu/test/ops/test_to_copy.py +196 -0
- executorch/backends/webgpu/test/ops/test_unary_activations.py +110 -0
- executorch/backends/webgpu/test/ops/test_unsqueeze.py +75 -0
- executorch/backends/webgpu/test/ops/test_update_cache.py +196 -0
- executorch/backends/webgpu/test/ops/test_upsample_bilinear2d.py +29 -0
- executorch/backends/webgpu/test/ops/test_upsample_nearest2d.py +33 -0
- executorch/backends/webgpu/test/ops/test_view_copy.py +66 -0
- executorch/backends/webgpu/test/ops/test_where.py +86 -0
- executorch/backends/webgpu/test/test_cmake_configuration.py +87 -0
- executorch/backends/webgpu/test/test_native_ci_contract.py +79 -0
- executorch/backends/webgpu/test/test_webgpu_partitioner.py +240 -0
- executorch/backends/webgpu/test/test_wgsl_codegen.py +1178 -0
- executorch/backends/webgpu/test/tester.py +145 -0
- executorch/backends/xnnpack/__init__.py +28 -0
- executorch/backends/xnnpack/_passes/__init__.py +116 -0
- executorch/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py +642 -0
- executorch/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py +206 -0
- executorch/backends/xnnpack/_passes/convert_to_linear.py +202 -0
- executorch/backends/xnnpack/_passes/convert_to_sdpa.py +114 -0
- executorch/backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py +65 -0
- executorch/backends/xnnpack/_passes/decompose_batch_norm.py +294 -0
- executorch/backends/xnnpack/_passes/decompose_cat.py +109 -0
- executorch/backends/xnnpack/_passes/fuse_activation_pass.py +87 -0
- executorch/backends/xnnpack/_passes/fuse_batch_norm.py +294 -0
- executorch/backends/xnnpack/_passes/insert_pad_qdq.py +88 -0
- executorch/backends/xnnpack/_passes/prelu_reshape_pass.py +75 -0
- executorch/backends/xnnpack/_passes/propagate_custom_meta_pass.py +44 -0
- executorch/backends/xnnpack/_passes/remove_noop_expand_copy_pass.py +59 -0
- executorch/backends/xnnpack/_passes/remove_redundant_copy_pass.py +158 -0
- executorch/backends/xnnpack/_passes/rewrite_fp16_silu.py +44 -0
- executorch/backends/xnnpack/_passes/xnnpack_pass.py +22 -0
- executorch/backends/xnnpack/operators/__init__.py +61 -0
- executorch/backends/xnnpack/operators/node_visitor.py +780 -0
- executorch/backends/xnnpack/operators/op_abs.py +52 -0
- executorch/backends/xnnpack/operators/op_add.py +77 -0
- executorch/backends/xnnpack/operators/op_addmm.py +70 -0
- executorch/backends/xnnpack/operators/op_avg_pooling2d.py +70 -0
- executorch/backends/xnnpack/operators/op_bmm.py +54 -0
- executorch/backends/xnnpack/operators/op_cat.py +121 -0
- executorch/backends/xnnpack/operators/op_ceiling.py +52 -0
- executorch/backends/xnnpack/operators/op_clamp.py +64 -0
- executorch/backends/xnnpack/operators/op_clone.py +71 -0
- executorch/backends/xnnpack/operators/op_conv2d.py +189 -0
- executorch/backends/xnnpack/operators/op_cos.py +52 -0
- executorch/backends/xnnpack/operators/op_div.py +56 -0
- executorch/backends/xnnpack/operators/op_dynamic_dequantize_ops.py +114 -0
- executorch/backends/xnnpack/operators/op_dynamic_quantize_ops.py +179 -0
- executorch/backends/xnnpack/operators/op_elu.py +58 -0
- executorch/backends/xnnpack/operators/op_exp.py +52 -0
- executorch/backends/xnnpack/operators/op_floor.py +48 -0
- executorch/backends/xnnpack/operators/op_gelu.py +60 -0
- executorch/backends/xnnpack/operators/op_hardswish.py +52 -0
- executorch/backends/xnnpack/operators/op_hardtanh.py +67 -0
- executorch/backends/xnnpack/operators/op_leaky_relu.py +65 -0
- executorch/backends/xnnpack/operators/op_linear.py +115 -0
- executorch/backends/xnnpack/operators/op_log.py +52 -0
- executorch/backends/xnnpack/operators/op_matrix_multiplication.py +66 -0
- executorch/backends/xnnpack/operators/op_max_dim.py +206 -0
- executorch/backends/xnnpack/operators/op_max_pool2d.py +124 -0
- executorch/backends/xnnpack/operators/op_maximum.py +55 -0
- executorch/backends/xnnpack/operators/op_mean_dim.py +87 -0
- executorch/backends/xnnpack/operators/op_minimum.py +54 -0
- executorch/backends/xnnpack/operators/op_multiply.py +77 -0
- executorch/backends/xnnpack/operators/op_negate.py +51 -0
- executorch/backends/xnnpack/operators/op_permute.py +87 -0
- executorch/backends/xnnpack/operators/op_prelu.py +56 -0
- executorch/backends/xnnpack/operators/op_quant_dequant.py +196 -0
- executorch/backends/xnnpack/operators/op_relu.py +61 -0
- executorch/backends/xnnpack/operators/op_rsqrt.py +52 -0
- executorch/backends/xnnpack/operators/op_sigmoid.py +48 -0
- executorch/backends/xnnpack/operators/op_sin.py +52 -0
- executorch/backends/xnnpack/operators/op_skip_ops.py +89 -0
- executorch/backends/xnnpack/operators/op_slice_copy.py +100 -0
- executorch/backends/xnnpack/operators/op_softmax.py +58 -0
- executorch/backends/xnnpack/operators/op_square.py +52 -0
- executorch/backends/xnnpack/operators/op_square_root.py +52 -0
- executorch/backends/xnnpack/operators/op_squeeze.py +147 -0
- executorch/backends/xnnpack/operators/op_static_constant_pad.py +145 -0
- executorch/backends/xnnpack/operators/op_static_resize_bilinear_2d.py +61 -0
- executorch/backends/xnnpack/operators/op_sub.py +77 -0
- executorch/backends/xnnpack/operators/op_tanh.py +52 -0
- executorch/backends/xnnpack/operators/op_to_copy.py +91 -0
- executorch/backends/xnnpack/operators/op_view_copy.py +96 -0
- executorch/backends/xnnpack/operators/quant_params.py +412 -0
- executorch/backends/xnnpack/partition/config/__init__.py +136 -0
- executorch/backends/xnnpack/partition/config/gemm_configs.py +621 -0
- executorch/backends/xnnpack/partition/config/generic_node_configs.py +925 -0
- executorch/backends/xnnpack/partition/config/node_configs.py +151 -0
- executorch/backends/xnnpack/partition/config/quant_affine_configs.py +56 -0
- executorch/backends/xnnpack/partition/config/xnnpack_config.py +310 -0
- executorch/backends/xnnpack/partition/graphs/bilinear_2d.py +55 -0
- executorch/backends/xnnpack/partition/graphs/sdpa.py +86 -0
- executorch/backends/xnnpack/partition/xnnpack_partitioner.py +166 -0
- executorch/backends/xnnpack/quantizer/xnnpack_quantizer.py +461 -0
- executorch/backends/xnnpack/quantizer/xnnpack_quantizer_utils.py +1214 -0
- executorch/backends/xnnpack/recipes/__init__.py +19 -0
- executorch/backends/xnnpack/recipes/xnnpack_recipe_provider.py +200 -0
- executorch/backends/xnnpack/recipes/xnnpack_recipe_types.py +37 -0
- executorch/backends/xnnpack/serialization/runtime_schema.fbs +390 -0
- executorch/backends/xnnpack/serialization/schema.fbs +382 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +548 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +393 -0
- executorch/backends/xnnpack/test/__init__.py +0 -0
- executorch/backends/xnnpack/test/passes/__init__.py +0 -0
- executorch/backends/xnnpack/test/test_xnnpack_utils.py +533 -0
- executorch/backends/xnnpack/test/test_xnnpack_utils_classes.py +44 -0
- executorch/backends/xnnpack/test/tester/__init__.py +29 -0
- executorch/backends/xnnpack/test/tester/tester.py +134 -0
- executorch/backends/xnnpack/utils/configs.py +41 -0
- executorch/backends/xnnpack/utils/quant_utils.py +301 -0
- executorch/backends/xnnpack/utils/utils.py +241 -0
- executorch/backends/xnnpack/utils/xnnpack_constants.py +37 -0
- executorch/backends/xnnpack/xnnpack_preprocess.py +194 -0
- executorch/codegen/__init__.py +0 -0
- executorch/codegen/api/__init__.py +0 -0
- executorch/codegen/api/custom_ops.py +151 -0
- executorch/codegen/api/et_cpp.py +367 -0
- executorch/codegen/api/types/__init__.py +5 -0
- executorch/codegen/api/types/signatures.py +77 -0
- executorch/codegen/api/types/types.py +76 -0
- executorch/codegen/api/unboxing.py +232 -0
- executorch/codegen/gen.py +1055 -0
- executorch/codegen/model.py +220 -0
- executorch/codegen/parse.py +158 -0
- executorch/codegen/tools/__init__.py +20 -0
- executorch/codegen/tools/combine_prim_ops_headers.py +164 -0
- executorch/codegen/tools/gen_all_oplist.py +252 -0
- executorch/codegen/tools/gen_max_kernel_num.py +174 -0
- executorch/codegen/tools/gen_oplist.py +370 -0
- executorch/codegen/tools/gen_ops_def.py +96 -0
- executorch/codegen/tools/gen_selected_op_variants.py +135 -0
- executorch/codegen/tools/gen_selected_prim_ops.py +133 -0
- executorch/codegen/tools/merge_yaml.py +125 -0
- executorch/codegen/tools/selective_build.cp315-win_amd64.pyd +0 -0
- executorch/codegen/tools/selective_build.pyi +23 -0
- executorch/codegen/tools/yaml_util.py +15 -0
- executorch/data/bin/__init__.py +44 -0
- executorch/data/bin/flatc.exe +0 -0
- executorch/devtools/__init__.py +19 -0
- executorch/devtools/backend_debug/__init__.py +13 -0
- executorch/devtools/backend_debug/delegation_info.py +183 -0
- executorch/devtools/bundled_program/config.py +120 -0
- executorch/devtools/bundled_program/core.py +395 -0
- executorch/devtools/bundled_program/schema/__init__.py +9 -0
- executorch/devtools/bundled_program/schema/bundled_program_schema.fbs +97 -0
- executorch/devtools/bundled_program/schema/bundled_program_schema.py +99 -0
- executorch/devtools/bundled_program/schema/scalar_type.fbs +43 -0
- executorch/devtools/bundled_program/serialize/__init__.py +298 -0
- executorch/devtools/bundled_program/serialize/bundled_program_schema.fbs +97 -0
- executorch/devtools/bundled_program/serialize/generate_bundled_program.py +174 -0
- executorch/devtools/bundled_program/serialize/generated/__init__.py +9 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Bool.py +92 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledMethodTestCase.py +194 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledMethodTestSuite.py +158 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledProgram.py +212 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Double.py +92 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Int.py +92 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Tensor.py +267 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Value.py +125 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/ValueUnion.py +29 -0
- executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/__init__.py +23 -0
- executorch/devtools/bundled_program/serialize/generated/executorch_flatbuffer/ScalarType.py +28 -0
- executorch/devtools/bundled_program/serialize/generated/executorch_flatbuffer/__init__.py +7 -0
- executorch/devtools/bundled_program/serialize/scalar_type.fbs +43 -0
- executorch/devtools/bundled_program/util/test_util.py +289 -0
- executorch/devtools/bundled_program/version.py +13 -0
- executorch/devtools/debug_format/base_schema.py +61 -0
- executorch/devtools/debug_format/et_schema.py +432 -0
- executorch/devtools/etdump/etdump_schema_flatcc.fbs +181 -0
- executorch/devtools/etdump/scalar_type.fbs +43 -0
- executorch/devtools/etdump/schema_flatcc.py +154 -0
- executorch/devtools/etdump/serialize.py +118 -0
- executorch/devtools/etrecord/__init__.py +13 -0
- executorch/devtools/etrecord/_etrecord.py +929 -0
- executorch/devtools/etrecord/tests/etrecord_test.py +1936 -0
- executorch/devtools/inspector/__init__.py +31 -0
- executorch/devtools/inspector/_inspector.py +1702 -0
- executorch/devtools/inspector/_inspector_utils.py +1264 -0
- executorch/devtools/inspector/_intermediate_output_capturer.py +62 -0
- executorch/devtools/inspector/inspector_cli.py +84 -0
- executorch/devtools/inspector/numerical_comparator/__init__.py +55 -0
- executorch/devtools/inspector/numerical_comparator/l1_numerical_comparator.py +35 -0
- executorch/devtools/inspector/numerical_comparator/mse_numerical_comparator.py +37 -0
- executorch/devtools/inspector/numerical_comparator/numerical_comparator_base.py +266 -0
- executorch/devtools/inspector/numerical_comparator/snr_numerical_comparator.py +47 -0
- executorch/devtools/inspector/tests/inspector_test_utils.py +189 -0
- executorch/devtools/inspector/vgf_neural_statistics.py +183 -0
- executorch/devtools/intermediate_output_tap/__init__.py +93 -0
- executorch/devtools/intermediate_output_tap/_convenience.py +191 -0
- executorch/devtools/intermediate_output_tap/_reducers.py +319 -0
- executorch/devtools/intermediate_output_tap/_selectors.py +231 -0
- executorch/devtools/intermediate_output_tap/_spec.py +55 -0
- executorch/devtools/intermediate_output_tap/_strip_pass.py +92 -0
- executorch/devtools/intermediate_output_tap/_tap_pass.py +278 -0
- executorch/devtools/intermediate_output_tap/custom_ops_lib.py +24 -0
- executorch/devtools/pte_tool/diff_pte.py +895 -0
- executorch/devtools/scripts/generate_profiling_csv.py +62 -0
- executorch/devtools/size_analysis_tool/size_analysis_tool.py +194 -0
- executorch/devtools/size_analysis_tool/size_analysis_tool_test.py +107 -0
- executorch/devtools/visualization/__init__.py +13 -0
- executorch/devtools/visualization/visualization_utils.py +313 -0
- executorch/devtools/visualization/visualization_utils_test.py +177 -0
- executorch/examples/apple/coreml/llama/export.py +224 -0
- executorch/examples/apple/coreml/llama/export_static_llm_coreml.py +717 -0
- executorch/examples/apple/coreml/llama/llama_transformer.py +899 -0
- executorch/examples/apple/coreml/llama/run.py +206 -0
- executorch/examples/apple/coreml/llama/run_lookahead.py +284 -0
- executorch/examples/apple/coreml/llama/run_static_llm.py +293 -0
- executorch/examples/apple/coreml/llama/run_static_llm_multifunction.py +325 -0
- executorch/examples/apple/coreml/llama/test.py +48 -0
- executorch/examples/apple/coreml/llama/utils.py +334 -0
- executorch/examples/apple/coreml/scripts/coreml_compute_plan.py +236 -0
- executorch/examples/apple/coreml/scripts/debugger_cli.py +181 -0
- executorch/examples/apple/coreml/scripts/export.py +280 -0
- executorch/examples/apple/coreml/scripts/extract_coreml_models.py +143 -0
- executorch/examples/apple/coreml/scripts/inspector_cli.py +64 -0
- executorch/examples/apple/coreml/scripts/inspector_utils.py +425 -0
- executorch/examples/apple/coreml/scripts/test_coreml_compute_plan.py +161 -0
- executorch/examples/cuda/scripts/__init__.py +0 -0
- executorch/examples/cuda/scripts/export.py +124 -0
- executorch/examples/cuda/scripts/export_amd_pointwise.py +142 -0
- executorch/examples/llm_pte_finetuning/__init__.py +19 -0
- executorch/examples/llm_pte_finetuning/llama3_config.yaml +96 -0
- executorch/examples/llm_pte_finetuning/model_exporter.py +87 -0
- executorch/examples/llm_pte_finetuning/model_loading_lib.py +143 -0
- executorch/examples/llm_pte_finetuning/phi3_alpaca_code_config.yaml +44 -0
- executorch/examples/llm_pte_finetuning/phi3_config.yaml +42 -0
- executorch/examples/llm_pte_finetuning/qwen_05b_config.yaml +43 -0
- executorch/examples/llm_pte_finetuning/runner.py +135 -0
- executorch/examples/llm_pte_finetuning/training_lib.py +157 -0
- executorch/examples/llm_server/__init__.py +5 -0
- executorch/examples/llm_server/conformance/test_openai_contract.py +207 -0
- executorch/examples/llm_server/evals/__init__.py +5 -0
- executorch/examples/llm_server/evals/terminal_bench/__init__.py +5 -0
- executorch/examples/llm_server/evals/terminal_bench/runner.py +501 -0
- executorch/examples/llm_server/evals/terminal_bench/sessions.py +80 -0
- executorch/examples/llm_server/python/__init__.py +7 -0
- executorch/examples/llm_server/python/chat_template.py +345 -0
- executorch/examples/llm_server/python/errors.py +105 -0
- executorch/examples/llm_server/python/multiplexed_worker_client.py +844 -0
- executorch/examples/llm_server/python/openai_transcript.py +385 -0
- executorch/examples/llm_server/python/protocol.py +165 -0
- executorch/examples/llm_server/python/serve.py +185 -0
- executorch/examples/llm_server/python/server.py +347 -0
- executorch/examples/llm_server/python/serving_chat.py +966 -0
- executorch/examples/llm_server/python/session_runtime.py +873 -0
- executorch/examples/llm_server/python/tests/test_multiplexed_worker_client.py +1681 -0
- executorch/examples/llm_server/python/tests/test_worker_client.py +712 -0
- executorch/examples/llm_server/python/tool_parsers/__init__.py +29 -0
- executorch/examples/llm_server/python/tool_parsers/gemma.py +258 -0
- executorch/examples/llm_server/python/tool_parsers/hermes.py +119 -0
- executorch/examples/llm_server/python/tool_parsers/qwen.py +193 -0
- executorch/examples/llm_server/python/tool_parsers/types.py +33 -0
- executorch/examples/llm_server/python/worker_client.py +660 -0
- executorch/examples/models/__init__.py +125 -0
- executorch/examples/models/checkpoint.py +142 -0
- executorch/examples/models/codegen/__init__.py +16 -0
- executorch/examples/models/codegen/convert_weight.py +93 -0
- executorch/examples/models/deeplab_v3/__init__.py +9 -0
- executorch/examples/models/deeplab_v3/model.py +50 -0
- executorch/examples/models/deepseek-r1-distill-llama-8B/config/deepseek_xnnpack_q8da4w.yaml +16 -0
- executorch/examples/models/deit_tiny/__init__.py +8 -0
- executorch/examples/models/deit_tiny/model.py +36 -0
- executorch/examples/models/dinov2/__init__.py +0 -0
- executorch/examples/models/dinov2/export_dinov2.py +187 -0
- executorch/examples/models/edsr/__init__.py +11 -0
- executorch/examples/models/edsr/model.py +28 -0
- executorch/examples/models/efficient_sam/__init__.py +11 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/build_efficient_sam.py +25 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam.py +316 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_decoder.py +373 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_encoder.py +261 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/mlp.py +31 -0
- executorch/examples/models/efficient_sam/efficient_sam_core/two_way_transformer.py +268 -0
- executorch/examples/models/efficient_sam/model.py +34 -0
- executorch/examples/models/emformer_rnnt/__init__.py +17 -0
- executorch/examples/models/emformer_rnnt/model.py +132 -0
- executorch/examples/models/gemma/__init__.py +16 -0
- executorch/examples/models/gemma/convert_weights.py +104 -0
- executorch/examples/models/gemma2/__init__.py +19 -0
- executorch/examples/models/gemma2/convert_weights.py +113 -0
- executorch/examples/models/gemma3/__init__.py +16 -0
- executorch/examples/models/gemma3/convert_weights.py +110 -0
- executorch/examples/models/gemma4/__init__.py +13 -0
- executorch/examples/models/gemma4/export_gemma4.py +884 -0
- executorch/examples/models/gemma4/image_utils.py +155 -0
- executorch/examples/models/gemma4/quant_utils.py +93 -0
- executorch/examples/models/gemma4/run_gemma4.py +365 -0
- executorch/examples/models/gemma4/speech_transform.py +149 -0
- executorch/examples/models/gemma4/text_decoder/__init__.py +17 -0
- executorch/examples/models/gemma4/text_decoder/convert_weights.py +314 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_attention.py +629 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_config.py +299 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_cross_decoder.py +83 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_decoder_layer.py +185 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_model.py +207 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_self_decoder.py +229 -0
- executorch/examples/models/gemma4/text_decoder/gemma4_transformer.py +171 -0
- executorch/examples/models/gemma4_31b/__init__.py +5 -0
- executorch/examples/models/gemma4_31b/cuda_packers.py +160 -0
- executorch/examples/models/gemma4_31b/cuda_source_transformations.py +361 -0
- executorch/examples/models/gemma4_31b/export.py +612 -0
- executorch/examples/models/gemma4_31b/gguf_loader.py +60 -0
- executorch/examples/models/gemma4_31b/inference.py +263 -0
- executorch/examples/models/gemma4_31b/mlx_source_transformations.py +234 -0
- executorch/examples/models/gemma4_31b/model.py +645 -0
- executorch/examples/models/gemma4_31b/quant/quantize.py +340 -0
- executorch/examples/models/gemma4_31b/quant/recipe.py +62 -0
- executorch/examples/models/gemma4_31b/quantize_and_save.py +158 -0
- executorch/examples/models/gemma4_31b/sampler.py +37 -0
- executorch/examples/models/gemma4_31b/serve.py +214 -0
- executorch/examples/models/gemma4_31b/test_ondevice_serving.py +62 -0
- executorch/examples/models/gemma4_31b/test_serve.py +184 -0
- executorch/examples/models/gemma4_31b/tests/test_pipeline.py +504 -0
- executorch/examples/models/glm/__init__.py +16 -0
- executorch/examples/models/glm/convert_weights.py +79 -0
- executorch/examples/models/granite/__init__.py +16 -0
- executorch/examples/models/granite/convert_weights.py +106 -0
- executorch/examples/models/granite_speech/__init__.py +16 -0
- executorch/examples/models/granite_speech/convert_weights.py +111 -0
- executorch/examples/models/inception_v3/__init__.py +11 -0
- executorch/examples/models/inception_v3/model.py +28 -0
- executorch/examples/models/inception_v4/__init__.py +11 -0
- executorch/examples/models/inception_v4/model.py +26 -0
- executorch/examples/models/internvl3/__init__.py +16 -0
- executorch/examples/models/internvl3/convert_weights.py +82 -0
- executorch/examples/models/lfm2/__init__.py +10 -0
- executorch/examples/models/lfm2/config/lfm2_coreml_fp32.yaml +15 -0
- executorch/examples/models/lfm2/config/lfm2_mlx_4w.yaml +15 -0
- executorch/examples/models/lfm2/config/lfm2_xnnpack_fp32.yaml +12 -0
- executorch/examples/models/lfm2/config/lfm2_xnnpack_q8da4w.yaml +15 -0
- executorch/examples/models/lfm2/convert_weights.py +92 -0
- executorch/examples/models/lfm2/short_conv.py +124 -0
- executorch/examples/models/lfm2/test_lfm2_5_mlx.py +102 -0
- executorch/examples/models/llama/__init__.py +20 -0
- executorch/examples/models/llama/attention.py +981 -0
- executorch/examples/models/llama/config/llama_attention_sink.yaml +30 -0
- executorch/examples/models/llama/config/llama_bf16.yaml +7 -0
- executorch/examples/models/llama/config/llama_q8da4w.yaml +11 -0
- executorch/examples/models/llama/config/llama_xnnpack.yaml +17 -0
- executorch/examples/models/llama/config/llama_xnnpack_qat.yaml +23 -0
- executorch/examples/models/llama/config/llama_xnnpack_spinquant.yaml +22 -0
- executorch/examples/models/llama/config/test_llm_config.py +145 -0
- executorch/examples/models/llama/convert_weights.py +135 -0
- executorch/examples/models/llama/eval_llama.py +38 -0
- executorch/examples/models/llama/eval_llama_lib.py +441 -0
- executorch/examples/models/llama/evaluate/__init__.py +11 -0
- executorch/examples/models/llama/evaluate/eager_eval.py +93 -0
- executorch/examples/models/llama/experimental/__init__.py +0 -0
- executorch/examples/models/llama/experimental/generate.py +190 -0
- executorch/examples/models/llama/experimental/load_gguf_q4_0.py +184 -0
- executorch/examples/models/llama/experimental/subclass.py +413 -0
- executorch/examples/models/llama/experimental/test_subclass.py +28 -0
- executorch/examples/models/llama/export_llama.py +56 -0
- executorch/examples/models/llama/export_llama_lib.py +2378 -0
- executorch/examples/models/llama/fairseq2.py +63 -0
- executorch/examples/models/llama/feed_forward.py +73 -0
- executorch/examples/models/llama/hf_download.py +169 -0
- executorch/examples/models/llama/install_requirement_helper.py +70 -0
- executorch/examples/models/llama/llama_transformer.py +604 -0
- executorch/examples/models/llama/lora.py +80 -0
- executorch/examples/models/llama/model.py +402 -0
- executorch/examples/models/llama/model_args.py +243 -0
- executorch/examples/models/llama/norm.py +250 -0
- executorch/examples/models/llama/rope.py +402 -0
- executorch/examples/models/llama/runner/eager.py +142 -0
- executorch/examples/models/llama/runner/generation.py +234 -0
- executorch/examples/models/llama/runner/native.py +145 -0
- executorch/examples/models/llama/source_transformation/__init__.py +0 -0
- executorch/examples/models/llama/source_transformation/apply_spin_quant_r1_r2.py +202 -0
- executorch/examples/models/llama/source_transformation/attention.py +223 -0
- executorch/examples/models/llama/source_transformation/attention_sink.py +375 -0
- executorch/examples/models/llama/source_transformation/custom_kv_cache.py +1034 -0
- executorch/examples/models/llama/source_transformation/lora.py +153 -0
- executorch/examples/models/llama/source_transformation/moe.py +359 -0
- executorch/examples/models/llama/source_transformation/pre_quantization.py +348 -0
- executorch/examples/models/llama/source_transformation/prune_vocab.py +119 -0
- executorch/examples/models/llama/source_transformation/quantize.py +913 -0
- executorch/examples/models/llama/source_transformation/rms_norm.py +23 -0
- executorch/examples/models/llama/source_transformation/rope.py +39 -0
- executorch/examples/models/llama/source_transformation/sdpa.py +553 -0
- executorch/examples/models/llama/source_transformation/spin_quant.py +88 -0
- executorch/examples/models/llama/source_transformation/test_attention_sink.py +624 -0
- executorch/examples/models/llama/source_transformation/test_quantized_kv_cache.py +126 -0
- executorch/examples/models/llama/source_transformation/test_quantized_sdpa.py +167 -0
- executorch/examples/models/llama/source_transformation/test_sdpa_with_quantized_kv_cache.py +170 -0
- executorch/examples/models/llama/static_attention.py +1663 -0
- executorch/examples/models/llama/tokenizer/tiktoken.py +224 -0
- executorch/examples/models/llama3_2_vision/__init__.py +14 -0
- executorch/examples/models/llama3_2_vision/preprocess/__init__.py +0 -0
- executorch/examples/models/llama3_2_vision/preprocess/export_preprocess.py +45 -0
- executorch/examples/models/llama3_2_vision/preprocess/model.py +72 -0
- executorch/examples/models/llama3_2_vision/preprocess/test_preprocess.py +338 -0
- executorch/examples/models/llama3_2_vision/runner/eager.py +59 -0
- executorch/examples/models/llama3_2_vision/runner/exported.py +94 -0
- executorch/examples/models/llama3_2_vision/runner/generation.py +102 -0
- executorch/examples/models/llama3_2_vision/runner/native.py +143 -0
- executorch/examples/models/llama3_2_vision/text_decoder/model.py +199 -0
- executorch/examples/models/llama3_2_vision/vision_encoder/__init__.py +12 -0
- executorch/examples/models/llama3_2_vision/vision_encoder/model.py +96 -0
- executorch/examples/models/llama3_2_vision/vision_encoder/test/__init__.py +0 -0
- executorch/examples/models/llava/__init__.py +11 -0
- executorch/examples/models/llava/export_llava.py +365 -0
- executorch/examples/models/llava/model.py +415 -0
- executorch/examples/models/llava/test/test_llava.py +151 -0
- executorch/examples/models/llava/test/test_pte.py +105 -0
- executorch/examples/models/lstm/__init__.py +12 -0
- executorch/examples/models/lstm/model.py +31 -0
- executorch/examples/models/mlperf_tiny/__init__.py +23 -0
- executorch/examples/models/mlperf_tiny/deep_autoencoder.py +40 -0
- executorch/examples/models/mlperf_tiny/ds_cnn.py +90 -0
- executorch/examples/models/mlperf_tiny/mobilenet_v1_025.py +102 -0
- executorch/examples/models/mlperf_tiny/resnet8.py +98 -0
- executorch/examples/models/mlperf_tiny/streaming_wakeword.py +87 -0
- executorch/examples/models/mobilebert/__init__.py +11 -0
- executorch/examples/models/mobilebert/model.py +31 -0
- executorch/examples/models/mobilenet_v2/__init__.py +12 -0
- executorch/examples/models/mobilenet_v2/model.py +41 -0
- executorch/examples/models/mobilenet_v3/__init__.py +11 -0
- executorch/examples/models/mobilenet_v3/model.py +30 -0
- executorch/examples/models/model_base.py +47 -0
- executorch/examples/models/model_factory.py +60 -0
- executorch/examples/models/moshi/mimi/test_mimi.py +245 -0
- executorch/examples/models/muse-glimmer/__init__.py +13 -0
- executorch/examples/models/muse-glimmer/export/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/export/common.py +169 -0
- executorch/examples/models/muse-glimmer/export/export_dflash.py +1171 -0
- executorch/examples/models/muse-glimmer/export/export_solo.py +1214 -0
- executorch/examples/models/muse-glimmer/inference.py +356 -0
- executorch/examples/models/muse-glimmer/loaders/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/loaders/checkpoint_loader.py +880 -0
- executorch/examples/models/muse-glimmer/loaders/dflash_loader.py +203 -0
- executorch/examples/models/muse-glimmer/loaders/quantize_and_save.py +199 -0
- executorch/examples/models/muse-glimmer/model/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/model/dflash_model.py +532 -0
- executorch/examples/models/muse-glimmer/model/dflash_token_sampler.py +336 -0
- executorch/examples/models/muse-glimmer/model/model.py +969 -0
- executorch/examples/models/muse-glimmer/model/vision_tower.py +197 -0
- executorch/examples/models/muse-glimmer/serving/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/serving/serve.py +512 -0
- executorch/examples/models/muse-glimmer/serving/serve_batching.py +228 -0
- executorch/examples/models/muse-glimmer/serving/stream_parser.py +164 -0
- executorch/examples/models/muse-glimmer/serving/tool_parsers/__init__.py +11 -0
- executorch/examples/models/muse-glimmer/serving/tool_parsers/atem.py +185 -0
- executorch/examples/models/muse-glimmer/source_transformations/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/source_transformations/cuda.py +1130 -0
- executorch/examples/models/muse-glimmer/source_transformations/mlx.py +707 -0
- executorch/examples/models/muse-glimmer/source_transformations/sampler.py +39 -0
- executorch/examples/models/muse-glimmer/tests/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/vision/__init__.py +5 -0
- executorch/examples/models/muse-glimmer/vision/precompute.py +297 -0
- executorch/examples/models/muse_glimmer/__init__.py +13 -0
- executorch/examples/models/muse_glimmer/export/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/export/common.py +169 -0
- executorch/examples/models/muse_glimmer/export/export_dflash.py +1171 -0
- executorch/examples/models/muse_glimmer/export/export_solo.py +1214 -0
- executorch/examples/models/muse_glimmer/inference.py +356 -0
- executorch/examples/models/muse_glimmer/loaders/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/loaders/checkpoint_loader.py +880 -0
- executorch/examples/models/muse_glimmer/loaders/dflash_loader.py +203 -0
- executorch/examples/models/muse_glimmer/loaders/quantize_and_save.py +199 -0
- executorch/examples/models/muse_glimmer/model/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/model/dflash_model.py +532 -0
- executorch/examples/models/muse_glimmer/model/dflash_token_sampler.py +336 -0
- executorch/examples/models/muse_glimmer/model/model.py +969 -0
- executorch/examples/models/muse_glimmer/model/vision_tower.py +197 -0
- executorch/examples/models/muse_glimmer/serving/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/serving/serve.py +512 -0
- executorch/examples/models/muse_glimmer/serving/serve_batching.py +228 -0
- executorch/examples/models/muse_glimmer/serving/stream_parser.py +164 -0
- executorch/examples/models/muse_glimmer/serving/tool_parsers/__init__.py +11 -0
- executorch/examples/models/muse_glimmer/serving/tool_parsers/atem.py +185 -0
- executorch/examples/models/muse_glimmer/source_transformations/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/source_transformations/cuda.py +1130 -0
- executorch/examples/models/muse_glimmer/source_transformations/mlx.py +707 -0
- executorch/examples/models/muse_glimmer/source_transformations/sampler.py +39 -0
- executorch/examples/models/muse_glimmer/tests/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/tests/gen_prompt_golden.py +59 -0
- executorch/examples/models/muse_glimmer/tests/gen_resize_golden.py +46 -0
- executorch/examples/models/muse_glimmer/tests/prompt_cases.py +193 -0
- executorch/examples/models/muse_glimmer/tests/test_mlx_pipeline.py +289 -0
- executorch/examples/models/muse_glimmer/tests/test_pipeline.py +1235 -0
- executorch/examples/models/muse_glimmer/tests/test_prompt_tokens.py +365 -0
- executorch/examples/models/muse_glimmer/tests/test_serve.py +1041 -0
- executorch/examples/models/muse_glimmer/vision/__init__.py +5 -0
- executorch/examples/models/muse_glimmer/vision/precompute.py +297 -0
- executorch/examples/models/nemotron3_diarization/__init__.py +5 -0
- executorch/examples/models/nemotron3_diarization/export_nemotron.py +295 -0
- executorch/examples/models/parakeet/export_parakeet_tdt.py +826 -0
- executorch/examples/models/parakeet/quantize.py +8 -0
- executorch/examples/models/phi-3-mini/__init__.py +11 -0
- executorch/examples/models/phi-3-mini-lora/export_model.py +144 -0
- executorch/examples/models/phi_4_mini/__init__.py +16 -0
- executorch/examples/models/phi_4_mini/config/phi_4_mini_xnnpack.yaml +12 -0
- executorch/examples/models/phi_4_mini/convert_weights.py +153 -0
- executorch/examples/models/qwen2_5/__init__.py +16 -0
- executorch/examples/models/qwen2_5/config/qwen2_5_coder_xnnpack_q8da4w.yaml +20 -0
- executorch/examples/models/qwen2_5/config/qwen2_5_xnnpack_q8da4w.yaml +14 -0
- executorch/examples/models/qwen2_5/convert_weights.py +105 -0
- executorch/examples/models/qwen3/__init__.py +16 -0
- executorch/examples/models/qwen3/config/qwen3_multimethod.yaml +34 -0
- executorch/examples/models/qwen3/config/qwen3_xnnpack_lora.yaml +21 -0
- executorch/examples/models/qwen3/config/qwen3_xnnpack_q8da4w.yaml +20 -0
- executorch/examples/models/qwen3/convert_weights.py +142 -0
- executorch/examples/models/qwen3_5/__init__.py +19 -0
- executorch/examples/models/qwen3_5/config/qwen3_5_xnnpack_fp32.yaml +21 -0
- executorch/examples/models/qwen3_5/convert_weights.py +165 -0
- executorch/examples/models/qwen3_5/tests/__init__.py +2 -0
- executorch/examples/models/qwen3_5_moe/__init__.py +0 -0
- executorch/examples/models/qwen3_5_moe/export.py +1379 -0
- executorch/examples/models/qwen3_5_moe/inference.py +196 -0
- executorch/examples/models/qwen3_5_moe/metal_source_transformations.py +336 -0
- executorch/examples/models/qwen3_5_moe/mlx_source_transformations.py +371 -0
- executorch/examples/models/qwen3_5_moe/model.py +955 -0
- executorch/examples/models/qwen3_5_moe/quantize_and_save.py +570 -0
- executorch/examples/models/qwen3_5_moe/run.py +329 -0
- executorch/examples/models/qwen3_5_moe/sampler.py +60 -0
- executorch/examples/models/qwen3_5_moe/serve.py +182 -0
- executorch/examples/models/qwen3_5_moe/test_chunked_prefill.py +124 -0
- executorch/examples/models/qwen3_5_moe/test_quantize_roundtrip.py +323 -0
- executorch/examples/models/qwen3_5_moe/test_sampler.py +142 -0
- executorch/examples/models/qwen3_5_moe/test_serve.py +158 -0
- executorch/examples/models/qwen3_5_moe/test_turboquant.py +211 -0
- executorch/examples/models/resnet/__init__.py +12 -0
- executorch/examples/models/resnet/model.py +48 -0
- executorch/examples/models/silero_vad/export_silero_vad.py +232 -0
- executorch/examples/models/smollm2/__init__.py +16 -0
- executorch/examples/models/smollm2/convert_weights.py +84 -0
- executorch/examples/models/smollm3/__init__.py +16 -0
- executorch/examples/models/smollm3/convert_weights.py +112 -0
- executorch/examples/models/smolvlm/__init__.py +16 -0
- executorch/examples/models/smolvlm/convert_weights.py +77 -0
- executorch/examples/models/sortformer/export_sortformer.py +409 -0
- executorch/examples/models/sortformer/validate_pte.py +136 -0
- executorch/examples/models/spark_x2_5/__init__.py +5 -0
- executorch/examples/models/spark_x2_5/config/spark_x2_5_xnnpack_fp32.yaml +12 -0
- executorch/examples/models/spark_x2_5/config/spark_x2_5_xnnpack_q8da4w.yaml +15 -0
- executorch/examples/models/spark_x2_5/convert_weights.py +136 -0
- executorch/examples/models/spark_x2_5/test_spark_x2_5.py +125 -0
- executorch/examples/models/stable_diffusion/__init__.py +21 -0
- executorch/examples/models/stable_diffusion/model.py +202 -0
- executorch/examples/models/stable_diffusion_3_5_large/__init__.py +28 -0
- executorch/examples/models/stable_diffusion_3_5_large/export_sd3_5_large.py +445 -0
- executorch/examples/models/stable_diffusion_3_5_large/model.py +415 -0
- executorch/examples/models/supertonic/__init__.py +5 -0
- executorch/examples/models/supertonic/export/__init__.py +5 -0
- executorch/examples/models/supertonic/export/common.py +348 -0
- executorch/examples/models/supertonic/export/export_supertonic.py +147 -0
- executorch/examples/models/supertonic/loaders/__init__.py +5 -0
- executorch/examples/models/supertonic/loaders/checkpoint_loader.py +549 -0
- executorch/examples/models/supertonic/loaders/voice_style_loader.py +57 -0
- executorch/examples/models/supertonic/model/__init__.py +5 -0
- executorch/examples/models/supertonic/model/config.py +62 -0
- executorch/examples/models/supertonic/model/duration_predictor.py +153 -0
- executorch/examples/models/supertonic/model/layers.py +200 -0
- executorch/examples/models/supertonic/model/text_encoder.py +346 -0
- executorch/examples/models/supertonic/model/vector_estimator.py +576 -0
- executorch/examples/models/supertonic/model/vocoder.py +204 -0
- executorch/examples/models/supertonic/preprocessing.py +207 -0
- executorch/examples/models/supertonic/source_transformations/__init__.py +5 -0
- executorch/examples/models/supertonic/source_transformations/mlx.py +245 -0
- executorch/examples/models/supertonic/tests/__init__.py +5 -0
- executorch/examples/models/test/__init__.py +0 -0
- executorch/examples/models/torchvision_vit/__init__.py +11 -0
- executorch/examples/models/torchvision_vit/model.py +28 -0
- executorch/examples/models/toy_model/__init__.py +25 -0
- executorch/examples/models/toy_model/model.py +143 -0
- executorch/examples/models/voxtral_realtime/__init__.py +5 -0
- executorch/examples/models/voxtral_realtime/export_voxtral_rt.py +798 -0
- executorch/examples/models/voxtral_realtime/model.py +1517 -0
- executorch/examples/models/voxtral_tts/__init__.py +5 -0
- executorch/examples/models/voxtral_tts/export_voxtral_tts.py +720 -0
- executorch/examples/models/voxtral_tts/model.py +1609 -0
- executorch/examples/models/voxtral_tts/voice.py +91 -0
- executorch/examples/models/wav2letter/__init__.py +11 -0
- executorch/examples/models/wav2letter/model.py +29 -0
- executorch/examples/models/whisper/__init__.py +8 -0
- executorch/examples/models/whisper/model.py +43 -0
- executorch/examples/models/yolo26/__init__.py +8 -0
- executorch/examples/models/yolo26/export_and_validate.py +400 -0
- executorch/examples/models/yolo26/model.py +31 -0
- executorch/examples/nxp/__init__.py +4 -0
- executorch/examples/nxp/analyzing_with_inspector.py +90 -0
- executorch/examples/nxp/aot_neutron_compile.py +511 -0
- executorch/examples/nxp/experimental/__init__.py +4 -0
- executorch/examples/nxp/experimental/cifar_net/__init__.py +4 -0
- executorch/examples/nxp/experimental/cifar_net/cifar_net.py +301 -0
- executorch/examples/nxp/models/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/anomaly_detection/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/anomaly_detection/mlperf_tiny_anomaly_detection.py +182 -0
- executorch/examples/nxp/models/mlperf_tiny/image_classification/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/image_classification/mlperf_tiny_image_classification.py +52 -0
- executorch/examples/nxp/models/mlperf_tiny/keyword_spotting/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/keyword_spotting/mlperf_tiny_keyword_spotting.py +60 -0
- executorch/examples/nxp/models/mlperf_tiny/visual_wake_words/__init__.py +4 -0
- executorch/examples/nxp/models/mlperf_tiny/visual_wake_words/mlperf_tiny_visual_wake_words.py +64 -0
- executorch/examples/nxp/models/mobilenet_v2.py +103 -0
- executorch/examples/nxp/models/nxp_test_base_model.py +202 -0
- executorch/examples/qualcomm/__init__.py +5 -0
- executorch/examples/qualcomm/custom_op/custom_ops_1.py +307 -0
- executorch/examples/qualcomm/custom_op/custom_ops_2.py +317 -0
- executorch/examples/qualcomm/custom_op/custom_ops_lpai.py +511 -0
- executorch/examples/qualcomm/oss_scripts/__init__.py +5 -0
- executorch/examples/qualcomm/oss_scripts/albert.py +175 -0
- executorch/examples/qualcomm/oss_scripts/bert.py +163 -0
- executorch/examples/qualcomm/oss_scripts/conv_former.py +135 -0
- executorch/examples/qualcomm/oss_scripts/convnext_small.py +139 -0
- executorch/examples/qualcomm/oss_scripts/cvt.py +201 -0
- executorch/examples/qualcomm/oss_scripts/deit.py +153 -0
- executorch/examples/qualcomm/oss_scripts/depthanything_v2_small.py +214 -0
- executorch/examples/qualcomm/oss_scripts/dino_v2.py +139 -0
- executorch/examples/qualcomm/oss_scripts/distilbert.py +164 -0
- executorch/examples/qualcomm/oss_scripts/dit.py +153 -0
- executorch/examples/qualcomm/oss_scripts/efficientSAM/efficientSAM.py +329 -0
- executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/__init__.py +17 -0
- executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/mask_decoder.py +125 -0
- executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/pos_emb.py +64 -0
- executorch/examples/qualcomm/oss_scripts/efficientnet.py +144 -0
- executorch/examples/qualcomm/oss_scripts/esrgan.py +172 -0
- executorch/examples/qualcomm/oss_scripts/eurobert.py +173 -0
- executorch/examples/qualcomm/oss_scripts/fastvit.py +218 -0
- executorch/examples/qualcomm/oss_scripts/fbnet.py +137 -0
- executorch/examples/qualcomm/oss_scripts/focalnet.py +138 -0
- executorch/examples/qualcomm/oss_scripts/gMLP_image_classification.py +127 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/model_wrapper.py +232 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/__init__.py +9 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/attention.py +253 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/convert_weights.py +26 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/cross_decoder.py +80 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/decoder_layer.py +114 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/feed_forward.py +56 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/self_decoder.py +80 -0
- executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/text_model.py +128 -0
- executorch/examples/qualcomm/oss_scripts/hf_causal_lm.py +288 -0
- executorch/examples/qualcomm/oss_scripts/llama/__init__.py +632 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/__init__.py +69 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/builders.py +549 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/collators.py +127 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/config.py +61 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/constants.py +7 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/datasets.py +48 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/loaders.py +192 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/preprocessors.py +122 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/schema.py +34 -0
- executorch/examples/qualcomm/oss_scripts/llama/dataset/targets.py +43 -0
- executorch/examples/qualcomm/oss_scripts/llama/decoder_constants.py +67 -0
- executorch/examples/qualcomm/oss_scripts/llama/encoder/__init__.py +31 -0
- executorch/examples/qualcomm/oss_scripts/llama/encoder/encoder_config.py +120 -0
- executorch/examples/qualcomm/oss_scripts/llama/encoder/encoder_quant_recipe.py +118 -0
- executorch/examples/qualcomm/oss_scripts/llama/evaluator/__init__.py +25 -0
- executorch/examples/qualcomm/oss_scripts/llama/evaluator/device_evaluator.py +795 -0
- executorch/examples/qualcomm/oss_scripts/llama/evaluator/lm_eval_adapter.py +99 -0
- executorch/examples/qualcomm/oss_scripts/llama/inference/__init__.py +25 -0
- executorch/examples/qualcomm/oss_scripts/llama/inference/decoder.py +164 -0
- executorch/examples/qualcomm/oss_scripts/llama/inference/encoder.py +22 -0
- executorch/examples/qualcomm/oss_scripts/llama/inference/model.py +59 -0
- executorch/examples/qualcomm/oss_scripts/llama/llama.py +990 -0
- executorch/examples/qualcomm/oss_scripts/llama/masking_utils.py +312 -0
- executorch/examples/qualcomm/oss_scripts/llama/mix_precision_analyzer.py +694 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/__init__.py +18 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/apply_rope.py +52 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/audio_encoder.py +163 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/embedding.py +39 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/feed_forward.py +141 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/layernorm.py +50 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/static_llama.py +1093 -0
- executorch/examples/qualcomm/oss_scripts/llama/model/vision_encoder.py +374 -0
- executorch/examples/qualcomm/oss_scripts/llama/quantize/__init__.py +13 -0
- executorch/examples/qualcomm/oss_scripts/llama/quantize/ptq.py +77 -0
- executorch/examples/qualcomm/oss_scripts/llama/quantize/qat.py +105 -0
- executorch/examples/qualcomm/oss_scripts/llama/quantize/strategy.py +34 -0
- executorch/examples/qualcomm/oss_scripts/llama/range_setting_pt2e.py +279 -0
- executorch/examples/qualcomm/oss_scripts/llama/static_llm_quant_recipe.py +802 -0
- executorch/examples/qualcomm/oss_scripts/llama/tokenizer.py +417 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/__init__.py +25 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/config/__init__.py +11 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/config/config.py +45 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/config/lr_config.yaml +49 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/config/qad.yaml +20 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/loss.py +66 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/trainer.py +303 -0
- executorch/examples/qualcomm/oss_scripts/llama/train/utils.py +96 -0
- executorch/examples/qualcomm/oss_scripts/llama/utils.py +70 -0
- executorch/examples/qualcomm/oss_scripts/llama/wrappers/__init__.py +23 -0
- executorch/examples/qualcomm/oss_scripts/llama/wrappers/attention_sink_wrappers.py +469 -0
- executorch/examples/qualcomm/oss_scripts/llama/wrappers/base_component.py +201 -0
- executorch/examples/qualcomm/oss_scripts/llama/wrappers/llm_wrappers.py +1534 -0
- executorch/examples/qualcomm/oss_scripts/llm_utils/decoder_model_wrapper.py +283 -0
- executorch/examples/qualcomm/oss_scripts/llm_utils/eval_decoder_model_qnn.py +299 -0
- executorch/examples/qualcomm/oss_scripts/llm_utils/llm_quant_recipe.py +314 -0
- executorch/examples/qualcomm/oss_scripts/llm_utils/qnn_decoder_model_manager.py +423 -0
- executorch/examples/qualcomm/oss_scripts/maxvit_t.py +247 -0
- executorch/examples/qualcomm/oss_scripts/mobilevit_v1.py +166 -0
- executorch/examples/qualcomm/oss_scripts/mobilevit_v2.py +171 -0
- executorch/examples/qualcomm/oss_scripts/moshi/mimi.py +525 -0
- executorch/examples/qualcomm/oss_scripts/moshi/model/static_conv.py +145 -0
- executorch/examples/qualcomm/oss_scripts/moshi/model/static_convtr.py +175 -0
- executorch/examples/qualcomm/oss_scripts/moshi/model/static_mimi.py +679 -0
- executorch/examples/qualcomm/oss_scripts/moshi/model/static_seanet_decoder.py +313 -0
- executorch/examples/qualcomm/oss_scripts/pvt.py +137 -0
- executorch/examples/qualcomm/oss_scripts/regnet.py +144 -0
- executorch/examples/qualcomm/oss_scripts/retinanet.py +319 -0
- executorch/examples/qualcomm/oss_scripts/roberta.py +191 -0
- executorch/examples/qualcomm/oss_scripts/squeezenet.py +129 -0
- executorch/examples/qualcomm/oss_scripts/ssd300_vgg16.py +275 -0
- executorch/examples/qualcomm/oss_scripts/swin_transformer.py +191 -0
- executorch/examples/qualcomm/oss_scripts/swin_v2_t.py +189 -0
- executorch/examples/qualcomm/oss_scripts/t5/t5.py +380 -0
- executorch/examples/qualcomm/oss_scripts/t5/t5_model.py +550 -0
- executorch/examples/qualcomm/oss_scripts/vit_b_16.py +140 -0
- executorch/examples/qualcomm/oss_scripts/whisper/whisper.py +543 -0
- executorch/examples/qualcomm/oss_scripts/whisper/whisper_model.py +114 -0
- executorch/examples/qualcomm/qaihub_scripts/llama/llama2/qaihub_llama2_7b.py +241 -0
- executorch/examples/qualcomm/qaihub_scripts/llama/llama3/qaihub_llama3_8b.py +248 -0
- executorch/examples/qualcomm/qaihub_scripts/stable_diffusion/qaihub_stable_diffusion.py +403 -0
- executorch/examples/qualcomm/qaihub_scripts/stable_diffusion/stable_diffusion_lib.py +22 -0
- executorch/examples/qualcomm/qaihub_scripts/utils/export.py +509 -0
- executorch/examples/qualcomm/qaihub_scripts/utils/utils.py +82 -0
- executorch/examples/qualcomm/scripts/deeplab_v3.py +199 -0
- executorch/examples/qualcomm/scripts/edsr.py +231 -0
- executorch/examples/qualcomm/scripts/export_example.py +127 -0
- executorch/examples/qualcomm/scripts/inception_v3.py +133 -0
- executorch/examples/qualcomm/scripts/inception_v4.py +132 -0
- executorch/examples/qualcomm/scripts/mobilebert_fine_tune.py +378 -0
- executorch/examples/qualcomm/scripts/mobilenet_v2.py +133 -0
- executorch/examples/qualcomm/scripts/mobilenet_v3.py +140 -0
- executorch/examples/qualcomm/scripts/torchvision_vit.py +180 -0
- executorch/examples/qualcomm/scripts/wav2letter.py +218 -0
- executorch/examples/qualcomm/util_scripts/cli.py +731 -0
- executorch/examples/qualcomm/util_scripts/fcb.py +347 -0
- executorch/examples/qualcomm/util_scripts/gen_etrecord.py +104 -0
- executorch/examples/qualcomm/util_scripts/htp_profiling_on_device_op_trace_offline.py +132 -0
- executorch/examples/qualcomm/util_scripts/htp_profiling_on_device_op_trace_online.py +130 -0
- executorch/examples/qualcomm/util_scripts/htp_profiling_on_host_hextimate.py +112 -0
- executorch/examples/qualcomm/util_scripts/qnn_intermediate_debugger_demo.py +217 -0
- executorch/examples/qualcomm/utils.py +364 -0
- executorch/examples/xnnpack/__init__.py +51 -0
- executorch/examples/xnnpack/aot_compiler.py +151 -0
- executorch/examples/xnnpack/quantization/example.py +205 -0
- executorch/examples/xnnpack/quantization/utils.py +42 -0
- executorch/exir/__init__.py +57 -0
- executorch/exir/_program_utils.py +109 -0
- executorch/exir/_serialize/__init__.py +20 -0
- executorch/exir/_serialize/_cord.py +140 -0
- executorch/exir/_serialize/_dataclass.py +145 -0
- executorch/exir/_serialize/_flatbuffer.py +467 -0
- executorch/exir/_serialize/_flatbuffer_program.py +359 -0
- executorch/exir/_serialize/_named_data_store.py +358 -0
- executorch/exir/_serialize/_program.py +809 -0
- executorch/exir/_serialize/_ptn.py +370 -0
- executorch/exir/_serialize/_serialize.py +123 -0
- executorch/exir/_serialize/data_serializer.py +120 -0
- executorch/exir/_serialize/generate_program.py +167 -0
- executorch/exir/_serialize/generated/__init__.py +7 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/AllocationDetails.py +130 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegate.py +189 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegateDataReference.py +113 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegateInlineData.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Bool.py +96 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/BoolList.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Buffer.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Chain.py +317 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/CompileSpec.py +162 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/ContainerMetadata.py +120 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DataLocation.py +7 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DataSegment.py +113 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DelegateCall.py +218 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DelegateScratch.py +128 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DeviceType.py +7 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Double.py +96 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/DoubleList.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/EValue.py +137 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/ExecutionPlan.py +595 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/ExtraTensorInfo.py +168 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Frame.py +157 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/FrameList.py +143 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/FreeCall.py +96 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Instruction.py +131 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/InstructionArguments.py +33 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Int.py +96 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/IntList.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/JumpFalseCall.py +113 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/KernelCall.py +158 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/KernelTypes.py +57 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/MoveCall.py +113 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/NamedData.py +117 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/NonConstBufferDevice.py +130 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Null.py +80 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Operator.py +120 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/OptionalTensorList.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Program.py +474 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/ScalarType.py +28 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/String.py +100 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/SubsegmentOffsets.py +158 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/Tensor.py +355 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/TensorDataLocation.py +7 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/TensorList.py +141 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/TensorShapeDynamism.py +8 -0
- executorch/exir/_serialize/generated/executorch_flatbuffer/__init__.py +93 -0
- executorch/exir/_serialize/padding.py +39 -0
- executorch/exir/_serialize/program.fbs +551 -0
- executorch/exir/_serialize/scalar_type.fbs +43 -0
- executorch/exir/_serialize/test/__init__.py +0 -0
- executorch/exir/_warnings.py +44 -0
- executorch/exir/backend/backend_api.py +808 -0
- executorch/exir/backend/backend_details.py +206 -0
- executorch/exir/backend/canonical_partitioners/all_node_partitioner.py +55 -0
- executorch/exir/backend/canonical_partitioners/config_partitioner.py +262 -0
- executorch/exir/backend/canonical_partitioners/duplicate_constant_node_pass.py +154 -0
- executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
- executorch/exir/backend/canonical_partitioners/group_partitioner.py +495 -0
- executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +188 -0
- executorch/exir/backend/compile_spec_schema.py +17 -0
- executorch/exir/backend/operator_support.py +127 -0
- executorch/exir/backend/partitioner.py +139 -0
- executorch/exir/backend/test/backend_with_compiler_demo.py +144 -0
- executorch/exir/backend/test/backend_with_delegate_mapping_demo.py +210 -0
- executorch/exir/backend/test/backend_with_named_data_map.py +115 -0
- executorch/exir/backend/test/backend_with_preprocess_all_demo.py +297 -0
- executorch/exir/backend/test/demo_backend.py +35 -0
- executorch/exir/backend/test/demos/rpc/executor_backend_partitioner.py +77 -0
- executorch/exir/backend/test/demos/rpc/executor_backend_preprocess.py +39 -0
- executorch/exir/backend/test/device_util.py +112 -0
- executorch/exir/backend/test/hta_partitioner_demo.py +247 -0
- executorch/exir/backend/test/op_partitioner_demo.py +266 -0
- executorch/exir/backend/utils.py +750 -0
- executorch/exir/banked_memory_planning.py +490 -0
- executorch/exir/capture/__init__.py +28 -0
- executorch/exir/capture/_capture.py +381 -0
- executorch/exir/capture/_config.py +140 -0
- executorch/exir/capture/_unlift.py +159 -0
- executorch/exir/common.py +140 -0
- executorch/exir/control_flow.py +204 -0
- executorch/exir/debug_handle_utils.py +29 -0
- executorch/exir/delegate.py +171 -0
- executorch/exir/delegate.pyi +21 -0
- executorch/exir/dialects/__init__.py +0 -0
- executorch/exir/dialects/_ops.py +166 -0
- executorch/exir/dialects/backend/_ops.py +123 -0
- executorch/exir/dialects/edge/_ops.py +405 -0
- executorch/exir/dialects/edge/arg/model.py +238 -0
- executorch/exir/dialects/edge/arg/type.py +46 -0
- executorch/exir/dialects/edge/dtype/runner.py +122 -0
- executorch/exir/dialects/edge/dtype/supported.py +49 -0
- executorch/exir/dialects/edge/dtype/utils.py +36 -0
- executorch/exir/dialects/edge/edge.yaml +8388 -0
- executorch/exir/dialects/edge/op/api.py +86 -0
- executorch/exir/dialects/edge/op/sample_input.py +1283 -0
- executorch/exir/dialects/edge/spec/gen.py +523 -0
- executorch/exir/dialects/edge/spec/utils.py +328 -0
- executorch/exir/dim_order_utils.py +85 -0
- executorch/exir/dynamic_shape.py +12 -0
- executorch/exir/emit/__init__.py +11 -0
- executorch/exir/emit/_emit_program.py +216 -0
- executorch/exir/emit/_emitter.py +2220 -0
- executorch/exir/error.py +55 -0
- executorch/exir/graph.py +86 -0
- executorch/exir/graph_module.py +181 -0
- executorch/exir/inplace_aliasing.py +197 -0
- executorch/exir/lowered_backend_module.py +1134 -0
- executorch/exir/memory.py +91 -0
- executorch/exir/memory_planning.py +1567 -0
- executorch/exir/native/__init__.py +14 -0
- executorch/exir/native/native.py +449 -0
- executorch/exir/native/test/__init__.py +0 -0
- executorch/exir/operator/convert.py +371 -0
- executorch/exir/operator/manip.py +89 -0
- executorch/exir/operator/util.py +68 -0
- executorch/exir/pass_base.py +1141 -0
- executorch/exir/pass_manager.py +280 -0
- executorch/exir/passes/__init__.py +553 -0
- executorch/exir/passes/_device_copy_ops_registry.py +58 -0
- executorch/exir/passes/_quant_patterns_and_replacements.py +1564 -0
- executorch/exir/passes/const_prop_pass.py +84 -0
- executorch/exir/passes/constant_prop_pass.py +563 -0
- executorch/exir/passes/convert_constant_dim_order_pass.py +159 -0
- executorch/exir/passes/cse_pass.py +201 -0
- executorch/exir/passes/debug_handle_generator_pass.py +81 -0
- executorch/exir/passes/delegate_scratch_pass.py +100 -0
- executorch/exir/passes/dim_order_ops_registry.py +90 -0
- executorch/exir/passes/dynamic_shape_prop_pass.py +301 -0
- executorch/exir/passes/executorch_prim_ops_registry.py +186 -0
- executorch/exir/passes/external_constants_pass.py +113 -0
- executorch/exir/passes/fold_redundant_qdq_pass.py +36 -0
- executorch/exir/passes/init_mutable_pass.py +32 -0
- executorch/exir/passes/insert_write_back_for_buffers_pass.py +481 -0
- executorch/exir/passes/legalize_portable_dim_order_pass.py +173 -0
- executorch/exir/passes/memory_format_ops_pass.py +187 -0
- executorch/exir/passes/memory_planning_pass.py +372 -0
- executorch/exir/passes/normalize_transpose_pass.py +24 -0
- executorch/exir/passes/normalize_view_copy_base_pass.py +62 -0
- executorch/exir/passes/pass_registry.py +89 -0
- executorch/exir/passes/propagate_device_config.py +133 -0
- executorch/exir/passes/propagate_device_pass.py +890 -0
- executorch/exir/passes/prune_empty_tensors_pass.py +68 -0
- executorch/exir/passes/quant_fusion_pass.py +174 -0
- executorch/exir/passes/quantize_io_pass.py +414 -0
- executorch/exir/passes/reinplace.py +532 -0
- executorch/exir/passes/remove_graph_asserts_pass.py +62 -0
- executorch/exir/passes/remove_mixed_type_operators.py +116 -0
- executorch/exir/passes/remove_noop_pass.py +128 -0
- executorch/exir/passes/remove_unused_parameters_pass.py +55 -0
- executorch/exir/passes/replace_aten_with_edge_pass.py +59 -0
- executorch/exir/passes/replace_broken_ops_with_function_ops_pass.py +42 -0
- executorch/exir/passes/replace_edge_with_backend_pass.py +56 -0
- executorch/exir/passes/replace_sym_size_op_pass.py +35 -0
- executorch/exir/passes/replace_view_copy_with_view_pass.py +516 -0
- executorch/exir/passes/scalar_to_tensor_pass.py +44 -0
- executorch/exir/passes/spec_prop_pass.py +136 -0
- executorch/exir/passes/sym_shape_eval_pass.py +289 -0
- executorch/exir/passes/sym_to_tensor_pass.py +64 -0
- executorch/exir/passes/to_device_pass.py +45 -0
- executorch/exir/passes/weights_to_outputs_pass.py +88 -0
- executorch/exir/print_program.py +435 -0
- executorch/exir/program/__init__.py +32 -0
- executorch/exir/program/_fake_program.py +67 -0
- executorch/exir/program/_program.py +2056 -0
- executorch/exir/program/test/__init__.py +0 -0
- executorch/exir/scalar_type.py +38 -0
- executorch/exir/schema.py +337 -0
- executorch/exir/serde/__init__.py +0 -0
- executorch/exir/serde/export_serialize.py +2897 -0
- executorch/exir/serde/schema.py +418 -0
- executorch/exir/serde/schema_check.py +293 -0
- executorch/exir/serde/serialize.py +859 -0
- executorch/exir/serde/union.py +77 -0
- executorch/exir/sym_util.py +105 -0
- executorch/exir/tensor.py +480 -0
- executorch/exir/tensor_layout.py +39 -0
- executorch/exir/tests/common.py +96 -0
- executorch/exir/tests/control_flow_models.py +105 -0
- executorch/exir/tests/dynamic_shape_models.py +51 -0
- executorch/exir/tests/models.py +576 -0
- executorch/exir/tests/test_memory_format_ops_pass_utils.py +266 -0
- executorch/exir/tests/transformer.py +122 -0
- executorch/exir/tracer.py +828 -0
- executorch/exir/types.py +18 -0
- executorch/exir/verification/arg_validator.py +148 -0
- executorch/exir/verification/dev_html.py +68 -0
- executorch/exir/verification/interpreter.py +425 -0
- executorch/exir/verification/verifier.py +372 -0
- executorch/exir/version.py +17 -0
- executorch/exir/wrap.py +32 -0
- executorch/export/__init__.py +40 -0
- executorch/export/export.py +759 -0
- executorch/export/huggingface/__init__.py +7 -0
- executorch/export/huggingface/diffusers/__init__.py +11 -0
- executorch/export/huggingface/diffusers/backends.py +68 -0
- executorch/export/huggingface/diffusers/config.py +88 -0
- executorch/export/huggingface/diffusers/export.py +296 -0
- executorch/export/huggingface/diffusers/pipeline_discovery.py +109 -0
- executorch/export/huggingface/diffusers/pipeline_specs/__init__.py +31 -0
- executorch/export/huggingface/diffusers/pipeline_specs/_stable_diffusion.py +85 -0
- executorch/export/huggingface/diffusers/pipeline_specs/base.py +118 -0
- executorch/export/huggingface/diffusers/pipeline_specs/sd15.py +169 -0
- executorch/export/huggingface/diffusers/pipeline_specs/sdxl.py +190 -0
- executorch/export/huggingface/diffusers/wrappers.py +226 -0
- executorch/export/recipe.py +721 -0
- executorch/export/recipe_provider.py +60 -0
- executorch/export/recipe_registry.py +86 -0
- executorch/export/stages.py +932 -0
- executorch/export/target_recipes.py +203 -0
- executorch/export/types.py +22 -0
- executorch/export/utils.py +63 -0
- executorch/extension/apple/ExecuTorch/__tests__/resources/generate_coreml_test_models.py +81 -0
- executorch/extension/audio/mel_spectrogram.py +332 -0
- executorch/extension/diffusers/__init__.py +19 -0
- executorch/extension/diffusers/metadata.py +147 -0
- executorch/extension/diffusers/pipeline_behaviors/__init__.py +23 -0
- executorch/extension/diffusers/pipeline_behaviors/_stable_diffusion.py +80 -0
- executorch/extension/diffusers/pipeline_behaviors/base.py +147 -0
- executorch/extension/diffusers/pipeline_behaviors/sd15.py +50 -0
- executorch/extension/diffusers/pipeline_behaviors/sdxl.py +57 -0
- executorch/extension/diffusers/runner.py +473 -0
- executorch/extension/diffusers/test/__init__.py +7 -0
- executorch/extension/export_util/__init__.py +13 -0
- executorch/extension/export_util/utils.py +154 -0
- executorch/extension/flat_tensor/__init__.py +0 -0
- executorch/extension/flat_tensor/serialize/__init__.py +0 -0
- executorch/extension/flat_tensor/serialize/flat_tensor.fbs +73 -0
- executorch/extension/flat_tensor/serialize/flat_tensor_schema.py +34 -0
- executorch/extension/flat_tensor/serialize/scalar_type.fbs +43 -0
- executorch/extension/flat_tensor/serialize/serialize.py +429 -0
- executorch/extension/gguf_util/convert_main.py +53 -0
- executorch/extension/gguf_util/converter.py +27 -0
- executorch/extension/gguf_util/converters/llama_converter.py +123 -0
- executorch/extension/gguf_util/load_gguf.py +103 -0
- executorch/extension/image/benchmark/compare_benchmarks.py +122 -0
- executorch/extension/llm/batching/sampler.py +118 -0
- executorch/extension/llm/cache/__init__.py +0 -0
- executorch/extension/llm/cache/reference_cache.py +871 -0
- executorch/extension/llm/cache/test_update_and_attend.py +1186 -0
- executorch/extension/llm/cache/update_and_attend.py +120 -0
- executorch/extension/llm/custom_ops/__init__.py +0 -0
- executorch/extension/llm/custom_ops/bench_gated_delta_rule.py +104 -0
- executorch/extension/llm/custom_ops/custom_ops.py +695 -0
- executorch/extension/llm/custom_ops/custom_ops_aot_lib.dll +0 -0
- executorch/extension/llm/custom_ops/model_sharding.py +130 -0
- executorch/extension/llm/custom_ops/op_fallback.py +29 -0
- executorch/extension/llm/custom_ops/op_tile_crop_aot.py +54 -0
- executorch/extension/llm/custom_ops/preprocess_custom_ops.py +69 -0
- executorch/extension/llm/custom_ops/spinquant/special_hadamard_code_gen.py +279 -0
- executorch/extension/llm/custom_ops/test_gated_delta.py +574 -0
- executorch/extension/llm/custom_ops/test_preprocess_custom_ops.py +34 -0
- executorch/extension/llm/custom_ops/test_quantized_moe.py +705 -0
- executorch/extension/llm/custom_ops/test_quantized_sdpa.py +550 -0
- executorch/extension/llm/custom_ops/test_sdpa_with_kv_cache.py +685 -0
- executorch/extension/llm/custom_ops/test_update_cache.py +433 -0
- executorch/extension/llm/custom_ops/test_update_cross_attn_cache.py +286 -0
- executorch/extension/llm/export/__init__.py +29 -0
- executorch/extension/llm/export/builder.py +600 -0
- executorch/extension/llm/export/config/llm_config.py +973 -0
- executorch/extension/llm/export/export_llm.py +106 -0
- executorch/extension/llm/export/export_passes.py +202 -0
- executorch/extension/llm/export/gguf.py +577 -0
- executorch/extension/llm/export/int4.py +193 -0
- executorch/extension/llm/export/load.py +329 -0
- executorch/extension/llm/export/model_metadata.py +118 -0
- executorch/extension/llm/export/mx.py +244 -0
- executorch/extension/llm/export/nvfp4.py +213 -0
- executorch/extension/llm/export/partitioner_lib.py +289 -0
- executorch/extension/llm/export/quant/__init__.py +20 -0
- executorch/extension/llm/export/quant/convert.py +247 -0
- executorch/extension/llm/export/quant/quantize.py +386 -0
- executorch/extension/llm/export/quant/recipe.py +62 -0
- executorch/extension/llm/export/quantize.py +286 -0
- executorch/extension/llm/export/quantizer_lib.py +443 -0
- executorch/extension/llm/export/test/__init__.py +0 -0
- executorch/extension/llm/export/test/test_gguf.py +409 -0
- executorch/extension/llm/export/test_export_passes.py +209 -0
- executorch/extension/llm/modules/__init__.py +24 -0
- executorch/extension/llm/modules/_position_embeddings.py +729 -0
- executorch/extension/llm/modules/attention.py +413 -0
- executorch/extension/llm/modules/kv_cache.py +151 -0
- executorch/extension/llm/modules/test/__init__.py +0 -0
- executorch/extension/llm/modules/turboquant/__init__.py +11 -0
- executorch/extension/llm/modules/turboquant/codebook.py +124 -0
- executorch/extension/llm/modules/turboquant/kv_cache.py +170 -0
- executorch/extension/llm/runner/__init__.py +267 -0
- executorch/extension/llm/runner/_llm_runner.pyi +606 -0
- executorch/extension/pybindings/_C.cp315-win_amd64.pyd +0 -0
- executorch/extension/pybindings/_C.pyi +486 -0
- executorch/extension/pybindings/data_loader.cp315-win_amd64.pyd +0 -0
- executorch/extension/pybindings/data_loader.pyi +12 -0
- executorch/extension/pybindings/portable_lib.py +159 -0
- executorch/extension/pybindings/py.typed +0 -0
- executorch/extension/pybindings/pybindings.pyi +486 -0
- executorch/extension/pybindings/test/make_test.py +237 -0
- executorch/extension/pybindings/test/test_pybindings.py +4062 -0
- executorch/extension/pytree/__init__.py +54 -0
- executorch/extension/training/__init__.py +22 -0
- executorch/extension/training/examples/CIFAR/data_utils.py +389 -0
- executorch/extension/training/examples/CIFAR/export.py +220 -0
- executorch/extension/training/examples/CIFAR/main.py +188 -0
- executorch/extension/training/examples/CIFAR/model.py +73 -0
- executorch/extension/training/examples/CIFAR/train_utils.py +622 -0
- executorch/extension/training/examples/XOR/export_model.py +77 -0
- executorch/extension/training/examples/XOR/model.py +34 -0
- executorch/extension/training/pybindings/_training_lib.pyi +45 -0
- executorch/extension/training/pybindings/_training_module.py +86 -0
- executorch/include/executorch/devtools/etdump/data_sinks/buffer_data_sink.h +127 -0
- executorch/include/executorch/devtools/etdump/data_sinks/data_sink_base.h +61 -0
- executorch/include/executorch/devtools/etdump/data_sinks/file_data_sink.h +95 -0
- executorch/include/executorch/devtools/etdump/emitter.h +28 -0
- executorch/include/executorch/devtools/etdump/etdump_flatcc.h +213 -0
- executorch/include/executorch/devtools/etdump/utils.h +39 -0
- executorch/include/executorch/extension/data_loader/buffer_data_loader.h +89 -0
- executorch/include/executorch/extension/data_loader/file_data_loader.h +114 -0
- executorch/include/executorch/extension/data_loader/mman.h +140 -0
- executorch/include/executorch/extension/data_loader/mman_windows.h +75 -0
- executorch/include/executorch/extension/data_loader/mmap_data_loader.h +149 -0
- executorch/include/executorch/extension/data_loader/shared_ptr_data_loader.h +89 -0
- executorch/include/executorch/extension/flat_tensor/flat_tensor_data_map.h +142 -0
- executorch/include/executorch/extension/flat_tensor/serialize/flat_tensor_header.h +90 -0
- executorch/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +260 -0
- executorch/include/executorch/extension/kernel_util/meta_programming.h +119 -0
- executorch/include/executorch/extension/kernel_util/type_list.h +145 -0
- executorch/include/executorch/extension/memory_allocator/malloc_memory_allocator.h +94 -0
- executorch/include/executorch/extension/memory_allocator/memory_allocator_utils.h +39 -0
- executorch/include/executorch/extension/module/module.h +810 -0
- executorch/include/executorch/extension/module/ptn_module.h +109 -0
- executorch/include/executorch/extension/named_data_map/merged_data_map.h +118 -0
- executorch/include/executorch/extension/tensor/tensor.h +14 -0
- executorch/include/executorch/extension/tensor/tensor_accessor.h +218 -0
- executorch/include/executorch/extension/tensor/tensor_ptr.h +650 -0
- executorch/include/executorch/extension/tensor/tensor_ptr_maker.h +811 -0
- executorch/include/executorch/extension/threadpool/threadpool_guard.h +37 -0
- executorch/include/executorch/runtime/backend/backend_execution_context.h +107 -0
- executorch/include/executorch/runtime/backend/backend_init_context.h +149 -0
- executorch/include/executorch/runtime/backend/backend_option_context.h +34 -0
- executorch/include/executorch/runtime/backend/backend_options_map.h +229 -0
- executorch/include/executorch/runtime/backend/interface.h +238 -0
- executorch/include/executorch/runtime/backend/options.h +208 -0
- executorch/include/executorch/runtime/core/array_ref.h +264 -0
- executorch/include/executorch/runtime/core/data_loader.h +206 -0
- executorch/include/executorch/runtime/core/defines.h +20 -0
- executorch/include/executorch/runtime/core/device_allocator.h +215 -0
- executorch/include/executorch/runtime/core/device_memory_buffer.h +129 -0
- executorch/include/executorch/runtime/core/error.h +264 -0
- executorch/include/executorch/runtime/core/evalue.h +877 -0
- executorch/include/executorch/runtime/core/event_tracer.h +592 -0
- executorch/include/executorch/runtime/core/event_tracer_hooks.h +340 -0
- executorch/include/executorch/runtime/core/event_tracer_hooks_delegate.h +204 -0
- executorch/include/executorch/runtime/core/exec_aten/exec_aten.h +208 -0
- executorch/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +290 -0
- executorch/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1430 -0
- executorch/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +23 -0
- executorch/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +68 -0
- executorch/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1428 -0
- executorch/include/executorch/runtime/core/freeable_buffer.h +281 -0
- executorch/include/executorch/runtime/core/function_ref.h +108 -0
- executorch/include/executorch/runtime/core/hierarchical_allocator.h +167 -0
- executorch/include/executorch/runtime/core/memory_allocator.h +249 -0
- executorch/include/executorch/runtime/core/named_data_map.h +76 -0
- executorch/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
- executorch/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
- executorch/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +3 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +8 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +73 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +441 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +1 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +3 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +906 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +11 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +112 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +145 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +830 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16-math.h +337 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +481 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/Half.h +788 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/TypeSafeSignMath.h +100 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/bit_cast.h +50 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex.h +676 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex_utils.h +48 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/floating_point_utils.h +38 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/irange.h +137 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/overflows.h +120 -0
- executorch/include/executorch/runtime/core/portable_type/complex.h +21 -0
- executorch/include/executorch/runtime/core/portable_type/device.h +85 -0
- executorch/include/executorch/runtime/core/portable_type/half.h +27 -0
- executorch/include/executorch/runtime/core/portable_type/optional.h +37 -0
- executorch/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
- executorch/include/executorch/runtime/core/portable_type/scalar.h +123 -0
- executorch/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
- executorch/include/executorch/runtime/core/portable_type/string_view.h +31 -0
- executorch/include/executorch/runtime/core/portable_type/tensor.h +190 -0
- executorch/include/executorch/runtime/core/portable_type/tensor_impl.h +345 -0
- executorch/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
- executorch/include/executorch/runtime/core/result.h +333 -0
- executorch/include/executorch/runtime/core/span.h +110 -0
- executorch/include/executorch/runtime/core/tag.h +90 -0
- executorch/include/executorch/runtime/core/tensor_layout.h +93 -0
- executorch/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
- executorch/include/executorch/runtime/executor/memory_manager.h +149 -0
- executorch/include/executorch/runtime/executor/merged_data_map.h +150 -0
- executorch/include/executorch/runtime/executor/method.h +466 -0
- executorch/include/executorch/runtime/executor/method_meta.h +338 -0
- executorch/include/executorch/runtime/executor/platform_memory_allocator.h +125 -0
- executorch/include/executorch/runtime/executor/program.h +365 -0
- executorch/include/executorch/runtime/executor/program_validation.h +51 -0
- executorch/include/executorch/runtime/executor/pte_data_map.h +151 -0
- executorch/include/executorch/runtime/kernel/kernel_includes.h +62 -0
- executorch/include/executorch/runtime/kernel/kernel_runtime_context.h +131 -0
- executorch/include/executorch/runtime/kernel/operator_registry.h +308 -0
- executorch/include/executorch/runtime/kernel/thread_parallel_interface.h +121 -0
- executorch/include/executorch/runtime/platform/abort.h +36 -0
- executorch/include/executorch/runtime/platform/assert.h +124 -0
- executorch/include/executorch/runtime/platform/clock.h +43 -0
- executorch/include/executorch/runtime/platform/compat_unistd.h +75 -0
- executorch/include/executorch/runtime/platform/compiler.h +254 -0
- executorch/include/executorch/runtime/platform/log.h +216 -0
- executorch/include/executorch/runtime/platform/platform.h +276 -0
- executorch/include/executorch/runtime/platform/profiler.h +293 -0
- executorch/include/executorch/runtime/platform/runtime.h +35 -0
- executorch/include/executorch/runtime/platform/system.h +49 -0
- executorch/include/executorch/runtime/platform/types.h +24 -0
- executorch/kernels/portable/__init__.py +26 -0
- executorch/kernels/portable/custom_ops.yaml +32 -0
- executorch/kernels/portable/et_copy_ops.yaml +16 -0
- executorch/kernels/portable/functions.yaml +1096 -0
- executorch/kernels/portable/test/supported_features_def.yaml +1 -0
- executorch/kernels/quantized/__init__.py +36 -0
- executorch/kernels/quantized/quantized.yaml +113 -0
- executorch/kernels/quantized/quantized_ops_aot_lib.dll +0 -0
- executorch/kernels/quantized/test/supported_features_def.yaml +1 -0
- executorch/lib/cmake/executorch/executorch-config-version.cmake +60 -0
- executorch/lib/cmake/executorch/executorch-config.cmake +1056 -0
- executorch/lib/executorch.dll +0 -0
- executorch/lib/executorch.lib +0 -0
- executorch/lib/executorch_backend_openvino.dll +0 -0
- executorch/lib/executorch_backend_openvino.lib +0 -0
- executorch/lib/executorch_backend_xnnpack.dll +0 -0
- executorch/lib/executorch_backend_xnnpack.lib +0 -0
- executorch/lib/executorch_etdump.dll +0 -0
- executorch/lib/executorch_kernels_optimized.dll +0 -0
- executorch/lib/executorch_kernels_optimized.lib +0 -0
- executorch/lib/executorch_kernels_quantized.dll +0 -0
- executorch/lib/executorch_kernels_quantized.lib +0 -0
- executorch/lib/executorch_threadpool.dll +0 -0
- executorch/lib/executorch_threadpool.lib +0 -0
- executorch/runtime/__init__.py +390 -0
- executorch/runtime/cuda.py +222 -0
- executorch/runtime/kernel/test/functions.yaml +13 -0
- executorch/schema/program.fbs +551 -0
- executorch/schema/scalar_type.fbs +43 -0
- executorch/share/cmake/executorch-config-version.cmake +60 -0
- executorch/share/cmake/executorch-config.cmake +1056 -0
- executorch/util/activation_memory_profiler.py +177 -0
- executorch/util/collect_env.py +748 -0
- executorch/util/python_profiler.py +96 -0
- executorch/version.py +4 -0
- executorch-1.6.0.dist-info/METADATA +123 -0
- executorch-1.6.0.dist-info/RECORD +3166 -0
- executorch-1.6.0.dist-info/WHEEL +5 -0
- executorch-1.6.0.dist-info/entry_points.txt +2 -0
- executorch-1.6.0.dist-info/licenses/LICENSE +37 -0
- executorch-1.6.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,3533 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
# pyre-strict
|
|
8
|
+
|
|
9
|
+
from math import ceil, prod
|
|
10
|
+
from typing import Callable, Optional, Tuple
|
|
11
|
+
|
|
12
|
+
import torch
|
|
13
|
+
from executorch.backends.cadence.aot.utils import (
|
|
14
|
+
get_conv1d_output_size,
|
|
15
|
+
get_conv2d_output_size,
|
|
16
|
+
get_im2row_output_size,
|
|
17
|
+
is_depthwise_conv,
|
|
18
|
+
)
|
|
19
|
+
from executorch.exir.scalar_type import ScalarType
|
|
20
|
+
from torch._meta_registrations import _linalg_svd_meta
|
|
21
|
+
from torch.library import Library, register_fake
|
|
22
|
+
|
|
23
|
+
lib = Library("cadence", "DEF")
|
|
24
|
+
|
|
25
|
+
# Track meta kernels that have been registered
|
|
26
|
+
_REGISTERED_META_KERNELS: set[str] = set()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Original register_fake function to use for registrations
|
|
30
|
+
_register_fake_original = register_fake
|
|
31
|
+
|
|
32
|
+
_OUTPUTS_TYPE = torch.Tensor | tuple[torch.Tensor, ...]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _validate_ref_impl_exists() -> None:
|
|
36
|
+
"""
|
|
37
|
+
Validates that all registered meta kernels have corresponding reference implementations.
|
|
38
|
+
This is called at module initialization time after both files have been imported.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
# Import here after module initialization to ensure ref_implementations has been loaded
|
|
42
|
+
from executorch.backends.cadence.aot.ref_implementations import (
|
|
43
|
+
get_registered_ref_implementations,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# If reference implementation should not be in
|
|
47
|
+
# executorch.backends.cadence.aot.ref_implementations, add here
|
|
48
|
+
_SKIP_OPS = {
|
|
49
|
+
"cadence::roi_align_box_processor",
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ref_impls = get_registered_ref_implementations()
|
|
53
|
+
error_impls = []
|
|
54
|
+
for op_name in _REGISTERED_META_KERNELS:
|
|
55
|
+
# Strip the namespace prefix if present (e.g., "cadence::" -> "")
|
|
56
|
+
op_name_clean = op_name.split("::")[-1] if "::" in op_name else op_name
|
|
57
|
+
|
|
58
|
+
if op_name_clean not in ref_impls:
|
|
59
|
+
if op_name not in _SKIP_OPS:
|
|
60
|
+
error_impls.append(op_name)
|
|
61
|
+
|
|
62
|
+
if error_impls:
|
|
63
|
+
error_msg = (
|
|
64
|
+
f"The following {len(error_impls)} meta kernel registrations are missing reference implementations:\n"
|
|
65
|
+
+ "\n".join(f" - {op}" for op in error_impls)
|
|
66
|
+
+ "\n\nPlease add reference implementations in ref_implementations.py using "
|
|
67
|
+
+ "@impl_tracked(m, '<op_name>')."
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
raise RuntimeError(error_msg)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Wrap register_fake to track all registrations
|
|
74
|
+
def register_fake(
|
|
75
|
+
op_name: str,
|
|
76
|
+
) -> Callable[[Callable[..., _OUTPUTS_TYPE]], Callable[..., _OUTPUTS_TYPE]]:
|
|
77
|
+
"""
|
|
78
|
+
Wrapped version of register_fake that tracks all meta kernel registrations.
|
|
79
|
+
This enables validation that all meta kernels have reference implementations.
|
|
80
|
+
"""
|
|
81
|
+
global _REGISTERED_META_KERNELS
|
|
82
|
+
_REGISTERED_META_KERNELS.add(op_name)
|
|
83
|
+
return _register_fake_original(op_name)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
lib.define(
|
|
87
|
+
"quantize_per_tensor(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
88
|
+
)
|
|
89
|
+
lib.define(
|
|
90
|
+
"quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
lib.define(
|
|
94
|
+
"quantize_per_tensor_asym8s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
95
|
+
)
|
|
96
|
+
lib.define(
|
|
97
|
+
"quantize_per_tensor_asym8s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
lib.define(
|
|
101
|
+
"quantize_per_tensor_asym8u(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
102
|
+
)
|
|
103
|
+
lib.define(
|
|
104
|
+
"quantize_per_tensor_asym8u.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
lib.define(
|
|
108
|
+
"quantize_per_tensor_asym16s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
109
|
+
)
|
|
110
|
+
lib.define(
|
|
111
|
+
"quantize_per_tensor_asym16s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
lib.define(
|
|
115
|
+
"quantize_per_tensor_asym16u(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
116
|
+
)
|
|
117
|
+
lib.define(
|
|
118
|
+
"quantize_per_tensor_asym16u.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
lib.define(
|
|
122
|
+
"quantize_per_tensor_asym32s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
123
|
+
)
|
|
124
|
+
lib.define(
|
|
125
|
+
"quantize_per_tensor_asym32s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
lib.define(
|
|
129
|
+
"dequantize_per_tensor(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
130
|
+
)
|
|
131
|
+
lib.define(
|
|
132
|
+
"dequantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
133
|
+
)
|
|
134
|
+
lib.define(
|
|
135
|
+
"dequantize_per_tensor_asym8s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
136
|
+
)
|
|
137
|
+
lib.define(
|
|
138
|
+
"dequantize_per_tensor_asym8s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
139
|
+
)
|
|
140
|
+
lib.define(
|
|
141
|
+
"dequantize_per_tensor_asym8u(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
142
|
+
)
|
|
143
|
+
lib.define(
|
|
144
|
+
"dequantize_per_tensor_asym8u.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
145
|
+
)
|
|
146
|
+
lib.define(
|
|
147
|
+
"dequantize_per_tensor_asym16s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
148
|
+
)
|
|
149
|
+
lib.define(
|
|
150
|
+
"dequantize_per_tensor_asym16s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
151
|
+
)
|
|
152
|
+
lib.define(
|
|
153
|
+
"dequantize_per_tensor_asym16u(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
154
|
+
)
|
|
155
|
+
lib.define(
|
|
156
|
+
"dequantize_per_tensor_asym16u.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
lib.define(
|
|
160
|
+
"dequantize_per_tensor_asym32s(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype) -> (Tensor Z)"
|
|
161
|
+
)
|
|
162
|
+
lib.define(
|
|
163
|
+
"dequantize_per_tensor_asym32s.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
lib.define(
|
|
167
|
+
"quantized_layer_norm(Tensor X, Tensor X_scale, Tensor X_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point) -> (Tensor Y)"
|
|
168
|
+
)
|
|
169
|
+
lib.define(
|
|
170
|
+
"quantized_layer_norm.out(Tensor X, Tensor X_scale, Tensor X_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point, *, Tensor(a!) out) -> Tensor (a!)"
|
|
171
|
+
)
|
|
172
|
+
lib.define(
|
|
173
|
+
"quantized_layer_norm.per_tensor(Tensor X, float X_scale, int X_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point) -> (Tensor Y)"
|
|
174
|
+
)
|
|
175
|
+
lib.define(
|
|
176
|
+
"quantized_layer_norm.per_tensor_out(Tensor X, float X_scale, int X_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point, *, Tensor(a!) out) -> Tensor (a!)"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
lib.define(
|
|
180
|
+
"quantized_linear(Tensor src, Tensor weight, Tensor bias, int src_zero_point, Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
181
|
+
)
|
|
182
|
+
lib.define(
|
|
183
|
+
"quantized_linear.out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
184
|
+
)
|
|
185
|
+
lib.define(
|
|
186
|
+
"quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
187
|
+
)
|
|
188
|
+
lib.define(
|
|
189
|
+
"quantized_linear_asym8sxasym8s_asym8s.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
190
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
191
|
+
)
|
|
192
|
+
lib.define(
|
|
193
|
+
"quantized_linear_asym8uxasym8u_asym8u.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
194
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
195
|
+
)
|
|
196
|
+
lib.define(
|
|
197
|
+
"quantized_linear.per_tensor(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, "
|
|
198
|
+
"SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset) -> Tensor"
|
|
199
|
+
)
|
|
200
|
+
lib.define(
|
|
201
|
+
"quantized_linear_asym8sxasym8s_asym8s.per_tensor(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
202
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
203
|
+
)
|
|
204
|
+
lib.define(
|
|
205
|
+
"quantized_linear_asym8uxasym8u_asym8u.per_tensor(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
206
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
lib.define(
|
|
210
|
+
"quantized_relu(Tensor X, Tensor X_zero_point, int out_zero_point, Tensor out_multiplier, Tensor out_shift) -> (Tensor Y)"
|
|
211
|
+
)
|
|
212
|
+
lib.define(
|
|
213
|
+
"quantized_relu.out(Tensor X, Tensor X_zero_point, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor (a!)"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
lib.define(
|
|
217
|
+
"quantized_max_pool2d_nchw(Tensor input, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> Tensor"
|
|
218
|
+
)
|
|
219
|
+
lib.define(
|
|
220
|
+
"quantized_max_pool2d_nchw.out(Tensor input, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode, *, Tensor(a!) out) -> Tensor(a!)"
|
|
221
|
+
)
|
|
222
|
+
lib.define(
|
|
223
|
+
"quantized_max_pool2d_nhwc(Tensor input, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> Tensor"
|
|
224
|
+
)
|
|
225
|
+
lib.define(
|
|
226
|
+
"quantized_max_pool2d_nhwc.out(Tensor input, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode, *, Tensor(a!) out) -> Tensor(a!)"
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
lib.define(
|
|
230
|
+
"quantized_conv2d_nhwc(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)"
|
|
231
|
+
)
|
|
232
|
+
lib.define(
|
|
233
|
+
"quantized_conv2d_nhwc.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!)"
|
|
234
|
+
)
|
|
235
|
+
lib.define(
|
|
236
|
+
"quantized_conv2d_nhwc.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? offset=None) -> (Tensor Z)"
|
|
237
|
+
)
|
|
238
|
+
lib.define(
|
|
239
|
+
"quantized_conv2d_nhwc.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? offset=None, *, Tensor(a!) out) -> Tensor(a!)"
|
|
240
|
+
)
|
|
241
|
+
lib.define(
|
|
242
|
+
"quantized_conv2d_depthwise_nhwc(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)"
|
|
243
|
+
)
|
|
244
|
+
lib.define(
|
|
245
|
+
"quantized_conv2d_depthwise_nhwc.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!)"
|
|
246
|
+
)
|
|
247
|
+
lib.define(
|
|
248
|
+
"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)"
|
|
249
|
+
)
|
|
250
|
+
lib.define(
|
|
251
|
+
"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!)"
|
|
252
|
+
)
|
|
253
|
+
lib.define(
|
|
254
|
+
"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)"
|
|
255
|
+
)
|
|
256
|
+
lib.define(
|
|
257
|
+
"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!)"
|
|
258
|
+
)
|
|
259
|
+
lib.define(
|
|
260
|
+
"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)"
|
|
261
|
+
)
|
|
262
|
+
lib.define(
|
|
263
|
+
"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!)"
|
|
264
|
+
)
|
|
265
|
+
lib.define(
|
|
266
|
+
"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? offset=None) -> (Tensor Z)"
|
|
267
|
+
)
|
|
268
|
+
lib.define(
|
|
269
|
+
"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? offset=None, *, Tensor(a!) out) -> Tensor(a!)"
|
|
270
|
+
)
|
|
271
|
+
lib.define(
|
|
272
|
+
"quantized_depthwise_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)"
|
|
273
|
+
)
|
|
274
|
+
lib.define(
|
|
275
|
+
"quantized_depthwise_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!)"
|
|
276
|
+
)
|
|
277
|
+
lib.define(
|
|
278
|
+
"quantized_depthwise_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)"
|
|
279
|
+
)
|
|
280
|
+
lib.define(
|
|
281
|
+
"quantized_depthwise_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!)"
|
|
282
|
+
)
|
|
283
|
+
lib.define(
|
|
284
|
+
"quantized_depthwise_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)"
|
|
285
|
+
)
|
|
286
|
+
lib.define(
|
|
287
|
+
"quantized_depthwise_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!)"
|
|
288
|
+
)
|
|
289
|
+
lib.define(
|
|
290
|
+
"quantized_depthwise_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)"
|
|
291
|
+
)
|
|
292
|
+
lib.define(
|
|
293
|
+
"quantized_depthwise_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!)"
|
|
294
|
+
)
|
|
295
|
+
lib.define(
|
|
296
|
+
"quantized_conv2d_nchw(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)"
|
|
297
|
+
)
|
|
298
|
+
lib.define(
|
|
299
|
+
"quantized_conv2d_nchw.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!)"
|
|
300
|
+
)
|
|
301
|
+
lib.define(
|
|
302
|
+
"quantized_conv2d_nchw.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)"
|
|
303
|
+
)
|
|
304
|
+
lib.define(
|
|
305
|
+
"quantized_conv2d_nchw.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!)"
|
|
306
|
+
)
|
|
307
|
+
lib.define(
|
|
308
|
+
"quantized_matmul(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)"
|
|
309
|
+
)
|
|
310
|
+
lib.define(
|
|
311
|
+
"quantized_matmul.out(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(a!) out) -> Tensor(a!)"
|
|
312
|
+
)
|
|
313
|
+
lib.define(
|
|
314
|
+
"quantized_matmul_asym8sxasym8s_asym8s(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)"
|
|
315
|
+
)
|
|
316
|
+
lib.define(
|
|
317
|
+
"quantized_matmul_asym8sxasym8s_asym8s.out(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(a!) out) -> Tensor(a!)"
|
|
318
|
+
)
|
|
319
|
+
lib.define(
|
|
320
|
+
"quantized_conv2d_nchw_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)"
|
|
321
|
+
)
|
|
322
|
+
lib.define(
|
|
323
|
+
"quantized_conv2d_nchw_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!)"
|
|
324
|
+
)
|
|
325
|
+
lib.define(
|
|
326
|
+
"quantized_conv2d_nchw_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)"
|
|
327
|
+
)
|
|
328
|
+
lib.define(
|
|
329
|
+
"quantized_conv2d_nchw_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!)"
|
|
330
|
+
)
|
|
331
|
+
lib.define(
|
|
332
|
+
"quantized_conv2d_nhwc_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)"
|
|
333
|
+
)
|
|
334
|
+
lib.define(
|
|
335
|
+
"quantized_conv2d_nhwc_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!)"
|
|
336
|
+
)
|
|
337
|
+
lib.define(
|
|
338
|
+
"quantized_conv2d_nhwc_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)"
|
|
339
|
+
)
|
|
340
|
+
lib.define(
|
|
341
|
+
"quantized_conv2d_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!)"
|
|
342
|
+
)
|
|
343
|
+
lib.define(
|
|
344
|
+
"quantized_conv2d_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)"
|
|
345
|
+
)
|
|
346
|
+
lib.define(
|
|
347
|
+
"quantized_conv2d_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!)"
|
|
348
|
+
)
|
|
349
|
+
lib.define(
|
|
350
|
+
"quantized_conv2d_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)"
|
|
351
|
+
)
|
|
352
|
+
lib.define(
|
|
353
|
+
"quantized_conv2d_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!)"
|
|
354
|
+
)
|
|
355
|
+
lib.define(
|
|
356
|
+
"quantized_conv2d_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)"
|
|
357
|
+
)
|
|
358
|
+
lib.define(
|
|
359
|
+
"quantized_conv2d_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!)"
|
|
360
|
+
)
|
|
361
|
+
lib.define(
|
|
362
|
+
"quantized_conv2d_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)"
|
|
363
|
+
)
|
|
364
|
+
lib.define(
|
|
365
|
+
"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!)"
|
|
366
|
+
)
|
|
367
|
+
lib.define(
|
|
368
|
+
"quantized_conv2d_nchw_depthwise_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)"
|
|
369
|
+
)
|
|
370
|
+
lib.define(
|
|
371
|
+
"quantized_conv2d_nchw_depthwise_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!)"
|
|
372
|
+
)
|
|
373
|
+
lib.define(
|
|
374
|
+
"quantized_conv2d_nchw_depthwise_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)"
|
|
375
|
+
)
|
|
376
|
+
lib.define(
|
|
377
|
+
"quantized_conv2d_nchw_depthwise_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!)"
|
|
378
|
+
)
|
|
379
|
+
lib.define(
|
|
380
|
+
"quantized_conv2d_nhwc_depthwise_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)"
|
|
381
|
+
)
|
|
382
|
+
lib.define(
|
|
383
|
+
"quantized_conv2d_nhwc_depthwise_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!)"
|
|
384
|
+
)
|
|
385
|
+
lib.define(
|
|
386
|
+
"quantized_conv2d_nhwc_depthwise_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)"
|
|
387
|
+
)
|
|
388
|
+
lib.define(
|
|
389
|
+
"quantized_conv2d_nhwc_depthwise_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!)"
|
|
390
|
+
)
|
|
391
|
+
lib.define(
|
|
392
|
+
"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)"
|
|
393
|
+
)
|
|
394
|
+
lib.define(
|
|
395
|
+
"quantized_matmul_asym8uxasym8u_asym8u.out(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(a!) out) -> Tensor(a!)"
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
lib.define(
|
|
399
|
+
"transposed_convolution(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, "
|
|
400
|
+
"int[] dilation, SymInt[] output_padding, int groups, bool channel_last=False) -> (Tensor Y)"
|
|
401
|
+
)
|
|
402
|
+
lib.define("dequantize(Tensor X, Tensor X_scale, Tensor X_zero_point) -> (Tensor Y)")
|
|
403
|
+
lib.define(
|
|
404
|
+
"quantized_add(Tensor X, Tensor X_scale, Tensor X_zero_point, Tensor Y, Tensor Y_scale, "
|
|
405
|
+
"Tensor Y_zero_point, float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
406
|
+
)
|
|
407
|
+
lib.define(
|
|
408
|
+
"quantized_add.per_tensor(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
409
|
+
"int Y_zero_point, float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
410
|
+
)
|
|
411
|
+
lib.define(
|
|
412
|
+
"quantized_mul(Tensor X, Tensor X_scale, Tensor X_zero_point, Tensor Y, Tensor Y_scale, "
|
|
413
|
+
"Tensor Y_zero_point, float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
414
|
+
)
|
|
415
|
+
lib.define(
|
|
416
|
+
"quantized_mul.per_tensor(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
417
|
+
"int Y_zero_point, float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
418
|
+
)
|
|
419
|
+
lib.define(
|
|
420
|
+
"quantized_add_Scalar(Tensor X, Tensor X_scale, Tensor X_zero_point, Scalar Y, "
|
|
421
|
+
"float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
422
|
+
)
|
|
423
|
+
lib.define(
|
|
424
|
+
"quantized_mul_Scalar(Tensor X, Tensor X_scale, Tensor X_zero_point, Scalar Y, "
|
|
425
|
+
"float out_scale, int out_zero_point) -> (Tensor Z)"
|
|
426
|
+
)
|
|
427
|
+
lib.define(
|
|
428
|
+
"quantized_embedding_byte(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, "
|
|
429
|
+
"Tensor indices, bool pruned_weights=False) -> (Tensor X)"
|
|
430
|
+
)
|
|
431
|
+
lib.define(
|
|
432
|
+
"quantized_transposed_conv(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, "
|
|
433
|
+
"int[] dilation, SymInt[] output_padding, int groups, int input_zero_point, Tensor weight_zero_point, "
|
|
434
|
+
"Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, bool channel_last=False) -> (Tensor out)"
|
|
435
|
+
)
|
|
436
|
+
lib.define(
|
|
437
|
+
"avg_pool2d(Tensor input, int[2] kernel_size, int[2] stride=[], int[2] padding=[], bool ceil_mode=False, "
|
|
438
|
+
"bool count_include_pad=True, int? divisor_override=None, Tensor? in_zero_point=None, bool channel_last=False) -> (Tensor out)"
|
|
439
|
+
)
|
|
440
|
+
lib.define(
|
|
441
|
+
"im2row(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, "
|
|
442
|
+
"Tensor in_zero_point, bool channel_last=False) -> (Tensor out)"
|
|
443
|
+
)
|
|
444
|
+
lib.define(
|
|
445
|
+
"im2row.per_tensor(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, "
|
|
446
|
+
"int in_zero_point, bool channel_last=False) -> (Tensor out)"
|
|
447
|
+
)
|
|
448
|
+
lib.define(
|
|
449
|
+
"linalg_svd(Tensor A, bool full_matrices=False, bool compute_uv=True, str? driver=None) -> (Tensor U, Tensor S, Tensor Vh)"
|
|
450
|
+
)
|
|
451
|
+
lib.define(
|
|
452
|
+
"linalg_svd.out(Tensor A, bool full_matrices=False, bool compute_uv=True, str? driver=None, *, Tensor(a!) U, Tensor(b!) S, Tensor(c!) Vh) -> (Tensor(a!) U, Tensor(b!) S, Tensor(c!) Vh)"
|
|
453
|
+
)
|
|
454
|
+
lib.define(
|
|
455
|
+
"transposed_im2row(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, "
|
|
456
|
+
"int[2] output_padding, Tensor in_zero_point, bool channel_last=False) -> (Tensor out)"
|
|
457
|
+
)
|
|
458
|
+
lib.define(
|
|
459
|
+
"requantize(Tensor input, Tensor in_scale, Tensor in_zero_point, Tensor out_scale, "
|
|
460
|
+
"Tensor out_zero_point, ScalarType out_dtype) -> (Tensor Y)"
|
|
461
|
+
)
|
|
462
|
+
lib.define(
|
|
463
|
+
"requantize.per_tensor(Tensor input, float in_scale, int in_zero_point, float out_scale, "
|
|
464
|
+
"int out_zero_point, ScalarType out_dtype) -> (Tensor Y)"
|
|
465
|
+
)
|
|
466
|
+
lib.define(
|
|
467
|
+
"fully_connected(Tensor input, Tensor weight, Tensor? bias=None) -> (Tensor out)"
|
|
468
|
+
)
|
|
469
|
+
lib.define(
|
|
470
|
+
"quantized_fully_connected(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
471
|
+
"Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
472
|
+
)
|
|
473
|
+
lib.define(
|
|
474
|
+
"quantized_fully_connected.per_tensor(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
475
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
476
|
+
)
|
|
477
|
+
lib.define(
|
|
478
|
+
"quantized_fully_connected_asym8sxasym8s_asym8s.per_tensor(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
479
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
480
|
+
)
|
|
481
|
+
lib.define(
|
|
482
|
+
"quantized_fully_connected_asym8uxasym8u_asym8u.per_tensor(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
483
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset) -> (Tensor Z)"
|
|
484
|
+
)
|
|
485
|
+
# Sub-byte weights: `weight` is a [out_dim, packed_row_bytes] int8 blob, so
|
|
486
|
+
# in_dim and the bit width can no longer be read off its shape.
|
|
487
|
+
lib.define(
|
|
488
|
+
"quantized_fully_connected_packed(Tensor src, Tensor weight, Tensor bias, int in_dim, int weight_bits, "
|
|
489
|
+
"int src_zero_point, Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, "
|
|
490
|
+
"Tensor? offset) -> (Tensor Z)"
|
|
491
|
+
)
|
|
492
|
+
lib.define("where_Scalar(Tensor condition, float self, float other) -> (Tensor Z)")
|
|
493
|
+
lib.define(
|
|
494
|
+
"where_Scalar.out(Tensor condition, float self, float other, *, Tensor(a!) out) -> Tensor(a!)"
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
lib.define(
|
|
498
|
+
"rope(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos) -> (Tensor out)"
|
|
499
|
+
)
|
|
500
|
+
lib.define(
|
|
501
|
+
"rope.out(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos, *, Tensor(a!) out) -> Tensor(a!)"
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
lib.define(
|
|
505
|
+
"rope_rotate_stacked_halves(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos) -> (Tensor out)"
|
|
506
|
+
)
|
|
507
|
+
lib.define(
|
|
508
|
+
"rope_rotate_stacked_halves.out(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos, *, Tensor(a!) out) -> Tensor(a!)"
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
lib.define(
|
|
512
|
+
"quantized_rope_rotate_stacked_halves(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos, float in_scale, int in_zero_point, float out_scale, int out_zero_point) -> (Tensor out)"
|
|
513
|
+
)
|
|
514
|
+
lib.define(
|
|
515
|
+
"quantized_rope_rotate_stacked_halves.out(Tensor input, Tensor sin_tensor, Tensor cos_tensor, Tensor? pos, float in_scale, int in_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
lib.define(
|
|
519
|
+
"quantized_softmax(Tensor input, Tensor mask, int dim, int mask_type, Tensor pos, Tensor in_scale, Tensor in_zero_point, Tensor out_scale, Tensor out_zero_point) -> (Tensor out)"
|
|
520
|
+
)
|
|
521
|
+
lib.define(
|
|
522
|
+
"quantized_softmax.per_tensor(Tensor input, Tensor mask, int dim, int mask_type, Tensor pos, float in_scale, int in_zero_point, float out_scale, int out_zero_point) -> (Tensor out)"
|
|
523
|
+
)
|
|
524
|
+
lib.define(
|
|
525
|
+
"quantized_softmax.out(Tensor input, Tensor mask, int dim, int mask_type, Tensor pos, Tensor in_scale, Tensor in_zero_point, Tensor out_scale, Tensor out_zero_point, *, Tensor(a!) out) -> Tensor (a!)"
|
|
526
|
+
)
|
|
527
|
+
lib.define(
|
|
528
|
+
"quantized_softmax.per_tensor_out(Tensor input, Tensor mask, int dim, int mask_type, Tensor pos, float in_scale, int in_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor (a!)"
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
# pack float/bool mask tensor into a bitmask of type uint8 (each element holding 8 bool mask elements)
|
|
532
|
+
lib.define("sdpa_bitwise_mask_gen(Tensor mask, float threshold) -> (Tensor out)")
|
|
533
|
+
lib.define(
|
|
534
|
+
"sdpa_bitwise_mask_gen.out(Tensor mask, float threshold, *, Tensor(a!) out) -> Tensor (a!)"
|
|
535
|
+
)
|
|
536
|
+
lib.define(
|
|
537
|
+
"sdpa_bitwise_causal_mask_gen(Tensor positions, int key_length) -> (Tensor out)"
|
|
538
|
+
)
|
|
539
|
+
lib.define(
|
|
540
|
+
"sdpa_bitwise_causal_mask_gen.out(Tensor positions, int key_length, *, Tensor(a!) out) -> Tensor(a!)"
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
lib.define(
|
|
544
|
+
"sdpa_bitwise_ring_mask_gen(Tensor positions, int sliding_window, int cache_length) -> Tensor"
|
|
545
|
+
)
|
|
546
|
+
lib.define(
|
|
547
|
+
"sdpa_bitwise_ring_mask_gen.out(Tensor positions, int sliding_window, int cache_length, *, Tensor(a!) out) -> Tensor(a!)"
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
# Load/store with iDMA. These only exist before memory planning.
|
|
551
|
+
# Post memory planning, we check that outputs/inputs for the load/store are in
|
|
552
|
+
# DTCM and replace idma_load/idma_store with idma_copy.
|
|
553
|
+
lib.define("idma_load(Tensor src, int task_num=0, int channel=0) -> Tensor")
|
|
554
|
+
lib.define(
|
|
555
|
+
"idma_load.out(Tensor src, int task_num=0, int channel=0, *, Tensor(a!) out) -> Tensor(a!)"
|
|
556
|
+
)
|
|
557
|
+
lib.define("idma_store(Tensor src, int task_num=0, int channel=0) -> Tensor")
|
|
558
|
+
lib.define(
|
|
559
|
+
"idma_store.out(Tensor src, int task_num=0, int channel=0, *, Tensor(a!) out) -> Tensor(a!)"
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
# Non-blocking iDMA copy.
|
|
563
|
+
lib.define("idma_copy(Tensor src, int task_num=0, int channel=0) -> Tensor")
|
|
564
|
+
lib.define(
|
|
565
|
+
"idma_copy.out(Tensor src, int task_num=0, int channel=0, *, Tensor(a!) out) -> Tensor(a!)"
|
|
566
|
+
)
|
|
567
|
+
# iDMA wait.
|
|
568
|
+
lib.define("idma_wait(Tensor src, int task_num=0) -> Tensor")
|
|
569
|
+
lib.define("idma_wait.out(Tensor src, int task_num=0, *, Tensor(a!) out) -> Tensor(a!)")
|
|
570
|
+
|
|
571
|
+
# ------------------------------------ #
|
|
572
|
+
# Migrated from custom_ops.yaml #
|
|
573
|
+
# ------------------------------------ #
|
|
574
|
+
# Migrated from the custom_ops.yaml files containing different operator variants (e.g., .out, .tensor_out)
|
|
575
|
+
lib.define(
|
|
576
|
+
"conv1d(Tensor input, Tensor weight, Tensor bias, int[1] stride, SymInt[1] padding, int[1] dilation, "
|
|
577
|
+
"int groups) -> Tensor"
|
|
578
|
+
)
|
|
579
|
+
lib.define(
|
|
580
|
+
"conv1d.out(Tensor input, Tensor weight, Tensor bias, int[1] stride, SymInt[1] padding, int[1] dilation, "
|
|
581
|
+
"int groups, *, Tensor(a!) out) -> Tensor(a!)"
|
|
582
|
+
)
|
|
583
|
+
lib.define(
|
|
584
|
+
"conv2d(Tensor input, Tensor weight, Tensor bias, int[2] stride, SymInt[2] padding, int[2] dilation, "
|
|
585
|
+
"int groups) -> Tensor"
|
|
586
|
+
)
|
|
587
|
+
lib.define(
|
|
588
|
+
"conv2d.out(Tensor input, Tensor weight, Tensor bias, int[2] stride, SymInt[2] padding, int[2] dilation, "
|
|
589
|
+
"int groups, *, Tensor(a!) out) -> Tensor(a!)"
|
|
590
|
+
)
|
|
591
|
+
lib.define(
|
|
592
|
+
"conv3d(Tensor input, Tensor weight, Tensor bias, int[3] stride, SymInt[3] padding, int[3] dilation, "
|
|
593
|
+
"int groups) -> Tensor"
|
|
594
|
+
)
|
|
595
|
+
lib.define(
|
|
596
|
+
"conv3d.out(Tensor input, Tensor weight, Tensor bias, int[3] stride, SymInt[3] padding, int[3] dilation, "
|
|
597
|
+
"int groups, *, Tensor(a!) out) -> Tensor(a!)"
|
|
598
|
+
)
|
|
599
|
+
lib.define(
|
|
600
|
+
"transposed_convolution.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, "
|
|
601
|
+
"int[] dilation, SymInt[] output_padding, int groups, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
602
|
+
)
|
|
603
|
+
lib.define(
|
|
604
|
+
"quantized_relu.per_tensor(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, int out_shift) -> Tensor"
|
|
605
|
+
)
|
|
606
|
+
lib.define(
|
|
607
|
+
"quantized_relu.per_tensor_out(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, "
|
|
608
|
+
"int out_shift, *, Tensor(a!) out) -> Tensor(a!)"
|
|
609
|
+
)
|
|
610
|
+
lib.define(
|
|
611
|
+
"quantized_relu_asym8s_asym8s.per_tensor(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, int out_shift) -> Tensor"
|
|
612
|
+
)
|
|
613
|
+
lib.define(
|
|
614
|
+
"quantized_relu_asym8s_asym8s.per_tensor_out(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, "
|
|
615
|
+
"int out_shift, *, Tensor(a!) out) -> Tensor(a!)"
|
|
616
|
+
)
|
|
617
|
+
lib.define(
|
|
618
|
+
"quantized_relu_asym8u_asym8u.per_tensor(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, int out_shift) -> Tensor"
|
|
619
|
+
)
|
|
620
|
+
lib.define(
|
|
621
|
+
"quantized_relu_asym8u_asym8u.per_tensor_out(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, "
|
|
622
|
+
"int out_shift, *, Tensor(a!) out) -> Tensor(a!)"
|
|
623
|
+
)
|
|
624
|
+
lib.define(
|
|
625
|
+
"quantized_add.out(Tensor X, Tensor X_scale, Tensor X_zero_point, Tensor Y, Tensor Y_scale, "
|
|
626
|
+
"Tensor Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
627
|
+
)
|
|
628
|
+
lib.define(
|
|
629
|
+
"quantized_add.per_tensor_out(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
630
|
+
"int Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
631
|
+
)
|
|
632
|
+
lib.define(
|
|
633
|
+
"quantized_add_asym8sxasym8s_asym8s.per_tensor(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
634
|
+
"int Y_zero_point, float out_scale, int out_zero_point) -> Tensor"
|
|
635
|
+
)
|
|
636
|
+
lib.define(
|
|
637
|
+
"quantized_add_asym8sxasym8s_asym8s.per_tensor_out(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
638
|
+
"int Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
639
|
+
)
|
|
640
|
+
lib.define(
|
|
641
|
+
"quantized_add_asym8uxasym8u_asym8u.per_tensor(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
642
|
+
"int Y_zero_point, float out_scale, int out_zero_point) -> Tensor"
|
|
643
|
+
)
|
|
644
|
+
lib.define(
|
|
645
|
+
"quantized_add_asym8uxasym8u_asym8u.per_tensor_out(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
646
|
+
"int Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
647
|
+
)
|
|
648
|
+
lib.define(
|
|
649
|
+
"quantized_mul.out(Tensor X, Tensor X_scale, Tensor X_zero_point, Tensor Y, Tensor Y_scale, "
|
|
650
|
+
"Tensor Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
651
|
+
)
|
|
652
|
+
lib.define(
|
|
653
|
+
"quantized_mul.per_tensor_out(Tensor X, float X_scale, int X_zero_point, Tensor Y, float Y_scale, "
|
|
654
|
+
"int Y_zero_point, float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
655
|
+
)
|
|
656
|
+
lib.define(
|
|
657
|
+
"quantized_add_Scalar.out(Tensor X, Tensor X_scale, Tensor X_zero_point, Scalar Y, "
|
|
658
|
+
"float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
659
|
+
)
|
|
660
|
+
lib.define(
|
|
661
|
+
"quantized_mul_Scalar.out(Tensor X, Tensor X_scale, Tensor X_zero_point, Scalar Y, "
|
|
662
|
+
"float out_scale, int out_zero_point, *, Tensor(a!) out) -> Tensor(a!)"
|
|
663
|
+
)
|
|
664
|
+
lib.define(
|
|
665
|
+
"fully_connected.out(Tensor input, Tensor weight, Tensor? bias=None, *, Tensor(a!) out) -> Tensor(a!)"
|
|
666
|
+
)
|
|
667
|
+
lib.define(
|
|
668
|
+
"quantized_fully_connected.out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
669
|
+
"Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
670
|
+
)
|
|
671
|
+
lib.define(
|
|
672
|
+
"quantized_fully_connected.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
673
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
674
|
+
)
|
|
675
|
+
lib.define(
|
|
676
|
+
"quantized_fully_connected_asym8sxasym8s_asym8s.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
677
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
678
|
+
)
|
|
679
|
+
lib.define(
|
|
680
|
+
"quantized_fully_connected_asym8uxasym8u_asym8u.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, "
|
|
681
|
+
"int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
682
|
+
)
|
|
683
|
+
lib.define(
|
|
684
|
+
"quantized_fully_connected_packed.out(Tensor src, Tensor weight, Tensor bias, int in_dim, int weight_bits, "
|
|
685
|
+
"int src_zero_point, Tensor? weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, "
|
|
686
|
+
"Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)"
|
|
687
|
+
)
|
|
688
|
+
lib.define(
|
|
689
|
+
"quantized_embedding_byte.out(Tensor weight, Tensor weight_scales, Tensor? weight_zero_points, "
|
|
690
|
+
"Tensor indices, bool pruned_weights=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
lib.define(
|
|
694
|
+
"quantized_transposed_conv.out(Tensor input, Tensor weight, Tensor bias, int[] stride, "
|
|
695
|
+
"SymInt[] padding, int[] dilation, SymInt[] output_padding, int groups, int input_zero_point, "
|
|
696
|
+
"Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, "
|
|
697
|
+
"Tensor out_multiplier, Tensor out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
698
|
+
)
|
|
699
|
+
lib.define(
|
|
700
|
+
"avg_pool2d.out(Tensor input, int[2] kernel_size, int[2] stride=[], int[2] padding=[], "
|
|
701
|
+
"bool ceil_mode=False, bool count_include_pad=True, int? divisor_override=None, "
|
|
702
|
+
"Tensor? in_zero_point=None, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
703
|
+
)
|
|
704
|
+
lib.define(
|
|
705
|
+
"im2row.out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, "
|
|
706
|
+
"Tensor in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
707
|
+
)
|
|
708
|
+
lib.define(
|
|
709
|
+
"im2row.per_tensor_out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, "
|
|
710
|
+
"int in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
711
|
+
)
|
|
712
|
+
lib.define(
|
|
713
|
+
"transposed_im2row.out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, "
|
|
714
|
+
"int[2] stride, int[2] output_padding, Tensor in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)"
|
|
715
|
+
)
|
|
716
|
+
lib.define(
|
|
717
|
+
"requantize.out(Tensor input, Tensor in_scale, Tensor in_zero_point, Tensor out_scale, "
|
|
718
|
+
"Tensor out_zero_point, ScalarType out_dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
719
|
+
)
|
|
720
|
+
lib.define(
|
|
721
|
+
"requantize.per_tensor_out(Tensor input, float in_scale, int in_zero_point, float out_scale, "
|
|
722
|
+
"int out_zero_point, ScalarType out_dtype, *, Tensor(a!) out) -> Tensor(a!)"
|
|
723
|
+
)
|
|
724
|
+
lib.define(
|
|
725
|
+
"roi_align_box_processor.out(Tensor rois, int output_size_h, int output_size_w, "
|
|
726
|
+
"int sampling_ratio, bool aligned, *, Tensor(a!) out) -> Tensor(a!)"
|
|
727
|
+
)
|
|
728
|
+
lib.define(
|
|
729
|
+
"roi_align_box_processor(Tensor rois, int output_size_h, int output_size_w, "
|
|
730
|
+
"int sampling_ratio, bool aligned) -> (Tensor out)"
|
|
731
|
+
)
|
|
732
|
+
lib.define(
|
|
733
|
+
"_softmax_f32_f32(Tensor self, int dim, bool? half_to_float = None) -> (Tensor out)"
|
|
734
|
+
)
|
|
735
|
+
lib.define(
|
|
736
|
+
"_softmax_f32_f32.out(Tensor self, int dim, bool? half_to_float = None, *, Tensor(a!) out) -> Tensor(a!)"
|
|
737
|
+
)
|
|
738
|
+
|
|
739
|
+
lib.define(
|
|
740
|
+
"quantized_w8a32_linear(Tensor input, Tensor weight, float w_scale, Tensor bias, float b_scale) -> Tensor"
|
|
741
|
+
)
|
|
742
|
+
lib.define(
|
|
743
|
+
"quantized_w8a32_linear.out(Tensor input, Tensor weight, float w_scale, Tensor bias, float b_scale, *, Tensor(a!) output) -> Tensor(a!)"
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
lib.define(
|
|
747
|
+
"quantized_w8a32_conv(Tensor input, Tensor weight, float w_scale, Tensor bias, float b_scale) -> Tensor"
|
|
748
|
+
)
|
|
749
|
+
lib.define(
|
|
750
|
+
"quantized_w8a32_conv.out(Tensor input, Tensor weight, float w_scale, Tensor bias, float b_scale, *, Tensor(a!) output) -> Tensor(a!)"
|
|
751
|
+
)
|
|
752
|
+
|
|
753
|
+
lib.define(
|
|
754
|
+
"quantized_w8a32_gru(Tensor inputs, Tensor hidden, Tensor weights_inputs, float w_i_scale, Tensor weights_hidden, float w_h_scale, Tensor bias_inputs, float b_scale, Tensor bias_hidden) -> Tensor"
|
|
755
|
+
)
|
|
756
|
+
|
|
757
|
+
lib.define(
|
|
758
|
+
"quantized_w8a32_gru.out(Tensor inputs, Tensor hidden, Tensor weights_inputs, float w_i_scale, Tensor weights_hidden, float w_h_scale, Tensor bias_inputs, float b_scale, Tensor bias_hidden, *, Tensor(a!) out) -> Tensor(a!)"
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
lib.define(
|
|
762
|
+
"slice_scatter_(Tensor(a!) self, Tensor src, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor(a!)"
|
|
763
|
+
)
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
# Custom ops with aten namespace. Need to specify the lib var as FRAGMENT type as aten library is already defined
|
|
767
|
+
aten_lib = Library("aten", "FRAGMENT")
|
|
768
|
+
aten_lib.define(
|
|
769
|
+
"chunk.out(Tensor self, int chunks, int dim=0, *, Tensor(a!)[] out) -> ()"
|
|
770
|
+
)
|
|
771
|
+
aten_lib.define(
|
|
772
|
+
"contiguous.out(Tensor self, *, MemoryFormat memory_format=contiguous_format, "
|
|
773
|
+
"Tensor(a!) out) -> Tensor(a!)"
|
|
774
|
+
)
|
|
775
|
+
aten_lib.define(
|
|
776
|
+
"tensor_split.sections_out(Tensor self, int sections, int dim=0, *, Tensor(a!)[] out) -> ()"
|
|
777
|
+
)
|
|
778
|
+
aten_lib.define(
|
|
779
|
+
"_slice_copy_nop(Tensor self, int dim=0, SymInt? start=None, SymInt? end=None, "
|
|
780
|
+
"SymInt step=1) -> Tensor(a!)"
|
|
781
|
+
)
|
|
782
|
+
aten_lib.define(
|
|
783
|
+
"_select_copy_nop.int_out(Tensor self, int dim, SymInt index, *, Tensor(a!) out) -> Tensor(a!)"
|
|
784
|
+
)
|
|
785
|
+
aten_lib.define(
|
|
786
|
+
"_slice_copy_nop.Tensor_out(Tensor self, int dim=0, SymInt? start=None, SymInt? end=None, "
|
|
787
|
+
"SymInt step=1, *, Tensor(a!) out) -> Tensor(a!)"
|
|
788
|
+
)
|
|
789
|
+
aten_lib.define("_cat_nop(Tensor[] tensors, int dim=0) -> Tensor(a!)")
|
|
790
|
+
aten_lib.define(
|
|
791
|
+
"_cat_nop.out(Tensor[] tensors, int dim=0, *, Tensor(a!) out) -> Tensor(a!)"
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
# Custom ops in aten namespace. RMSNorm is usually decomposed, so having
|
|
795
|
+
# an out-variant is non-standard
|
|
796
|
+
|
|
797
|
+
lib_aten = Library("aten", "FRAGMENT")
|
|
798
|
+
|
|
799
|
+
lib_aten.define(
|
|
800
|
+
"rms_norm.out(Tensor input, SymInt[] normalized_shape, Tensor? weight=None, float? eps=None, *, Tensor(a!) out) -> Tensor(a!)"
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
@register_fake("cadence::quantize_per_tensor")
|
|
805
|
+
def quantize_per_tensor_meta(
|
|
806
|
+
input: torch.Tensor,
|
|
807
|
+
scale: float,
|
|
808
|
+
zero_point: int,
|
|
809
|
+
quant_min: int,
|
|
810
|
+
quant_max: int,
|
|
811
|
+
dtype: torch.dtype,
|
|
812
|
+
) -> torch.Tensor:
|
|
813
|
+
torch._check(
|
|
814
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
815
|
+
)
|
|
816
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
@register_fake("cadence::quantize_per_tensor_asym8s")
|
|
820
|
+
def quantize_per_tensor_asym8s_meta(
|
|
821
|
+
input: torch.Tensor,
|
|
822
|
+
scale: float,
|
|
823
|
+
zero_point: int,
|
|
824
|
+
quant_min: int,
|
|
825
|
+
quant_max: int,
|
|
826
|
+
dtype: torch.dtype,
|
|
827
|
+
) -> torch.Tensor:
|
|
828
|
+
torch._check(
|
|
829
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
830
|
+
)
|
|
831
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
@register_fake("cadence::quantize_per_tensor_asym8u")
|
|
835
|
+
def quantize_per_tensor_asym8u_meta(
|
|
836
|
+
input: torch.Tensor,
|
|
837
|
+
scale: float,
|
|
838
|
+
zero_point: int,
|
|
839
|
+
quant_min: int,
|
|
840
|
+
quant_max: int,
|
|
841
|
+
dtype: torch.dtype,
|
|
842
|
+
) -> torch.Tensor:
|
|
843
|
+
torch._check(
|
|
844
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
845
|
+
)
|
|
846
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
@register_fake("cadence::quantize_per_tensor_asym16s")
|
|
850
|
+
def quantize_per_tensor_asym16s_meta(
|
|
851
|
+
input: torch.Tensor,
|
|
852
|
+
scale: float,
|
|
853
|
+
zero_point: int,
|
|
854
|
+
quant_min: int,
|
|
855
|
+
quant_max: int,
|
|
856
|
+
dtype: torch.dtype,
|
|
857
|
+
) -> torch.Tensor:
|
|
858
|
+
torch._check(
|
|
859
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
860
|
+
)
|
|
861
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
@register_fake("cadence::quantize_per_tensor_asym16u")
|
|
865
|
+
def quantize_per_tensor_asym16u_meta(
|
|
866
|
+
input: torch.Tensor,
|
|
867
|
+
scale: float,
|
|
868
|
+
zero_point: int,
|
|
869
|
+
quant_min: int,
|
|
870
|
+
quant_max: int,
|
|
871
|
+
dtype: torch.dtype,
|
|
872
|
+
) -> torch.Tensor:
|
|
873
|
+
torch._check(
|
|
874
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
875
|
+
)
|
|
876
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
@register_fake("cadence::quantize_per_tensor_asym32s")
|
|
880
|
+
def quantize_per_tensor_asym32s_meta(
|
|
881
|
+
input: torch.Tensor,
|
|
882
|
+
scale: float,
|
|
883
|
+
zero_point: int,
|
|
884
|
+
quant_min: int,
|
|
885
|
+
quant_max: int,
|
|
886
|
+
dtype: torch.dtype,
|
|
887
|
+
) -> torch.Tensor:
|
|
888
|
+
torch._check(
|
|
889
|
+
input.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
890
|
+
)
|
|
891
|
+
return input.new_empty(input.size(), dtype=dtype)
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
@register_fake("cadence::dequantize_per_tensor")
|
|
895
|
+
def dequantize_per_tensor_meta(
|
|
896
|
+
input: torch.Tensor,
|
|
897
|
+
scale: float,
|
|
898
|
+
zero_point: int,
|
|
899
|
+
quant_min: int,
|
|
900
|
+
quant_max: int,
|
|
901
|
+
dtype: torch.dtype,
|
|
902
|
+
) -> torch.Tensor:
|
|
903
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
@register_fake("cadence::dequantize_per_tensor_asym8s")
|
|
907
|
+
def dequantize_per_tensor_asym8s_meta(
|
|
908
|
+
input: torch.Tensor,
|
|
909
|
+
scale: float,
|
|
910
|
+
zero_point: int,
|
|
911
|
+
quant_min: int,
|
|
912
|
+
quant_max: int,
|
|
913
|
+
dtype: torch.dtype,
|
|
914
|
+
) -> torch.Tensor:
|
|
915
|
+
torch._check(
|
|
916
|
+
input.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
917
|
+
)
|
|
918
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
@register_fake("cadence::dequantize_per_tensor_asym8u")
|
|
922
|
+
def dequantize_per_tensor_asym8u_meta(
|
|
923
|
+
input: torch.Tensor,
|
|
924
|
+
scale: float,
|
|
925
|
+
zero_point: int,
|
|
926
|
+
quant_min: int,
|
|
927
|
+
quant_max: int,
|
|
928
|
+
dtype: torch.dtype,
|
|
929
|
+
) -> torch.Tensor:
|
|
930
|
+
torch._check(
|
|
931
|
+
input.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
932
|
+
)
|
|
933
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
@register_fake("cadence::dequantize_per_tensor_asym16s")
|
|
937
|
+
def dequantize_per_tensor_asym16s_meta(
|
|
938
|
+
input: torch.Tensor,
|
|
939
|
+
scale: float,
|
|
940
|
+
zero_point: int,
|
|
941
|
+
quant_min: int,
|
|
942
|
+
quant_max: int,
|
|
943
|
+
dtype: torch.dtype,
|
|
944
|
+
) -> torch.Tensor:
|
|
945
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
@register_fake("cadence::dequantize_per_tensor_asym16u")
|
|
949
|
+
def dequantize_per_tensor_asym16u_meta(
|
|
950
|
+
input: torch.Tensor,
|
|
951
|
+
scale: float,
|
|
952
|
+
zero_point: int,
|
|
953
|
+
quant_min: int,
|
|
954
|
+
quant_max: int,
|
|
955
|
+
dtype: torch.dtype,
|
|
956
|
+
) -> torch.Tensor:
|
|
957
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
@register_fake("cadence::dequantize_per_tensor_asym32s")
|
|
961
|
+
def dequantize_per_tensor_asym32s_meta(
|
|
962
|
+
input: torch.Tensor,
|
|
963
|
+
scale: float,
|
|
964
|
+
zero_point: int,
|
|
965
|
+
quant_min: int,
|
|
966
|
+
quant_max: int,
|
|
967
|
+
dtype: torch.dtype,
|
|
968
|
+
) -> torch.Tensor:
|
|
969
|
+
return input.new_empty(input.size(), dtype=torch.float)
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
@register_fake("cadence::quantized_add")
|
|
973
|
+
def quantized_add_meta(
|
|
974
|
+
X: torch.Tensor,
|
|
975
|
+
X_scale: torch.Tensor,
|
|
976
|
+
X_zero_point: torch.Tensor,
|
|
977
|
+
Y: torch.Tensor,
|
|
978
|
+
Y_scale: torch.Tensor,
|
|
979
|
+
Y_zero_point: torch.Tensor,
|
|
980
|
+
out_scale: float,
|
|
981
|
+
out_zero_point: int,
|
|
982
|
+
) -> torch.Tensor:
|
|
983
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
984
|
+
|
|
985
|
+
# Determine output shape by broadcasting X and Y
|
|
986
|
+
out_size = torch.broadcast_shapes(X.size(), Y.size())
|
|
987
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
@register_fake("cadence::quantized_mul.per_tensor")
|
|
991
|
+
def quantized_mul_per_tensor_meta(
|
|
992
|
+
X: torch.Tensor,
|
|
993
|
+
X_scale: float,
|
|
994
|
+
X_zero_point: int,
|
|
995
|
+
Y: torch.Tensor,
|
|
996
|
+
Y_scale: float,
|
|
997
|
+
Y_zero_point: int,
|
|
998
|
+
out_scale: float,
|
|
999
|
+
out_zero_point: int,
|
|
1000
|
+
) -> torch.Tensor:
|
|
1001
|
+
|
|
1002
|
+
out_size = torch.broadcast_shapes(X.size(), Y.size())
|
|
1003
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
@register_fake("cadence::quantized_add.per_tensor")
|
|
1007
|
+
def quantized_add_per_tensor_meta(
|
|
1008
|
+
X: torch.Tensor,
|
|
1009
|
+
X_scale: float,
|
|
1010
|
+
X_zero_point: int,
|
|
1011
|
+
Y: torch.Tensor,
|
|
1012
|
+
Y_scale: float,
|
|
1013
|
+
Y_zero_point: int,
|
|
1014
|
+
out_scale: float,
|
|
1015
|
+
out_zero_point: int,
|
|
1016
|
+
) -> torch.Tensor:
|
|
1017
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
1018
|
+
|
|
1019
|
+
out_size = torch.broadcast_shapes(X.size(), Y.size())
|
|
1020
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
@register_fake("cadence::quantized_add_asym8sxasym8s_asym8s.per_tensor")
|
|
1024
|
+
def quantized_add_asym8sxasym8s_asym8s_per_tensor_meta(
|
|
1025
|
+
X: torch.Tensor,
|
|
1026
|
+
X_scale: float,
|
|
1027
|
+
X_zero_point: int,
|
|
1028
|
+
Y: torch.Tensor,
|
|
1029
|
+
Y_scale: float,
|
|
1030
|
+
Y_zero_point: int,
|
|
1031
|
+
out_scale: float,
|
|
1032
|
+
out_zero_point: int,
|
|
1033
|
+
) -> torch.Tensor:
|
|
1034
|
+
torch._check(X.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1035
|
+
torch._check(Y.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1036
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
1037
|
+
out_size = torch.broadcast_shapes(X.size(), Y.size())
|
|
1038
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
@register_fake("cadence::quantized_add_asym8uxasym8u_asym8u.per_tensor")
|
|
1042
|
+
def quantized_add_asym8uxasym8u_asym8u_per_tensor_meta(
|
|
1043
|
+
X: torch.Tensor,
|
|
1044
|
+
X_scale: float,
|
|
1045
|
+
X_zero_point: int,
|
|
1046
|
+
Y: torch.Tensor,
|
|
1047
|
+
Y_scale: float,
|
|
1048
|
+
Y_zero_point: int,
|
|
1049
|
+
out_scale: float,
|
|
1050
|
+
out_zero_point: int,
|
|
1051
|
+
) -> torch.Tensor:
|
|
1052
|
+
torch._check(X.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1053
|
+
torch._check(Y.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1054
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
1055
|
+
out_size = torch.broadcast_shapes(X.size(), Y.size())
|
|
1056
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
@register_fake("cadence::quantized_linear")
|
|
1060
|
+
def quantized_linear_meta(
|
|
1061
|
+
src: torch.Tensor,
|
|
1062
|
+
weight: torch.Tensor,
|
|
1063
|
+
bias: torch.Tensor,
|
|
1064
|
+
in_zero_point: int,
|
|
1065
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1066
|
+
out_multiplier: torch.Tensor,
|
|
1067
|
+
out_shift: torch.Tensor,
|
|
1068
|
+
out_zero_point: int,
|
|
1069
|
+
offset: Optional[torch.Tensor],
|
|
1070
|
+
) -> torch.Tensor:
|
|
1071
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1072
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
1073
|
+
# src comes in shape [leading_dims, in_dim]
|
|
1074
|
+
# weight comes in shape [out_dim, in_dim]
|
|
1075
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
1076
|
+
out_size = list(src.size())
|
|
1077
|
+
weight_size = list(weight.size())
|
|
1078
|
+
assert len(weight_size) == 2
|
|
1079
|
+
out_size[-1] = weight_size[0]
|
|
1080
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
@register_fake("cadence::quantized_linear.per_tensor")
|
|
1084
|
+
def quantized_linear_per_tensor_meta(
|
|
1085
|
+
src: torch.Tensor,
|
|
1086
|
+
weight: torch.Tensor,
|
|
1087
|
+
bias: torch.Tensor,
|
|
1088
|
+
in_zero_point: torch.SymInt,
|
|
1089
|
+
weight_zero_point: torch.SymInt,
|
|
1090
|
+
out_multiplier: torch.SymInt,
|
|
1091
|
+
out_shift: torch.SymInt,
|
|
1092
|
+
out_zero_point: torch.SymInt,
|
|
1093
|
+
offset: Optional[torch.Tensor],
|
|
1094
|
+
) -> torch.Tensor:
|
|
1095
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1096
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
1097
|
+
# src comes in shape [leading_dims, in_dim]
|
|
1098
|
+
# weight comes in shape [out_dim, in_dim]
|
|
1099
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
1100
|
+
out_size = list(src.size())
|
|
1101
|
+
weight_size = list(weight.size())
|
|
1102
|
+
assert len(weight_size) == 2
|
|
1103
|
+
out_size[-1] = weight_size[0]
|
|
1104
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
@register_fake("cadence::quantized_linear_asym8sxasym8s_asym8s.per_tensor")
|
|
1108
|
+
def quantized_linear_asym8sxasym8s_asym8s_per_tensor_meta(
|
|
1109
|
+
src: torch.Tensor,
|
|
1110
|
+
weight: torch.Tensor,
|
|
1111
|
+
bias: torch.Tensor,
|
|
1112
|
+
in_zero_point: int,
|
|
1113
|
+
weight_zero_point: int,
|
|
1114
|
+
out_multiplier: int,
|
|
1115
|
+
out_shift: int,
|
|
1116
|
+
out_zero_point: int,
|
|
1117
|
+
offset: Optional[torch.Tensor],
|
|
1118
|
+
) -> torch.Tensor:
|
|
1119
|
+
torch._check(src.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1120
|
+
torch._check(
|
|
1121
|
+
weight.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
1122
|
+
)
|
|
1123
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1124
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
1125
|
+
# src comes in shape [leading_dims, in_dim]
|
|
1126
|
+
# weight comes in shape [out_dim, in_dim]
|
|
1127
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
1128
|
+
out_size = list(src.size())
|
|
1129
|
+
weight_size = list(weight.size())
|
|
1130
|
+
assert len(weight_size) == 2
|
|
1131
|
+
out_size[-1] = weight_size[0]
|
|
1132
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
@register_fake("cadence::quantized_linear_asym8uxasym8u_asym8u.per_tensor")
|
|
1136
|
+
def quantized_linear_asym8uxasym8u_asym8u_per_tensor_meta(
|
|
1137
|
+
src: torch.Tensor,
|
|
1138
|
+
weight: torch.Tensor,
|
|
1139
|
+
bias: torch.Tensor,
|
|
1140
|
+
in_zero_point: int,
|
|
1141
|
+
weight_zero_point: int,
|
|
1142
|
+
out_multiplier: int,
|
|
1143
|
+
out_shift: int,
|
|
1144
|
+
out_zero_point: int,
|
|
1145
|
+
offset: Optional[torch.Tensor],
|
|
1146
|
+
) -> torch.Tensor:
|
|
1147
|
+
torch._check(src.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
1148
|
+
torch._check(
|
|
1149
|
+
weight.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
1150
|
+
)
|
|
1151
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1152
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
1153
|
+
# src comes in shape [leading_dims, in_dim]
|
|
1154
|
+
# weight comes in shape [out_dim, in_dim]
|
|
1155
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
1156
|
+
out_size = list(src.size())
|
|
1157
|
+
weight_size = list(weight.size())
|
|
1158
|
+
assert len(weight_size) == 2
|
|
1159
|
+
out_size[-1] = weight_size[0]
|
|
1160
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
@register_fake("cadence::quantized_conv2d_nhwc")
|
|
1164
|
+
def quantized_conv2d_nhwc_meta(
|
|
1165
|
+
input: torch.Tensor,
|
|
1166
|
+
weight: torch.Tensor,
|
|
1167
|
+
bias: torch.Tensor,
|
|
1168
|
+
stride: Tuple[int],
|
|
1169
|
+
padding: Tuple[int],
|
|
1170
|
+
dilation: Tuple[int],
|
|
1171
|
+
groups: int,
|
|
1172
|
+
in_zero_point: int,
|
|
1173
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1174
|
+
bias_scale: torch.Tensor,
|
|
1175
|
+
output_scale: float,
|
|
1176
|
+
output_zero_point: int,
|
|
1177
|
+
out_multiplier: torch.Tensor,
|
|
1178
|
+
out_shift: torch.Tensor,
|
|
1179
|
+
) -> torch.Tensor:
|
|
1180
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1181
|
+
in_size = input.shape
|
|
1182
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1183
|
+
assert len(in_size) > 2
|
|
1184
|
+
assert len(in_size) < 6
|
|
1185
|
+
|
|
1186
|
+
# Determine weight layout based on depthwise vs regular conv.
|
|
1187
|
+
in_channels = in_size[-1]
|
|
1188
|
+
if is_depthwise_conv(groups, in_channels):
|
|
1189
|
+
# Depthwise conv: weight is [*kernel_size, OC]
|
|
1190
|
+
*kernel_size, out_channels = weight.shape
|
|
1191
|
+
else:
|
|
1192
|
+
# 1D conv: weight is [OC, K, IC]
|
|
1193
|
+
# 2D regular conv: weight is [OC, KH, KW, IC]
|
|
1194
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1195
|
+
|
|
1196
|
+
# Compute the output tensor size
|
|
1197
|
+
output_size = (
|
|
1198
|
+
get_conv1d_output_size(
|
|
1199
|
+
in_size,
|
|
1200
|
+
out_channels,
|
|
1201
|
+
stride[-1],
|
|
1202
|
+
padding[-1],
|
|
1203
|
+
dilation[-1],
|
|
1204
|
+
kernel_size[0],
|
|
1205
|
+
True,
|
|
1206
|
+
)
|
|
1207
|
+
if len(in_size) == 3
|
|
1208
|
+
else get_conv2d_output_size(
|
|
1209
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
1210
|
+
)
|
|
1211
|
+
)
|
|
1212
|
+
|
|
1213
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
@register_fake("cadence::quantized_conv1d_ncl")
|
|
1217
|
+
def quantized_conv1d_ncl_meta(
|
|
1218
|
+
input: torch.Tensor,
|
|
1219
|
+
weight: torch.Tensor,
|
|
1220
|
+
bias: torch.Tensor,
|
|
1221
|
+
stride: Tuple[int],
|
|
1222
|
+
padding: Tuple[int],
|
|
1223
|
+
dilation: Tuple[int],
|
|
1224
|
+
groups: int,
|
|
1225
|
+
in_zero_point: int,
|
|
1226
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1227
|
+
bias_scale: torch.Tensor,
|
|
1228
|
+
output_scale: float,
|
|
1229
|
+
output_zero_point: int,
|
|
1230
|
+
out_multiplier: torch.Tensor,
|
|
1231
|
+
out_shift: torch.Tensor,
|
|
1232
|
+
) -> torch.Tensor:
|
|
1233
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1234
|
+
# NCL format: input is [N, C, L], weight is [OC, IC/groups, K]
|
|
1235
|
+
out_channels, _, kernel_size = weight.shape
|
|
1236
|
+
|
|
1237
|
+
in_size = input.shape
|
|
1238
|
+
assert len(in_size) == 3
|
|
1239
|
+
|
|
1240
|
+
# Compute the output tensor size for 1D conv (NCL format, channel_last=False)
|
|
1241
|
+
output_size = get_conv1d_output_size(
|
|
1242
|
+
in_size,
|
|
1243
|
+
out_channels,
|
|
1244
|
+
stride[-1],
|
|
1245
|
+
padding[-1],
|
|
1246
|
+
dilation[-1],
|
|
1247
|
+
kernel_size,
|
|
1248
|
+
False,
|
|
1249
|
+
)
|
|
1250
|
+
|
|
1251
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
@register_fake("cadence::quantized_conv1d_ncl.per_tensor")
|
|
1255
|
+
def quantized_conv1d_ncl_per_tensor_meta(
|
|
1256
|
+
input: torch.Tensor,
|
|
1257
|
+
weight: torch.Tensor,
|
|
1258
|
+
bias: torch.Tensor,
|
|
1259
|
+
stride: Tuple[int],
|
|
1260
|
+
padding: Tuple[int],
|
|
1261
|
+
dilation: Tuple[int],
|
|
1262
|
+
groups: int,
|
|
1263
|
+
in_zero_point: int,
|
|
1264
|
+
weight_zero_point: int,
|
|
1265
|
+
bias_scale: float,
|
|
1266
|
+
output_scale: float,
|
|
1267
|
+
output_zero_point: int,
|
|
1268
|
+
out_multiplier: int,
|
|
1269
|
+
out_shift: int,
|
|
1270
|
+
) -> torch.Tensor:
|
|
1271
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1272
|
+
# NCL format: input is [N, C, L], weight is [OC, IC/groups, K]
|
|
1273
|
+
out_channels, _, kernel_size = weight.shape
|
|
1274
|
+
|
|
1275
|
+
in_size = input.shape
|
|
1276
|
+
assert len(in_size) == 3
|
|
1277
|
+
|
|
1278
|
+
# Compute the output tensor size for 1D conv (NCL format, channel_last=False)
|
|
1279
|
+
output_size = get_conv1d_output_size(
|
|
1280
|
+
in_size,
|
|
1281
|
+
out_channels,
|
|
1282
|
+
stride[-1],
|
|
1283
|
+
padding[-1],
|
|
1284
|
+
dilation[-1],
|
|
1285
|
+
kernel_size,
|
|
1286
|
+
False,
|
|
1287
|
+
)
|
|
1288
|
+
|
|
1289
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
@register_fake("cadence::quantized_conv1d_nlc")
|
|
1293
|
+
def quantized_conv1d_nlc_meta(
|
|
1294
|
+
input: torch.Tensor,
|
|
1295
|
+
weight: torch.Tensor,
|
|
1296
|
+
bias: torch.Tensor,
|
|
1297
|
+
stride: Tuple[int],
|
|
1298
|
+
padding: Tuple[int],
|
|
1299
|
+
dilation: Tuple[int],
|
|
1300
|
+
groups: int,
|
|
1301
|
+
in_zero_point: int,
|
|
1302
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1303
|
+
bias_scale: torch.Tensor,
|
|
1304
|
+
output_scale: float,
|
|
1305
|
+
output_zero_point: int,
|
|
1306
|
+
out_multiplier: torch.Tensor,
|
|
1307
|
+
out_shift: torch.Tensor,
|
|
1308
|
+
) -> torch.Tensor:
|
|
1309
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1310
|
+
# NLC format: input is [N, L, C], weight is [OC, K, IC/groups]
|
|
1311
|
+
out_channels, kernel_size, _ = weight.shape
|
|
1312
|
+
|
|
1313
|
+
in_size = input.shape
|
|
1314
|
+
assert len(in_size) == 3
|
|
1315
|
+
|
|
1316
|
+
# Compute the output tensor size for 1D conv (NLC format, channel_last=True)
|
|
1317
|
+
output_size = get_conv1d_output_size(
|
|
1318
|
+
in_size,
|
|
1319
|
+
out_channels,
|
|
1320
|
+
stride[-1],
|
|
1321
|
+
padding[-1],
|
|
1322
|
+
dilation[-1],
|
|
1323
|
+
kernel_size,
|
|
1324
|
+
True,
|
|
1325
|
+
)
|
|
1326
|
+
|
|
1327
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
@register_fake("cadence::quantized_conv1d_nlc.per_tensor")
|
|
1331
|
+
def quantized_conv1d_nlc_per_tensor_meta(
|
|
1332
|
+
input: torch.Tensor,
|
|
1333
|
+
weight: torch.Tensor,
|
|
1334
|
+
bias: torch.Tensor,
|
|
1335
|
+
stride: Tuple[int],
|
|
1336
|
+
padding: Tuple[int],
|
|
1337
|
+
dilation: Tuple[int],
|
|
1338
|
+
groups: int,
|
|
1339
|
+
in_zero_point: int,
|
|
1340
|
+
weight_zero_point: int,
|
|
1341
|
+
bias_scale: float,
|
|
1342
|
+
output_scale: float,
|
|
1343
|
+
output_zero_point: int,
|
|
1344
|
+
out_multiplier: int,
|
|
1345
|
+
out_shift: int,
|
|
1346
|
+
offset: Optional[torch.Tensor] = None,
|
|
1347
|
+
) -> torch.Tensor:
|
|
1348
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1349
|
+
# NLC format: input is [N, L, C], weight is [OC, K, IC/groups]
|
|
1350
|
+
out_channels, kernel_size, _ = weight.shape
|
|
1351
|
+
|
|
1352
|
+
in_size = input.shape
|
|
1353
|
+
assert len(in_size) == 3
|
|
1354
|
+
|
|
1355
|
+
# Compute the output tensor size for 1D conv (NLC format, channel_last=True)
|
|
1356
|
+
output_size = get_conv1d_output_size(
|
|
1357
|
+
in_size,
|
|
1358
|
+
out_channels,
|
|
1359
|
+
stride[-1],
|
|
1360
|
+
padding[-1],
|
|
1361
|
+
dilation[-1],
|
|
1362
|
+
kernel_size,
|
|
1363
|
+
True,
|
|
1364
|
+
)
|
|
1365
|
+
|
|
1366
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
@register_fake("cadence::quantized_depthwise_conv1d_ncl.per_tensor")
|
|
1370
|
+
def quantized_depthwise_conv1d_ncl_per_tensor_meta(
|
|
1371
|
+
input: torch.Tensor,
|
|
1372
|
+
weight: torch.Tensor,
|
|
1373
|
+
bias: torch.Tensor,
|
|
1374
|
+
stride: Tuple[int],
|
|
1375
|
+
padding: Tuple[int],
|
|
1376
|
+
dilation: Tuple[int],
|
|
1377
|
+
groups: int,
|
|
1378
|
+
in_zero_point: int,
|
|
1379
|
+
weight_zero_point: int,
|
|
1380
|
+
bias_scale: float,
|
|
1381
|
+
output_scale: float,
|
|
1382
|
+
output_zero_point: int,
|
|
1383
|
+
out_multiplier: int,
|
|
1384
|
+
out_shift: int,
|
|
1385
|
+
) -> torch.Tensor:
|
|
1386
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1387
|
+
# NCL format: input is [N, C, L], weight is [OC, IC/groups, K]
|
|
1388
|
+
out_channels, _, kernel_size = weight.shape
|
|
1389
|
+
|
|
1390
|
+
in_size = input.shape
|
|
1391
|
+
assert len(in_size) == 3
|
|
1392
|
+
|
|
1393
|
+
output_size = get_conv1d_output_size(
|
|
1394
|
+
in_size,
|
|
1395
|
+
out_channels,
|
|
1396
|
+
stride[-1],
|
|
1397
|
+
padding[-1],
|
|
1398
|
+
dilation[-1],
|
|
1399
|
+
kernel_size,
|
|
1400
|
+
False,
|
|
1401
|
+
)
|
|
1402
|
+
|
|
1403
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
@register_fake("cadence::quantized_depthwise_conv1d_nlc.per_tensor")
|
|
1407
|
+
def quantized_depthwise_conv1d_nlc_per_tensor_meta(
|
|
1408
|
+
input: torch.Tensor,
|
|
1409
|
+
weight: torch.Tensor,
|
|
1410
|
+
bias: torch.Tensor,
|
|
1411
|
+
stride: Tuple[int],
|
|
1412
|
+
padding: Tuple[int],
|
|
1413
|
+
dilation: Tuple[int],
|
|
1414
|
+
groups: int,
|
|
1415
|
+
in_zero_point: int,
|
|
1416
|
+
weight_zero_point: int,
|
|
1417
|
+
bias_scale: float,
|
|
1418
|
+
output_scale: float,
|
|
1419
|
+
output_zero_point: int,
|
|
1420
|
+
out_multiplier: int,
|
|
1421
|
+
out_shift: int,
|
|
1422
|
+
) -> torch.Tensor:
|
|
1423
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1424
|
+
# NLC format: input is [N, L, C], weight is [OC, K, IC/groups]
|
|
1425
|
+
out_channels, kernel_size, _ = weight.shape
|
|
1426
|
+
|
|
1427
|
+
in_size = input.shape
|
|
1428
|
+
assert len(in_size) == 3
|
|
1429
|
+
|
|
1430
|
+
output_size = get_conv1d_output_size(
|
|
1431
|
+
in_size,
|
|
1432
|
+
out_channels,
|
|
1433
|
+
stride[-1],
|
|
1434
|
+
padding[-1],
|
|
1435
|
+
dilation[-1],
|
|
1436
|
+
kernel_size,
|
|
1437
|
+
True,
|
|
1438
|
+
)
|
|
1439
|
+
|
|
1440
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
@register_fake("cadence::quantized_depthwise_conv1d_ncl")
|
|
1444
|
+
def quantized_depthwise_conv1d_ncl_meta(
|
|
1445
|
+
input: torch.Tensor,
|
|
1446
|
+
weight: torch.Tensor,
|
|
1447
|
+
bias: torch.Tensor,
|
|
1448
|
+
stride: Tuple[int],
|
|
1449
|
+
padding: Tuple[int],
|
|
1450
|
+
dilation: Tuple[int],
|
|
1451
|
+
groups: int,
|
|
1452
|
+
in_zero_point: int,
|
|
1453
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1454
|
+
bias_scale: torch.Tensor,
|
|
1455
|
+
output_scale: float,
|
|
1456
|
+
output_zero_point: int,
|
|
1457
|
+
out_multiplier: torch.Tensor,
|
|
1458
|
+
out_shift: torch.Tensor,
|
|
1459
|
+
) -> torch.Tensor:
|
|
1460
|
+
return quantized_depthwise_conv1d_ncl_per_tensor_meta(
|
|
1461
|
+
input,
|
|
1462
|
+
weight,
|
|
1463
|
+
bias,
|
|
1464
|
+
stride,
|
|
1465
|
+
padding,
|
|
1466
|
+
dilation,
|
|
1467
|
+
groups,
|
|
1468
|
+
in_zero_point,
|
|
1469
|
+
0,
|
|
1470
|
+
1.0,
|
|
1471
|
+
output_scale,
|
|
1472
|
+
output_zero_point,
|
|
1473
|
+
1,
|
|
1474
|
+
0,
|
|
1475
|
+
)
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
@register_fake("cadence::quantized_depthwise_conv1d_nlc")
|
|
1479
|
+
def quantized_depthwise_conv1d_nlc_meta(
|
|
1480
|
+
input: torch.Tensor,
|
|
1481
|
+
weight: torch.Tensor,
|
|
1482
|
+
bias: torch.Tensor,
|
|
1483
|
+
stride: Tuple[int],
|
|
1484
|
+
padding: Tuple[int],
|
|
1485
|
+
dilation: Tuple[int],
|
|
1486
|
+
groups: int,
|
|
1487
|
+
in_zero_point: int,
|
|
1488
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1489
|
+
bias_scale: torch.Tensor,
|
|
1490
|
+
output_scale: float,
|
|
1491
|
+
output_zero_point: int,
|
|
1492
|
+
out_multiplier: torch.Tensor,
|
|
1493
|
+
out_shift: torch.Tensor,
|
|
1494
|
+
) -> torch.Tensor:
|
|
1495
|
+
return quantized_depthwise_conv1d_nlc_per_tensor_meta(
|
|
1496
|
+
input,
|
|
1497
|
+
weight,
|
|
1498
|
+
bias,
|
|
1499
|
+
stride,
|
|
1500
|
+
padding,
|
|
1501
|
+
dilation,
|
|
1502
|
+
groups,
|
|
1503
|
+
in_zero_point,
|
|
1504
|
+
0,
|
|
1505
|
+
1.0,
|
|
1506
|
+
output_scale,
|
|
1507
|
+
output_zero_point,
|
|
1508
|
+
1,
|
|
1509
|
+
0,
|
|
1510
|
+
)
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
@register_fake("cadence::quantized_conv2d_nchw")
|
|
1514
|
+
def quantized_conv2d_nchw_meta(
|
|
1515
|
+
input: torch.Tensor,
|
|
1516
|
+
weight: torch.Tensor,
|
|
1517
|
+
bias: torch.Tensor,
|
|
1518
|
+
stride: Tuple[int],
|
|
1519
|
+
padding: Tuple[int],
|
|
1520
|
+
dilation: Tuple[int],
|
|
1521
|
+
groups: int,
|
|
1522
|
+
in_zero_point: int,
|
|
1523
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
1524
|
+
bias_scale: torch.Tensor,
|
|
1525
|
+
output_scale: float,
|
|
1526
|
+
output_zero_point: int,
|
|
1527
|
+
out_multiplier: torch.Tensor,
|
|
1528
|
+
out_shift: torch.Tensor,
|
|
1529
|
+
) -> torch.Tensor:
|
|
1530
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1531
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1532
|
+
|
|
1533
|
+
in_size = input.shape
|
|
1534
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1535
|
+
assert len(in_size) > 2
|
|
1536
|
+
assert len(in_size) < 6
|
|
1537
|
+
|
|
1538
|
+
# Compute the output tensor size
|
|
1539
|
+
output_size = (
|
|
1540
|
+
get_conv1d_output_size(
|
|
1541
|
+
in_size,
|
|
1542
|
+
out_channels,
|
|
1543
|
+
stride[-1],
|
|
1544
|
+
padding[-1],
|
|
1545
|
+
dilation[-1],
|
|
1546
|
+
kernel_size[0],
|
|
1547
|
+
False,
|
|
1548
|
+
)
|
|
1549
|
+
if len(in_size) == 3
|
|
1550
|
+
else get_conv2d_output_size(
|
|
1551
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1552
|
+
)
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
@register_fake("cadence::quantized_conv2d_nchw.per_tensor")
|
|
1559
|
+
def quantized_conv2d_nchw_per_tensor_meta(
|
|
1560
|
+
input: torch.Tensor,
|
|
1561
|
+
weight: torch.Tensor,
|
|
1562
|
+
bias: torch.Tensor,
|
|
1563
|
+
stride: Tuple[int],
|
|
1564
|
+
padding: Tuple[int],
|
|
1565
|
+
dilation: Tuple[int],
|
|
1566
|
+
groups: int,
|
|
1567
|
+
in_zero_point: int,
|
|
1568
|
+
weight_zero_point: int,
|
|
1569
|
+
bias_scale: float,
|
|
1570
|
+
output_scale: float,
|
|
1571
|
+
output_zero_point: int,
|
|
1572
|
+
out_multiplier: int,
|
|
1573
|
+
out_shift: int,
|
|
1574
|
+
) -> torch.Tensor:
|
|
1575
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1576
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1577
|
+
|
|
1578
|
+
in_size = input.shape
|
|
1579
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1580
|
+
assert len(in_size) > 2
|
|
1581
|
+
assert len(in_size) < 6
|
|
1582
|
+
|
|
1583
|
+
# Compute the output tensor size
|
|
1584
|
+
output_size = (
|
|
1585
|
+
get_conv1d_output_size(
|
|
1586
|
+
in_size,
|
|
1587
|
+
out_channels,
|
|
1588
|
+
stride[-1],
|
|
1589
|
+
padding[-1],
|
|
1590
|
+
dilation[-1],
|
|
1591
|
+
kernel_size[0],
|
|
1592
|
+
False,
|
|
1593
|
+
)
|
|
1594
|
+
if len(in_size) == 3
|
|
1595
|
+
else get_conv2d_output_size(
|
|
1596
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1597
|
+
)
|
|
1598
|
+
)
|
|
1599
|
+
|
|
1600
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
@register_fake("cadence::quantized_conv2d_nhwc.per_tensor")
|
|
1604
|
+
def quantized_conv2d_nhwc_per_tensor_meta(
|
|
1605
|
+
input: torch.Tensor,
|
|
1606
|
+
weight: torch.Tensor,
|
|
1607
|
+
bias: torch.Tensor,
|
|
1608
|
+
stride: Tuple[int],
|
|
1609
|
+
padding: Tuple[int],
|
|
1610
|
+
dilation: Tuple[int],
|
|
1611
|
+
groups: int,
|
|
1612
|
+
in_zero_point: int,
|
|
1613
|
+
weight_zero_point: int,
|
|
1614
|
+
bias_scale: float,
|
|
1615
|
+
output_scale: float,
|
|
1616
|
+
output_zero_point: int,
|
|
1617
|
+
out_multiplier: int,
|
|
1618
|
+
out_shift: int,
|
|
1619
|
+
offset: Optional[torch.Tensor] = None,
|
|
1620
|
+
) -> torch.Tensor:
|
|
1621
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
1622
|
+
in_size = input.shape
|
|
1623
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1624
|
+
assert len(in_size) > 2
|
|
1625
|
+
assert len(in_size) < 5
|
|
1626
|
+
|
|
1627
|
+
# Determine weight layout based on depthwise vs regular conv.
|
|
1628
|
+
in_channels = in_size[-1]
|
|
1629
|
+
depthwise = is_depthwise_conv(groups, in_channels)
|
|
1630
|
+
if len(in_size) == 3:
|
|
1631
|
+
if len(weight.shape) == 2:
|
|
1632
|
+
assert depthwise
|
|
1633
|
+
*kernel_size, out_channels = weight.shape
|
|
1634
|
+
else:
|
|
1635
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1636
|
+
elif len(in_size) == 4:
|
|
1637
|
+
if len(weight.shape) == 3:
|
|
1638
|
+
assert depthwise
|
|
1639
|
+
*kernel_size, out_channels = weight.shape
|
|
1640
|
+
else:
|
|
1641
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1642
|
+
else:
|
|
1643
|
+
raise ValueError("Unsupported input tensor size")
|
|
1644
|
+
|
|
1645
|
+
# Compute the output tensor size
|
|
1646
|
+
output_size = (
|
|
1647
|
+
get_conv1d_output_size(
|
|
1648
|
+
in_size,
|
|
1649
|
+
out_channels,
|
|
1650
|
+
stride[-1],
|
|
1651
|
+
padding[-1],
|
|
1652
|
+
dilation[-1],
|
|
1653
|
+
kernel_size[0],
|
|
1654
|
+
True,
|
|
1655
|
+
)
|
|
1656
|
+
if len(in_size) == 3
|
|
1657
|
+
else get_conv2d_output_size(
|
|
1658
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
1659
|
+
)
|
|
1660
|
+
)
|
|
1661
|
+
|
|
1662
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1663
|
+
|
|
1664
|
+
|
|
1665
|
+
@register_fake("cadence::quantized_conv2d_nchw_asym8sxsym8s_asym8s.per_tensor")
|
|
1666
|
+
def quantized_conv2d_nchw_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
1667
|
+
input: torch.Tensor,
|
|
1668
|
+
weight: torch.Tensor,
|
|
1669
|
+
bias: torch.Tensor,
|
|
1670
|
+
stride: Tuple[int],
|
|
1671
|
+
padding: Tuple[int],
|
|
1672
|
+
dilation: Tuple[int],
|
|
1673
|
+
groups: int,
|
|
1674
|
+
in_zero_point: int,
|
|
1675
|
+
weight_zero_point: int,
|
|
1676
|
+
bias_scale: float,
|
|
1677
|
+
output_scale: float,
|
|
1678
|
+
output_zero_point: int,
|
|
1679
|
+
out_multiplier: int,
|
|
1680
|
+
out_shift: int,
|
|
1681
|
+
) -> torch.Tensor:
|
|
1682
|
+
assert (
|
|
1683
|
+
input.dtype == torch.int8
|
|
1684
|
+
and weight.dtype == torch.int8
|
|
1685
|
+
and bias.dtype == torch.int32
|
|
1686
|
+
)
|
|
1687
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1688
|
+
|
|
1689
|
+
in_size = input.shape
|
|
1690
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1691
|
+
assert len(in_size) > 2
|
|
1692
|
+
assert len(in_size) < 6
|
|
1693
|
+
|
|
1694
|
+
# Compute the output tensor size
|
|
1695
|
+
output_size = (
|
|
1696
|
+
get_conv1d_output_size(
|
|
1697
|
+
in_size,
|
|
1698
|
+
out_channels,
|
|
1699
|
+
stride[-1],
|
|
1700
|
+
padding[-1],
|
|
1701
|
+
dilation[-1],
|
|
1702
|
+
kernel_size[0],
|
|
1703
|
+
False,
|
|
1704
|
+
)
|
|
1705
|
+
if len(in_size) == 3
|
|
1706
|
+
else get_conv2d_output_size(
|
|
1707
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1708
|
+
)
|
|
1709
|
+
)
|
|
1710
|
+
|
|
1711
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
@register_fake("cadence::quantized_conv2d_nchw_asym8uxsym8u_asym8u.per_tensor")
|
|
1715
|
+
def quantized_conv2d_nchw_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
1716
|
+
input: torch.Tensor,
|
|
1717
|
+
weight: torch.Tensor,
|
|
1718
|
+
bias: torch.Tensor,
|
|
1719
|
+
stride: Tuple[int],
|
|
1720
|
+
padding: Tuple[int],
|
|
1721
|
+
dilation: Tuple[int],
|
|
1722
|
+
groups: int,
|
|
1723
|
+
in_zero_point: int,
|
|
1724
|
+
weight_zero_point: int,
|
|
1725
|
+
bias_scale: float,
|
|
1726
|
+
output_scale: float,
|
|
1727
|
+
output_zero_point: int,
|
|
1728
|
+
out_multiplier: int,
|
|
1729
|
+
out_shift: int,
|
|
1730
|
+
) -> torch.Tensor:
|
|
1731
|
+
assert (
|
|
1732
|
+
input.dtype == torch.uint8
|
|
1733
|
+
and weight.dtype == torch.uint8
|
|
1734
|
+
and bias.dtype == torch.int32
|
|
1735
|
+
)
|
|
1736
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1737
|
+
|
|
1738
|
+
in_size = input.shape
|
|
1739
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1740
|
+
assert len(in_size) > 2
|
|
1741
|
+
assert len(in_size) < 6
|
|
1742
|
+
|
|
1743
|
+
# Compute the output tensor size
|
|
1744
|
+
output_size = (
|
|
1745
|
+
get_conv1d_output_size(
|
|
1746
|
+
in_size,
|
|
1747
|
+
out_channels,
|
|
1748
|
+
stride[-1],
|
|
1749
|
+
padding[-1],
|
|
1750
|
+
dilation[-1],
|
|
1751
|
+
kernel_size[0],
|
|
1752
|
+
False,
|
|
1753
|
+
)
|
|
1754
|
+
if len(in_size) == 3
|
|
1755
|
+
else get_conv2d_output_size(
|
|
1756
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1757
|
+
)
|
|
1758
|
+
)
|
|
1759
|
+
|
|
1760
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
@register_fake("cadence::quantized_conv2d_nhwc_asym8sxsym8s_asym8s.per_tensor")
|
|
1764
|
+
def quantized_conv2d_nhwc_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
1765
|
+
input: torch.Tensor,
|
|
1766
|
+
weight: torch.Tensor,
|
|
1767
|
+
bias: torch.Tensor,
|
|
1768
|
+
stride: Tuple[int],
|
|
1769
|
+
padding: Tuple[int],
|
|
1770
|
+
dilation: Tuple[int],
|
|
1771
|
+
groups: int,
|
|
1772
|
+
in_zero_point: int,
|
|
1773
|
+
weight_zero_point: int,
|
|
1774
|
+
bias_scale: float,
|
|
1775
|
+
output_scale: float,
|
|
1776
|
+
output_zero_point: int,
|
|
1777
|
+
out_multiplier: int,
|
|
1778
|
+
out_shift: int,
|
|
1779
|
+
) -> torch.Tensor:
|
|
1780
|
+
assert (
|
|
1781
|
+
input.dtype == torch.int8
|
|
1782
|
+
and weight.dtype == torch.int8
|
|
1783
|
+
and bias.dtype == torch.int32
|
|
1784
|
+
)
|
|
1785
|
+
in_size = input.shape
|
|
1786
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1787
|
+
assert len(in_size) > 2
|
|
1788
|
+
assert len(in_size) < 6
|
|
1789
|
+
|
|
1790
|
+
# Determine weight layout based on depthwise vs regular conv.
|
|
1791
|
+
in_channels = in_size[-1]
|
|
1792
|
+
if is_depthwise_conv(groups, in_channels):
|
|
1793
|
+
*kernel_size, out_channels = weight.shape
|
|
1794
|
+
elif len(in_size) == 3:
|
|
1795
|
+
# 1D conv: weight is [OC, K, IC]
|
|
1796
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1797
|
+
else:
|
|
1798
|
+
# 2D regular conv: weight is [OC, KH, KW, IC]
|
|
1799
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1800
|
+
|
|
1801
|
+
# Compute the output tensor size
|
|
1802
|
+
output_size = (
|
|
1803
|
+
get_conv1d_output_size(
|
|
1804
|
+
in_size,
|
|
1805
|
+
out_channels,
|
|
1806
|
+
stride[-1],
|
|
1807
|
+
padding[-1],
|
|
1808
|
+
dilation[-1],
|
|
1809
|
+
kernel_size[0],
|
|
1810
|
+
True,
|
|
1811
|
+
)
|
|
1812
|
+
if len(in_size) == 3
|
|
1813
|
+
else get_conv2d_output_size(
|
|
1814
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
1815
|
+
)
|
|
1816
|
+
)
|
|
1817
|
+
|
|
1818
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
@register_fake("cadence::quantized_conv2d_nhwc_asym8uxsym8u_asym8u.per_tensor")
|
|
1822
|
+
def quantized_conv2d_nhwc_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
1823
|
+
input: torch.Tensor,
|
|
1824
|
+
weight: torch.Tensor,
|
|
1825
|
+
bias: torch.Tensor,
|
|
1826
|
+
stride: Tuple[int],
|
|
1827
|
+
padding: Tuple[int],
|
|
1828
|
+
dilation: Tuple[int],
|
|
1829
|
+
groups: int,
|
|
1830
|
+
in_zero_point: int,
|
|
1831
|
+
weight_zero_point: int,
|
|
1832
|
+
bias_scale: float,
|
|
1833
|
+
output_scale: float,
|
|
1834
|
+
output_zero_point: int,
|
|
1835
|
+
out_multiplier: int,
|
|
1836
|
+
out_shift: int,
|
|
1837
|
+
) -> torch.Tensor:
|
|
1838
|
+
assert (
|
|
1839
|
+
input.dtype == torch.uint8
|
|
1840
|
+
and weight.dtype == torch.uint8
|
|
1841
|
+
and bias.dtype == torch.int32
|
|
1842
|
+
)
|
|
1843
|
+
in_size = input.shape
|
|
1844
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1845
|
+
assert len(in_size) > 2
|
|
1846
|
+
assert len(in_size) < 6
|
|
1847
|
+
|
|
1848
|
+
# Determine weight layout based on depthwise vs regular conv.
|
|
1849
|
+
in_channels = in_size[-1]
|
|
1850
|
+
if is_depthwise_conv(groups, in_channels):
|
|
1851
|
+
*kernel_size, out_channels = weight.shape
|
|
1852
|
+
elif len(in_size) == 3:
|
|
1853
|
+
# 1D conv: weight is [OC, K, IC]
|
|
1854
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1855
|
+
else:
|
|
1856
|
+
# 2D regular conv: weight is [OC, KH, KW, IC]
|
|
1857
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
1858
|
+
|
|
1859
|
+
# Compute the output tensor size
|
|
1860
|
+
output_size = (
|
|
1861
|
+
get_conv1d_output_size(
|
|
1862
|
+
in_size,
|
|
1863
|
+
out_channels,
|
|
1864
|
+
stride[-1],
|
|
1865
|
+
padding[-1],
|
|
1866
|
+
dilation[-1],
|
|
1867
|
+
kernel_size[0],
|
|
1868
|
+
True,
|
|
1869
|
+
)
|
|
1870
|
+
if len(in_size) == 3
|
|
1871
|
+
else get_conv2d_output_size(
|
|
1872
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
1873
|
+
)
|
|
1874
|
+
)
|
|
1875
|
+
|
|
1876
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
@register_fake("cadence::quantized_conv2d_nchw_dilated_asym8sxsym8s_asym8s.per_tensor")
|
|
1880
|
+
def quantized_conv2d_nchw_dilated_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
1881
|
+
input: torch.Tensor,
|
|
1882
|
+
weight: torch.Tensor,
|
|
1883
|
+
bias: torch.Tensor,
|
|
1884
|
+
stride: Tuple[int],
|
|
1885
|
+
padding: Tuple[int],
|
|
1886
|
+
dilation: Tuple[int],
|
|
1887
|
+
groups: int,
|
|
1888
|
+
in_zero_point: int,
|
|
1889
|
+
weight_zero_point: int,
|
|
1890
|
+
bias_scale: float,
|
|
1891
|
+
output_scale: float,
|
|
1892
|
+
output_zero_point: int,
|
|
1893
|
+
out_multiplier: int,
|
|
1894
|
+
out_shift: int,
|
|
1895
|
+
) -> torch.Tensor:
|
|
1896
|
+
assert (
|
|
1897
|
+
input.dtype == torch.int8
|
|
1898
|
+
and weight.dtype == torch.int8
|
|
1899
|
+
and bias.dtype == torch.int32
|
|
1900
|
+
)
|
|
1901
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1902
|
+
|
|
1903
|
+
in_size = input.shape
|
|
1904
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1905
|
+
assert len(in_size) > 2
|
|
1906
|
+
assert len(in_size) < 6
|
|
1907
|
+
|
|
1908
|
+
# Compute the output tensor size
|
|
1909
|
+
output_size = (
|
|
1910
|
+
get_conv1d_output_size(
|
|
1911
|
+
in_size,
|
|
1912
|
+
out_channels,
|
|
1913
|
+
stride[-1],
|
|
1914
|
+
padding[-1],
|
|
1915
|
+
dilation[-1],
|
|
1916
|
+
kernel_size[0],
|
|
1917
|
+
False,
|
|
1918
|
+
)
|
|
1919
|
+
if len(in_size) == 3
|
|
1920
|
+
else get_conv2d_output_size(
|
|
1921
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1922
|
+
)
|
|
1923
|
+
)
|
|
1924
|
+
|
|
1925
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
@register_fake("cadence::quantized_conv2d_nchw_dilated_asym8uxsym8u_asym8u.per_tensor")
|
|
1929
|
+
def quantized_conv2d_nchw_dilated_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
1930
|
+
input: torch.Tensor,
|
|
1931
|
+
weight: torch.Tensor,
|
|
1932
|
+
bias: torch.Tensor,
|
|
1933
|
+
stride: Tuple[int],
|
|
1934
|
+
padding: Tuple[int],
|
|
1935
|
+
dilation: Tuple[int],
|
|
1936
|
+
groups: int,
|
|
1937
|
+
in_zero_point: int,
|
|
1938
|
+
weight_zero_point: int,
|
|
1939
|
+
bias_scale: float,
|
|
1940
|
+
output_scale: float,
|
|
1941
|
+
output_zero_point: int,
|
|
1942
|
+
out_multiplier: int,
|
|
1943
|
+
out_shift: int,
|
|
1944
|
+
) -> torch.Tensor:
|
|
1945
|
+
assert (
|
|
1946
|
+
input.dtype == torch.uint8
|
|
1947
|
+
and weight.dtype == torch.uint8
|
|
1948
|
+
and bias.dtype == torch.int32
|
|
1949
|
+
)
|
|
1950
|
+
out_channels, _, *kernel_size = weight.shape
|
|
1951
|
+
|
|
1952
|
+
in_size = input.shape
|
|
1953
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
1954
|
+
assert len(in_size) > 2
|
|
1955
|
+
assert len(in_size) < 6
|
|
1956
|
+
|
|
1957
|
+
# Compute the output tensor size
|
|
1958
|
+
output_size = (
|
|
1959
|
+
get_conv1d_output_size(
|
|
1960
|
+
in_size,
|
|
1961
|
+
out_channels,
|
|
1962
|
+
stride[-1],
|
|
1963
|
+
padding[-1],
|
|
1964
|
+
dilation[-1],
|
|
1965
|
+
kernel_size[0],
|
|
1966
|
+
False,
|
|
1967
|
+
)
|
|
1968
|
+
if len(in_size) == 3
|
|
1969
|
+
else get_conv2d_output_size(
|
|
1970
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
1971
|
+
)
|
|
1972
|
+
)
|
|
1973
|
+
|
|
1974
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
@register_fake("cadence::quantized_conv2d_nhwc_dilated_asym8sxsym8s_asym8s.per_tensor")
|
|
1978
|
+
def quantized_conv2d_nhwc_dilated_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
1979
|
+
input: torch.Tensor,
|
|
1980
|
+
weight: torch.Tensor,
|
|
1981
|
+
bias: torch.Tensor,
|
|
1982
|
+
stride: Tuple[int],
|
|
1983
|
+
padding: Tuple[int],
|
|
1984
|
+
dilation: Tuple[int],
|
|
1985
|
+
groups: int,
|
|
1986
|
+
in_zero_point: int,
|
|
1987
|
+
weight_zero_point: int,
|
|
1988
|
+
bias_scale: float,
|
|
1989
|
+
output_scale: float,
|
|
1990
|
+
output_zero_point: int,
|
|
1991
|
+
out_multiplier: int,
|
|
1992
|
+
out_shift: int,
|
|
1993
|
+
) -> torch.Tensor:
|
|
1994
|
+
assert (
|
|
1995
|
+
input.dtype == torch.int8
|
|
1996
|
+
and weight.dtype == torch.int8
|
|
1997
|
+
and bias.dtype == torch.int32
|
|
1998
|
+
)
|
|
1999
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
2000
|
+
|
|
2001
|
+
in_size = input.shape
|
|
2002
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2003
|
+
assert len(in_size) > 2
|
|
2004
|
+
assert len(in_size) < 6
|
|
2005
|
+
|
|
2006
|
+
# Compute the output tensor size
|
|
2007
|
+
output_size = (
|
|
2008
|
+
get_conv1d_output_size(
|
|
2009
|
+
in_size,
|
|
2010
|
+
out_channels,
|
|
2011
|
+
stride[-1],
|
|
2012
|
+
padding[-1],
|
|
2013
|
+
dilation[-1],
|
|
2014
|
+
kernel_size[0],
|
|
2015
|
+
True,
|
|
2016
|
+
)
|
|
2017
|
+
if len(in_size) == 3
|
|
2018
|
+
else get_conv2d_output_size(
|
|
2019
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
2020
|
+
)
|
|
2021
|
+
)
|
|
2022
|
+
|
|
2023
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
@register_fake("cadence::quantized_conv2d_nhwc_dilated_asym8uxsym8u_asym8u.per_tensor")
|
|
2027
|
+
def quantized_conv2d_nhwc_dilated_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
2028
|
+
input: torch.Tensor,
|
|
2029
|
+
weight: torch.Tensor,
|
|
2030
|
+
bias: torch.Tensor,
|
|
2031
|
+
stride: Tuple[int],
|
|
2032
|
+
padding: Tuple[int],
|
|
2033
|
+
dilation: Tuple[int],
|
|
2034
|
+
groups: int,
|
|
2035
|
+
in_zero_point: int,
|
|
2036
|
+
weight_zero_point: int,
|
|
2037
|
+
bias_scale: float,
|
|
2038
|
+
output_scale: float,
|
|
2039
|
+
output_zero_point: int,
|
|
2040
|
+
out_multiplier: int,
|
|
2041
|
+
out_shift: int,
|
|
2042
|
+
) -> torch.Tensor:
|
|
2043
|
+
assert (
|
|
2044
|
+
input.dtype == torch.uint8
|
|
2045
|
+
and weight.dtype == torch.uint8
|
|
2046
|
+
and bias.dtype == torch.int32
|
|
2047
|
+
)
|
|
2048
|
+
out_channels, *kernel_size, _ = weight.shape
|
|
2049
|
+
|
|
2050
|
+
in_size = input.shape
|
|
2051
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2052
|
+
assert len(in_size) > 2
|
|
2053
|
+
assert len(in_size) < 6
|
|
2054
|
+
|
|
2055
|
+
# Compute the output tensor size
|
|
2056
|
+
output_size = (
|
|
2057
|
+
get_conv1d_output_size(
|
|
2058
|
+
in_size,
|
|
2059
|
+
out_channels,
|
|
2060
|
+
stride[-1],
|
|
2061
|
+
padding[-1],
|
|
2062
|
+
dilation[-1],
|
|
2063
|
+
kernel_size[0],
|
|
2064
|
+
True,
|
|
2065
|
+
)
|
|
2066
|
+
if len(in_size) == 3
|
|
2067
|
+
else get_conv2d_output_size(
|
|
2068
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
2069
|
+
)
|
|
2070
|
+
)
|
|
2071
|
+
|
|
2072
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
@register_fake(
|
|
2076
|
+
"cadence::quantized_conv2d_nchw_depthwise_asym8sxsym8s_asym8s.per_tensor"
|
|
2077
|
+
)
|
|
2078
|
+
def quantized_conv2d_nchw_depthwise_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
2079
|
+
input: torch.Tensor,
|
|
2080
|
+
weight: torch.Tensor,
|
|
2081
|
+
bias: torch.Tensor,
|
|
2082
|
+
stride: Tuple[int],
|
|
2083
|
+
padding: Tuple[int],
|
|
2084
|
+
dilation: Tuple[int],
|
|
2085
|
+
groups: int,
|
|
2086
|
+
in_zero_point: int,
|
|
2087
|
+
weight_zero_point: int,
|
|
2088
|
+
bias_scale: float,
|
|
2089
|
+
output_scale: float,
|
|
2090
|
+
output_zero_point: int,
|
|
2091
|
+
out_multiplier: int,
|
|
2092
|
+
out_shift: int,
|
|
2093
|
+
) -> torch.Tensor:
|
|
2094
|
+
assert (
|
|
2095
|
+
input.dtype == torch.int8
|
|
2096
|
+
and weight.dtype == torch.int8
|
|
2097
|
+
and bias.dtype == torch.int32
|
|
2098
|
+
)
|
|
2099
|
+
out_channels, _, *kernel_size = weight.shape
|
|
2100
|
+
|
|
2101
|
+
in_size = input.shape
|
|
2102
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2103
|
+
assert len(in_size) > 2
|
|
2104
|
+
assert len(in_size) < 6
|
|
2105
|
+
|
|
2106
|
+
# Compute the output tensor size
|
|
2107
|
+
output_size = (
|
|
2108
|
+
get_conv1d_output_size(
|
|
2109
|
+
in_size,
|
|
2110
|
+
out_channels,
|
|
2111
|
+
stride[-1],
|
|
2112
|
+
padding[-1],
|
|
2113
|
+
dilation[-1],
|
|
2114
|
+
kernel_size[0],
|
|
2115
|
+
False,
|
|
2116
|
+
)
|
|
2117
|
+
if len(in_size) == 3
|
|
2118
|
+
else get_conv2d_output_size(
|
|
2119
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
2120
|
+
)
|
|
2121
|
+
)
|
|
2122
|
+
|
|
2123
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
@register_fake(
|
|
2127
|
+
"cadence::quantized_conv2d_nchw_depthwise_asym8uxsym8u_asym8u.per_tensor"
|
|
2128
|
+
)
|
|
2129
|
+
def quantized_conv2d_nchw_depthwise_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
2130
|
+
input: torch.Tensor,
|
|
2131
|
+
weight: torch.Tensor,
|
|
2132
|
+
bias: torch.Tensor,
|
|
2133
|
+
stride: Tuple[int],
|
|
2134
|
+
padding: Tuple[int],
|
|
2135
|
+
dilation: Tuple[int],
|
|
2136
|
+
groups: int,
|
|
2137
|
+
in_zero_point: int,
|
|
2138
|
+
weight_zero_point: int,
|
|
2139
|
+
bias_scale: float,
|
|
2140
|
+
output_scale: float,
|
|
2141
|
+
output_zero_point: int,
|
|
2142
|
+
out_multiplier: int,
|
|
2143
|
+
out_shift: int,
|
|
2144
|
+
) -> torch.Tensor:
|
|
2145
|
+
assert (
|
|
2146
|
+
input.dtype == torch.uint8
|
|
2147
|
+
and weight.dtype == torch.uint8
|
|
2148
|
+
and bias.dtype == torch.int32
|
|
2149
|
+
)
|
|
2150
|
+
out_channels, _, *kernel_size = weight.shape
|
|
2151
|
+
|
|
2152
|
+
in_size = input.shape
|
|
2153
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2154
|
+
assert len(in_size) > 2
|
|
2155
|
+
assert len(in_size) < 6
|
|
2156
|
+
|
|
2157
|
+
# Compute the output tensor size
|
|
2158
|
+
output_size = (
|
|
2159
|
+
get_conv1d_output_size(
|
|
2160
|
+
in_size,
|
|
2161
|
+
out_channels,
|
|
2162
|
+
stride[-1],
|
|
2163
|
+
padding[-1],
|
|
2164
|
+
dilation[-1],
|
|
2165
|
+
kernel_size[0],
|
|
2166
|
+
False,
|
|
2167
|
+
)
|
|
2168
|
+
if len(in_size) == 3
|
|
2169
|
+
else get_conv2d_output_size(
|
|
2170
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
2171
|
+
)
|
|
2172
|
+
)
|
|
2173
|
+
|
|
2174
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
@register_fake(
|
|
2178
|
+
"cadence::quantized_conv2d_nhwc_depthwise_asym8sxsym8s_asym8s.per_tensor"
|
|
2179
|
+
)
|
|
2180
|
+
def quantized_conv2d_nhwc_depthwise_asym8sxsym8s_asym8s_per_tensor_meta(
|
|
2181
|
+
input: torch.Tensor,
|
|
2182
|
+
weight: torch.Tensor,
|
|
2183
|
+
bias: torch.Tensor,
|
|
2184
|
+
stride: Tuple[int],
|
|
2185
|
+
padding: Tuple[int],
|
|
2186
|
+
dilation: Tuple[int],
|
|
2187
|
+
groups: int,
|
|
2188
|
+
in_zero_point: int,
|
|
2189
|
+
weight_zero_point: int,
|
|
2190
|
+
bias_scale: float,
|
|
2191
|
+
output_scale: float,
|
|
2192
|
+
output_zero_point: int,
|
|
2193
|
+
out_multiplier: int,
|
|
2194
|
+
out_shift: int,
|
|
2195
|
+
) -> torch.Tensor:
|
|
2196
|
+
assert (
|
|
2197
|
+
input.dtype == torch.int8
|
|
2198
|
+
and weight.dtype == torch.int8
|
|
2199
|
+
and bias.dtype == torch.int32
|
|
2200
|
+
)
|
|
2201
|
+
in_size = input.shape
|
|
2202
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2203
|
+
assert len(in_size) > 2
|
|
2204
|
+
assert len(in_size) < 6
|
|
2205
|
+
# Depthwise weight is always [*kernel_size, OC]:
|
|
2206
|
+
# 2D: [KH, KW, OC], 1D: [K, OC]
|
|
2207
|
+
*kernel_size, out_channels = weight.shape
|
|
2208
|
+
|
|
2209
|
+
# Compute the output tensor size
|
|
2210
|
+
output_size = (
|
|
2211
|
+
get_conv1d_output_size(
|
|
2212
|
+
in_size,
|
|
2213
|
+
out_channels,
|
|
2214
|
+
stride[-1],
|
|
2215
|
+
padding[-1],
|
|
2216
|
+
dilation[-1],
|
|
2217
|
+
kernel_size[0],
|
|
2218
|
+
True,
|
|
2219
|
+
)
|
|
2220
|
+
if len(in_size) == 3
|
|
2221
|
+
else get_conv2d_output_size(
|
|
2222
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
2223
|
+
)
|
|
2224
|
+
)
|
|
2225
|
+
|
|
2226
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2227
|
+
|
|
2228
|
+
|
|
2229
|
+
@register_fake(
|
|
2230
|
+
"cadence::quantized_conv2d_nhwc_depthwise_asym8uxsym8u_asym8u.per_tensor"
|
|
2231
|
+
)
|
|
2232
|
+
def quantized_conv2d_nhwc_depthwise_asym8uxsym8u_asym8u_per_tensor_meta(
|
|
2233
|
+
input: torch.Tensor,
|
|
2234
|
+
weight: torch.Tensor,
|
|
2235
|
+
bias: torch.Tensor,
|
|
2236
|
+
stride: Tuple[int],
|
|
2237
|
+
padding: Tuple[int],
|
|
2238
|
+
dilation: Tuple[int],
|
|
2239
|
+
groups: int,
|
|
2240
|
+
in_zero_point: int,
|
|
2241
|
+
weight_zero_point: int,
|
|
2242
|
+
bias_scale: float,
|
|
2243
|
+
output_scale: float,
|
|
2244
|
+
output_zero_point: int,
|
|
2245
|
+
out_multiplier: int,
|
|
2246
|
+
out_shift: int,
|
|
2247
|
+
) -> torch.Tensor:
|
|
2248
|
+
assert (
|
|
2249
|
+
input.dtype == torch.uint8
|
|
2250
|
+
and weight.dtype == torch.uint8
|
|
2251
|
+
and bias.dtype == torch.int32
|
|
2252
|
+
)
|
|
2253
|
+
in_size = input.shape
|
|
2254
|
+
# Assert that the input tensor has at least 3 dimensions, and at most 6
|
|
2255
|
+
assert len(in_size) > 2
|
|
2256
|
+
assert len(in_size) < 6
|
|
2257
|
+
# Depthwise weight is always [*kernel_size, OC]:
|
|
2258
|
+
# 2D: [KH, KW, OC], 1D: [K, OC]
|
|
2259
|
+
*kernel_size, out_channels = weight.shape
|
|
2260
|
+
|
|
2261
|
+
# Compute the output tensor size
|
|
2262
|
+
output_size = (
|
|
2263
|
+
get_conv1d_output_size(
|
|
2264
|
+
in_size,
|
|
2265
|
+
out_channels,
|
|
2266
|
+
stride[-1],
|
|
2267
|
+
padding[-1],
|
|
2268
|
+
dilation[-1],
|
|
2269
|
+
kernel_size[0],
|
|
2270
|
+
True,
|
|
2271
|
+
)
|
|
2272
|
+
if len(in_size) == 3
|
|
2273
|
+
else get_conv2d_output_size(
|
|
2274
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
2275
|
+
)
|
|
2276
|
+
)
|
|
2277
|
+
|
|
2278
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
@register_fake("cadence::quantized_conv2d_depthwise_nhwc")
|
|
2282
|
+
def quantized_conv2d_depthwise_nhwc_meta(
|
|
2283
|
+
input: torch.Tensor,
|
|
2284
|
+
weight: torch.Tensor,
|
|
2285
|
+
bias: torch.Tensor,
|
|
2286
|
+
stride: Tuple[int],
|
|
2287
|
+
padding: Tuple[int],
|
|
2288
|
+
dilation: Tuple[int],
|
|
2289
|
+
groups: int,
|
|
2290
|
+
in_zero_point: int,
|
|
2291
|
+
weight_zero_point: int,
|
|
2292
|
+
bias_scale: float,
|
|
2293
|
+
output_scale: float,
|
|
2294
|
+
output_zero_point: int,
|
|
2295
|
+
out_multiplier: int,
|
|
2296
|
+
out_shift: int,
|
|
2297
|
+
) -> torch.Tensor:
|
|
2298
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2299
|
+
in_size = input.shape
|
|
2300
|
+
assert len(in_size) > 2
|
|
2301
|
+
assert len(in_size) < 6
|
|
2302
|
+
# Depthwise weight is always [*kernel_size, OC]:
|
|
2303
|
+
# 2D: [KH, KW, OC], 1D: [K, OC]
|
|
2304
|
+
*kernel_size, out_channels = weight.shape
|
|
2305
|
+
|
|
2306
|
+
output_size = (
|
|
2307
|
+
get_conv1d_output_size(
|
|
2308
|
+
in_size,
|
|
2309
|
+
out_channels,
|
|
2310
|
+
stride[-1],
|
|
2311
|
+
padding[-1],
|
|
2312
|
+
dilation[-1],
|
|
2313
|
+
kernel_size[0],
|
|
2314
|
+
True,
|
|
2315
|
+
)
|
|
2316
|
+
if len(in_size) == 3
|
|
2317
|
+
else get_conv2d_output_size(
|
|
2318
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, True
|
|
2319
|
+
)
|
|
2320
|
+
)
|
|
2321
|
+
|
|
2322
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
@register_fake("cadence::quantized_layer_norm")
|
|
2326
|
+
def quantized_layer_norm_meta(
|
|
2327
|
+
input: torch.Tensor,
|
|
2328
|
+
X_scale: torch.Tensor,
|
|
2329
|
+
X_zero_point: torch.Tensor,
|
|
2330
|
+
normalized_shape: list[int],
|
|
2331
|
+
weight: torch.Tensor,
|
|
2332
|
+
bias: torch.Tensor,
|
|
2333
|
+
eps: float,
|
|
2334
|
+
output_scale: float,
|
|
2335
|
+
output_zero_point: int,
|
|
2336
|
+
) -> torch.Tensor:
|
|
2337
|
+
torch._check(weight.dtype == torch.float32, lambda: "expected float32")
|
|
2338
|
+
torch._check(bias.dtype == torch.float32, lambda: "expected float32")
|
|
2339
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
@register_fake("cadence::quantized_layer_norm.per_tensor")
|
|
2343
|
+
def quantized_layer_norm_per_tensor_meta(
|
|
2344
|
+
input: torch.Tensor,
|
|
2345
|
+
X_scale: float,
|
|
2346
|
+
X_zero_point: int,
|
|
2347
|
+
normalized_shape: list[int],
|
|
2348
|
+
weight: torch.Tensor,
|
|
2349
|
+
bias: torch.Tensor,
|
|
2350
|
+
eps: float,
|
|
2351
|
+
output_scale: float,
|
|
2352
|
+
output_zero_point: int,
|
|
2353
|
+
) -> torch.Tensor:
|
|
2354
|
+
torch._check(weight.dtype == torch.float32, lambda: "expected float32")
|
|
2355
|
+
torch._check(bias.dtype == torch.float32, lambda: "expected float32")
|
|
2356
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
2357
|
+
|
|
2358
|
+
|
|
2359
|
+
@register_fake("cadence::quantized_relu")
|
|
2360
|
+
def quantized_relu_meta(
|
|
2361
|
+
X: torch.Tensor,
|
|
2362
|
+
X_zero_point: torch.Tensor,
|
|
2363
|
+
out_zero_point: int,
|
|
2364
|
+
out_multiplier: torch.Tensor,
|
|
2365
|
+
out_shift: torch.Tensor,
|
|
2366
|
+
) -> torch.Tensor:
|
|
2367
|
+
return X.new_empty(X.size(), dtype=X.dtype)
|
|
2368
|
+
|
|
2369
|
+
|
|
2370
|
+
@register_fake("cadence::quantized_matmul")
|
|
2371
|
+
def quantized_matmul_meta(
|
|
2372
|
+
X: torch.Tensor,
|
|
2373
|
+
X_zero_point: int,
|
|
2374
|
+
Y: torch.Tensor,
|
|
2375
|
+
Y_zero_point: int,
|
|
2376
|
+
bias: Optional[torch.Tensor],
|
|
2377
|
+
out_multiplier: int,
|
|
2378
|
+
out_shift: int,
|
|
2379
|
+
out_zero_point: int,
|
|
2380
|
+
transposed: bool = False,
|
|
2381
|
+
) -> torch.Tensor:
|
|
2382
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
2383
|
+
torch._check(X.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2384
|
+
torch._check(Y.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2385
|
+
X_size = list(X.size())
|
|
2386
|
+
Y_size = list(Y.size())
|
|
2387
|
+
|
|
2388
|
+
# Get the batch dimensions for both tensors
|
|
2389
|
+
X_batch_dims = X_size[:-2]
|
|
2390
|
+
Y_batch_dims = Y_size[:-2]
|
|
2391
|
+
|
|
2392
|
+
# If they don't match, check that they're compatible
|
|
2393
|
+
if X_batch_dims != Y_batch_dims:
|
|
2394
|
+
assert prod(X_batch_dims) == prod(
|
|
2395
|
+
Y_batch_dims
|
|
2396
|
+
), f"Batch dimensions of X and Y do not match: {X_batch_dims} vs {Y_batch_dims}"
|
|
2397
|
+
|
|
2398
|
+
# Get the matmul output size
|
|
2399
|
+
if transposed:
|
|
2400
|
+
assert X_size[-1] == Y_size[-1], "matrices cannot be multiplied"
|
|
2401
|
+
mat_size = [X_size[-2], Y_size[-2]]
|
|
2402
|
+
else:
|
|
2403
|
+
assert X_size[-1] == Y_size[-2], "matrices cannot be multiplied"
|
|
2404
|
+
mat_size = [X_size[-2], Y_size[-1]]
|
|
2405
|
+
|
|
2406
|
+
# Combine the larger batch dimensions with the matmul output size
|
|
2407
|
+
out_size = (
|
|
2408
|
+
X_batch_dims + mat_size
|
|
2409
|
+
if len(X_batch_dims) > len(Y_batch_dims)
|
|
2410
|
+
else Y_batch_dims + mat_size
|
|
2411
|
+
)
|
|
2412
|
+
|
|
2413
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
@register_fake("cadence::quantized_matmul_asym8sxasym8s_asym8s")
|
|
2417
|
+
def quantized_matmul_asym8sxasym8s_asym8s_meta(
|
|
2418
|
+
X: torch.Tensor,
|
|
2419
|
+
X_zero_point: int,
|
|
2420
|
+
Y: torch.Tensor,
|
|
2421
|
+
Y_zero_point: int,
|
|
2422
|
+
bias: Optional[torch.Tensor],
|
|
2423
|
+
out_multiplier: int,
|
|
2424
|
+
out_shift: int,
|
|
2425
|
+
out_zero_point: int,
|
|
2426
|
+
transposed: bool = False,
|
|
2427
|
+
) -> torch.Tensor:
|
|
2428
|
+
torch._check(X.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2429
|
+
torch._check(Y.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2430
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
2431
|
+
torch._check(X.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2432
|
+
torch._check(Y.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2433
|
+
X_size = list(X.size())
|
|
2434
|
+
Y_size = list(Y.size())
|
|
2435
|
+
|
|
2436
|
+
# Get the batch dimensions for both tensors
|
|
2437
|
+
X_batch_dims = X_size[:-2]
|
|
2438
|
+
Y_batch_dims = Y_size[:-2]
|
|
2439
|
+
|
|
2440
|
+
# If they don't match, check that they're compatible
|
|
2441
|
+
if X_batch_dims != Y_batch_dims:
|
|
2442
|
+
assert prod(X_batch_dims) == prod(
|
|
2443
|
+
Y_batch_dims
|
|
2444
|
+
), f"Batch dimensions of X and Y do not match: {X_batch_dims} vs {Y_batch_dims}"
|
|
2445
|
+
|
|
2446
|
+
# Get the matmul output size
|
|
2447
|
+
if transposed:
|
|
2448
|
+
assert X_size[-1] == Y_size[-1], "matrices cannot be multiplied"
|
|
2449
|
+
mat_size = [X_size[-2], Y_size[-2]]
|
|
2450
|
+
else:
|
|
2451
|
+
assert X_size[-1] == Y_size[-2], "matrices cannot be multiplied"
|
|
2452
|
+
mat_size = [X_size[-2], Y_size[-1]]
|
|
2453
|
+
|
|
2454
|
+
# Combine the larger batch dimensions with the matmul output size
|
|
2455
|
+
out_size = (
|
|
2456
|
+
X_batch_dims + mat_size
|
|
2457
|
+
if len(X_batch_dims) > len(Y_batch_dims)
|
|
2458
|
+
else Y_batch_dims + mat_size
|
|
2459
|
+
)
|
|
2460
|
+
|
|
2461
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
2462
|
+
|
|
2463
|
+
|
|
2464
|
+
@register_fake("cadence::quantized_matmul_asym8uxasym8u_asym8u")
|
|
2465
|
+
def quantized_matmul_asym8uxasym8u_asym8u_meta(
|
|
2466
|
+
X: torch.Tensor,
|
|
2467
|
+
X_zero_point: int,
|
|
2468
|
+
Y: torch.Tensor,
|
|
2469
|
+
Y_zero_point: int,
|
|
2470
|
+
bias: Optional[torch.Tensor],
|
|
2471
|
+
out_multiplier: int,
|
|
2472
|
+
out_shift: int,
|
|
2473
|
+
out_zero_point: int,
|
|
2474
|
+
transposed: bool = False,
|
|
2475
|
+
) -> torch.Tensor:
|
|
2476
|
+
torch._check(X.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2477
|
+
torch._check(Y.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2478
|
+
torch._check(X.dtype == Y.dtype, lambda: "expected same dtype")
|
|
2479
|
+
torch._check(X.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2480
|
+
torch._check(Y.dim() >= 2, lambda: "expected at least 2D tensor")
|
|
2481
|
+
X_size = list(X.size())
|
|
2482
|
+
Y_size = list(Y.size())
|
|
2483
|
+
|
|
2484
|
+
# Get the batch dimensions for both tensors
|
|
2485
|
+
X_batch_dims = X_size[:-2]
|
|
2486
|
+
Y_batch_dims = Y_size[:-2]
|
|
2487
|
+
|
|
2488
|
+
# If they don't match, check that they're compatible
|
|
2489
|
+
if X_batch_dims != Y_batch_dims:
|
|
2490
|
+
assert prod(X_batch_dims) == prod(
|
|
2491
|
+
Y_batch_dims
|
|
2492
|
+
), f"Batch dimensions of X and Y do not match: {X_batch_dims} vs {Y_batch_dims}"
|
|
2493
|
+
|
|
2494
|
+
# Get the matmul output size
|
|
2495
|
+
if transposed:
|
|
2496
|
+
assert X_size[-1] == Y_size[-1], "matrices cannot be multiplied"
|
|
2497
|
+
mat_size = [X_size[-2], Y_size[-2]]
|
|
2498
|
+
else:
|
|
2499
|
+
assert X_size[-1] == Y_size[-2], "matrices cannot be multiplied"
|
|
2500
|
+
mat_size = [X_size[-2], Y_size[-1]]
|
|
2501
|
+
|
|
2502
|
+
# Combine the larger batch dimensions with the matmul output size
|
|
2503
|
+
out_size = (
|
|
2504
|
+
X_batch_dims + mat_size
|
|
2505
|
+
if len(X_batch_dims) > len(Y_batch_dims)
|
|
2506
|
+
else Y_batch_dims + mat_size
|
|
2507
|
+
)
|
|
2508
|
+
|
|
2509
|
+
return X.new_empty(out_size, dtype=X.dtype)
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
@register_fake("cadence::im2row")
|
|
2513
|
+
def im2row_meta(
|
|
2514
|
+
input: torch.Tensor,
|
|
2515
|
+
kernel_size: Tuple[int],
|
|
2516
|
+
dilation: Tuple[int],
|
|
2517
|
+
padding: Tuple[int],
|
|
2518
|
+
stride: Tuple[int],
|
|
2519
|
+
in_zero_point: torch.Tensor,
|
|
2520
|
+
channel_last: bool = False,
|
|
2521
|
+
) -> torch.Tensor:
|
|
2522
|
+
torch._check(3 <= input.dim() <= 4, lambda: "expected 3-4D tensor")
|
|
2523
|
+
output_size = get_im2row_output_size(
|
|
2524
|
+
input, kernel_size, dilation, padding, stride, channel_last
|
|
2525
|
+
)
|
|
2526
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
@register_fake("cadence::im2row.per_tensor")
|
|
2530
|
+
def im2row_per_tensor_meta(
|
|
2531
|
+
input: torch.Tensor,
|
|
2532
|
+
kernel_size: Tuple[int],
|
|
2533
|
+
dilation: Tuple[int],
|
|
2534
|
+
padding: Tuple[int],
|
|
2535
|
+
stride: Tuple[int],
|
|
2536
|
+
in_zero_point: int,
|
|
2537
|
+
channel_last: bool = False,
|
|
2538
|
+
) -> torch.Tensor:
|
|
2539
|
+
torch._check(3 <= input.dim() <= 4, lambda: "expected 3-4D tensor")
|
|
2540
|
+
output_size = get_im2row_output_size(
|
|
2541
|
+
input, kernel_size, dilation, padding, stride, channel_last
|
|
2542
|
+
)
|
|
2543
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
@register_fake("cadence::linalg_svd")
|
|
2547
|
+
def linalg_svd_meta(
|
|
2548
|
+
A: torch.Tensor,
|
|
2549
|
+
full_matrices: bool = False,
|
|
2550
|
+
compute_uv: bool = True,
|
|
2551
|
+
driver: Optional[str] = None,
|
|
2552
|
+
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
|
2553
|
+
# Based on the _linalg_svd meta implementation, but ensuring contiguous strides
|
|
2554
|
+
|
|
2555
|
+
# Get the shapes from the original meta function
|
|
2556
|
+
U, S, Vh = _linalg_svd_meta(A, full_matrices, compute_uv, driver)
|
|
2557
|
+
|
|
2558
|
+
# Create new tensors with contiguous strides to fix the non-contiguous issue
|
|
2559
|
+
U_contiguous = A.new_empty(U.shape, dtype=A.dtype).contiguous()
|
|
2560
|
+
S_contiguous = A.new_empty(S.shape, dtype=A.dtype).contiguous()
|
|
2561
|
+
Vh_contiguous = A.new_empty(Vh.shape, dtype=A.dtype).contiguous()
|
|
2562
|
+
|
|
2563
|
+
return U_contiguous, S_contiguous, Vh_contiguous
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
@register_fake("cadence::requantize")
|
|
2567
|
+
def requantize_meta(
|
|
2568
|
+
input: torch.Tensor,
|
|
2569
|
+
in_scale: torch.Tensor,
|
|
2570
|
+
in_zero_point: torch.Tensor,
|
|
2571
|
+
out_scale: torch.Tensor,
|
|
2572
|
+
out_zero_point: torch.Tensor,
|
|
2573
|
+
dtype: ScalarType,
|
|
2574
|
+
) -> torch.Tensor:
|
|
2575
|
+
return input.new_empty(
|
|
2576
|
+
input.size(),
|
|
2577
|
+
# pyre-ignore[6]: Incompatible type
|
|
2578
|
+
dtype=dtype,
|
|
2579
|
+
)
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
@register_fake("cadence::requantize.per_tensor")
|
|
2583
|
+
def requantize_per_tensor_meta(
|
|
2584
|
+
input: torch.Tensor,
|
|
2585
|
+
in_scale: float,
|
|
2586
|
+
in_zero_point: int,
|
|
2587
|
+
out_scale: float,
|
|
2588
|
+
out_zero_point: int,
|
|
2589
|
+
dtype: ScalarType,
|
|
2590
|
+
) -> torch.Tensor:
|
|
2591
|
+
return input.new_empty(
|
|
2592
|
+
input.size(),
|
|
2593
|
+
# pyre-ignore[6]: Incompatible type
|
|
2594
|
+
dtype=dtype,
|
|
2595
|
+
)
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
@register_fake("cadence::quantized_relu.per_tensor")
|
|
2599
|
+
def quantized_relu_per_tensor_meta(
|
|
2600
|
+
input: torch.Tensor,
|
|
2601
|
+
in_zero_point: int,
|
|
2602
|
+
out_zero_point: int,
|
|
2603
|
+
out_multiplier: int,
|
|
2604
|
+
out_shift: int,
|
|
2605
|
+
) -> torch.Tensor:
|
|
2606
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
2607
|
+
|
|
2608
|
+
|
|
2609
|
+
@register_fake("cadence::quantized_relu_asym8s_asym8s.per_tensor")
|
|
2610
|
+
def quantized_relu_asym8s_asym8s_per_tensor_meta(
|
|
2611
|
+
input: torch.Tensor,
|
|
2612
|
+
in_zero_point: int,
|
|
2613
|
+
out_zero_point: int,
|
|
2614
|
+
out_multiplier: int,
|
|
2615
|
+
out_shift: int,
|
|
2616
|
+
) -> torch.Tensor:
|
|
2617
|
+
torch._check(
|
|
2618
|
+
input.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
2619
|
+
)
|
|
2620
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
2621
|
+
|
|
2622
|
+
|
|
2623
|
+
@register_fake("cadence::quantized_relu_asym8u_asym8u.per_tensor")
|
|
2624
|
+
def quantized_relu_asym8u_asym8u_per_tensor_meta(
|
|
2625
|
+
input: torch.Tensor,
|
|
2626
|
+
in_zero_point: int,
|
|
2627
|
+
out_zero_point: int,
|
|
2628
|
+
out_multiplier: int,
|
|
2629
|
+
out_shift: int,
|
|
2630
|
+
) -> torch.Tensor:
|
|
2631
|
+
torch._check(
|
|
2632
|
+
input.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
2633
|
+
)
|
|
2634
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
@register_fake("cadence::quantized_max_pool2d_nchw")
|
|
2638
|
+
def quantized_max_pool2d_nchw_meta(
|
|
2639
|
+
input: torch.Tensor,
|
|
2640
|
+
kernel_size: list[int],
|
|
2641
|
+
stride: list[int],
|
|
2642
|
+
padding: list[int],
|
|
2643
|
+
dilation: list[int],
|
|
2644
|
+
ceil_mode: bool,
|
|
2645
|
+
) -> torch.Tensor:
|
|
2646
|
+
assert (
|
|
2647
|
+
len(kernel_size) == 2
|
|
2648
|
+
), f"kernel_size must have 2 elements, got {len(kernel_size)}"
|
|
2649
|
+
assert len(stride) == 2, f"stride must have 2 elements, got {len(stride)}"
|
|
2650
|
+
assert len(padding) == 2, f"padding must have 2 elements, got {len(padding)}"
|
|
2651
|
+
assert len(dilation) == 2, f"dilation must have 2 elements, got {len(dilation)}"
|
|
2652
|
+
assert (
|
|
2653
|
+
len(input.size()) == 4
|
|
2654
|
+
), f"input must be 4D (N, C, H, W), got {len(input.size())}D"
|
|
2655
|
+
|
|
2656
|
+
batch = input.size(0)
|
|
2657
|
+
channels = input.size(1)
|
|
2658
|
+
height_in = input.size(2)
|
|
2659
|
+
width_in = input.size(3)
|
|
2660
|
+
|
|
2661
|
+
height_out_raw = (
|
|
2662
|
+
height_in + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1
|
|
2663
|
+
) / stride[0] + 1
|
|
2664
|
+
width_out_raw = (
|
|
2665
|
+
width_in + 2 * padding[1] - dilation[1] * (kernel_size[1] - 1) - 1
|
|
2666
|
+
) / stride[1] + 1
|
|
2667
|
+
|
|
2668
|
+
if ceil_mode:
|
|
2669
|
+
height_out = ceil(height_out_raw)
|
|
2670
|
+
width_out = ceil(width_out_raw)
|
|
2671
|
+
else:
|
|
2672
|
+
height_out = int(height_out_raw)
|
|
2673
|
+
width_out = int(width_out_raw)
|
|
2674
|
+
|
|
2675
|
+
return input.new_empty([batch, channels, height_out, width_out], dtype=input.dtype)
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
@register_fake("cadence::quantized_max_pool2d_nhwc")
|
|
2679
|
+
def quantized_max_pool2d_nhwc_meta(
|
|
2680
|
+
input: torch.Tensor,
|
|
2681
|
+
kernel_size: list[int],
|
|
2682
|
+
stride: list[int],
|
|
2683
|
+
padding: list[int],
|
|
2684
|
+
dilation: list[int],
|
|
2685
|
+
ceil_mode: bool,
|
|
2686
|
+
) -> torch.Tensor:
|
|
2687
|
+
assert (
|
|
2688
|
+
len(kernel_size) == 2
|
|
2689
|
+
), f"kernel_size must have 2 elements, got {len(kernel_size)}"
|
|
2690
|
+
assert len(stride) == 2, f"stride must have 2 elements, got {len(stride)}"
|
|
2691
|
+
assert len(padding) == 2, f"padding must have 2 elements, got {len(padding)}"
|
|
2692
|
+
assert len(dilation) == 2, f"dilation must have 2 elements, got {len(dilation)}"
|
|
2693
|
+
assert (
|
|
2694
|
+
len(input.size()) == 4
|
|
2695
|
+
), f"input must be 4D (N, H, W, C), got {len(input.size())}D"
|
|
2696
|
+
|
|
2697
|
+
batch = input.size(0)
|
|
2698
|
+
height_in = input.size(1)
|
|
2699
|
+
width_in = input.size(2)
|
|
2700
|
+
channels = input.size(3)
|
|
2701
|
+
|
|
2702
|
+
height_out_raw = (
|
|
2703
|
+
height_in + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1
|
|
2704
|
+
) / stride[0] + 1
|
|
2705
|
+
width_out_raw = (
|
|
2706
|
+
width_in + 2 * padding[1] - dilation[1] * (kernel_size[1] - 1) - 1
|
|
2707
|
+
) / stride[1] + 1
|
|
2708
|
+
|
|
2709
|
+
if ceil_mode:
|
|
2710
|
+
height_out = ceil(height_out_raw)
|
|
2711
|
+
width_out = ceil(width_out_raw)
|
|
2712
|
+
else:
|
|
2713
|
+
height_out = int(height_out_raw)
|
|
2714
|
+
width_out = int(width_out_raw)
|
|
2715
|
+
|
|
2716
|
+
return input.new_empty([batch, height_out, width_out, channels], dtype=input.dtype)
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
@register_fake("cadence::fully_connected")
|
|
2720
|
+
def fully_connected_meta(
|
|
2721
|
+
src: torch.Tensor,
|
|
2722
|
+
weight: torch.Tensor,
|
|
2723
|
+
bias: Optional[torch.Tensor] = None,
|
|
2724
|
+
) -> torch.Tensor:
|
|
2725
|
+
torch._check(
|
|
2726
|
+
src.dtype in (torch.float32, torch.bfloat16), lambda: "expected float dtype"
|
|
2727
|
+
)
|
|
2728
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2729
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2730
|
+
# weight comes in shape [out_dim, in_dim]
|
|
2731
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
2732
|
+
out_size = list(src.size())
|
|
2733
|
+
weight_size = list(weight.size())
|
|
2734
|
+
assert len(weight_size) == 2
|
|
2735
|
+
out_size[-1] = weight_size[0]
|
|
2736
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2737
|
+
|
|
2738
|
+
|
|
2739
|
+
@register_fake("cadence::quantized_fully_connected")
|
|
2740
|
+
def quantized_fully_connected_meta(
|
|
2741
|
+
src: torch.Tensor,
|
|
2742
|
+
weight: torch.Tensor,
|
|
2743
|
+
bias: torch.Tensor,
|
|
2744
|
+
in_zero_point: int,
|
|
2745
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
2746
|
+
out_multiplier: torch.Tensor,
|
|
2747
|
+
out_shift: torch.Tensor,
|
|
2748
|
+
out_zero_point: int,
|
|
2749
|
+
offset: Optional[torch.Tensor],
|
|
2750
|
+
) -> torch.Tensor:
|
|
2751
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2752
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
2753
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2754
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2755
|
+
# weight comes in shape [out_dim, in_dim]
|
|
2756
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
2757
|
+
assert src.shape[0] == 1
|
|
2758
|
+
out_size = list(src.size())
|
|
2759
|
+
weight_size = list(weight.size())
|
|
2760
|
+
assert len(weight_size) == 2
|
|
2761
|
+
out_size[-1] = weight_size[0]
|
|
2762
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2763
|
+
|
|
2764
|
+
|
|
2765
|
+
@register_fake("cadence::quantized_fully_connected.per_tensor")
|
|
2766
|
+
def quantized_fully_connected_per_tensor_meta(
|
|
2767
|
+
src: torch.Tensor,
|
|
2768
|
+
weight: torch.Tensor,
|
|
2769
|
+
bias: torch.Tensor,
|
|
2770
|
+
in_zero_point: int,
|
|
2771
|
+
weight_zero_point: int,
|
|
2772
|
+
out_multiplier: int,
|
|
2773
|
+
out_shift: int,
|
|
2774
|
+
out_zero_point: int,
|
|
2775
|
+
offset: Optional[torch.Tensor],
|
|
2776
|
+
) -> torch.Tensor:
|
|
2777
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2778
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
2779
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2780
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2781
|
+
# weight comes in shape [out_dim, in_dim]
|
|
2782
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
2783
|
+
assert src.shape[0] == 1
|
|
2784
|
+
out_size = list(src.size())
|
|
2785
|
+
weight_size = list(weight.size())
|
|
2786
|
+
assert len(weight_size) == 2
|
|
2787
|
+
out_size[-1] = weight_size[0]
|
|
2788
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2789
|
+
|
|
2790
|
+
|
|
2791
|
+
@register_fake("cadence::quantized_fully_connected_packed")
|
|
2792
|
+
def quantized_fully_connected_packed_meta(
|
|
2793
|
+
src: torch.Tensor,
|
|
2794
|
+
weight: torch.Tensor,
|
|
2795
|
+
bias: torch.Tensor,
|
|
2796
|
+
in_dim: int,
|
|
2797
|
+
weight_bits: int,
|
|
2798
|
+
in_zero_point: int,
|
|
2799
|
+
weight_zero_point: Optional[torch.Tensor],
|
|
2800
|
+
out_multiplier: torch.Tensor,
|
|
2801
|
+
out_shift: torch.Tensor,
|
|
2802
|
+
out_zero_point: int,
|
|
2803
|
+
offset: Optional[torch.Tensor],
|
|
2804
|
+
) -> torch.Tensor:
|
|
2805
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2806
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
2807
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2808
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2809
|
+
# weight comes in shape [out_dim, packed_row_bytes], so out_dim is still
|
|
2810
|
+
# size(0) - that is what packing per row buys us - but in_dim is an
|
|
2811
|
+
# argument rather than size(1).
|
|
2812
|
+
torch._check(src.size(-1) == in_dim, lambda: "src last dim must equal in_dim")
|
|
2813
|
+
out_size = list(src.size())
|
|
2814
|
+
out_size[-1] = weight.size(0)
|
|
2815
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2816
|
+
|
|
2817
|
+
|
|
2818
|
+
@register_fake("cadence::quantized_fully_connected_asym8sxasym8s_asym8s.per_tensor")
|
|
2819
|
+
def quantized_fully_connected_asym8sxasym8s_asym8s_per_tensor_meta(
|
|
2820
|
+
src: torch.Tensor,
|
|
2821
|
+
weight: torch.Tensor,
|
|
2822
|
+
bias: torch.Tensor,
|
|
2823
|
+
in_zero_point: int,
|
|
2824
|
+
weight_zero_point: int,
|
|
2825
|
+
out_multiplier: int,
|
|
2826
|
+
out_shift: int,
|
|
2827
|
+
out_zero_point: int,
|
|
2828
|
+
offset: Optional[torch.Tensor],
|
|
2829
|
+
) -> torch.Tensor:
|
|
2830
|
+
torch._check(src.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2831
|
+
torch._check(
|
|
2832
|
+
weight.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
2833
|
+
)
|
|
2834
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2835
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
2836
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2837
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2838
|
+
# weight comes in shape [out_dim, in_dim]
|
|
2839
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
2840
|
+
assert src.shape[0] == 1
|
|
2841
|
+
out_size = list(src.size())
|
|
2842
|
+
weight_size = list(weight.size())
|
|
2843
|
+
assert len(weight_size) == 2
|
|
2844
|
+
out_size[-1] = weight_size[0]
|
|
2845
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
@register_fake("cadence::quantized_fully_connected_asym8uxasym8u_asym8u.per_tensor")
|
|
2849
|
+
def quantized_fully_connected_asym8uxasym8u_asym8u_per_tensor_meta(
|
|
2850
|
+
src: torch.Tensor,
|
|
2851
|
+
weight: torch.Tensor,
|
|
2852
|
+
bias: torch.Tensor,
|
|
2853
|
+
in_zero_point: int,
|
|
2854
|
+
weight_zero_point: int,
|
|
2855
|
+
out_multiplier: int,
|
|
2856
|
+
out_shift: int,
|
|
2857
|
+
out_zero_point: int,
|
|
2858
|
+
offset: Optional[torch.Tensor],
|
|
2859
|
+
) -> torch.Tensor:
|
|
2860
|
+
torch._check(src.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype")
|
|
2861
|
+
torch._check(
|
|
2862
|
+
weight.dtype in (torch.int8, torch.uint8), lambda: "expected 8-bit dtype"
|
|
2863
|
+
)
|
|
2864
|
+
torch._check(bias.dtype == torch.int32, lambda: "expected int32")
|
|
2865
|
+
torch._check(weight.dim() == 2, lambda: "expected 2D tensor")
|
|
2866
|
+
torch._check(src.size(0) == 1, lambda: "expected batch size of 1")
|
|
2867
|
+
# src comes in shape [leading_dims, in_dim]
|
|
2868
|
+
# weight comes in shape [out_dim, in_dim]
|
|
2869
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
2870
|
+
assert src.shape[0] == 1
|
|
2871
|
+
out_size = list(src.size())
|
|
2872
|
+
weight_size = list(weight.size())
|
|
2873
|
+
assert len(weight_size) == 2
|
|
2874
|
+
out_size[-1] = weight_size[0]
|
|
2875
|
+
return src.new_empty(out_size, dtype=src.dtype)
|
|
2876
|
+
|
|
2877
|
+
|
|
2878
|
+
@register_fake("cadence::conv1d")
|
|
2879
|
+
def conv1d_meta(
|
|
2880
|
+
input: torch.Tensor,
|
|
2881
|
+
weight: torch.Tensor,
|
|
2882
|
+
bias: torch.Tensor,
|
|
2883
|
+
stride: Tuple[int],
|
|
2884
|
+
padding: Tuple[int],
|
|
2885
|
+
dilation: Tuple[int],
|
|
2886
|
+
groups: int,
|
|
2887
|
+
) -> torch.Tensor:
|
|
2888
|
+
torch._check(input.dtype == torch.float32, lambda: "expected float32")
|
|
2889
|
+
# Validate tensor dimensions
|
|
2890
|
+
assert len(input.shape) == 3, f"Conv1d expects 3D input, got {len(input.shape)}D"
|
|
2891
|
+
assert len(weight.shape) == 3, f"Conv1d expects 3D weight, got {len(weight.shape)}D"
|
|
2892
|
+
|
|
2893
|
+
# Extract dimensions
|
|
2894
|
+
batch_size, in_channels, length = input.shape
|
|
2895
|
+
out_channels, weight_in_channels, kernel_size = weight.shape
|
|
2896
|
+
|
|
2897
|
+
# Validate groups parameter and channel consistency
|
|
2898
|
+
assert groups > 0, f"groups must be positive, got {groups}"
|
|
2899
|
+
assert (
|
|
2900
|
+
in_channels % groups == 0
|
|
2901
|
+
), f"in_channels ({in_channels}) must be divisible by groups ({groups})"
|
|
2902
|
+
assert (
|
|
2903
|
+
out_channels % groups == 0
|
|
2904
|
+
), f"out_channels ({out_channels}) must be divisible by groups ({groups})"
|
|
2905
|
+
|
|
2906
|
+
# Validate weight channels match input channels divided by groups
|
|
2907
|
+
expected_weight_in_channels = in_channels // groups
|
|
2908
|
+
assert (
|
|
2909
|
+
weight_in_channels == expected_weight_in_channels
|
|
2910
|
+
), f"Expected weight to have {expected_weight_in_channels} input channels (in_channels/groups), but got {weight_in_channels}"
|
|
2911
|
+
|
|
2912
|
+
output_size = get_conv1d_output_size(
|
|
2913
|
+
input.shape,
|
|
2914
|
+
out_channels,
|
|
2915
|
+
stride[0],
|
|
2916
|
+
padding[0],
|
|
2917
|
+
dilation[0],
|
|
2918
|
+
kernel_size,
|
|
2919
|
+
False,
|
|
2920
|
+
)
|
|
2921
|
+
|
|
2922
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2923
|
+
|
|
2924
|
+
|
|
2925
|
+
@register_fake("cadence::conv2d")
|
|
2926
|
+
def conv2d_meta(
|
|
2927
|
+
input: torch.Tensor,
|
|
2928
|
+
weight: torch.Tensor,
|
|
2929
|
+
bias: torch.Tensor,
|
|
2930
|
+
stride: Tuple[int],
|
|
2931
|
+
padding: Tuple[int],
|
|
2932
|
+
dilation: Tuple[int],
|
|
2933
|
+
groups: int,
|
|
2934
|
+
) -> torch.Tensor:
|
|
2935
|
+
torch._check(input.dtype == torch.float32, lambda: "expected float32")
|
|
2936
|
+
assert (
|
|
2937
|
+
len(weight.shape) == 4
|
|
2938
|
+
), f"Conv2d expects a 4D weight, got {len(weight.shape)}D"
|
|
2939
|
+
out_channels, _, *kernel_size = weight.shape
|
|
2940
|
+
in_size = input.shape
|
|
2941
|
+
assert len(in_size) == 4, f"conv2d expects 4D input, got {len(in_size)}D"
|
|
2942
|
+
|
|
2943
|
+
output_size = get_conv2d_output_size(
|
|
2944
|
+
in_size, out_channels, stride, padding, dilation, kernel_size, False
|
|
2945
|
+
)
|
|
2946
|
+
|
|
2947
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
@register_fake("cadence::conv3d")
|
|
2951
|
+
def conv3d_meta(
|
|
2952
|
+
input: torch.Tensor,
|
|
2953
|
+
weight: torch.Tensor,
|
|
2954
|
+
bias: torch.Tensor,
|
|
2955
|
+
stride: Tuple[int, int, int],
|
|
2956
|
+
padding: Tuple[int, int, int],
|
|
2957
|
+
dilation: Tuple[int, int, int],
|
|
2958
|
+
groups: int,
|
|
2959
|
+
) -> torch.Tensor:
|
|
2960
|
+
torch._check(input.dtype == torch.float32, lambda: "expected float32")
|
|
2961
|
+
assert (
|
|
2962
|
+
len(weight.shape) == 5
|
|
2963
|
+
), f"Conv3d expects a 5D weight, got {len(weight.shape)}D"
|
|
2964
|
+
out_channels, _, *kernel_size = weight.shape
|
|
2965
|
+
in_size = input.shape
|
|
2966
|
+
assert len(in_size) == 5, f"conv3d expects 5D input, got {len(in_size)}D"
|
|
2967
|
+
|
|
2968
|
+
# Helper to compute 3D convolution output size
|
|
2969
|
+
def get_conv3d_output_size(
|
|
2970
|
+
in_size: torch.Size,
|
|
2971
|
+
out_channels: int,
|
|
2972
|
+
stride: Tuple[int, int, int],
|
|
2973
|
+
padding: Tuple[int, int, int],
|
|
2974
|
+
dilation: Tuple[int, int, int],
|
|
2975
|
+
kernel_size: list[int],
|
|
2976
|
+
) -> torch.Size:
|
|
2977
|
+
N, C, D, H, W = in_size
|
|
2978
|
+
|
|
2979
|
+
dout = (D + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1) // stride[
|
|
2980
|
+
0
|
|
2981
|
+
] + 1
|
|
2982
|
+
hout = (H + 2 * padding[1] - dilation[1] * (kernel_size[1] - 1) - 1) // stride[
|
|
2983
|
+
1
|
|
2984
|
+
] + 1
|
|
2985
|
+
wout = (W + 2 * padding[2] - dilation[2] * (kernel_size[2] - 1) - 1) // stride[
|
|
2986
|
+
2
|
|
2987
|
+
] + 1
|
|
2988
|
+
|
|
2989
|
+
return torch.Size((N, out_channels, dout, hout, wout))
|
|
2990
|
+
|
|
2991
|
+
output_size = get_conv3d_output_size(
|
|
2992
|
+
in_size, out_channels, stride, padding, dilation, kernel_size
|
|
2993
|
+
)
|
|
2994
|
+
|
|
2995
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
@register_fake("cadence::transposed_convolution")
|
|
2999
|
+
def transposed_convolution_meta(
|
|
3000
|
+
input: torch.Tensor,
|
|
3001
|
+
weight: torch.Tensor,
|
|
3002
|
+
bias: torch.Tensor,
|
|
3003
|
+
stride: Tuple[int],
|
|
3004
|
+
padding: Tuple[int],
|
|
3005
|
+
dilation: Tuple[int],
|
|
3006
|
+
output_padding: Tuple[int],
|
|
3007
|
+
groups: int,
|
|
3008
|
+
channel_last: bool = False,
|
|
3009
|
+
) -> torch.Tensor:
|
|
3010
|
+
# The native definition of torch transposed conv will have weight shape as
|
|
3011
|
+
# (in_channels, out_channels/groups, *kernel_size).
|
|
3012
|
+
# However, the two channel position is flipped in the Cadence pass of replacing it
|
|
3013
|
+
# with cadence::transposed_convolution here: https://fburl.com/code/d2s7pkyy
|
|
3014
|
+
out_channels, _input_channels, *kernel_size = weight.shape
|
|
3015
|
+
out_channels *= groups
|
|
3016
|
+
in_size = input.shape
|
|
3017
|
+
|
|
3018
|
+
# Get the output size of a transposed 1D convolution given the input size and parameters
|
|
3019
|
+
def get_conv_transpose1d_output_size(
|
|
3020
|
+
in_size: torch.Size,
|
|
3021
|
+
kernel_size: list[int],
|
|
3022
|
+
out_channels: int,
|
|
3023
|
+
stride: Tuple[int],
|
|
3024
|
+
padding: Tuple[int],
|
|
3025
|
+
dilation: Tuple[int],
|
|
3026
|
+
output_padding: Tuple[int],
|
|
3027
|
+
channel_last: bool = False,
|
|
3028
|
+
) -> torch.Size:
|
|
3029
|
+
assert len(in_size) == 3
|
|
3030
|
+
if channel_last:
|
|
3031
|
+
N, L, C = in_size
|
|
3032
|
+
else:
|
|
3033
|
+
N, C, L = in_size
|
|
3034
|
+
|
|
3035
|
+
# Reference: https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose1d.html
|
|
3036
|
+
lout = (
|
|
3037
|
+
(L - 1) * stride[0]
|
|
3038
|
+
- 2 * padding[0]
|
|
3039
|
+
+ dilation[0] * (kernel_size[0] - 1)
|
|
3040
|
+
+ output_padding[0]
|
|
3041
|
+
+ 1
|
|
3042
|
+
)
|
|
3043
|
+
|
|
3044
|
+
if channel_last:
|
|
3045
|
+
return torch.Size((in_size[0], lout, out_channels))
|
|
3046
|
+
else:
|
|
3047
|
+
return torch.Size((in_size[0], out_channels, lout))
|
|
3048
|
+
|
|
3049
|
+
def get_conv_transpose2d_output_size(
|
|
3050
|
+
in_size: torch.Size,
|
|
3051
|
+
kernel_size: list[int],
|
|
3052
|
+
out_channels: int,
|
|
3053
|
+
stride: Tuple[int],
|
|
3054
|
+
padding: Tuple[int],
|
|
3055
|
+
dilation: Tuple[int],
|
|
3056
|
+
output_padding: Tuple[int],
|
|
3057
|
+
channel_last: bool = False,
|
|
3058
|
+
) -> torch.Size:
|
|
3059
|
+
assert len(in_size) == 4
|
|
3060
|
+
if channel_last:
|
|
3061
|
+
N, H, W, C = in_size
|
|
3062
|
+
else:
|
|
3063
|
+
N, C, H, W = in_size
|
|
3064
|
+
|
|
3065
|
+
# Reference: https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose2d.html
|
|
3066
|
+
hout = (
|
|
3067
|
+
(H - 1) * stride[0]
|
|
3068
|
+
- 2 * padding[0]
|
|
3069
|
+
+ dilation[0] * (kernel_size[0] - 1)
|
|
3070
|
+
+ output_padding[0]
|
|
3071
|
+
+ 1
|
|
3072
|
+
)
|
|
3073
|
+
wout = (
|
|
3074
|
+
(W - 1) * stride[1]
|
|
3075
|
+
- 2 * padding[1]
|
|
3076
|
+
+ dilation[1] * (kernel_size[1] - 1)
|
|
3077
|
+
+ output_padding[1]
|
|
3078
|
+
+ 1
|
|
3079
|
+
)
|
|
3080
|
+
|
|
3081
|
+
if channel_last:
|
|
3082
|
+
return torch.Size((in_size[0], hout, wout, out_channels))
|
|
3083
|
+
else:
|
|
3084
|
+
return torch.Size((in_size[0], out_channels, hout, wout))
|
|
3085
|
+
|
|
3086
|
+
# Compute the output tensor size
|
|
3087
|
+
if len(in_size) == 3:
|
|
3088
|
+
output_size = get_conv_transpose1d_output_size(
|
|
3089
|
+
in_size,
|
|
3090
|
+
kernel_size,
|
|
3091
|
+
out_channels,
|
|
3092
|
+
stride,
|
|
3093
|
+
padding,
|
|
3094
|
+
dilation,
|
|
3095
|
+
output_padding,
|
|
3096
|
+
channel_last,
|
|
3097
|
+
)
|
|
3098
|
+
elif len(in_size) == 4:
|
|
3099
|
+
output_size = get_conv_transpose2d_output_size(
|
|
3100
|
+
in_size,
|
|
3101
|
+
kernel_size,
|
|
3102
|
+
out_channels,
|
|
3103
|
+
stride,
|
|
3104
|
+
padding,
|
|
3105
|
+
dilation,
|
|
3106
|
+
output_padding,
|
|
3107
|
+
channel_last,
|
|
3108
|
+
)
|
|
3109
|
+
else:
|
|
3110
|
+
raise NotImplementedError(
|
|
3111
|
+
f"transposed_convolution meta is not implemented for input tensor with {len(in_size)} dimensions"
|
|
3112
|
+
)
|
|
3113
|
+
|
|
3114
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
@register_fake("cadence::avg_pool2d")
|
|
3118
|
+
def avg_pool2d_meta(
|
|
3119
|
+
input: torch.Tensor,
|
|
3120
|
+
kernel_size: Tuple[int],
|
|
3121
|
+
stride: Tuple[int],
|
|
3122
|
+
padding: Tuple[int],
|
|
3123
|
+
ceil_mode: bool = False,
|
|
3124
|
+
count_include_pad: bool = True,
|
|
3125
|
+
divisor_override: Optional[int] = None,
|
|
3126
|
+
in_zero_point: Optional[torch.Tensor] = None,
|
|
3127
|
+
channel_last: bool = False,
|
|
3128
|
+
) -> torch.Tensor:
|
|
3129
|
+
torch._check(input.dim() == 4, lambda: "expected 4D tensor")
|
|
3130
|
+
# Use torch native meta kernels when operator semantics are similar
|
|
3131
|
+
return torch._meta_registrations.meta_avg_pool2d(
|
|
3132
|
+
input,
|
|
3133
|
+
kernel_size,
|
|
3134
|
+
stride,
|
|
3135
|
+
padding,
|
|
3136
|
+
ceil_mode,
|
|
3137
|
+
count_include_pad,
|
|
3138
|
+
divisor_override,
|
|
3139
|
+
)
|
|
3140
|
+
|
|
3141
|
+
|
|
3142
|
+
@register_fake("cadence::transposed_im2row")
|
|
3143
|
+
def transposed_im2row_meta(
|
|
3144
|
+
input: torch.Tensor,
|
|
3145
|
+
kernel_size: Tuple[int],
|
|
3146
|
+
dilation: Tuple[int],
|
|
3147
|
+
padding: Tuple[int],
|
|
3148
|
+
stride: Tuple[int],
|
|
3149
|
+
output_padding: Tuple[int],
|
|
3150
|
+
in_zero_point: torch.Tensor,
|
|
3151
|
+
channel_last: bool = False,
|
|
3152
|
+
) -> torch.Tensor:
|
|
3153
|
+
"""
|
|
3154
|
+
Shape inference for transposed_im2row operation.
|
|
3155
|
+
|
|
3156
|
+
Returns shape: (N, H_out * W_out, K_h * K_w * C_in)
|
|
3157
|
+
"""
|
|
3158
|
+
if len(input.shape) == 3:
|
|
3159
|
+
height_dim = 1 if channel_last else 2
|
|
3160
|
+
input = input.unsqueeze(height_dim)
|
|
3161
|
+
|
|
3162
|
+
batch_size = input.shape[0]
|
|
3163
|
+
n_input_channels = input.shape[3] if channel_last else input.shape[1]
|
|
3164
|
+
input_height = input.shape[1] if channel_last else input.shape[2]
|
|
3165
|
+
input_width = input.shape[2] if channel_last else input.shape[3]
|
|
3166
|
+
|
|
3167
|
+
# Calculate output spatial dimensions
|
|
3168
|
+
output_height = (
|
|
3169
|
+
(input_height - 1) * stride[0]
|
|
3170
|
+
- 2 * padding[0]
|
|
3171
|
+
+ dilation[0] * (kernel_size[0] - 1)
|
|
3172
|
+
+ output_padding[0]
|
|
3173
|
+
+ 1
|
|
3174
|
+
)
|
|
3175
|
+
output_width = (
|
|
3176
|
+
(input_width - 1) * stride[1]
|
|
3177
|
+
- 2 * padding[1]
|
|
3178
|
+
+ dilation[1] * (kernel_size[1] - 1)
|
|
3179
|
+
+ output_padding[1]
|
|
3180
|
+
+ 1
|
|
3181
|
+
)
|
|
3182
|
+
|
|
3183
|
+
# Patch size is kernel_h * kernel_w * in_channels
|
|
3184
|
+
patch_size = kernel_size[0] * kernel_size[1] * n_input_channels
|
|
3185
|
+
num_patches = output_height * output_width
|
|
3186
|
+
output_size = torch.Size((batch_size, num_patches, patch_size))
|
|
3187
|
+
|
|
3188
|
+
return input.new_empty(output_size, dtype=input.dtype)
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
@register_fake("cadence::quantized_embedding_byte")
|
|
3192
|
+
def quantized_embedding_byte_meta(
|
|
3193
|
+
weight: torch.Tensor,
|
|
3194
|
+
weight_scales: torch.Tensor,
|
|
3195
|
+
weight_zero_points: torch.Tensor | None,
|
|
3196
|
+
indices: torch.Tensor,
|
|
3197
|
+
pruned_weights: bool = False,
|
|
3198
|
+
) -> torch.Tensor:
|
|
3199
|
+
assert not pruned_weights
|
|
3200
|
+
assert len(weight.shape) == 2
|
|
3201
|
+
assert 1 <= len(weight_scales.shape) <= 2
|
|
3202
|
+
if len(weight_scales.shape) == 2:
|
|
3203
|
+
num_groups = weight_scales.shape[-1]
|
|
3204
|
+
assert weight.shape[1] % num_groups == 0
|
|
3205
|
+
|
|
3206
|
+
if weight_zero_points is not None:
|
|
3207
|
+
assert weight_zero_points.shape == weight_scales.shape
|
|
3208
|
+
|
|
3209
|
+
assert 1 <= len(indices.shape) <= 2
|
|
3210
|
+
return torch.empty(*indices.shape, weight.shape[1], dtype=torch.float32)
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
@register_fake("cadence::where_Scalar")
|
|
3214
|
+
def where_Scalar_meta(
|
|
3215
|
+
condition: torch.Tensor,
|
|
3216
|
+
self: float,
|
|
3217
|
+
other: float,
|
|
3218
|
+
) -> torch.Tensor:
|
|
3219
|
+
return condition.new_empty(condition.size(), dtype=torch.float32)
|
|
3220
|
+
|
|
3221
|
+
|
|
3222
|
+
@register_fake("cadence::rope")
|
|
3223
|
+
def rope_meta(
|
|
3224
|
+
input: torch.Tensor,
|
|
3225
|
+
sin_tensor: torch.Tensor,
|
|
3226
|
+
cos_tensor: torch.Tensor,
|
|
3227
|
+
pos: Optional[torch.Tensor],
|
|
3228
|
+
) -> torch.Tensor:
|
|
3229
|
+
torch._check(sin_tensor.dtype == torch.float32, lambda: "expected float32")
|
|
3230
|
+
torch._check(cos_tensor.dtype == torch.float32, lambda: "expected float32")
|
|
3231
|
+
input_shape = list(input.shape)
|
|
3232
|
+
assert (
|
|
3233
|
+
len(input_shape) in (4, 5) and input_shape[0] == 1
|
|
3234
|
+
), f"input shape {input_shape} must be (1, seq, h, hd) or (1, seq, h, hd / 2, 2)"
|
|
3235
|
+
seq = input_shape[1]
|
|
3236
|
+
h = input_shape[2]
|
|
3237
|
+
hd = prod(input_shape) / (seq * h)
|
|
3238
|
+
sin_shape = list(sin_tensor.shape)
|
|
3239
|
+
cos_shape = list(cos_tensor.shape)
|
|
3240
|
+
assert sin_shape == cos_shape, f"{sin_shape=} must be same as {cos_shape}"
|
|
3241
|
+
assert (
|
|
3242
|
+
len(sin_shape) == 2 and sin_shape[-1] == hd // 2
|
|
3243
|
+
), f"{sin_shape=} must be [seq, hd/2]"
|
|
3244
|
+
if pos is not None:
|
|
3245
|
+
assert (
|
|
3246
|
+
len(pos.shape) == 1 and pos.shape[0] == seq
|
|
3247
|
+
), f"{pos.shape} must be [{seq}]"
|
|
3248
|
+
return input.new_empty(input.shape, dtype=input.dtype)
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
@register_fake("cadence::rope_rotate_stacked_halves")
|
|
3252
|
+
def rope_rotate_stacked_halves_meta(
|
|
3253
|
+
input: torch.Tensor,
|
|
3254
|
+
sin_tensor: torch.Tensor,
|
|
3255
|
+
cos_tensor: torch.Tensor,
|
|
3256
|
+
pos: Optional[torch.Tensor],
|
|
3257
|
+
) -> torch.Tensor:
|
|
3258
|
+
torch._check(sin_tensor.dtype == torch.float32, lambda: "expected float32")
|
|
3259
|
+
torch._check(cos_tensor.dtype == torch.float32, lambda: "expected float32")
|
|
3260
|
+
input_shape = list(input.shape)
|
|
3261
|
+
assert (
|
|
3262
|
+
len(input_shape) in (4, 5) and input_shape[0] == 1
|
|
3263
|
+
), f"input shape {input_shape} must be (1, seq, h, hd) or (1, seq, h, 2, hd / 2)"
|
|
3264
|
+
seq = input_shape[1]
|
|
3265
|
+
h = input_shape[2]
|
|
3266
|
+
hd = prod(input_shape) / (seq * h)
|
|
3267
|
+
sin_shape = list(sin_tensor.shape)
|
|
3268
|
+
cos_shape = list(cos_tensor.shape)
|
|
3269
|
+
assert sin_shape == cos_shape, f"{sin_shape=} must be same as {cos_shape}"
|
|
3270
|
+
assert (
|
|
3271
|
+
len(sin_shape) == 2 and sin_shape[-1] == hd // 2
|
|
3272
|
+
), f"{sin_shape=} must be [seq, hd/2]"
|
|
3273
|
+
if pos is not None:
|
|
3274
|
+
assert (
|
|
3275
|
+
len(pos.shape) == 1 and pos.shape[0] == seq
|
|
3276
|
+
), f"{pos.shape} must be [{seq}]"
|
|
3277
|
+
return input.new_empty(input.shape, dtype=input.dtype)
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
@register_fake("cadence::quantized_rope_rotate_stacked_halves")
|
|
3281
|
+
def quantized_rope_rotate_stacked_halves_meta(
|
|
3282
|
+
input: torch.Tensor,
|
|
3283
|
+
sin_tensor: torch.Tensor,
|
|
3284
|
+
cos_tensor: torch.Tensor,
|
|
3285
|
+
pos: Optional[torch.Tensor],
|
|
3286
|
+
in_scale: float,
|
|
3287
|
+
in_zero_point: int,
|
|
3288
|
+
out_scale: float,
|
|
3289
|
+
out_zero_point: int,
|
|
3290
|
+
) -> torch.Tensor:
|
|
3291
|
+
return rope_rotate_stacked_halves_meta(input, sin_tensor, cos_tensor, pos)
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
@register_fake("cadence::idma_copy")
|
|
3295
|
+
def copy_idma_copy_impl(
|
|
3296
|
+
src: torch.Tensor,
|
|
3297
|
+
task_num: int = 0,
|
|
3298
|
+
channel: int = 0,
|
|
3299
|
+
) -> torch.Tensor:
|
|
3300
|
+
return src.new_empty(*src.shape, dtype=src.dtype)
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
@register_fake("cadence::idma_wait")
|
|
3304
|
+
def copy_idma_wait_impl(
|
|
3305
|
+
src: torch.Tensor,
|
|
3306
|
+
task_num: int = 0,
|
|
3307
|
+
) -> torch.Tensor:
|
|
3308
|
+
return src.new_empty(*src.shape, dtype=src.dtype)
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
@register_fake("cadence::idma_load")
|
|
3312
|
+
def idma_load_impl(
|
|
3313
|
+
src: torch.Tensor,
|
|
3314
|
+
task_num: int = 0,
|
|
3315
|
+
channel: int = 0,
|
|
3316
|
+
) -> torch.Tensor:
|
|
3317
|
+
res = copy_idma_copy_impl(src, task_num, channel)
|
|
3318
|
+
assert isinstance(res, torch.Tensor)
|
|
3319
|
+
return res
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
@register_fake("cadence::idma_store")
|
|
3323
|
+
def idma_store_impl(
|
|
3324
|
+
src: torch.Tensor,
|
|
3325
|
+
task_num: int = 0,
|
|
3326
|
+
channel: int = 0,
|
|
3327
|
+
) -> torch.Tensor:
|
|
3328
|
+
res = copy_idma_copy_impl(src, task_num, channel)
|
|
3329
|
+
assert isinstance(res, torch.Tensor)
|
|
3330
|
+
return res
|
|
3331
|
+
|
|
3332
|
+
|
|
3333
|
+
@register_fake("cadence::roi_align_box_processor")
|
|
3334
|
+
def roi_align_box_processor_meta(
|
|
3335
|
+
rois: torch.Tensor,
|
|
3336
|
+
output_size_h: int,
|
|
3337
|
+
output_size_w: int,
|
|
3338
|
+
sampling_ratio: int,
|
|
3339
|
+
aligned: bool,
|
|
3340
|
+
) -> torch.Tensor:
|
|
3341
|
+
torch._check(rois.dim() == 2, lambda: "expected 2D tensor")
|
|
3342
|
+
torch._check(rois.size(1) == 5, lambda: "expected dim[1] == 5")
|
|
3343
|
+
return rois.new_empty((rois.shape[0], 80), dtype=torch.uint8)
|
|
3344
|
+
|
|
3345
|
+
|
|
3346
|
+
@register_fake("cadence::_softmax_f32_f32")
|
|
3347
|
+
def softmax_f32_f32_meta(
|
|
3348
|
+
input_tensor: torch.Tensor,
|
|
3349
|
+
dim: int,
|
|
3350
|
+
half_to_float: Optional[bool] = None,
|
|
3351
|
+
) -> torch.Tensor:
|
|
3352
|
+
assert input_tensor.dtype == torch.float32, "input_tensor must be float32"
|
|
3353
|
+
assert not half_to_float, "half_to_float is not supported"
|
|
3354
|
+
return input_tensor.new_empty(input_tensor.size(), dtype=torch.float32)
|
|
3355
|
+
|
|
3356
|
+
|
|
3357
|
+
@register_fake("cadence::quantized_softmax")
|
|
3358
|
+
def quantized_softmax_meta(
|
|
3359
|
+
input: torch.Tensor,
|
|
3360
|
+
mask: torch.Tensor,
|
|
3361
|
+
dim: int,
|
|
3362
|
+
mask_type: int,
|
|
3363
|
+
pos: torch.Tensor,
|
|
3364
|
+
in_scale: torch.Tensor,
|
|
3365
|
+
in_zero_point: torch.Tensor,
|
|
3366
|
+
out_scale: torch.Tensor,
|
|
3367
|
+
out_zero_point: torch.Tensor,
|
|
3368
|
+
) -> torch.Tensor:
|
|
3369
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
3370
|
+
|
|
3371
|
+
|
|
3372
|
+
@register_fake("cadence::quantized_softmax.per_tensor")
|
|
3373
|
+
def quantized_softmax_per_tensor_meta(
|
|
3374
|
+
input: torch.Tensor,
|
|
3375
|
+
mask: torch.Tensor,
|
|
3376
|
+
dim: int,
|
|
3377
|
+
mask_type: int,
|
|
3378
|
+
pos: torch.Tensor,
|
|
3379
|
+
in_scale: float,
|
|
3380
|
+
in_zero_point: int,
|
|
3381
|
+
out_scale: float,
|
|
3382
|
+
out_zero_point: int,
|
|
3383
|
+
) -> torch.Tensor:
|
|
3384
|
+
return input.new_empty(input.size(), dtype=input.dtype)
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
@register_fake("cadence::sdpa_bitwise_mask_gen")
|
|
3388
|
+
def sdpa_bitwise_mask_gen_meta(
|
|
3389
|
+
mask: torch.Tensor,
|
|
3390
|
+
threshold: float,
|
|
3391
|
+
) -> torch.Tensor:
|
|
3392
|
+
torch._check(
|
|
3393
|
+
mask.dtype in (torch.float32, torch.bool), lambda: "expected float32 or bool"
|
|
3394
|
+
)
|
|
3395
|
+
# Expect mask to be a float/bool tensor with last dimension representing sequence length
|
|
3396
|
+
assert mask.dim() >= 1, "mask must have at least 1 dimension"
|
|
3397
|
+
mask_shape = list(mask.shape)
|
|
3398
|
+
|
|
3399
|
+
last = mask_shape[-1]
|
|
3400
|
+
assert last % 8 == 0, "last dimension must be a multiple of 8"
|
|
3401
|
+
mask_shape[-1] = last // 8 # pack 8 elements into 1 byte
|
|
3402
|
+
return mask.new_empty(mask_shape, dtype=torch.uint8)
|
|
3403
|
+
|
|
3404
|
+
|
|
3405
|
+
@register_fake("cadence::sdpa_bitwise_causal_mask_gen")
|
|
3406
|
+
def sdpa_bitwise_causal_mask_gen_meta(
|
|
3407
|
+
positions: torch.Tensor,
|
|
3408
|
+
key_length: int,
|
|
3409
|
+
) -> torch.Tensor:
|
|
3410
|
+
torch._check(
|
|
3411
|
+
positions.dtype in (torch.int32, torch.int64),
|
|
3412
|
+
lambda: "expected int32 or int64 positions",
|
|
3413
|
+
)
|
|
3414
|
+
torch._check(positions.dim() == 1, lambda: "positions must be one-dimensional")
|
|
3415
|
+
torch._check(key_length > 0, lambda: "key_length must be positive")
|
|
3416
|
+
torch._check(key_length % 8 == 0, lambda: "key_length must be a multiple of 8")
|
|
3417
|
+
return positions.new_empty((positions.numel(), key_length // 8), dtype=torch.uint8)
|
|
3418
|
+
|
|
3419
|
+
|
|
3420
|
+
@register_fake("cadence::sdpa_bitwise_ring_mask_gen")
|
|
3421
|
+
def sdpa_bitwise_ring_mask_gen_meta(
|
|
3422
|
+
positions: torch.Tensor, sliding_window: int, cache_length: int
|
|
3423
|
+
) -> torch.Tensor:
|
|
3424
|
+
torch._check(
|
|
3425
|
+
positions.dtype in (torch.int32, torch.int64),
|
|
3426
|
+
lambda: "expected int32 or int64 positions",
|
|
3427
|
+
)
|
|
3428
|
+
torch._check(positions.dim() == 1, lambda: "positions must be one-dimensional")
|
|
3429
|
+
torch._check(cache_length > 0, lambda: "cache_length must be positive")
|
|
3430
|
+
torch._check(cache_length % 8 == 0, lambda: "cache_length must be a multiple of 8")
|
|
3431
|
+
torch._check(
|
|
3432
|
+
0 < sliding_window <= cache_length,
|
|
3433
|
+
lambda: "sliding_window must be positive and at most cache_length",
|
|
3434
|
+
)
|
|
3435
|
+
return positions.new_empty(
|
|
3436
|
+
(positions.numel(), cache_length // 8), dtype=torch.uint8
|
|
3437
|
+
)
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
@register_fake("cadence::quantized_w8a32_linear")
|
|
3441
|
+
def quantized_w8a32_linear_meta(
|
|
3442
|
+
src: torch.Tensor,
|
|
3443
|
+
weight: torch.Tensor,
|
|
3444
|
+
w_scale: float,
|
|
3445
|
+
bias: torch.Tensor,
|
|
3446
|
+
b_scale: float,
|
|
3447
|
+
) -> torch.Tensor:
|
|
3448
|
+
# src comes in shape [leading_dims, in_dim]
|
|
3449
|
+
# weight comes in shape [in_dim, out_dim]
|
|
3450
|
+
# output comes in empty with shape [leading_dims, out_dim]
|
|
3451
|
+
src_shape = list(src.shape)
|
|
3452
|
+
weight_shape = weight.shape
|
|
3453
|
+
assert (src_shape[-1] % 4) == 0
|
|
3454
|
+
if len(src_shape) >= 2:
|
|
3455
|
+
assert src_shape[-2] == 1
|
|
3456
|
+
assert len(weight_shape) == 2
|
|
3457
|
+
assert src_shape[-1] == weight_shape[-1]
|
|
3458
|
+
src_shape[-1] = weight_shape[0]
|
|
3459
|
+
return src.new_empty(src_shape, dtype=src.dtype)
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
@register_fake("cadence::quantized_w8a32_conv")
|
|
3463
|
+
def quantized_w8a32_conv_meta(
|
|
3464
|
+
src: torch.Tensor,
|
|
3465
|
+
weight: torch.Tensor,
|
|
3466
|
+
w_scale: float,
|
|
3467
|
+
bias: torch.Tensor,
|
|
3468
|
+
b_scale: float,
|
|
3469
|
+
) -> torch.Tensor:
|
|
3470
|
+
# src comes in shape [batch, in_length, in_channels]
|
|
3471
|
+
# weight comes in shape [kernel_dim, out_ch, in_ch]
|
|
3472
|
+
# output comes in empty with shape [batch, out_ch, in_length - kernel_dim + 1]
|
|
3473
|
+
assert len(src.shape) == 3
|
|
3474
|
+
|
|
3475
|
+
kernel_size, out_channels, in_channels = weight.shape
|
|
3476
|
+
assert kernel_size == 3
|
|
3477
|
+
assert (out_channels % 4) == 0
|
|
3478
|
+
assert (in_channels % 4) == 0
|
|
3479
|
+
assert in_channels == src.shape[-1]
|
|
3480
|
+
|
|
3481
|
+
# Compute the output tensor size
|
|
3482
|
+
output_size = get_conv1d_output_size(
|
|
3483
|
+
src.permute(0, 2, 1).shape,
|
|
3484
|
+
out_channels,
|
|
3485
|
+
stride=1,
|
|
3486
|
+
padding=0,
|
|
3487
|
+
dilation=1,
|
|
3488
|
+
kernel_size=kernel_size,
|
|
3489
|
+
channel_last=False,
|
|
3490
|
+
)
|
|
3491
|
+
return src.new_empty(output_size, dtype=src.dtype)
|
|
3492
|
+
|
|
3493
|
+
|
|
3494
|
+
@register_fake("cadence::quantized_w8a32_gru")
|
|
3495
|
+
def quantized_w8a32_gru_meta(
|
|
3496
|
+
inputs: torch.Tensor,
|
|
3497
|
+
hidden: torch.Tensor,
|
|
3498
|
+
weights_inputs: torch.Tensor,
|
|
3499
|
+
w_i_scale: float,
|
|
3500
|
+
weights_hidden: torch.Tensor,
|
|
3501
|
+
w_h_scale: float,
|
|
3502
|
+
bias_inputs: torch.Tensor,
|
|
3503
|
+
b_scale: float,
|
|
3504
|
+
bias_hidden: torch.Tensor,
|
|
3505
|
+
) -> torch.Tensor:
|
|
3506
|
+
seq_len = inputs.shape[1]
|
|
3507
|
+
assert seq_len == 1
|
|
3508
|
+
# inputs comes in shape [batch, seq_len, input_size]
|
|
3509
|
+
# hidden comes in shape [batch, seq_len, hidden_size]
|
|
3510
|
+
# weights_inputs comes in shape [3 * hidden_size, input_size]
|
|
3511
|
+
# weights_hidden comes in shape [3 * hidden_size, hidden_size]
|
|
3512
|
+
# output comes in empty with shape [2, batch, seq_len, hidden_size]
|
|
3513
|
+
# The first dimension stacks the output and the new hidden state
|
|
3514
|
+
return hidden.new_empty(
|
|
3515
|
+
(2, inputs.shape[0], inputs.shape[1], hidden.shape[-1]), dtype=torch.float32
|
|
3516
|
+
)
|
|
3517
|
+
|
|
3518
|
+
|
|
3519
|
+
@register_fake("cadence::slice_scatter_")
|
|
3520
|
+
def slice_scatter_meta(
|
|
3521
|
+
self: torch.Tensor,
|
|
3522
|
+
src: torch.Tensor,
|
|
3523
|
+
dim: int = 0,
|
|
3524
|
+
start: Optional[int] = None,
|
|
3525
|
+
end: Optional[int] = None,
|
|
3526
|
+
step: int = 1,
|
|
3527
|
+
) -> torch.Tensor:
|
|
3528
|
+
return self.new_empty(self.shape, dtype=self.dtype)
|
|
3529
|
+
|
|
3530
|
+
|
|
3531
|
+
# Validate that all meta kernels have reference implementations
|
|
3532
|
+
# This is called at module import time to catch missing implementations early
|
|
3533
|
+
_validate_ref_impl_exists()
|