executorch 1.1.0__cp313-cp313-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 +271 -0
- executorch/backends/aoti/aoti_partitioner.py +109 -0
- executorch/backends/aoti/passes/replace_view_copy_with_view.py +118 -0
- executorch/backends/apple/coreml/compiler/__init__.py +9 -0
- executorch/backends/apple/coreml/compiler/coreml_preprocess.py +588 -0
- executorch/backends/apple/coreml/compiler/enumerated_shape_utils.py +244 -0
- executorch/backends/apple/coreml/compiler/torch_ops.py +219 -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 +307 -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/runtime/test/export_stateful_model.py +77 -0
- executorch/backends/apple/coreml/test/test_coreml_partitioner.py +348 -0
- executorch/backends/apple/coreml/test/test_coreml_quantizer.py +172 -0
- executorch/backends/apple/coreml/test/test_coreml_recipes.py +552 -0
- executorch/backends/apple/coreml/test/test_coreml_utils.py +19 -0
- executorch/backends/apple/coreml/test/test_enumerated_shapes.py +112 -0
- executorch/backends/apple/coreml/test/test_torch_ops.py +333 -0
- executorch/backends/apple/coreml/test/tester.py +121 -0
- executorch/backends/apple/metal/metal_backend.py +67 -0
- executorch/backends/apple/metal/metal_partitioner.py +25 -0
- executorch/backends/apple/metal/tests/__init__.py +5 -0
- executorch/backends/apple/metal/tests/test_metal_backend.py +79 -0
- executorch/backends/apple/metal/tests/test_metal_partitioner.py +172 -0
- executorch/backends/apple/mps/__init__.py +10 -0
- executorch/backends/apple/mps/mps_preprocess.py +301 -0
- executorch/backends/apple/mps/operators/__init__.py +77 -0
- executorch/backends/apple/mps/operators/activation_ops.py +99 -0
- executorch/backends/apple/mps/operators/binary_ops.py +156 -0
- executorch/backends/apple/mps/operators/clamp_ops.py +60 -0
- executorch/backends/apple/mps/operators/constant_ops.py +128 -0
- executorch/backends/apple/mps/operators/convolution_ops.py +70 -0
- executorch/backends/apple/mps/operators/indexing_ops.py +225 -0
- executorch/backends/apple/mps/operators/linear_algebra_ops.py +52 -0
- executorch/backends/apple/mps/operators/node_visitor.py +473 -0
- executorch/backends/apple/mps/operators/normalization_ops.py +97 -0
- executorch/backends/apple/mps/operators/op_clone.py +54 -0
- executorch/backends/apple/mps/operators/op_getitem.py +29 -0
- executorch/backends/apple/mps/operators/op_quant_dequant.py +142 -0
- executorch/backends/apple/mps/operators/op_skip_ops.py +24 -0
- executorch/backends/apple/mps/operators/pad_ops.py +37 -0
- executorch/backends/apple/mps/operators/pooling_ops.py +142 -0
- executorch/backends/apple/mps/operators/range_ops.py +53 -0
- executorch/backends/apple/mps/operators/reduce_ops.py +39 -0
- executorch/backends/apple/mps/operators/shape_ops.py +263 -0
- executorch/backends/apple/mps/operators/unary_ops.py +130 -0
- executorch/backends/apple/mps/partition/__init__.py +10 -0
- executorch/backends/apple/mps/partition/mps_partitioner.py +133 -0
- executorch/backends/apple/mps/serialization/mps_graph_schema.py +817 -0
- executorch/backends/apple/mps/serialization/mps_graph_serialize.py +34 -0
- executorch/backends/apple/mps/serialization/schema.fbs +523 -0
- executorch/backends/apple/mps/test/test_mps.py +2507 -0
- executorch/backends/apple/mps/test/test_mps_binary_ops.py +296 -0
- executorch/backends/apple/mps/test/test_mps_indexing_ops.py +264 -0
- executorch/backends/apple/mps/test/test_mps_linear.py +523 -0
- executorch/backends/apple/mps/test/test_mps_models.py +416 -0
- executorch/backends/apple/mps/test/test_mps_unary_ops.py +26 -0
- executorch/backends/apple/mps/test/test_mps_utils.py +326 -0
- executorch/backends/apple/mps/utils/mps_utils.py +82 -0
- executorch/backends/apple/mps/utils/quant_utils.py +41 -0
- executorch/backends/arm/_passes/__init__.py +134 -0
- executorch/backends/arm/_passes/_debug_passes.py +58 -0
- executorch/backends/arm/_passes/annotate_decomposed_matmul.py +127 -0
- executorch/backends/arm/_passes/annotate_output_dim_order_pass.py +26 -0
- executorch/backends/arm/_passes/arm_pass.py +95 -0
- executorch/backends/arm/_passes/arm_pass_manager.py +462 -0
- executorch/backends/arm/_passes/arm_pass_utils.py +281 -0
- executorch/backends/arm/_passes/broadcast_args_pass.py +72 -0
- executorch/backends/arm/_passes/cast_int64_pass.py +70 -0
- executorch/backends/arm/_passes/cast_to_int32_pass.py +67 -0
- executorch/backends/arm/_passes/conv1d_unsqueeze_pass.py +98 -0
- executorch/backends/arm/_passes/convert_elu_params.py +67 -0
- executorch/backends/arm/_passes/convert_expand_copy_to_repeat.py +77 -0
- executorch/backends/arm/_passes/convert_full_like_to_full_pass.py +42 -0
- executorch/backends/arm/_passes/convert_int64_const_ops_to_int32.py +81 -0
- executorch/backends/arm/_passes/convert_int64_output_ops_to_int32.py +155 -0
- executorch/backends/arm/_passes/convert_minmax_pass.py +166 -0
- executorch/backends/arm/_passes/convert_permute_singleton_to_view_pass.py +64 -0
- executorch/backends/arm/_passes/convert_split_to_slice.py +132 -0
- executorch/backends/arm/_passes/convert_squeezes_to_view.py +36 -0
- executorch/backends/arm/_passes/convert_to_clamp_pass.py +45 -0
- executorch/backends/arm/_passes/decompose_acosh_pass.py +77 -0
- executorch/backends/arm/_passes/decompose_adaptive_avg_pool2d_pass.py +112 -0
- executorch/backends/arm/_passes/decompose_add_sub_alpha_pass.py +98 -0
- executorch/backends/arm/_passes/decompose_addmm_pass.py +72 -0
- executorch/backends/arm/_passes/decompose_any_pass.py +114 -0
- executorch/backends/arm/_passes/decompose_asin_and_acos_pass.py +236 -0
- executorch/backends/arm/_passes/decompose_asinh_pass.py +74 -0
- executorch/backends/arm/_passes/decompose_atan_pass.py +142 -0
- executorch/backends/arm/_passes/decompose_atanh_pass.py +86 -0
- executorch/backends/arm/_passes/decompose_avg_pool2d_pass.py +154 -0
- executorch/backends/arm/_passes/decompose_batch_norm_no_stats.py +233 -0
- executorch/backends/arm/_passes/decompose_cosh_pass.py +72 -0
- executorch/backends/arm/_passes/decompose_cosine_similarity_pass.py +92 -0
- executorch/backends/arm/_passes/decompose_cumsum_pass.py +167 -0
- executorch/backends/arm/_passes/decompose_div_pass.py +61 -0
- executorch/backends/arm/_passes/decompose_div_tensor_mode.py +94 -0
- executorch/backends/arm/_passes/decompose_elu_pass.py +107 -0
- executorch/backends/arm/_passes/decompose_embedding_pass.py +126 -0
- executorch/backends/arm/_passes/decompose_expm1_pass.py +163 -0
- executorch/backends/arm/_passes/decompose_floor_divide_pass.py +75 -0
- executorch/backends/arm/_passes/decompose_gelu_pass.py +172 -0
- executorch/backends/arm/_passes/decompose_glu_pass.py +81 -0
- executorch/backends/arm/_passes/decompose_grouped_conv_pass.py +185 -0
- executorch/backends/arm/_passes/decompose_groupnorm_pass.py +227 -0
- executorch/backends/arm/_passes/decompose_int16_activation_conv_pass.py +137 -0
- executorch/backends/arm/_passes/decompose_int_pow_pass.py +64 -0
- executorch/backends/arm/_passes/decompose_layernorm_pass.py +203 -0
- executorch/backends/arm/_passes/decompose_leaky_relu_pass.py +76 -0
- executorch/backends/arm/_passes/decompose_linalg_vector_norm_pass.py +92 -0
- executorch/backends/arm/_passes/decompose_linear_pass.py +109 -0
- executorch/backends/arm/_passes/decompose_log1p_pass.py +97 -0
- executorch/backends/arm/_passes/decompose_logit_pass.py +119 -0
- executorch/backends/arm/_passes/decompose_masked_fill_pass.py +58 -0
- executorch/backends/arm/_passes/decompose_maxpool2d_with_dilation_pass.py +218 -0
- executorch/backends/arm/_passes/decompose_meandim_pass.py +283 -0
- executorch/backends/arm/_passes/decompose_ne_pass.py +74 -0
- executorch/backends/arm/_passes/decompose_quant_nodes.py +156 -0
- executorch/backends/arm/_passes/decompose_remainder_pass.py +70 -0
- executorch/backends/arm/_passes/decompose_round_pass.py +96 -0
- executorch/backends/arm/_passes/decompose_sdpa_pass.py +36 -0
- executorch/backends/arm/_passes/decompose_select.py +75 -0
- executorch/backends/arm/_passes/decompose_select_scatter_pass.py +143 -0
- executorch/backends/arm/_passes/decompose_sign_pass.py +78 -0
- executorch/backends/arm/_passes/decompose_silu_pass.py +41 -0
- executorch/backends/arm/_passes/decompose_sinh_pass.py +77 -0
- executorch/backends/arm/_passes/decompose_softmax_pass.py +93 -0
- executorch/backends/arm/_passes/decompose_softmax_unstable_pass.py +86 -0
- executorch/backends/arm/_passes/decompose_sqrt_pass.py +53 -0
- executorch/backends/arm/_passes/decompose_sum_pass.py +93 -0
- executorch/backends/arm/_passes/decompose_tan_pass.py +51 -0
- executorch/backends/arm/_passes/decompose_tosa_unsupported_clamp_pass.py +97 -0
- executorch/backends/arm/_passes/decompose_var_pass.py +109 -0
- executorch/backends/arm/_passes/decorate_fp32_to_int32_casting_pass.py +88 -0
- executorch/backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py +394 -0
- executorch/backends/arm/_passes/fuse_batch_norm2d_pass.py +241 -0
- executorch/backends/arm/_passes/fuse_constant_ops_pass.py +272 -0
- executorch/backends/arm/_passes/fuse_duplicate_users_pass.py +165 -0
- executorch/backends/arm/_passes/fuse_equal_placeholders_pass.py +104 -0
- executorch/backends/arm/_passes/fuse_quantized_activation_pass.py +80 -0
- executorch/backends/arm/_passes/fuse_view_copy_transform_pass.py +14 -0
- executorch/backends/arm/_passes/insert_int32_casts_after_int64_placeholders.py +130 -0
- executorch/backends/arm/_passes/insert_rescales_pass.py +584 -0
- executorch/backends/arm/_passes/insert_table_ops.py +305 -0
- executorch/backends/arm/_passes/match_arg_dtype_pass.py +104 -0
- executorch/backends/arm/_passes/match_arg_ranks_pass.py +114 -0
- executorch/backends/arm/_passes/mm_to_bmm_pass.py +104 -0
- executorch/backends/arm/_passes/normalize_while_initial_args_pass.py +113 -0
- executorch/backends/arm/_passes/promote_bool_operands_pass.py +88 -0
- executorch/backends/arm/_passes/quant_args.py +125 -0
- executorch/backends/arm/_passes/remove_getitem_pass.py +14 -0
- executorch/backends/arm/_passes/remove_graph_asserts_pass.py +18 -0
- executorch/backends/arm/_passes/remove_noop_pass.py +40 -0
- executorch/backends/arm/_passes/replace_inf_and_limit_values_pass.py +73 -0
- executorch/backends/arm/_passes/replace_scalar_with_tensor_pass.py +121 -0
- executorch/backends/arm/_passes/rewrite_bool_bitwise_not_to_logical_not_pass.py +43 -0
- executorch/backends/arm/_passes/rewrite_bool_to_fp32_cast_via_int8_pass.py +77 -0
- executorch/backends/arm/_passes/rewrite_conv_pass.py +336 -0
- executorch/backends/arm/_passes/rewrite_matmul.py +98 -0
- executorch/backends/arm/_passes/rewrite_upsample.py +93 -0
- executorch/backends/arm/_passes/scalars_to_attribute_pass.py +97 -0
- executorch/backends/arm/_passes/size_adjust_input_pass.py +227 -0
- executorch/backends/arm/_passes/to_tosa_memory_format_pass.py +454 -0
- executorch/backends/arm/_passes/unsqueeze_before_repeat_pass.py +66 -0
- executorch/backends/arm/_passes/unsqueeze_scalar_placeholders_pass.py +85 -0
- executorch/backends/arm/arm_vela.py +137 -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 +271 -0
- executorch/backends/arm/common/debug.py +79 -0
- executorch/backends/arm/common/pipeline_config.py +59 -0
- executorch/backends/arm/common/type.py +28 -0
- executorch/backends/arm/constants.py +48 -0
- executorch/backends/arm/debug/__init__.py +4 -0
- executorch/backends/arm/debug/schema.py +145 -0
- executorch/backends/arm/ethosu/__init__.py +11 -0
- executorch/backends/arm/ethosu/backend.py +115 -0
- executorch/backends/arm/ethosu/compile_spec.py +117 -0
- executorch/backends/arm/ethosu/partitioner.py +35 -0
- executorch/backends/arm/operator_support/__init__.py +23 -0
- executorch/backends/arm/operator_support/clone_dim_order_support.py +82 -0
- executorch/backends/arm/operator_support/control_flow_support.py +162 -0
- executorch/backends/arm/operator_support/convolution_support.py +160 -0
- executorch/backends/arm/operator_support/embedding_support.py +61 -0
- executorch/backends/arm/operator_support/ethos_u55_support.py +598 -0
- executorch/backends/arm/operator_support/index_select_support.py +60 -0
- executorch/backends/arm/operator_support/index_tensor_support.py +160 -0
- executorch/backends/arm/operator_support/minmax_support.py +61 -0
- executorch/backends/arm/operator_support/pool_2d_support.py +214 -0
- executorch/backends/arm/operator_support/reduce_sum_support.py +76 -0
- executorch/backends/arm/operator_support/right_shift_support.py +52 -0
- executorch/backends/arm/operator_support/slice_copy_support.py +48 -0
- executorch/backends/arm/operator_support/to_dim_order_copy_support.py +200 -0
- executorch/backends/arm/operator_support/tosa_profile_supported_op_lists.py +251 -0
- executorch/backends/arm/operator_support/tosa_supported_operators.py +748 -0
- executorch/backends/arm/operator_support/where_support.py +77 -0
- executorch/backends/arm/operators/__init__.py +71 -0
- executorch/backends/arm/operators/node_visitor.py +177 -0
- executorch/backends/arm/operators/op_abs.py +59 -0
- executorch/backends/arm/operators/op_add.py +60 -0
- executorch/backends/arm/operators/op_amax.py +72 -0
- executorch/backends/arm/operators/op_amin.py +73 -0
- executorch/backends/arm/operators/op_any.py +61 -0
- executorch/backends/arm/operators/op_avg_pool2d.py +142 -0
- executorch/backends/arm/operators/op_bitwise_not.py +62 -0
- executorch/backends/arm/operators/op_cat.py +68 -0
- executorch/backends/arm/operators/op_ceil.py +56 -0
- executorch/backends/arm/operators/op_clamp.py +118 -0
- executorch/backends/arm/operators/op_cond_if.py +56 -0
- executorch/backends/arm/operators/op_constant_pad_nd.py +117 -0
- executorch/backends/arm/operators/op_cos.py +49 -0
- executorch/backends/arm/operators/op_eq.py +64 -0
- executorch/backends/arm/operators/op_erf.py +54 -0
- executorch/backends/arm/operators/op_exp.py +54 -0
- executorch/backends/arm/operators/op_floor.py +56 -0
- executorch/backends/arm/operators/op_ge.py +64 -0
- executorch/backends/arm/operators/op_gt.py +64 -0
- executorch/backends/arm/operators/op_index_select.py +109 -0
- executorch/backends/arm/operators/op_index_tensor.py +247 -0
- executorch/backends/arm/operators/op_le.py +64 -0
- executorch/backends/arm/operators/op_log.py +50 -0
- executorch/backends/arm/operators/op_logical_not.py +62 -0
- executorch/backends/arm/operators/op_lt.py +64 -0
- executorch/backends/arm/operators/op_max_pool2d.py +108 -0
- executorch/backends/arm/operators/op_maximum.py +66 -0
- executorch/backends/arm/operators/op_minimum.py +67 -0
- executorch/backends/arm/operators/op_mul.py +61 -0
- executorch/backends/arm/operators/op_neg.py +92 -0
- executorch/backends/arm/operators/op_permute.py +150 -0
- executorch/backends/arm/operators/op_pow.py +63 -0
- executorch/backends/arm/operators/op_reciprocal.py +51 -0
- executorch/backends/arm/operators/op_repeat.py +77 -0
- executorch/backends/arm/operators/op_rshift_tensor.py +62 -0
- executorch/backends/arm/operators/op_rsqrt.py +51 -0
- executorch/backends/arm/operators/op_sigmoid.py +50 -0
- executorch/backends/arm/operators/op_sin.py +49 -0
- executorch/backends/arm/operators/op_slice.py +151 -0
- executorch/backends/arm/operators/op_sub.py +63 -0
- executorch/backends/arm/operators/op_sum.py +64 -0
- executorch/backends/arm/operators/op_tanh.py +51 -0
- executorch/backends/arm/operators/op_to_dim_order_copy.py +49 -0
- executorch/backends/arm/operators/op_tosa_conv2d.py +139 -0
- executorch/backends/arm/operators/op_tosa_conv3d.py +24 -0
- executorch/backends/arm/operators/op_tosa_depthwise_conv2d.py +32 -0
- executorch/backends/arm/operators/op_tosa_matmul.py +102 -0
- executorch/backends/arm/operators/op_tosa_rescale.py +261 -0
- executorch/backends/arm/operators/op_tosa_resize.py +124 -0
- executorch/backends/arm/operators/op_tosa_table.py +72 -0
- executorch/backends/arm/operators/op_tosa_transpose.py +71 -0
- executorch/backends/arm/operators/op_view.py +81 -0
- executorch/backends/arm/operators/op_where.py +75 -0
- executorch/backends/arm/operators/op_while.py +103 -0
- executorch/backends/arm/operators/operator_validation_utils.py +201 -0
- executorch/backends/arm/operators/ops_binary.py +112 -0
- executorch/backends/arm/operators/ops_identity.py +80 -0
- executorch/backends/arm/process_node.py +230 -0
- executorch/backends/arm/quantizer/__init__.py +35 -0
- executorch/backends/arm/quantizer/arm_quantizer.py +710 -0
- executorch/backends/arm/quantizer/arm_quantizer_utils.py +76 -0
- executorch/backends/arm/quantizer/quantization_annotator.py +815 -0
- executorch/backends/arm/quantizer/quantization_config.py +228 -0
- executorch/backends/arm/scripts/collect_testname_resources.py +194 -0
- executorch/backends/arm/scripts/parse_test_names.py +271 -0
- executorch/backends/arm/test/common.py +302 -0
- executorch/backends/arm/test/conftest.py +134 -0
- executorch/backends/arm/test/misc/test_bn_relu_folding_qat.py +124 -0
- executorch/backends/arm/test/misc/test_call_operator_submodule.py +72 -0
- executorch/backends/arm/test/misc/test_compile_spec.py +55 -0
- executorch/backends/arm/test/misc/test_conv_relu_residual_add.py +108 -0
- executorch/backends/arm/test/misc/test_custom_partition.py +183 -0
- executorch/backends/arm/test/misc/test_debug_feats.py +316 -0
- executorch/backends/arm/test/misc/test_debug_hook.py +186 -0
- executorch/backends/arm/test/misc/test_dim_order.py +127 -0
- executorch/backends/arm/test/misc/test_dw_convs_with_shared_weights.py +46 -0
- executorch/backends/arm/test/misc/test_extract_io_params_tosa.py +92 -0
- executorch/backends/arm/test/misc/test_int64.py +112 -0
- executorch/backends/arm/test/misc/test_lifted_tensor.py +146 -0
- executorch/backends/arm/test/misc/test_mixed_type_lowering.py +83 -0
- executorch/backends/arm/test/misc/test_model_evaluator.py +58 -0
- executorch/backends/arm/test/misc/test_multiple_delegates.py +53 -0
- executorch/backends/arm/test/misc/test_multiple_outputs.py +70 -0
- executorch/backends/arm/test/misc/test_non_persistent_buffers.py +49 -0
- executorch/backends/arm/test/misc/test_outputs_order.py +122 -0
- executorch/backends/arm/test/misc/test_partition_decomposed_quantized_ops.py +181 -0
- executorch/backends/arm/test/misc/test_pass_pipeline_config.py +35 -0
- executorch/backends/arm/test/misc/test_pass_required_order.py +97 -0
- executorch/backends/arm/test/misc/test_qat_training_loop.py +100 -0
- executorch/backends/arm/test/misc/test_quant_custom_meta.py +105 -0
- executorch/backends/arm/test/misc/test_rescale_range.py +130 -0
- executorch/backends/arm/test/misc/test_save_exported_model.py +64 -0
- executorch/backends/arm/test/misc/test_tosa_dialect_conv2d.py +220 -0
- executorch/backends/arm/test/misc/test_tosa_dialect_dw_conv2d.py +227 -0
- executorch/backends/arm/test/misc/test_tosa_spec.py +169 -0
- executorch/backends/arm/test/models/stable_diffusion/stable_diffusion_module_test_configs.py +114 -0
- executorch/backends/arm/test/models/stable_diffusion/test_CLIPTextModelWithProjection.py +168 -0
- executorch/backends/arm/test/models/stable_diffusion/test_SD3Transformer2DModel.py +193 -0
- executorch/backends/arm/test/models/stable_diffusion/test_T5EncoderModel.py +161 -0
- executorch/backends/arm/test/models/stable_diffusion/test_vae_AutoencoderKL.py +118 -0
- executorch/backends/arm/test/models/test_conformer.py +138 -0
- executorch/backends/arm/test/models/test_deit_tiny_arm.py +120 -0
- executorch/backends/arm/test/models/test_dl3_arm.py +118 -0
- executorch/backends/arm/test/models/test_inception_v3_arm.py +120 -0
- executorch/backends/arm/test/models/test_llama.py +227 -0
- executorch/backends/arm/test/models/test_lstm_arm.py +194 -0
- executorch/backends/arm/test/models/test_mobilenet_v2_arm.py +179 -0
- executorch/backends/arm/test/models/test_mobilenet_v3_arm.py +113 -0
- executorch/backends/arm/test/models/test_nn_functional.py +124 -0
- executorch/backends/arm/test/models/test_nn_modules.py +161 -0
- executorch/backends/arm/test/models/test_nss.py +146 -0
- executorch/backends/arm/test/models/test_resnet18.py +98 -0
- executorch/backends/arm/test/models/test_torch_functions.py +151 -0
- executorch/backends/arm/test/models/test_w2l_arm.py +136 -0
- executorch/backends/arm/test/ops/test_abs.py +101 -0
- executorch/backends/arm/test/ops/test_acos.py +121 -0
- executorch/backends/arm/test/ops/test_acosh.py +137 -0
- executorch/backends/arm/test/ops/test_adaptive_avg_pool2d.py +242 -0
- executorch/backends/arm/test/ops/test_add.py +291 -0
- executorch/backends/arm/test/ops/test_addmm.py +285 -0
- executorch/backends/arm/test/ops/test_alias_copy.py +114 -0
- executorch/backends/arm/test/ops/test_amax.py +191 -0
- executorch/backends/arm/test/ops/test_amin.py +205 -0
- executorch/backends/arm/test/ops/test_any.py +210 -0
- executorch/backends/arm/test/ops/test_arange.py +258 -0
- executorch/backends/arm/test/ops/test_asin.py +105 -0
- executorch/backends/arm/test/ops/test_asinh.py +104 -0
- executorch/backends/arm/test/ops/test_at.py +256 -0
- executorch/backends/arm/test/ops/test_atan.py +111 -0
- executorch/backends/arm/test/ops/test_atanh.py +112 -0
- executorch/backends/arm/test/ops/test_avg_pool2d.py +295 -0
- executorch/backends/arm/test/ops/test_batch_norm.py +385 -0
- executorch/backends/arm/test/ops/test_bitwise.py +672 -0
- executorch/backends/arm/test/ops/test_bitwise_not.py +115 -0
- executorch/backends/arm/test/ops/test_bmm.py +193 -0
- executorch/backends/arm/test/ops/test_cat.py +219 -0
- executorch/backends/arm/test/ops/test_ceil.py +125 -0
- executorch/backends/arm/test/ops/test_clamp.py +474 -0
- executorch/backends/arm/test/ops/test_clone.py +150 -0
- executorch/backends/arm/test/ops/test_cond.py +338 -0
- executorch/backends/arm/test/ops/test_constant_pad_nd.py +119 -0
- executorch/backends/arm/test/ops/test_conv1d.py +356 -0
- executorch/backends/arm/test/ops/test_conv2d.py +592 -0
- executorch/backends/arm/test/ops/test_conv3d.py +711 -0
- executorch/backends/arm/test/ops/test_conv_combos.py +668 -0
- executorch/backends/arm/test/ops/test_conv_constant_pad_nd.py +145 -0
- executorch/backends/arm/test/ops/test_copy.py +171 -0
- executorch/backends/arm/test/ops/test_cos.py +115 -0
- executorch/backends/arm/test/ops/test_cosh.py +111 -0
- executorch/backends/arm/test/ops/test_cumsum.py +122 -0
- executorch/backends/arm/test/ops/test_depthwise_conv.py +404 -0
- executorch/backends/arm/test/ops/test_div.py +151 -0
- executorch/backends/arm/test/ops/test_div_tensor_mode.py +151 -0
- executorch/backends/arm/test/ops/test_elu.py +133 -0
- executorch/backends/arm/test/ops/test_embedding.py +146 -0
- executorch/backends/arm/test/ops/test_eq.py +286 -0
- executorch/backends/arm/test/ops/test_erf.py +96 -0
- executorch/backends/arm/test/ops/test_exp.py +110 -0
- executorch/backends/arm/test/ops/test_expand.py +153 -0
- executorch/backends/arm/test/ops/test_expm1.py +113 -0
- executorch/backends/arm/test/ops/test_eye.py +156 -0
- executorch/backends/arm/test/ops/test_fill_scalar.py +108 -0
- executorch/backends/arm/test/ops/test_floor.py +125 -0
- executorch/backends/arm/test/ops/test_floor_div.py +156 -0
- executorch/backends/arm/test/ops/test_full.py +255 -0
- executorch/backends/arm/test/ops/test_ge.py +292 -0
- executorch/backends/arm/test/ops/test_gelu.py +156 -0
- executorch/backends/arm/test/ops/test_glu.py +130 -0
- executorch/backends/arm/test/ops/test_group_norm.py +200 -0
- executorch/backends/arm/test/ops/test_gt.py +293 -0
- executorch/backends/arm/test/ops/test_hardsigmoid.py +114 -0
- executorch/backends/arm/test/ops/test_hardswish.py +104 -0
- executorch/backends/arm/test/ops/test_hardtanh.py +113 -0
- executorch/backends/arm/test/ops/test_index_select.py +177 -0
- executorch/backends/arm/test/ops/test_index_tensor.py +467 -0
- executorch/backends/arm/test/ops/test_layer_norm.py +186 -0
- executorch/backends/arm/test/ops/test_le.py +296 -0
- executorch/backends/arm/test/ops/test_leaky_relu.py +125 -0
- executorch/backends/arm/test/ops/test_linalg_vector_norm.py +160 -0
- executorch/backends/arm/test/ops/test_linear.py +389 -0
- executorch/backends/arm/test/ops/test_log.py +100 -0
- executorch/backends/arm/test/ops/test_log1p.py +78 -0
- executorch/backends/arm/test/ops/test_logical.py +429 -0
- executorch/backends/arm/test/ops/test_logit.py +119 -0
- executorch/backends/arm/test/ops/test_logsoftmax.py +124 -0
- executorch/backends/arm/test/ops/test_lshift.py +220 -0
- executorch/backends/arm/test/ops/test_lt.py +293 -0
- executorch/backends/arm/test/ops/test_masked_fill.py +171 -0
- executorch/backends/arm/test/ops/test_matmul.py +289 -0
- executorch/backends/arm/test/ops/test_max_pool.py +329 -0
- executorch/backends/arm/test/ops/test_maximum.py +98 -0
- executorch/backends/arm/test/ops/test_mean_dim.py +388 -0
- executorch/backends/arm/test/ops/test_minimum.py +98 -0
- executorch/backends/arm/test/ops/test_mm.py +93 -0
- executorch/backends/arm/test/ops/test_mul.py +376 -0
- executorch/backends/arm/test/ops/test_multihead_attention.py +138 -0
- executorch/backends/arm/test/ops/test_ne.py +243 -0
- executorch/backends/arm/test/ops/test_neg.py +99 -0
- executorch/backends/arm/test/ops/test_ones.py +152 -0
- executorch/backends/arm/test/ops/test_permute.py +256 -0
- executorch/backends/arm/test/ops/test_pixel_shuffling.py +237 -0
- executorch/backends/arm/test/ops/test_pow.py +204 -0
- executorch/backends/arm/test/ops/test_reciprocal.py +112 -0
- executorch/backends/arm/test/ops/test_relu.py +166 -0
- executorch/backends/arm/test/ops/test_remainder.py +199 -0
- executorch/backends/arm/test/ops/test_repeat.py +162 -0
- executorch/backends/arm/test/ops/test_round.py +111 -0
- executorch/backends/arm/test/ops/test_rshift.py +226 -0
- executorch/backends/arm/test/ops/test_rsqrt.py +153 -0
- executorch/backends/arm/test/ops/test_rsub.py +126 -0
- executorch/backends/arm/test/ops/test_scalar_tensor.py +135 -0
- executorch/backends/arm/test/ops/test_scalars.py +438 -0
- executorch/backends/arm/test/ops/test_sdpa.py +73 -0
- executorch/backends/arm/test/ops/test_select.py +219 -0
- executorch/backends/arm/test/ops/test_select_scatter.py +173 -0
- executorch/backends/arm/test/ops/test_sigmoid.py +357 -0
- executorch/backends/arm/test/ops/test_sigmoid_32bit.py +177 -0
- executorch/backends/arm/test/ops/test_sign.py +113 -0
- executorch/backends/arm/test/ops/test_silu.py +174 -0
- executorch/backends/arm/test/ops/test_sin.py +108 -0
- executorch/backends/arm/test/ops/test_sinh.py +103 -0
- executorch/backends/arm/test/ops/test_slice.py +217 -0
- executorch/backends/arm/test/ops/test_softmax.py +121 -0
- executorch/backends/arm/test/ops/test_split.py +312 -0
- executorch/backends/arm/test/ops/test_sqrt.py +112 -0
- executorch/backends/arm/test/ops/test_squeeze.py +291 -0
- executorch/backends/arm/test/ops/test_stack.py +150 -0
- executorch/backends/arm/test/ops/test_sub.py +366 -0
- executorch/backends/arm/test/ops/test_sum.py +161 -0
- executorch/backends/arm/test/ops/test_t_copy.py +115 -0
- executorch/backends/arm/test/ops/test_tan.py +146 -0
- executorch/backends/arm/test/ops/test_tanh.py +169 -0
- executorch/backends/arm/test/ops/test_to_copy.py +296 -0
- executorch/backends/arm/test/ops/test_transpose_copy.py +114 -0
- executorch/backends/arm/test/ops/test_unary_combos.py +144 -0
- executorch/backends/arm/test/ops/test_unbind.py +82 -0
- executorch/backends/arm/test/ops/test_unflatten.py +107 -0
- executorch/backends/arm/test/ops/test_unsqueeze.py +107 -0
- executorch/backends/arm/test/ops/test_upsample_bilinear2d.py +443 -0
- executorch/backends/arm/test/ops/test_upsample_nearest2d.py +520 -0
- executorch/backends/arm/test/ops/test_var.py +394 -0
- executorch/backends/arm/test/ops/test_view.py +253 -0
- executorch/backends/arm/test/ops/test_where.py +285 -0
- executorch/backends/arm/test/ops/test_while.py +264 -0
- executorch/backends/arm/test/ops/test_zeros.py +158 -0
- executorch/backends/arm/test/passes/test_broadcast_args_pass.py +57 -0
- executorch/backends/arm/test/passes/test_cast_int64_pass.py +49 -0
- executorch/backends/arm/test/passes/test_convert_expand_copy_to_repeat.py +51 -0
- executorch/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py +529 -0
- executorch/backends/arm/test/passes/test_convert_int64_output_ops_to_int32.py +129 -0
- executorch/backends/arm/test/passes/test_convert_permute_singleton_to_view_pass.py +100 -0
- executorch/backends/arm/test/passes/test_convert_split_to_slice.py +75 -0
- executorch/backends/arm/test/passes/test_convert_to_clamp.py +92 -0
- executorch/backends/arm/test/passes/test_decompose_avg_pool2d_pass.py +82 -0
- executorch/backends/arm/test/passes/test_decompose_cosine_similarity_pass.py +58 -0
- executorch/backends/arm/test/passes/test_decompose_div_pass.py +70 -0
- executorch/backends/arm/test/passes/test_decompose_int_pow_pass.py +80 -0
- executorch/backends/arm/test/passes/test_decompose_layernorm_pass.py +69 -0
- executorch/backends/arm/test/passes/test_decompose_linalg_vector_norm_pass.py +107 -0
- executorch/backends/arm/test/passes/test_decompose_meandim_pass.py +137 -0
- executorch/backends/arm/test/passes/test_decompose_quant_nodes.py +44 -0
- executorch/backends/arm/test/passes/test_decompose_softmax_pass.py +103 -0
- executorch/backends/arm/test/passes/test_decompose_tosa_unsupported_clamp_pass.py +73 -0
- executorch/backends/arm/test/passes/test_decompose_var_pass.py +89 -0
- executorch/backends/arm/test/passes/test_decorate_fp32_to_int32_casting_pass.py +85 -0
- executorch/backends/arm/test/passes/test_fold_qdq_pass.py +51 -0
- executorch/backends/arm/test/passes/test_fuse_batchnorm_pass.py +164 -0
- executorch/backends/arm/test/passes/test_fuse_constant_ops_pass.py +177 -0
- executorch/backends/arm/test/passes/test_fuse_duplicate_users_pass.py +70 -0
- executorch/backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py +170 -0
- executorch/backends/arm/test/passes/test_fuse_view_copy.py +82 -0
- executorch/backends/arm/test/passes/test_insert_int32_casts_after_int64_placeholders_pass.py +114 -0
- executorch/backends/arm/test/passes/test_insert_rescale_i32_pass.py +107 -0
- executorch/backends/arm/test/passes/test_insert_table_ops_pass.py +47 -0
- executorch/backends/arm/test/passes/test_int32_cast_embedding_pass.py +46 -0
- executorch/backends/arm/test/passes/test_ioquantization_pass.py +48 -0
- executorch/backends/arm/test/passes/test_promote_bool_operands_pass.py +103 -0
- executorch/backends/arm/test/passes/test_remove_clone_pass.py +45 -0
- executorch/backends/arm/test/passes/test_replace_inf_values_pass.py +96 -0
- executorch/backends/arm/test/passes/test_rescale_pass.py +81 -0
- executorch/backends/arm/test/passes/test_rewrite_conv_pass.py +20 -0
- executorch/backends/arm/test/passes/test_to_tosa_memory_format.py +213 -0
- executorch/backends/arm/test/passes/test_unsqueeze_before_repeat_pass.py +62 -0
- executorch/backends/arm/test/quantizer/test_conv_relu_fusing.py +118 -0
- executorch/backends/arm/test/quantizer/test_generic_annotater.py +109 -0
- executorch/backends/arm/test/quantizer/test_partial_quantization.py +104 -0
- executorch/backends/arm/test/quantizer/test_selective_quantization.py +212 -0
- executorch/backends/arm/test/quantizer/test_set_module_name.py +158 -0
- executorch/backends/arm/test/quantizer/test_tosa_quantizer_validate.py +55 -0
- executorch/backends/arm/test/runner_utils.py +840 -0
- executorch/backends/arm/test/test_memory_allocator_log.py +170 -0
- executorch/backends/arm/test/test_model.py +345 -0
- executorch/backends/arm/test/tester/__init__.py +6 -0
- executorch/backends/arm/test/tester/analyze_output_utils.py +346 -0
- executorch/backends/arm/test/tester/arm_tester.py +1149 -0
- executorch/backends/arm/test/tester/quantize.py +43 -0
- executorch/backends/arm/test/tester/serialize.py +78 -0
- executorch/backends/arm/test/tester/test_pipeline.py +1190 -0
- executorch/backends/arm/tosa/__init__.py +9 -0
- executorch/backends/arm/tosa/backend.py +443 -0
- executorch/backends/arm/tosa/compile_spec.py +48 -0
- executorch/backends/arm/tosa/dialect/__init__.py +15 -0
- executorch/backends/arm/tosa/dialect/lib.py +85 -0
- executorch/backends/arm/tosa/dialect/ops/conv2d.py +111 -0
- executorch/backends/arm/tosa/dialect/ops/conv3d.py +74 -0
- executorch/backends/arm/tosa/dialect/ops/depthwise_conv2d.py +56 -0
- executorch/backends/arm/tosa/dialect/ops/matmul.py +56 -0
- executorch/backends/arm/tosa/dialect/ops/rescale.py +53 -0
- executorch/backends/arm/tosa/dialect/ops/resize.py +66 -0
- executorch/backends/arm/tosa/dialect/ops/table.py +53 -0
- executorch/backends/arm/tosa/dialect/ops/transpose.py +35 -0
- executorch/backends/arm/tosa/dialect/ops_registration.py +68 -0
- executorch/backends/arm/tosa/mapping.py +309 -0
- executorch/backends/arm/tosa/partitioner.py +486 -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/specification.py +406 -0
- executorch/backends/arm/tosa/utils.py +304 -0
- executorch/backends/arm/util/_factory.py +59 -0
- executorch/backends/arm/util/arm_model_evaluator.py +388 -0
- executorch/backends/arm/vgf/__init__.py +11 -0
- executorch/backends/arm/vgf/backend.py +172 -0
- executorch/backends/arm/vgf/compile_spec.py +73 -0
- executorch/backends/arm/vgf/model_converter.py +34 -0
- executorch/backends/arm/vgf/partitioner.py +35 -0
- executorch/backends/cadence/aot/__init__.py +5 -0
- executorch/backends/cadence/aot/compiler.py +484 -0
- executorch/backends/cadence/aot/compiler_funcs.py +203 -0
- executorch/backends/cadence/aot/compiler_utils.py +293 -0
- executorch/backends/cadence/aot/decompose_ops.py +120 -0
- executorch/backends/cadence/aot/export_example.py +117 -0
- executorch/backends/cadence/aot/functions.yaml +470 -0
- executorch/backends/cadence/aot/functions_fusion_g3.yaml +191 -0
- executorch/backends/cadence/aot/functions_hifi.yaml +565 -0
- executorch/backends/cadence/aot/functions_vision.yaml +275 -0
- executorch/backends/cadence/aot/fuse_ops.py +1138 -0
- executorch/backends/cadence/aot/graph_builder.py +142 -0
- executorch/backends/cadence/aot/memory_constraints.py +731 -0
- executorch/backends/cadence/aot/memory_planning.py +469 -0
- executorch/backends/cadence/aot/memory_planning_algo.py +341 -0
- executorch/backends/cadence/aot/ops_registrations.py +2841 -0
- executorch/backends/cadence/aot/pass_utils.py +274 -0
- executorch/backends/cadence/aot/passes.py +132 -0
- executorch/backends/cadence/aot/program_builder.py +138 -0
- executorch/backends/cadence/aot/quantizer/fusion_pass.py +743 -0
- executorch/backends/cadence/aot/quantizer/patterns.py +738 -0
- executorch/backends/cadence/aot/quantizer/quantizer.py +409 -0
- executorch/backends/cadence/aot/quantizer/utils.py +288 -0
- executorch/backends/cadence/aot/ref_implementations.py +2210 -0
- executorch/backends/cadence/aot/remove_ops.py +936 -0
- executorch/backends/cadence/aot/reorder_ops.py +843 -0
- executorch/backends/cadence/aot/replace_ops.py +2526 -0
- executorch/backends/cadence/aot/simplify_ops.py +221 -0
- executorch/backends/cadence/aot/tests/test_decompose_ops_passes.py +80 -0
- executorch/backends/cadence/aot/tests/test_fusion_ops_passes.py +1023 -0
- executorch/backends/cadence/aot/tests/test_graph_builder.py +104 -0
- executorch/backends/cadence/aot/tests/test_idma_ops.py +31 -0
- executorch/backends/cadence/aot/tests/test_memory_passes.py +1367 -0
- executorch/backends/cadence/aot/tests/test_pass_filter.py +167 -0
- executorch/backends/cadence/aot/tests/test_program_builder.py +222 -0
- executorch/backends/cadence/aot/tests/test_quantizer_ops.py +649 -0
- executorch/backends/cadence/aot/tests/test_ref_implementations.py +3151 -0
- executorch/backends/cadence/aot/tests/test_remove_ops_passes.py +977 -0
- executorch/backends/cadence/aot/tests/test_reorder_ops_passes.py +635 -0
- executorch/backends/cadence/aot/tests/test_replace_ops_passes.py +2777 -0
- executorch/backends/cadence/aot/tests/test_simplify_ops_passes.py +160 -0
- executorch/backends/cadence/aot/tests/test_type_dispatch_passes.py +481 -0
- executorch/backends/cadence/aot/type_dispatch.py +190 -0
- executorch/backends/cadence/aot/typing_stubs.py +22 -0
- executorch/backends/cadence/aot/utils.py +363 -0
- executorch/backends/cadence/runtime/__init__.py +13 -0
- executorch/backends/cadence/runtime/etdump.py +173 -0
- executorch/backends/cadence/runtime/executor.py +202 -0
- executorch/backends/cadence/runtime/runtime.py +156 -0
- executorch/backends/cadence/runtime/utils.py +100 -0
- executorch/backends/cadence/utils/FACTO/calibrator/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/calibrator/runner.py +190 -0
- executorch/backends/cadence/utils/FACTO/examples/example.py +59 -0
- executorch/backends/cadence/utils/FACTO/examples/minimal_example.py +21 -0
- executorch/backends/cadence/utils/FACTO/examples/random_seed.py +35 -0
- executorch/backends/cadence/utils/FACTO/facto/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/engine.py +129 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/gen.py +47 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/engine.py +291 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/gen.py +139 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/type.py +134 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/engine.py +54 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/model.py +133 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/solve.py +125 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/specs/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/specs/model.py +149 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/utils/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/utils/random_manager.py +33 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/__init__.py +0 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/constants.py +9 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/gen.py +283 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/solve.py +142 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/space.py +450 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/type.py +105 -0
- executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/utils.py +30 -0
- executorch/backends/cadence/utils/FACTO/facto/specdb/db.py +4361 -0
- executorch/backends/cadence/utils/FACTO/facto/specdb/default.py +36 -0
- executorch/backends/cadence/utils/FACTO/facto/specdb/dtypes.py +25 -0
- executorch/backends/cadence/utils/FACTO/facto/specdb/function.py +537 -0
- executorch/backends/cadence/utils/FACTO/setup.py +19 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_argtuple_engine.py +53 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_argtuple_generator.py +58 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_attributes.py +78 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_generator.py +98 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_types.py +28 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_attribute_engine.py +62 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_attribute_solver.py +83 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_constraints.py +27 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_meta_arg_engine.py +70 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_specs.py +48 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_structural_engine.py +32 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_generation.py +80 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_solving.py +193 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_space.py +231 -0
- executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_types.py +71 -0
- executorch/backends/cadence/utils/facto_util.py +611 -0
- executorch/backends/cadence/utils/gen_header.py +49 -0
- executorch/backends/cadence/utils/post_compilation.py +173 -0
- executorch/backends/cortex_m/ops/operators.py +890 -0
- executorch/backends/cortex_m/ops/operators.yaml +78 -0
- executorch/backends/cortex_m/passes/__init__.py +12 -0
- executorch/backends/cortex_m/passes/activation_fusion_pass.py +181 -0
- executorch/backends/cortex_m/passes/clamp_hardswish_pass.py +37 -0
- executorch/backends/cortex_m/passes/convert_to_cortex_m_pass.py +318 -0
- executorch/backends/cortex_m/passes/cortex_m_pass_manager.py +73 -0
- executorch/backends/cortex_m/passes/decompose_hardswish_pass.py +127 -0
- executorch/backends/cortex_m/passes/passes_utils.py +226 -0
- executorch/backends/cortex_m/passes/quantized_op_fusion_pass.py +255 -0
- executorch/backends/cortex_m/passes/replace_quant_nodes_pass.py +67 -0
- executorch/backends/cortex_m/quantizer/__init__.py +18 -0
- executorch/backends/cortex_m/quantizer/operator_configs.py +74 -0
- executorch/backends/cortex_m/quantizer/quantization_configs.py +121 -0
- executorch/backends/cortex_m/quantizer/quantizer.py +500 -0
- executorch/backends/cortex_m/test/misc/test_quantization.py +359 -0
- executorch/backends/cortex_m/test/models/__init__.py +4 -0
- executorch/backends/cortex_m/test/models/test_mobilenet_v3.py +74 -0
- executorch/backends/cortex_m/test/ops/__init__.py +4 -0
- executorch/backends/cortex_m/test/ops/test_activation.py +528 -0
- executorch/backends/cortex_m/test/ops/test_add.py +182 -0
- executorch/backends/cortex_m/test/ops/test_avg_pool2d.py +99 -0
- executorch/backends/cortex_m/test/ops/test_conv.py +342 -0
- executorch/backends/cortex_m/test/ops/test_linear.py +130 -0
- executorch/backends/cortex_m/test/ops/test_lstm.py +98 -0
- executorch/backends/cortex_m/test/ops/test_maximum.py +83 -0
- executorch/backends/cortex_m/test/ops/test_minimum.py +104 -0
- executorch/backends/cortex_m/test/ops/test_mul.py +156 -0
- executorch/backends/cortex_m/test/ops/test_softmax.py +84 -0
- executorch/backends/cortex_m/test/ops/test_transpose.py +102 -0
- executorch/backends/cortex_m/test/test_helpers_passes_utils.py +103 -0
- executorch/backends/cortex_m/test/test_replace_quant_nodes.py +134 -0
- executorch/backends/cortex_m/test/tester.py +113 -0
- executorch/backends/cuda/__init__.py +5 -0
- executorch/backends/cuda/cuda_backend.py +250 -0
- executorch/backends/cuda/cuda_partitioner.py +25 -0
- executorch/backends/cuda/passes/__init__.py +0 -0
- executorch/backends/cuda/passes/move_cond_predicate_to_cpu.py +90 -0
- executorch/backends/cuda/passes/tests/__init__.py +0 -0
- executorch/backends/cuda/passes/tests/test_move_cond_predicate_to_cpu.py +553 -0
- executorch/backends/cuda/tests/__init__.py +5 -0
- executorch/backends/cuda/tests/test_cuda_export.py +327 -0
- executorch/backends/cuda/tests/test_cuda_partitioner.py +224 -0
- executorch/backends/cuda/triton/__init__.py +17 -0
- executorch/backends/cuda/triton/kernels/__init__.py +11 -0
- executorch/backends/cuda/triton/kernels/sdpa.py +827 -0
- executorch/backends/cuda/triton/replacement_pass.py +130 -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/nxp/_passes/remove_getitem_pass.py +105 -0
- executorch/backends/nxp/aten_passes/convert_unsqueeze_to_view.py +79 -0
- executorch/backends/nxp/aten_passes/decompose_split_to_slices_pass.py +193 -0
- executorch/backends/nxp/aten_passes/fuse_batch_norm_with_conv_pass.py +146 -0
- executorch/backends/nxp/aten_passes/fuse_batch_norm_with_linear_pass.py +150 -0
- executorch/backends/nxp/aten_passes/fuse_linear_and_add_pass.py +204 -0
- executorch/backends/nxp/aten_passes/move_activation_before_concat.py +102 -0
- executorch/backends/nxp/aten_passes/neutron_aten_pass_manager.py +80 -0
- executorch/backends/nxp/aten_passes/remove_nodes_with_known_outputs.py +196 -0
- executorch/backends/nxp/aten_passes/split_group_convolution.py +281 -0
- executorch/backends/nxp/aten_passes/split_gru_based_on_num_layers.py +307 -0
- executorch/backends/nxp/backend/custom_delegation_options.py +19 -0
- executorch/backends/nxp/backend/edge_helper.py +222 -0
- executorch/backends/nxp/backend/edge_program_converter.py +247 -0
- executorch/backends/nxp/backend/ir/conversion_config.py +54 -0
- executorch/backends/nxp/backend/ir/conversion_context.py +38 -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 +142 -0
- executorch/backends/nxp/backend/ir/converter/builder/model_builder.py +1720 -0
- executorch/backends/nxp/backend/ir/converter/builder/quantization_verification.py +377 -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 +207 -0
- executorch/backends/nxp/backend/ir/converter/conversion/translator.py +689 -0
- executorch/backends/nxp/backend/ir/converter/node_converter.py +234 -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 +101 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/abs_converter.py +35 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/adaptive_avg_pool_2d_converter.py +68 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/add_tensor_converter.py +57 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/addmm_converter.py +62 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/avg_pool_2d_converter.py +101 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/cat_converter.py +209 -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 +160 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/convolution_converter.py +535 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardtanh_converter.py +47 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/max_pool_2d_converter.py +104 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mean_dim_converter.py +112 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mm_converter.py +59 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py +61 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/permute_copy_converter.py +468 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_dequantize_converter.py +116 -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 +33 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sigmoid_converter.py +35 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py +158 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/softmax_converter.py +62 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sub_tensor_converter.py +59 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/tanh_converter.py +33 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/view_copy_converter.py +220 -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 +105 -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 +97 -0
- executorch/backends/nxp/backend/ir/converter/node_converters/shared/reshape_transposition.py +233 -0
- executorch/backends/nxp/backend/ir/converter/quantization_utils.py +149 -0
- executorch/backends/nxp/backend/ir/converter/tensor_utils.py +50 -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 +174 -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/tensor_formatting.py +69 -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 +814 -0
- executorch/backends/nxp/backend/neutron_converter_manager.py +117 -0
- executorch/backends/nxp/backend/neutron_operator_support.py +79 -0
- executorch/backends/nxp/backend/neutron_target_spec.py +143 -0
- executorch/backends/nxp/backend/node_format.py +26 -0
- executorch/backends/nxp/backend/node_format_inference.py +294 -0
- executorch/backends/nxp/edge_passes/move_auxiliary_operator_into_separate_qdq_cluster_pass.py +254 -0
- executorch/backends/nxp/edge_passes/neutron_edge_pass.py +55 -0
- executorch/backends/nxp/edge_passes/neutron_edge_pass_manager.py +29 -0
- executorch/backends/nxp/edge_passes/remove_additional_quantize_dequantize_nodes_pass.py +111 -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 +79 -0
- executorch/backends/nxp/neutron_node_extraction.py +152 -0
- executorch/backends/nxp/neutron_partitioner.py +421 -0
- executorch/backends/nxp/neutron_pass_manager.py +50 -0
- executorch/backends/nxp/nxp_backend.py +391 -0
- executorch/backends/nxp/quantizer/neutron_quantizer.py +353 -0
- executorch/backends/nxp/quantizer/patterns.py +1089 -0
- executorch/backends/nxp/quantizer/utils.py +195 -0
- executorch/backends/nxp/tests/executorch_pipeline.py +184 -0
- executorch/backends/nxp/tests/executors.py +401 -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/converter/node_converter/test_abs_converter.py +91 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_adaptive_avg_pool2d_converter.py +148 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_add_tensor_converter.py +161 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_addmm_converter.py +96 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_avg_pool2d_converter.py +221 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_cat_converter.py +495 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_clone_converter.py +344 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_constant_pad_nd_converter.py +188 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_conv_converter.py +680 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_hardtanh_converter.py +107 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_max_pool_2d_converter.py +132 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_mean_dim_converter.py +280 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_mm_converter.py +96 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_mul_tensor_converter.py +212 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_permute_copy_converter.py +426 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_relu_converter.py +114 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_sigmoid_converter.py +78 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py +244 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_softmax_converter.py +115 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_sub_tensor_converter.py +181 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_tanh_converter.py +90 -0
- executorch/backends/nxp/tests/ir/converter/node_converter/test_view_copy_converter.py +509 -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 +127 -0
- executorch/backends/nxp/tests/models.py +737 -0
- executorch/backends/nxp/tests/test_batch_norm_fusion.py +233 -0
- executorch/backends/nxp/tests/test_context_sensitive_delegation.py +71 -0
- executorch/backends/nxp/tests/test_convert_unsqueeze_to_view.py +143 -0
- executorch/backends/nxp/tests/test_decompose_split_to_slices.py +315 -0
- executorch/backends/nxp/tests/test_edge_passes.py +382 -0
- executorch/backends/nxp/tests/test_gru_splitting.py +267 -0
- executorch/backends/nxp/tests/test_integration.py +53 -0
- executorch/backends/nxp/tests/test_linear_and_add_fusion.py +653 -0
- executorch/backends/nxp/tests/test_move_activation_before_concatenation.py +905 -0
- executorch/backends/nxp/tests/test_neutron_backend.py +63 -0
- executorch/backends/nxp/tests/test_neutron_backend_executor.py +327 -0
- executorch/backends/nxp/tests/test_neutron_converter_manager.py +59 -0
- executorch/backends/nxp/tests/test_node_format_inference.py +91 -0
- executorch/backends/nxp/tests/test_operator_selector.py +24 -0
- executorch/backends/nxp/tests/test_per_channel_conversion.py +182 -0
- executorch/backends/nxp/tests/test_qdq_clustering_conv.py +31 -0
- executorch/backends/nxp/tests/test_quantizer.py +703 -0
- executorch/backends/nxp/tests/test_removing_dead_code.py +65 -0
- executorch/backends/nxp/tests/test_removing_nodes_with_known_outputs.py +116 -0
- executorch/backends/nxp/tests/test_split_group_convolution.py +291 -0
- executorch/backends/nxp/tests/use_qat.py +11 -0
- executorch/backends/openvino/__init__.py +5 -0
- executorch/backends/openvino/partitioner.py +238 -0
- executorch/backends/openvino/preprocess.py +62 -0
- executorch/backends/openvino/quantizer/__init__.py +3 -0
- executorch/backends/openvino/quantizer/observers.py +186 -0
- executorch/backends/openvino/quantizer/quantizer.py +595 -0
- executorch/backends/openvino/tests/models/test_classification.py +38 -0
- executorch/backends/openvino/tests/ops/base_openvino_op_test.py +86 -0
- executorch/backends/openvino/tests/ops/test_add.py +22 -0
- executorch/backends/openvino/tests/ops/test_addmm.py +28 -0
- executorch/backends/openvino/tests/ops/test_arange.py +23 -0
- executorch/backends/openvino/tests/ops/test_batch_norm.py +61 -0
- executorch/backends/openvino/tests/ops/test_convolution.py +296 -0
- executorch/backends/openvino/tests/ops/test_mean.py +90 -0
- executorch/backends/openvino/tests/ops/test_permute.py +33 -0
- executorch/backends/openvino/tests/ops/test_pooling.py +91 -0
- executorch/backends/openvino/tests/ops/test_unary_ops.py +37 -0
- executorch/backends/openvino/tests/ops/test_view.py +35 -0
- executorch/backends/openvino/tests/test_runner.py +76 -0
- executorch/backends/qualcomm/__init__.py +13 -0
- executorch/backends/qualcomm/_passes/__init__.py +101 -0
- executorch/backends/qualcomm/_passes/annotate_adaptive_avg_pool1d.py +43 -0
- executorch/backends/qualcomm/_passes/annotate_quant_attrs.py +145 -0
- executorch/backends/qualcomm/_passes/annotate_stack.py +44 -0
- executorch/backends/qualcomm/_passes/annotate_unbind.py +42 -0
- executorch/backends/qualcomm/_passes/build_quant_io.py +49 -0
- executorch/backends/qualcomm/_passes/canonicalize_conv.py +204 -0
- executorch/backends/qualcomm/_passes/convert_bmm_to_matmul.py +83 -0
- executorch/backends/qualcomm/_passes/convert_linear_to_conv2d.py +232 -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_any.py +64 -0
- executorch/backends/qualcomm/_passes/decompose_binary_alpha.py +61 -0
- executorch/backends/qualcomm/_passes/decompose_cdist.py +69 -0
- executorch/backends/qualcomm/_passes/decompose_col_im.py +121 -0
- executorch/backends/qualcomm/_passes/decompose_einsum.py +51 -0
- executorch/backends/qualcomm/_passes/decompose_expm1.py +46 -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_linalg_vector_norm.py +75 -0
- executorch/backends/qualcomm/_passes/decompose_maxpool3d.py +133 -0
- executorch/backends/qualcomm/_passes/decompose_minmaxdim.py +109 -0
- executorch/backends/qualcomm/_passes/decompose_roll.py +78 -0
- executorch/backends/qualcomm/_passes/decompose_silu.py +45 -0
- executorch/backends/qualcomm/_passes/decompose_threshold.py +61 -0
- executorch/backends/qualcomm/_passes/decompose_triu.py +71 -0
- executorch/backends/qualcomm/_passes/decompose_wrap_with_autocast.py +79 -0
- executorch/backends/qualcomm/_passes/expand_broadcast_tensor_shape.py +67 -0
- executorch/backends/qualcomm/_passes/fixed_linear_keep_dim.py +95 -0
- executorch/backends/qualcomm/_passes/fold_qdq.py +80 -0
- executorch/backends/qualcomm/_passes/fuse_consecutive_cast.py +116 -0
- executorch/backends/qualcomm/_passes/fuse_consecutive_transpose.py +109 -0
- executorch/backends/qualcomm/_passes/i64_to_i32.py +184 -0
- executorch/backends/qualcomm/_passes/insert_io_qdq.py +154 -0
- executorch/backends/qualcomm/_passes/insert_requantize.py +111 -0
- executorch/backends/qualcomm/_passes/insert_reshape_for_reduce_ops.py +59 -0
- executorch/backends/qualcomm/_passes/layout_transform.py +355 -0
- executorch/backends/qualcomm/_passes/lift_constant_scalar_operands.py +186 -0
- executorch/backends/qualcomm/_passes/qnn_pass_manager.py +271 -0
- executorch/backends/qualcomm/_passes/recompose_pad_maxpool2d.py +147 -0
- executorch/backends/qualcomm/_passes/recompose_pixel_unshuffle.py +81 -0
- executorch/backends/qualcomm/_passes/recompose_rms_norm.py +155 -0
- executorch/backends/qualcomm/_passes/reduce_dynamic_range.py +60 -0
- executorch/backends/qualcomm/_passes/remove_0d_tensor.py +36 -0
- executorch/backends/qualcomm/_passes/remove_redundancy.py +73 -0
- executorch/backends/qualcomm/_passes/replace_arange_args.py +48 -0
- executorch/backends/qualcomm/_passes/replace_inf_values.py +60 -0
- executorch/backends/qualcomm/_passes/seq_mse.py +224 -0
- executorch/backends/qualcomm/_passes/tag_quant_io.py +45 -0
- executorch/backends/qualcomm/_passes/utils.py +283 -0
- executorch/backends/qualcomm/builders/__init__.py +221 -0
- executorch/backends/qualcomm/builders/node_visitor.py +518 -0
- executorch/backends/qualcomm/builders/node_visitor_manager.py +79 -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 +168 -0
- executorch/backends/qualcomm/builders/op_avg_pool3d.py +299 -0
- executorch/backends/qualcomm/builders/op_batch_norm.py +151 -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_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 +93 -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 +79 -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 +81 -0
- executorch/backends/qualcomm/builders/op_floor.py +56 -0
- executorch/backends/qualcomm/builders/op_full.py +41 -0
- executorch/backends/qualcomm/builders/op_full_like.py +41 -0
- executorch/backends/qualcomm/builders/op_gather.py +76 -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 +94 -0
- executorch/backends/qualcomm/builders/op_gt.py +62 -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 +81 -0
- executorch/backends/qualcomm/builders/op_instance_norm.py +112 -0
- executorch/backends/qualcomm/builders/op_layer_norm.py +113 -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 +97 -0
- executorch/backends/qualcomm/builders/op_pow.py +75 -0
- executorch/backends/qualcomm/builders/op_prelu.py +81 -0
- executorch/backends/qualcomm/builders/op_quantize.py +73 -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 +132 -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_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_space_to_depth.py +78 -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_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_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 +630 -0
- executorch/backends/qualcomm/builders/utils.py +160 -0
- executorch/backends/qualcomm/debugger/format_outputs.py +221 -0
- executorch/backends/qualcomm/debugger/metrics_evaluator.py +90 -0
- executorch/backends/qualcomm/debugger/qnn_intermediate_debugger.py +328 -0
- executorch/backends/qualcomm/debugger/utils.py +435 -0
- executorch/backends/qualcomm/partition/common_defs.py +44 -0
- executorch/backends/qualcomm/partition/qnn_partitioner.py +225 -0
- executorch/backends/qualcomm/partition/utils.py +75 -0
- executorch/backends/qualcomm/qnn_preprocess.py +218 -0
- executorch/backends/qualcomm/quantizer/annotators.py +1501 -0
- executorch/backends/qualcomm/quantizer/custom_annotation.py +499 -0
- executorch/backends/qualcomm/quantizer/observers/concat_observer.py +74 -0
- executorch/backends/qualcomm/quantizer/observers/per_block_param_observer.py +145 -0
- executorch/backends/qualcomm/quantizer/observers/per_channel_param_observer.py +113 -0
- executorch/backends/qualcomm/quantizer/qconfig.py +802 -0
- executorch/backends/qualcomm/quantizer/quant_recipe.py +402 -0
- executorch/backends/qualcomm/quantizer/quantizer.py +507 -0
- executorch/backends/qualcomm/recipes/__init__.py +16 -0
- executorch/backends/qualcomm/recipes/qnn_recipe_provider.py +179 -0
- executorch/backends/qualcomm/recipes/qnn_recipe_types.py +28 -0
- executorch/backends/qualcomm/scripts/download_qnn_sdk.py +642 -0
- executorch/backends/qualcomm/serialization/qc_compiler_spec.fbs +299 -0
- executorch/backends/qualcomm/serialization/qc_schema.py +240 -0
- executorch/backends/qualcomm/serialization/qc_schema_serialize.py +59 -0
- executorch/backends/qualcomm/tests/models.py +2393 -0
- executorch/backends/qualcomm/tests/test_passes.py +154 -0
- executorch/backends/qualcomm/tests/test_qnn_delegate.py +8454 -0
- executorch/backends/qualcomm/tests/tester.py +113 -0
- executorch/backends/qualcomm/tests/utils.py +770 -0
- executorch/backends/qualcomm/utils/constants.py +49 -0
- executorch/backends/qualcomm/utils/qnn_manager_lifecycle.py +88 -0
- executorch/backends/qualcomm/utils/utils.py +1302 -0
- executorch/backends/samsung/_passes/annotate_qparams.py +201 -0
- executorch/backends/samsung/_passes/annotate_scalar_parameters.py +65 -0
- executorch/backends/samsung/_passes/conv1d_to_conv2d.py +97 -0
- executorch/backends/samsung/_passes/customized_constant_prop.py +40 -0
- executorch/backends/samsung/_passes/fold_qdq.py +36 -0
- executorch/backends/samsung/_passes/fuse_conv_act.py +77 -0
- executorch/backends/samsung/_passes/insert_qdq.py +164 -0
- executorch/backends/samsung/_passes/remove_useless_ops.py +87 -0
- executorch/backends/samsung/_passes/replace_scalar_ops.py +46 -0
- executorch/backends/samsung/_passes/utils.py +15 -0
- executorch/backends/samsung/builders/__init__.py +97 -0
- executorch/backends/samsung/builders/node_visitor.py +116 -0
- executorch/backends/samsung/builders/op_add.py +41 -0
- executorch/backends/samsung/builders/op_avg_pool2d.py +70 -0
- executorch/backends/samsung/builders/op_batch_norm.py +56 -0
- executorch/backends/samsung/builders/op_bmm.py +43 -0
- executorch/backends/samsung/builders/op_cat.py +50 -0
- executorch/backends/samsung/builders/op_clamp.py +47 -0
- executorch/backends/samsung/builders/op_constant_pad_nd.py +56 -0
- executorch/backends/samsung/builders/op_conv2d.py +89 -0
- executorch/backends/samsung/builders/op_dequantize.py +19 -0
- executorch/backends/samsung/builders/op_div.py +42 -0
- executorch/backends/samsung/builders/op_embedding.py +41 -0
- executorch/backends/samsung/builders/op_expand_copy.py +77 -0
- executorch/backends/samsung/builders/op_gelu.py +40 -0
- executorch/backends/samsung/builders/op_getitem.py +32 -0
- executorch/backends/samsung/builders/op_hardsigmoid.py +35 -0
- executorch/backends/samsung/builders/op_hardswish.py +35 -0
- executorch/backends/samsung/builders/op_hardtanh.py +42 -0
- executorch/backends/samsung/builders/op_layer_norm.py +53 -0
- executorch/backends/samsung/builders/op_leaky_relu.py +58 -0
- executorch/backends/samsung/builders/op_linear.py +51 -0
- executorch/backends/samsung/builders/op_log_softmax.py +39 -0
- executorch/backends/samsung/builders/op_max_pool2d.py +96 -0
- executorch/backends/samsung/builders/op_maximum.py +37 -0
- executorch/backends/samsung/builders/op_mean_dim.py +49 -0
- executorch/backends/samsung/builders/op_minimum.py +39 -0
- executorch/backends/samsung/builders/op_mul.py +43 -0
- executorch/backends/samsung/builders/op_permute.py +37 -0
- executorch/backends/samsung/builders/op_pixel_shuffle.py +38 -0
- executorch/backends/samsung/builders/op_quantize.py +60 -0
- executorch/backends/samsung/builders/op_relu.py +37 -0
- executorch/backends/samsung/builders/op_reshape.py +34 -0
- executorch/backends/samsung/builders/op_rsqrt.py +35 -0
- executorch/backends/samsung/builders/op_select.py +52 -0
- executorch/backends/samsung/builders/op_slice_copy.py +59 -0
- executorch/backends/samsung/builders/op_softmax.py +39 -0
- executorch/backends/samsung/builders/op_sqrt.py +35 -0
- executorch/backends/samsung/builders/op_squeeze.py +37 -0
- executorch/backends/samsung/builders/op_sub.py +39 -0
- executorch/backends/samsung/builders/op_to_copy.py +44 -0
- executorch/backends/samsung/builders/op_unsqueeze.py +35 -0
- executorch/backends/samsung/builders/op_upsample_bilinear2d.py +53 -0
- executorch/backends/samsung/builders/op_upsample_nearest2d.py +52 -0
- executorch/backends/samsung/builders/utils.py +64 -0
- executorch/backends/samsung/enn_preprocess.py +110 -0
- executorch/backends/samsung/partition/enn_partitioner.py +134 -0
- executorch/backends/samsung/quantizer/__init__.py +10 -0
- executorch/backends/samsung/quantizer/annotator.py +871 -0
- executorch/backends/samsung/quantizer/qconfig.py +174 -0
- executorch/backends/samsung/quantizer/quantizer.py +65 -0
- executorch/backends/samsung/serialization/compile_options.py +77 -0
- executorch/backends/samsung/serialization/compile_options_def.fbs +23 -0
- executorch/backends/samsung/serialization/enn_graph_schema.py +141 -0
- executorch/backends/samsung/test/models/test_deeplab_v3.py +28 -0
- executorch/backends/samsung/test/models/test_edsr.py +30 -0
- executorch/backends/samsung/test/models/test_inception_v3.py +30 -0
- executorch/backends/samsung/test/models/test_inception_v4.py +30 -0
- executorch/backends/samsung/test/models/test_mobilenet_v2.py +28 -0
- executorch/backends/samsung/test/models/test_mobilenet_v3.py +33 -0
- executorch/backends/samsung/test/models/test_resnet18.py +30 -0
- executorch/backends/samsung/test/models/test_resnet50.py +30 -0
- executorch/backends/samsung/test/models/test_torchvision_vit.py +32 -0
- executorch/backends/samsung/test/models/test_wav2letter.py +28 -0
- executorch/backends/samsung/test/ops/test_add.py +63 -0
- executorch/backends/samsung/test/ops/test_avg_pool2d.py +66 -0
- executorch/backends/samsung/test/ops/test_batch_norm.py +52 -0
- executorch/backends/samsung/test/ops/test_bmm.py +50 -0
- executorch/backends/samsung/test/ops/test_cat.py +49 -0
- executorch/backends/samsung/test/ops/test_clamp.py +50 -0
- executorch/backends/samsung/test/ops/test_constant_pad_nd.py +46 -0
- executorch/backends/samsung/test/ops/test_conv2d.py +95 -0
- executorch/backends/samsung/test/ops/test_div.py +50 -0
- executorch/backends/samsung/test/ops/test_embedding.py +46 -0
- executorch/backends/samsung/test/ops/test_expand_copy.py +46 -0
- executorch/backends/samsung/test/ops/test_gelu.py +65 -0
- executorch/backends/samsung/test/ops/test_leaky_relu.py +47 -0
- executorch/backends/samsung/test/ops/test_linear.py +48 -0
- executorch/backends/samsung/test/ops/test_log_softmax.py +46 -0
- executorch/backends/samsung/test/ops/test_max_pool2d.py +72 -0
- executorch/backends/samsung/test/ops/test_mean_dim.py +51 -0
- executorch/backends/samsung/test/ops/test_minimum.py +45 -0
- executorch/backends/samsung/test/ops/test_mul.py +63 -0
- executorch/backends/samsung/test/ops/test_permute.py +55 -0
- executorch/backends/samsung/test/ops/test_pixel_shuffle.py +49 -0
- executorch/backends/samsung/test/ops/test_relu.py +65 -0
- executorch/backends/samsung/test/ops/test_reshape.py +46 -0
- executorch/backends/samsung/test/ops/test_rsqrt.py +46 -0
- executorch/backends/samsung/test/ops/test_select.py +52 -0
- executorch/backends/samsung/test/ops/test_slice_copy.py +46 -0
- executorch/backends/samsung/test/ops/test_softmax.py +46 -0
- executorch/backends/samsung/test/ops/test_sqrt.py +46 -0
- executorch/backends/samsung/test/ops/test_squeeze.py +47 -0
- executorch/backends/samsung/test/ops/test_sub.py +63 -0
- executorch/backends/samsung/test/ops/test_to_copy.py +49 -0
- executorch/backends/samsung/test/ops/test_unsqueeze.py +47 -0
- executorch/backends/samsung/test/ops/test_upsample_bilinear2d.py +54 -0
- executorch/backends/samsung/test/ops/test_upsample_nearest2d.py +53 -0
- executorch/backends/samsung/test/tester/__init__.py +11 -0
- executorch/backends/samsung/test/tester/samsung_tester.py +125 -0
- executorch/backends/samsung/test/utils/__init__.py +11 -0
- executorch/backends/samsung/test/utils/runtime_executor.py +186 -0
- executorch/backends/samsung/utils/constants.py +45 -0
- executorch/backends/samsung/utils/export_utils.py +93 -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 +301 -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 +128 -0
- executorch/backends/test/harness/stages/run_passes.py +66 -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 +478 -0
- executorch/backends/test/harness/tests/test_error_statistics.py +67 -0
- executorch/backends/test/suite/__init__.py +74 -0
- executorch/backends/test/suite/conftest.py +182 -0
- executorch/backends/test/suite/context.py +34 -0
- executorch/backends/test/suite/discovery.py +100 -0
- executorch/backends/test/suite/flow.py +150 -0
- executorch/backends/test/suite/flows/__init__.py +7 -0
- executorch/backends/test/suite/flows/arm.py +92 -0
- executorch/backends/test/suite/flows/coreml.py +31 -0
- executorch/backends/test/suite/flows/portable.py +19 -0
- executorch/backends/test/suite/flows/qualcomm.py +61 -0
- executorch/backends/test/suite/flows/vulkan.py +44 -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 +71 -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 +421 -0
- executorch/backends/test/suite/runner.py +328 -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/convert_dtype_pass.py +103 -0
- executorch/backends/transforms/decompose_sdpa.py +120 -0
- executorch/backends/transforms/duplicate_dynamic_quant_chain.py +195 -0
- executorch/backends/transforms/fuse_batch_norm_with_conv.py +161 -0
- executorch/backends/transforms/fuse_conv_with_clamp.py +77 -0
- executorch/backends/transforms/fuse_view_copy.py +116 -0
- executorch/backends/transforms/mean_to_sum_div.py +41 -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/replace_scalar_with_tensor.py +93 -0
- executorch/backends/transforms/test/test_create_delete_constant_placeholder.py +122 -0
- executorch/backends/transforms/test/test_create_mutable_buffer.py +503 -0
- executorch/backends/transforms/test/test_duplicate_dynamic_quant_chain.py +184 -0
- executorch/backends/transforms/test/test_rank_0_to_rank_1.py +32 -0
- executorch/backends/transforms/test/test_remove_clone_ops.py +197 -0
- executorch/backends/transforms/utils.py +377 -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 +37 -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_prepack_nodes.py +83 -0
- executorch/backends/vulkan/_passes/remove_asserts.py +52 -0
- executorch/backends/vulkan/_passes/remove_redundant_ops.py +72 -0
- executorch/backends/vulkan/_passes/squeeze_unsqueeze_inputs.py +93 -0
- executorch/backends/vulkan/_passes/tag_memory_meta_pass.py +485 -0
- executorch/backends/vulkan/custom_ops_lib.py +597 -0
- executorch/backends/vulkan/op_registry.py +885 -0
- executorch/backends/vulkan/partitioner/vulkan_partitioner.py +401 -0
- executorch/backends/vulkan/patterns/__init__.py +139 -0
- executorch/backends/vulkan/patterns/pattern_registry.py +116 -0
- executorch/backends/vulkan/patterns/quantized_binary.py +161 -0
- executorch/backends/vulkan/patterns/quantized_convolution.py +260 -0
- executorch/backends/vulkan/patterns/quantized_linear.py +500 -0
- executorch/backends/vulkan/patterns/rope.py +173 -0
- executorch/backends/vulkan/patterns/sdpa.py +155 -0
- executorch/backends/vulkan/patterns/select_as_symint.py +104 -0
- executorch/backends/vulkan/quantizer/vulkan_quantizer.py +183 -0
- executorch/backends/vulkan/quantizer/vulkan_quantizer_utils.py +223 -0
- executorch/backends/vulkan/runtime/gen_vulkan_spv.py +1517 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_naive_buffer.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_naive_texture3d.yaml +24 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_optimized.yaml +43 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/arange.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/avg_pool2d.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/batchnorm.yaml +11 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml +118 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_buffer.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/bitw8_image_to_nchw_nobitw8buffer.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/buffer_to_buffer.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/buffer_to_nchw.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/choose_qparams_per_row.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/clone.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/col2im.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/concat_buffer.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/concat_texture.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv1d.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_output_tile.yaml +27 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_prepack_weights.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_q8ta_q8csw_q8to.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_sned_output_tile.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_prepack_weights.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw.yaml +21 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_q8ta_q8csw_q8to_tiled.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_s1p0.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8csw_linear_tiled.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_linear_tiled.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_q8to.yaml +21 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_q8to_linear_tiled.yaml +21 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv_transpose2d.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/conv_transpose2d_prepack_weights.yaml +16 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.yaml +16 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_legacy.yaml +12 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/expand_buffer.yaml +11 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/flip.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/full.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/gather_buffer.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/gather_texture.yaml +17 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/grid_priors.yaml +12 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/group_norm_reduce_texture.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/group_norm_texture.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/im2col.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/im2col_packed_int8.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/image_to_nchw.yaml +38 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/index_select.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/index_select_channel.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_dq8ca_q4gsw_tiled.yaml +29 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q4gsw_coop.yaml +43 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q4gsw_tiled.yaml +28 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q8csw_tiled.yaml +28 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q8ta_q8csw_tiled.yaml +24 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw.yaml +23 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw_coop.yaml +38 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw_tiled.yaml +54 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/max_pool2d.yaml +17 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/native_layer_norm.yaml +16 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_bitw8_image_nobitw8buffer.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_buffer.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_image.yaml +37 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/no_op.yaml +24 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pack_int4_linear_weight_transposed_interleaved.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q4_linear_weight.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_conv2d_dw_weights.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_conv2d_weights.yaml +15 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_linear_weight.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pad_channel.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pad_height_width.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/permute_buffer.yaml +11 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/permute_texture.yaml +11 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4h4w.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4h4w_with_group_sums.yaml +30 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4w4c.yaml +23 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_im2col.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/reduce.yaml +29 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/reduce2d.yaml +29 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/reduce_per_row_buffer.yaml +42 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/repeat.yaml +14 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/repeat_channel.yaml +12 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/repeat_interleave.yaml +12 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/rotary_embedding.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/scalar_tensor.yaml +27 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_attn_weights_softmax.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_attn_weights_coop.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_attn_weights_tiled.yaml +26 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_out_coop.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_out_tiled.yaml +26 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_kv_cache_update.yaml +23 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/set_zero.yaml +8 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/softmax.yaml +21 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/split_buffer.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/split_texture.yaml +17 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/tan.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/transfer_buffer.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/transfer_texture.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/unary_op.yaml +48 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/unpack_4w4c_and_dequantize.yaml +23 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/update_concat_offset.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/upsample_2d.yaml +19 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/var_buffer.yaml +16 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/var_texture3d.yaml +16 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/view.yaml +13 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/view_buffer.yaml +20 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/view_convert_buffer.yaml +22 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/where.yaml +12 -0
- executorch/backends/vulkan/serialization/schema.fbs +158 -0
- executorch/backends/vulkan/serialization/vulkan_graph_builder.py +505 -0
- executorch/backends/vulkan/serialization/vulkan_graph_schema.py +161 -0
- executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +274 -0
- executorch/backends/vulkan/test/custom_ops/glsl/add.yaml +29 -0
- executorch/backends/vulkan/test/glsl/all_shaders.yaml +68 -0
- executorch/backends/vulkan/test/glsl/dynamic_dispatch_test.yaml +7 -0
- executorch/backends/vulkan/test/glsl/reference_matmul_common.yaml +9 -0
- executorch/backends/vulkan/test/op_tests/cases.py +2026 -0
- executorch/backends/vulkan/test/op_tests/generate_op_benchmarks.py +88 -0
- executorch/backends/vulkan/test/op_tests/generate_op_correctness_tests.py +90 -0
- executorch/backends/vulkan/test/op_tests/utils/aten_types.py +31 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_benchmark_vk.py +350 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_computegraph.py +788 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_correctness_base.py +421 -0
- executorch/backends/vulkan/test/op_tests/utils/gen_correctness_vk.py +164 -0
- executorch/backends/vulkan/test/op_tests/utils/test_suite.py +53 -0
- executorch/backends/vulkan/test/test_serialization.py +135 -0
- executorch/backends/vulkan/test/test_vulkan_delegate.py +2696 -0
- executorch/backends/vulkan/test/test_vulkan_delegate_header.py +104 -0
- executorch/backends/vulkan/test/test_vulkan_passes.py +193 -0
- executorch/backends/vulkan/test/tester.py +91 -0
- executorch/backends/vulkan/test/utils.py +1111 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/apiconventions.py +21 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/base_generator.py +937 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/cgenerator.py +549 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/generator.py +1424 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/parse_dependency.py +404 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/reg.py +1885 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/conventions.py +562 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/util.py +58 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/stripAPI.py +42 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vkconventions.py +314 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vulkan_object.py +484 -0
- executorch/backends/vulkan/third-party/VulkanMemoryAllocator/tools/GpuMemDumpVis/GpuMemDumpVis.py +333 -0
- executorch/backends/vulkan/third-party/volk/generate.py +212 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/buf_bandwidth.yaml +18 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/buf_cacheline_size.yaml +12 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/reg_count.yaml +16 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/tex_bandwidth.yaml +15 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/tex_cacheline_concurr.yaml +14 -0
- executorch/backends/vulkan/tools/gpuinfo/glsl/warp_size.yaml +16 -0
- executorch/backends/vulkan/utils.py +1474 -0
- executorch/backends/vulkan/vulkan_preprocess.py +249 -0
- executorch/backends/xnnpack/__init__.py +34 -0
- executorch/backends/xnnpack/_passes/__init__.py +109 -0
- executorch/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py +561 -0
- executorch/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py +203 -0
- executorch/backends/xnnpack/_passes/convert_to_linear.py +198 -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_cat.py +105 -0
- executorch/backends/xnnpack/_passes/fuse_activation_pass.py +87 -0
- executorch/backends/xnnpack/_passes/fuse_batch_norm.py +261 -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_redundant_copy_pass.py +158 -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 +758 -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 +75 -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 +60 -0
- executorch/backends/xnnpack/operators/op_conv2d.py +186 -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 +56 -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 +52 -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 +110 -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 +136 -0
- executorch/backends/xnnpack/operators/op_maximum.py +55 -0
- executorch/backends/xnnpack/operators/op_mean_dim.py +78 -0
- executorch/backends/xnnpack/operators/op_minimum.py +54 -0
- executorch/backends/xnnpack/operators/op_multiply.py +84 -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 +145 -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 +127 -0
- executorch/backends/xnnpack/partition/config/gemm_configs.py +575 -0
- executorch/backends/xnnpack/partition/config/generic_node_configs.py +711 -0
- executorch/backends/xnnpack/partition/config/node_configs.py +148 -0
- executorch/backends/xnnpack/partition/config/quant_affine_configs.py +56 -0
- executorch/backends/xnnpack/partition/config/xnnpack_config.py +252 -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 +160 -0
- executorch/backends/xnnpack/quantizer/xnnpack_quantizer.py +462 -0
- executorch/backends/xnnpack/quantizer/xnnpack_quantizer_utils.py +1121 -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 +389 -0
- executorch/backends/xnnpack/serialization/schema.fbs +381 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +542 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +373 -0
- executorch/backends/xnnpack/test/__init__.py +0 -0
- executorch/backends/xnnpack/test/models/deeplab_v3.py +42 -0
- executorch/backends/xnnpack/test/models/edsr.py +55 -0
- executorch/backends/xnnpack/test/models/emformer_rnnt.py +98 -0
- executorch/backends/xnnpack/test/models/inception_v3.py +84 -0
- executorch/backends/xnnpack/test/models/inception_v4.py +62 -0
- executorch/backends/xnnpack/test/models/llama2_et_example.py +49 -0
- executorch/backends/xnnpack/test/models/mobilebert.py +55 -0
- executorch/backends/xnnpack/test/models/mobilenet_v2.py +103 -0
- executorch/backends/xnnpack/test/models/mobilenet_v3.py +84 -0
- executorch/backends/xnnpack/test/models/resnet.py +90 -0
- executorch/backends/xnnpack/test/models/torchvision_vit.py +105 -0
- executorch/backends/xnnpack/test/models/very_big_model.py +45 -0
- executorch/backends/xnnpack/test/models/w2l.py +60 -0
- executorch/backends/xnnpack/test/ops/test_abs.py +87 -0
- executorch/backends/xnnpack/test/ops/test_add.py +266 -0
- executorch/backends/xnnpack/test/ops/test_avgpool2d.py +92 -0
- executorch/backends/xnnpack/test/ops/test_bilinear2d.py +152 -0
- executorch/backends/xnnpack/test/ops/test_bmm.py +49 -0
- executorch/backends/xnnpack/test/ops/test_cat.py +254 -0
- executorch/backends/xnnpack/test/ops/test_ceil.py +63 -0
- executorch/backends/xnnpack/test/ops/test_check_quant_params.py +107 -0
- executorch/backends/xnnpack/test/ops/test_clamp.py +79 -0
- executorch/backends/xnnpack/test/ops/test_clone.py +137 -0
- executorch/backends/xnnpack/test/ops/test_conv1d.py +190 -0
- executorch/backends/xnnpack/test/ops/test_conv2d.py +747 -0
- executorch/backends/xnnpack/test/ops/test_cos.py +87 -0
- executorch/backends/xnnpack/test/ops/test_div.py +78 -0
- executorch/backends/xnnpack/test/ops/test_elu.py +98 -0
- executorch/backends/xnnpack/test/ops/test_exp.py +70 -0
- executorch/backends/xnnpack/test/ops/test_floor.py +58 -0
- executorch/backends/xnnpack/test/ops/test_gelu.py +71 -0
- executorch/backends/xnnpack/test/ops/test_hardswish.py +70 -0
- executorch/backends/xnnpack/test/ops/test_hardtanh.py +83 -0
- executorch/backends/xnnpack/test/ops/test_leaky_relu.py +131 -0
- executorch/backends/xnnpack/test/ops/test_linear.py +1059 -0
- executorch/backends/xnnpack/test/ops/test_log.py +45 -0
- executorch/backends/xnnpack/test/ops/test_lstm.py +67 -0
- executorch/backends/xnnpack/test/ops/test_max_dim.py +66 -0
- executorch/backends/xnnpack/test/ops/test_maximum.py +66 -0
- executorch/backends/xnnpack/test/ops/test_maxpool2d.py +221 -0
- executorch/backends/xnnpack/test/ops/test_mean_dim.py +98 -0
- executorch/backends/xnnpack/test/ops/test_minimum.py +49 -0
- executorch/backends/xnnpack/test/ops/test_multiply.py +149 -0
- executorch/backends/xnnpack/test/ops/test_negate.py +58 -0
- executorch/backends/xnnpack/test/ops/test_permute.py +134 -0
- executorch/backends/xnnpack/test/ops/test_pow.py +62 -0
- executorch/backends/xnnpack/test/ops/test_prelu.py +50 -0
- executorch/backends/xnnpack/test/ops/test_quantize_per_tensor.py +70 -0
- executorch/backends/xnnpack/test/ops/test_relu.py +38 -0
- executorch/backends/xnnpack/test/ops/test_rsqrt.py +45 -0
- executorch/backends/xnnpack/test/ops/test_sigmoid.py +45 -0
- executorch/backends/xnnpack/test/ops/test_sin.py +87 -0
- executorch/backends/xnnpack/test/ops/test_slice_copy.py +170 -0
- executorch/backends/xnnpack/test/ops/test_softmax.py +73 -0
- executorch/backends/xnnpack/test/ops/test_sqrt.py +45 -0
- executorch/backends/xnnpack/test/ops/test_square.py +48 -0
- executorch/backends/xnnpack/test/ops/test_static_constant_pad.py +294 -0
- executorch/backends/xnnpack/test/ops/test_sub.py +178 -0
- executorch/backends/xnnpack/test/ops/test_tanh.py +43 -0
- executorch/backends/xnnpack/test/ops/test_to_copy.py +113 -0
- executorch/backends/xnnpack/test/passes/__init__.py +0 -0
- executorch/backends/xnnpack/test/passes/test_activation_fusion.py +232 -0
- executorch/backends/xnnpack/test/passes/test_batch_norm_fusion.py +179 -0
- executorch/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py +635 -0
- executorch/backends/xnnpack/test/passes/test_convert_to_linear.py +43 -0
- executorch/backends/xnnpack/test/passes/test_decompose_cat_pass.py +112 -0
- executorch/backends/xnnpack/test/passes/test_propagate_custom_meta_pass.py +185 -0
- executorch/backends/xnnpack/test/passes/test_remove_get_item_pass.py +99 -0
- executorch/backends/xnnpack/test/passes/test_remove_redundant_copy_pass.py +182 -0
- executorch/backends/xnnpack/test/quantizer/test_pt2e_quantization.py +818 -0
- executorch/backends/xnnpack/test/quantizer/test_representation.py +308 -0
- executorch/backends/xnnpack/test/quantizer/test_xnnpack_quantizer.py +1217 -0
- executorch/backends/xnnpack/test/recipes/test_xnnpack_recipes.py +320 -0
- executorch/backends/xnnpack/test/serialization/test_serialization.py +50 -0
- executorch/backends/xnnpack/test/serialization/test_xnnheader.py +104 -0
- executorch/backends/xnnpack/test/test_xnnpack_partitioner.py +163 -0
- executorch/backends/xnnpack/test/test_xnnpack_utils.py +532 -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 +130 -0
- executorch/backends/xnnpack/third-party/FP16/configure.py +65 -0
- executorch/backends/xnnpack/third-party/FP16/confu.yaml +8 -0
- executorch/backends/xnnpack/third-party/FP16/include/fp16/__init__.py +0 -0
- executorch/backends/xnnpack/third-party/FP16/include/fp16/avx.py +50 -0
- executorch/backends/xnnpack/third-party/FP16/include/fp16/avx2.py +53 -0
- executorch/backends/xnnpack/third-party/FP16/test/peachpy/stubs.py +38 -0
- executorch/backends/xnnpack/third-party/FXdiv/configure.py +30 -0
- executorch/backends/xnnpack/third-party/FXdiv/confu.yaml +6 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/aarch32_template.py +361 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/aarch64_template.py +347 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/arm_template.py +78 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512bf16_template.py +81 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512f_template.py +390 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512vnni_template.py +703 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/base_architecture.py +276 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/fma3_template.py +260 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate.py +71 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_bf16_f32_gemm_microkernels.py +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_f32_gemm_microkernels.py +104 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_gemm_microkernels_main.py +29 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qd8_f32_qc4w_gemm_microkernels.py +69 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qd8_f32_qc8w_gemm_microkernels.py +93 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qs8_qc4w_gemm_microkernels.py +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qs8_qc8w_gemm_microkernels.py +43 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neondot_template.py +463 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neonfma_template.py +248 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neonmlal_aarch32_template.py +394 -0
- executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/x64_template.py +512 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/check_config.py +152 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/check_files_changed.py +53 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/generate-build-identifier.py +106 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/sort-filenames.py +134 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-f32-gemm-minmax.yaml +121 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-gemm-minmax.yaml +106 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-conv-hwc2chw.yaml +8 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv2d-chw.yaml +88 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-gemm-minmax.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-igemm-minmax.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-minmax.yaml +219 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear-chw.yaml +9 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-igemm-minmax.yaml +165 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-raddstoreexpminusmax.yaml +52 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-argmaxpool.yaml +15 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc2chw.yaml +32 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv2d-chw.yaml +712 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-minmax.yaml +1572 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-relu.yaml +123 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm.yaml +127 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear-chw.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear.yaml +23 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-minmax.yaml +1001 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-relu.yaml +123 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm.yaml +123 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ppmm-minmax.yaml +122 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc4w-gemm-minmax.yaml +277 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-minmax.yaml +757 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-relu.yaml +67 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm.yaml +115 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddexpminusmax.yaml +38 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddstoreexpminusmax.yaml +88 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/pf16-gemm-minmax.yaml +20 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/pf32-gemm-minmax.yaml +34 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/pqs8-qc8w-gemm-minmax.yaml +20 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qb4w-gemm-minmax.yaml +260 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc4w-gemm-minmax.yaml +678 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-gemm-minmax.yaml +412 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-igemm-minmax.yaml +360 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qb4w-gemm-minmax.yaml +537 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc4w-gemm-minmax.yaml +2176 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-gemm-minmax.yaml +1564 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-igemm-minmax.yaml +1035 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qb4w-gemm-minmax.yaml +54 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qc4w-gemm-minmax.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qc8w-gemm-minmax.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc4w-gemm-minmax-fp32.yaml +345 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-minmax-fp32.yaml +2029 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-minmax-fp32.yaml +1831 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-fp32.yaml +584 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-rndnu.yaml +148 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-fp32.yaml +581 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-rndnu.yaml +110 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s8-ibilinear.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-ibilinear.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x8-lut.yaml +47 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-argmaxpool-test.py +692 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc-test.py +543 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc2chw-test.py +591 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-test.py +339 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv2d-chw-test.py +463 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gemm-test.py +1150 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-chw-test.py +236 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-test.py +237 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-test.py +164 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddexpminusmax-test.py +159 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddstoreexpminusmax-test.py +210 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-discontiguous-test.py +495 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-test.py +289 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-spmm-test.py +554 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vbinary-test.py +179 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-test.py +280 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/parse-microkernel-bench.py +189 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/primes.py +1015 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/update-microkernels.py +567 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/xngen.py +159 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/xnncommon.py +275 -0
- executorch/backends/xnnpack/third-party/cpuinfo/configure.py +110 -0
- executorch/backends/xnnpack/third-party/cpuinfo/confu.yaml +9 -0
- executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/configure.py +26 -0
- executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/confu.yaml +5 -0
- executorch/backends/xnnpack/third-party/cpuinfo/scripts/android-device-dump.py +400 -0
- executorch/backends/xnnpack/third-party/cpuinfo/scripts/arm-linux-filesystem-dump.py +107 -0
- executorch/backends/xnnpack/third-party/cpuinfo/scripts/parse-x86-cpuid-dump.py +47 -0
- executorch/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py +93 -0
- executorch/backends/xnnpack/third-party/pthreadpool/configure.py +38 -0
- executorch/backends/xnnpack/third-party/pthreadpool/confu.yaml +8 -0
- executorch/backends/xnnpack/utils/configs.py +49 -0
- executorch/backends/xnnpack/utils/quant_utils.py +301 -0
- executorch/backends/xnnpack/utils/utils.py +221 -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 +368 -0
- executorch/codegen/api/types/__init__.py +5 -0
- executorch/codegen/api/types/signatures.py +77 -0
- executorch/codegen/api/types/types.py +77 -0
- executorch/codegen/api/unboxing.py +232 -0
- executorch/codegen/gen.py +1049 -0
- executorch/codegen/model.py +220 -0
- executorch/codegen/parse.py +158 -0
- executorch/codegen/test/test_executorch_custom_ops.py +153 -0
- executorch/codegen/test/test_executorch_gen.py +698 -0
- executorch/codegen/test/test_executorch_signatures.py +65 -0
- executorch/codegen/test/test_executorch_types.py +121 -0
- executorch/codegen/test/test_executorch_unboxing.py +165 -0
- executorch/codegen/test/test_selective_build.py +51 -0
- executorch/codegen/tools/__init__.py +0 -0
- executorch/codegen/tools/combine_prim_ops_headers.py +164 -0
- executorch/codegen/tools/gen_all_oplist.py +252 -0
- executorch/codegen/tools/gen_oplist.py +369 -0
- executorch/codegen/tools/gen_ops_def.py +96 -0
- executorch/codegen/tools/gen_selected_op_variants.py +133 -0
- executorch/codegen/tools/gen_selected_prim_ops.py +96 -0
- executorch/codegen/tools/merge_yaml.py +125 -0
- executorch/codegen/tools/selective_build.cp313-win_amd64.pyd +0 -0
- executorch/codegen/tools/selective_build.pyi +23 -0
- executorch/codegen/tools/test/test_gen_all_oplist.py +122 -0
- executorch/codegen/tools/test/test_gen_oplist.py +263 -0
- executorch/codegen/tools/test/test_gen_oplist_real_model.py +50 -0
- executorch/codegen/tools/test/test_gen_selected_op_variants.py +204 -0
- executorch/codegen/tools/test/test_tools_selective_build.py +129 -0
- executorch/codegen/tools/yaml_util.py +15 -0
- executorch/data/bin/__init__.py +44 -0
- executorch/data/bin/flatc.exe +0 -0
- executorch/data/lib/aoti_cuda_shims.lib +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/backend_debug/tests/test_delegation_info.py +79 -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/schema/test/test_schema.py +27 -0
- executorch/devtools/bundled_program/serialize/__init__.py +122 -0
- executorch/devtools/bundled_program/serialize/bundled_program_schema.fbs +97 -0
- executorch/devtools/bundled_program/serialize/scalar_type.fbs +43 -0
- executorch/devtools/bundled_program/serialize/test/test_serialize.py +37 -0
- executorch/devtools/bundled_program/test/test_bundle_data.py +168 -0
- executorch/devtools/bundled_program/test/test_config.py +131 -0
- executorch/devtools/bundled_program/test/test_end2end.py +64 -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 +108 -0
- executorch/devtools/etdump/tests/serialize_test.py +142 -0
- executorch/devtools/etrecord/__init__.py +13 -0
- executorch/devtools/etrecord/_etrecord.py +776 -0
- executorch/devtools/etrecord/tests/etrecord_test.py +1748 -0
- executorch/devtools/inspector/__init__.py +24 -0
- executorch/devtools/inspector/_inspector.py +1495 -0
- executorch/devtools/inspector/_inspector_utils.py +1286 -0
- executorch/devtools/inspector/_intermediate_output_capturer.py +62 -0
- executorch/devtools/inspector/inspector_cli.py +76 -0
- executorch/devtools/inspector/numerical_comparator/__init__.py +25 -0
- executorch/devtools/inspector/numerical_comparator/l1_numerical_comparator.py +27 -0
- executorch/devtools/inspector/numerical_comparator/mse_numerical_comparator.py +29 -0
- executorch/devtools/inspector/numerical_comparator/numerical_comparator_base.py +26 -0
- executorch/devtools/inspector/numerical_comparator/snr_numerical_comparator.py +39 -0
- executorch/devtools/inspector/tests/event_blocks_test.py +657 -0
- executorch/devtools/inspector/tests/inspector_test.py +1263 -0
- executorch/devtools/inspector/tests/inspector_test_utils.py +189 -0
- executorch/devtools/inspector/tests/inspector_utils_test.py +896 -0
- executorch/devtools/inspector/tests/intermediate_output_capturer_test.py +101 -0
- executorch/devtools/inspector/tests/l1_comparator_test.py +49 -0
- executorch/devtools/inspector/tests/mse_comparator_test.py +49 -0
- executorch/devtools/inspector/tests/snr_comparator_test.py +52 -0
- executorch/devtools/scripts/generate_profiling_csv.py +62 -0
- executorch/devtools/size_analysis_tool/size_analysis_tool.py +180 -0
- executorch/devtools/size_analysis_tool/size_analysis_tool_test.py +101 -0
- executorch/devtools/visualization/__init__.py +13 -0
- executorch/devtools/visualization/visualization_utils.py +301 -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 +504 -0
- executorch/examples/apple/coreml/llama/llama_transformer.py +958 -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/test.py +48 -0
- executorch/examples/apple/coreml/llama/utils.py +116 -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 +77 -0
- executorch/examples/apple/coreml/scripts/inspector_cli.py +64 -0
- executorch/examples/apple/coreml/scripts/inspector_utils.py +425 -0
- executorch/examples/apple/mps/scripts/bench_utils.py +108 -0
- executorch/examples/apple/mps/scripts/mps_example.py +230 -0
- executorch/examples/cuda/scripts/__init__.py +0 -0
- executorch/examples/cuda/scripts/export.py +107 -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/models/__init__.py +98 -0
- executorch/examples/models/checkpoint.py +114 -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/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/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/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_xnnpack_fp32.yaml +12 -0
- executorch/examples/models/lfm2/config/lfm2_xnnpack_q8da4w.yaml +15 -0
- executorch/examples/models/lfm2/convert_weights.py +74 -0
- executorch/examples/models/lfm2/short_conv.py +112 -0
- executorch/examples/models/llama/__init__.py +11 -0
- executorch/examples/models/llama/attention.py +536 -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 +104 -0
- executorch/examples/models/llama/convert_weights.py +61 -0
- executorch/examples/models/llama/eval_llama.py +38 -0
- executorch/examples/models/llama/eval_llama_lib.py +395 -0
- executorch/examples/models/llama/evaluate/__init__.py +11 -0
- executorch/examples/models/llama/evaluate/eager_eval.py +87 -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 +1560 -0
- executorch/examples/models/llama/fairseq2.py +63 -0
- executorch/examples/models/llama/feed_forward.py +68 -0
- executorch/examples/models/llama/hf_download.py +50 -0
- executorch/examples/models/llama/install_requirement_helper.py +29 -0
- executorch/examples/models/llama/llama_transformer.py +289 -0
- executorch/examples/models/llama/lora.py +48 -0
- executorch/examples/models/llama/model.py +378 -0
- executorch/examples/models/llama/model_args.py +173 -0
- executorch/examples/models/llama/norm.py +55 -0
- executorch/examples/models/llama/rope.py +327 -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 +312 -0
- executorch/examples/models/llama/source_transformation/custom_kv_cache.py +598 -0
- executorch/examples/models/llama/source_transformation/lora.py +153 -0
- executorch/examples/models/llama/source_transformation/pre_quantization.py +204 -0
- executorch/examples/models/llama/source_transformation/prune_vocab.py +119 -0
- executorch/examples/models/llama/source_transformation/quantize.py +910 -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 +550 -0
- executorch/examples/models/llama/source_transformation/spin_quant.py +88 -0
- executorch/examples/models/llama/source_transformation/test_attention_sink.py +514 -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 +97 -0
- executorch/examples/models/llama/static_attention.py +1257 -0
- executorch/examples/models/llama/tests/test_export_llama_lib.py +50 -0
- executorch/examples/models/llama/tests/test_pre_quantization_transforms.py +188 -0
- executorch/examples/models/llama/tests/test_replace_kv_cache.py +158 -0
- executorch/examples/models/llama/tests/test_ring_attention.py +359 -0
- executorch/examples/models/llama/tests/test_ring_kv_cache.py +492 -0
- executorch/examples/models/llama/tests/test_simple_sdpa.py +66 -0
- executorch/examples/models/llama/tests/test_static_attention.py +363 -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/text_decoder/test/__init__.py +0 -0
- executorch/examples/models/llama3_2_vision/text_decoder/test/test_text_decoder.py +89 -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/llama3_2_vision/vision_encoder/test/test_vision_encoder.py +46 -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 +106 -0
- executorch/examples/models/lstm/__init__.py +12 -0
- executorch/examples/models/lstm/model.py +31 -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 +73 -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/parakeet/export_parakeet_tdt.py +591 -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 +151 -0
- executorch/examples/models/qwen2_5/__init__.py +16 -0
- executorch/examples/models/qwen2_5/config/qwen2_5_xnnpack_q8da4w.yaml +14 -0
- executorch/examples/models/qwen2_5/convert_weights.py +90 -0
- executorch/examples/models/qwen3/__init__.py +16 -0
- executorch/examples/models/qwen3/config/qwen3_xnnpack.yaml +18 -0
- executorch/examples/models/qwen3/config/qwen3_xnnpack_q8da4w.yaml +20 -0
- executorch/examples/models/qwen3/convert_weights.py +140 -0
- executorch/examples/models/resnet/__init__.py +12 -0
- executorch/examples/models/resnet/model.py +48 -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/stable_diffusion/__init__.py +9 -0
- executorch/examples/models/stable_diffusion/model.py +193 -0
- executorch/examples/models/test/__init__.py +0 -0
- executorch/examples/models/test/test_export.py +161 -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/wav2letter/__init__.py +11 -0
- executorch/examples/models/wav2letter/model.py +29 -0
- executorch/examples/models/yolo12/export_and_validate.py +397 -0
- executorch/examples/nxp/experimental/cifar_net/cifar_net.py +270 -0
- executorch/examples/xnnpack/__init__.py +51 -0
- executorch/examples/xnnpack/aot_compiler.py +148 -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/_serialize/__init__.py +20 -0
- executorch/exir/_serialize/_cord.py +49 -0
- executorch/exir/_serialize/_dataclass.py +145 -0
- executorch/exir/_serialize/_flatbuffer.py +357 -0
- executorch/exir/_serialize/_named_data_store.py +222 -0
- executorch/exir/_serialize/_program.py +767 -0
- executorch/exir/_serialize/_serialize.py +123 -0
- executorch/exir/_serialize/data_serializer.py +80 -0
- executorch/exir/_serialize/padding.py +39 -0
- executorch/exir/_serialize/program.fbs +489 -0
- executorch/exir/_serialize/scalar_type.fbs +43 -0
- executorch/exir/_serialize/test/__init__.py +0 -0
- executorch/exir/_serialize/test/test_cord.py +63 -0
- executorch/exir/_serialize/test/test_flatbuffer.py +331 -0
- executorch/exir/_serialize/test/test_named_data_store.py +212 -0
- executorch/exir/_serialize/test/test_program.py +1265 -0
- executorch/exir/_serialize/test/test_serialize.py +289 -0
- executorch/exir/_warnings.py +44 -0
- executorch/exir/backend/backend_api.py +794 -0
- executorch/exir/backend/backend_details.py +150 -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 +156 -0
- executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
- executorch/exir/backend/canonical_partitioners/group_partitioner.py +371 -0
- executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +185 -0
- executorch/exir/backend/compile_spec_schema.py +17 -0
- executorch/exir/backend/operator_support.py +127 -0
- executorch/exir/backend/partitioner.py +114 -0
- executorch/exir/backend/test/backend_with_compiler_demo.py +142 -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/demos/rpc/test_rpc.py +189 -0
- executorch/exir/backend/test/demos/test_delegate_aten_mode.py +72 -0
- executorch/exir/backend/test/hta_partitioner_demo.py +288 -0
- executorch/exir/backend/test/op_partitioner_demo.py +266 -0
- executorch/exir/backend/test/test_backend_with_named_data_map.py +85 -0
- executorch/exir/backend/test/test_backends.py +1463 -0
- executorch/exir/backend/test/test_backends_lifted.py +1326 -0
- executorch/exir/backend/test/test_backends_nested.py +258 -0
- executorch/exir/backend/test/test_compatibility.py +118 -0
- executorch/exir/backend/test/test_debug_handle_map.py +143 -0
- executorch/exir/backend/test/test_delegate_map_builder.py +257 -0
- executorch/exir/backend/test/test_graph_partition.py +248 -0
- executorch/exir/backend/test/test_group_partitioner.py +1674 -0
- executorch/exir/backend/test/test_lowered_backend_module.py +207 -0
- executorch/exir/backend/test/test_partitioner.py +731 -0
- executorch/exir/backend/test/test_passes.py +48 -0
- executorch/exir/backend/test/test_to_backend_multi_method.py +595 -0
- executorch/exir/backend/test/test_utils.py +264 -0
- executorch/exir/backend/utils.py +661 -0
- executorch/exir/capture/__init__.py +28 -0
- executorch/exir/capture/_capture.py +381 -0
- executorch/exir/capture/_config.py +119 -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/backend/test/test_backend_ops.py +88 -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 +47 -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/op/test/test_api.py +51 -0
- executorch/exir/dialects/edge/spec/gen.py +523 -0
- executorch/exir/dialects/edge/spec/utils.py +328 -0
- executorch/exir/dialects/edge/test/test_edge_ops.py +443 -0
- executorch/exir/dialects/edge/test/test_edge_yaml.py +225 -0
- executorch/exir/dialects/test/test_exir_dialect_ops.py +22 -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 +2071 -0
- executorch/exir/emit/test/test_emit.py +2405 -0
- executorch/exir/error.py +55 -0
- executorch/exir/graph.py +86 -0
- executorch/exir/graph_module.py +153 -0
- executorch/exir/lowered_backend_module.py +966 -0
- executorch/exir/memory.py +50 -0
- executorch/exir/memory_planning.py +1250 -0
- executorch/exir/operator/convert.py +307 -0
- executorch/exir/operator/manip.py +89 -0
- executorch/exir/operator/test/test_operator.py +84 -0
- executorch/exir/operator/util.py +68 -0
- executorch/exir/pass_base.py +808 -0
- executorch/exir/pass_manager.py +78 -0
- executorch/exir/passes/__init__.py +528 -0
- executorch/exir/passes/_quant_patterns_and_replacements.py +1563 -0
- executorch/exir/passes/const_prop_pass.py +84 -0
- executorch/exir/passes/constant_prop_pass.py +402 -0
- executorch/exir/passes/debug_handle_generator_pass.py +81 -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 +166 -0
- executorch/exir/passes/external_constants_pass.py +113 -0
- executorch/exir/passes/init_mutable_pass.py +32 -0
- executorch/exir/passes/insert_write_back_for_buffers_pass.py +185 -0
- executorch/exir/passes/memory_format_ops_pass.py +119 -0
- executorch/exir/passes/memory_planning_pass.py +315 -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/prune_empty_tensors_pass.py +67 -0
- executorch/exir/passes/quant_fusion_pass.py +174 -0
- executorch/exir/passes/quantize_io_pass.py +414 -0
- executorch/exir/passes/reinplace.py +103 -0
- executorch/exir/passes/remove_graph_asserts_pass.py +62 -0
- executorch/exir/passes/remove_mixed_type_operators.py +95 -0
- executorch/exir/passes/remove_noop_pass.py +123 -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 +325 -0
- executorch/exir/passes/scalar_to_tensor_pass.py +32 -0
- executorch/exir/passes/spec_prop_pass.py +123 -0
- executorch/exir/passes/sym_shape_eval_pass.py +289 -0
- executorch/exir/passes/sym_to_tensor_pass.py +64 -0
- executorch/exir/passes/weights_to_outputs_pass.py +88 -0
- executorch/exir/print_program.py +420 -0
- executorch/exir/program/__init__.py +32 -0
- executorch/exir/program/_fake_program.py +67 -0
- executorch/exir/program/_program.py +1995 -0
- executorch/exir/program/test/__init__.py +0 -0
- executorch/exir/program/test/test_fake_program.py +78 -0
- executorch/exir/program/test/test_program.py +922 -0
- executorch/exir/scalar_type.py +38 -0
- executorch/exir/schema.py +308 -0
- executorch/exir/serde/__init__.py +0 -0
- executorch/exir/serde/export_serialize.py +2872 -0
- executorch/exir/serde/schema.py +406 -0
- executorch/exir/serde/schema_check.py +293 -0
- executorch/exir/serde/serialize.py +838 -0
- executorch/exir/serde/union.py +77 -0
- executorch/exir/sym_util.py +95 -0
- executorch/exir/tensor.py +392 -0
- executorch/exir/tensor_layout.py +39 -0
- executorch/exir/tests/asr_joiner.py +82 -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_arg_validator.py +72 -0
- executorch/exir/tests/test_capture.py +29 -0
- executorch/exir/tests/test_common.py +81 -0
- executorch/exir/tests/test_delegate.py +308 -0
- executorch/exir/tests/test_dim_order_utils.py +49 -0
- executorch/exir/tests/test_dynamic_shape_propagation.py +174 -0
- executorch/exir/tests/test_error.py +19 -0
- executorch/exir/tests/test_extract_io_quant_params.py +93 -0
- executorch/exir/tests/test_joint_graph.py +124 -0
- executorch/exir/tests/test_memory_format_ops_pass.py +443 -0
- executorch/exir/tests/test_memory_format_ops_pass_aten.py +142 -0
- executorch/exir/tests/test_memory_format_ops_pass_utils.py +266 -0
- executorch/exir/tests/test_memory_planning.py +1135 -0
- executorch/exir/tests/test_op_convert.py +88 -0
- executorch/exir/tests/test_pass_infra.py +179 -0
- executorch/exir/tests/test_passes.py +2332 -0
- executorch/exir/tests/test_print_program.py +54 -0
- executorch/exir/tests/test_prune_empty_tensors_pass.py +77 -0
- executorch/exir/tests/test_quant_fusion_pass.py +528 -0
- executorch/exir/tests/test_quantization.py +120 -0
- executorch/exir/tests/test_quantize_io_pass.py +156 -0
- executorch/exir/tests/test_reinplace_pass.py +124 -0
- executorch/exir/tests/test_remove_unused_parameters_pass.py +205 -0
- executorch/exir/tests/test_remove_view_copy.py +234 -0
- executorch/exir/tests/test_serde.py +352 -0
- executorch/exir/tests/test_tensor.py +341 -0
- executorch/exir/tests/test_tracer.py +497 -0
- executorch/exir/tests/test_verification.py +275 -0
- executorch/exir/tests/test_warnings.py +169 -0
- executorch/exir/tests/transformer.py +122 -0
- executorch/exir/tracer.py +803 -0
- executorch/exir/types.py +18 -0
- executorch/exir/verification/arg_validator.py +140 -0
- executorch/exir/verification/dev_html.py +68 -0
- executorch/exir/verification/interpreter.py +425 -0
- executorch/exir/verification/test/test_verifier.py +177 -0
- executorch/exir/verification/verifier.py +352 -0
- executorch/exir/version.py +9 -0
- executorch/exir/wrap.py +32 -0
- executorch/export/__init__.py +40 -0
- executorch/export/export.py +696 -0
- executorch/export/recipe.py +328 -0
- executorch/export/recipe_provider.py +60 -0
- executorch/export/recipe_registry.py +86 -0
- executorch/export/stages.py +686 -0
- executorch/export/target_recipes.py +185 -0
- executorch/export/tests/test_executorch_export.py +34 -0
- executorch/export/tests/test_export_recipe.py +131 -0
- executorch/export/tests/test_export_session.py +973 -0
- executorch/export/tests/test_export_stages.py +534 -0
- executorch/export/tests/test_recipe_provider.py +98 -0
- executorch/export/tests/test_recipe_registry.py +139 -0
- executorch/export/tests/test_target_recipes.py +539 -0
- executorch/export/types.py +22 -0
- executorch/export/utils.py +51 -0
- executorch/extension/audio/mel_spectrogram.py +279 -0
- executorch/extension/export_util/__init__.py +13 -0
- executorch/extension/export_util/utils.py +147 -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 +38 -0
- executorch/extension/flat_tensor/serialize/serialize.py +446 -0
- executorch/extension/flat_tensor/test/test_serialize.py +326 -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/llm/custom_ops/__init__.py +0 -0
- executorch/extension/llm/custom_ops/custom_ops.py +495 -0
- executorch/extension/llm/custom_ops/custom_ops_aot_lib.dll +0 -0
- executorch/extension/llm/custom_ops/model_sharding.py +117 -0
- executorch/extension/llm/custom_ops/op_tile_crop_aot.py +38 -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/spinquant/third-party/FFHT/example.py +20 -0
- executorch/extension/llm/custom_ops/spinquant/third-party/FFHT/gen.py +869 -0
- executorch/extension/llm/custom_ops/test_preprocess_custom_ops.py +34 -0
- executorch/extension/llm/custom_ops/test_quantized_sdpa.py +550 -0
- executorch/extension/llm/custom_ops/test_sdpa_with_kv_cache.py +651 -0
- executorch/extension/llm/custom_ops/test_update_cache.py +433 -0
- executorch/extension/llm/custom_ops/test_update_cross_attn_cache.py +284 -0
- executorch/extension/llm/export/__init__.py +11 -0
- executorch/extension/llm/export/builder.py +535 -0
- executorch/extension/llm/export/config/llm_config.py +727 -0
- executorch/extension/llm/export/export_llm.py +106 -0
- executorch/extension/llm/export/export_passes.py +202 -0
- executorch/extension/llm/export/partitioner_lib.py +238 -0
- executorch/extension/llm/export/quantizer_lib.py +322 -0
- executorch/extension/llm/export/test/__init__.py +0 -0
- executorch/extension/llm/export/test/test_builder.py +118 -0
- executorch/extension/llm/export/test/test_export_llm.py +155 -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 +415 -0
- executorch/extension/llm/modules/kv_cache.py +151 -0
- executorch/extension/llm/modules/test/__init__.py +0 -0
- executorch/extension/llm/modules/test/test_attention.py +353 -0
- executorch/extension/llm/modules/test/test_kv_cache.py +218 -0
- executorch/extension/llm/modules/test/test_position_embeddings.py +230 -0
- executorch/extension/llm/runner/__init__.py +235 -0
- executorch/extension/llm/runner/_llm_runner.pyi +523 -0
- executorch/extension/llm/runner/test/test_runner_pybindings.py +258 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/__init__.py +63 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/constants.py +31 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/hf_tokenizer.py +57 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/llama2c.py +111 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/tiktoken.py +198 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/__init__.py +0 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/llama2c/__init__.py +0 -0
- executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/llama2c/convert.py +49 -0
- executorch/extension/llm/tokenizers/setup.py +199 -0
- executorch/extension/llm/tokenizers/test/test_hf_tokenizer.py +83 -0
- executorch/extension/llm/tokenizers/test/test_python_bindings.py +131 -0
- executorch/extension/llm/tokenizers/test/test_tekken_python.py +453 -0
- executorch/extension/llm/tokenizers/test/test_tiktoken.py +49 -0
- executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/abseil.podspec.gen.py +243 -0
- executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/copts/copts.py +194 -0
- executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/copts/generate_copts.py +109 -0
- executorch/extension/llm/tokenizers/third-party/abseil-cpp/conanfile.py +51 -0
- executorch/extension/llm/tokenizers/third-party/abseil-cpp/create_lts.py +139 -0
- executorch/extension/llm/tokenizers/third-party/json/docs/mkdocs/scripts/check_structure.py +179 -0
- executorch/extension/llm/tokenizers/third-party/json/tests/thirdparty/imapdl/filterbr.py +109 -0
- executorch/extension/llm/tokenizers/third-party/json/tools/amalgamate/amalgamate.py +299 -0
- executorch/extension/llm/tokenizers/third-party/json/tools/gdb_pretty_printer/nlohmann-json.py +32 -0
- executorch/extension/llm/tokenizers/third-party/json/tools/generate_natvis/generate_natvis.py +41 -0
- executorch/extension/llm/tokenizers/third-party/json/tools/serve_header/serve_header.py +410 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateCommon.py +354 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateTest.py +186 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcd.py +999 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcpHeader.py +98 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcpTables.py +203 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateCommon.py +31 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateDates.py +59 -0
- executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateRelease.py +29 -0
- executorch/extension/llm/tokenizers/third-party/re2/benchlog/benchplot.py +98 -0
- executorch/extension/llm/tokenizers/third-party/re2/python/re2.py +583 -0
- executorch/extension/llm/tokenizers/third-party/re2/python/re2_test.py +489 -0
- executorch/extension/llm/tokenizers/third-party/re2/python/setup.py +158 -0
- executorch/extension/llm/tokenizers/third-party/re2/python/toolchains/generate.py +98 -0
- executorch/extension/llm/tokenizers/third-party/re2/re2/make_unicode_casefold.py +151 -0
- executorch/extension/llm/tokenizers/third-party/re2/re2/make_unicode_groups.py +117 -0
- executorch/extension/llm/tokenizers/third-party/re2/re2/unicode.py +284 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/setup.py +215 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/__init__.py +1224 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/_version.py +1 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/sentencepiece_model_pb2.py +44 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/sentencepiece_pb2.py +30 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/test/__init__.py +0 -0
- executorch/extension/llm/tokenizers/third-party/sentencepiece/python/test/sentencepiece_test.py +937 -0
- executorch/extension/module/test/resources/gen_bundled_program.py +99 -0
- executorch/extension/pybindings/_portable_lib.cp313-win_amd64.pyd +0 -0
- executorch/extension/pybindings/portable_lib.py +82 -0
- executorch/extension/pybindings/pybindings.pyi +299 -0
- executorch/extension/pybindings/test/make_test.py +186 -0
- executorch/extension/pybindings/test/test_backend_pybinding.py +27 -0
- executorch/extension/pybindings/test/test_pybindings.py +735 -0
- executorch/extension/pytree/__init__.py +54 -0
- executorch/extension/pytree/test/test.py +331 -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 +74 -0
- executorch/extension/training/examples/XOR/model.py +34 -0
- executorch/extension/training/examples/XOR/test/test_export.py +19 -0
- executorch/extension/training/pybindings/_training_lib.pyi +45 -0
- executorch/extension/training/pybindings/_training_module.py +86 -0
- executorch/extension/training/pybindings/test/test.py +67 -0
- executorch/extension/wasm/test/test_model.py +34 -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/tensor/tensor.h +14 -0
- executorch/include/executorch/extension/tensor/tensor_accessor.h +218 -0
- executorch/include/executorch/extension/tensor/tensor_ptr.h +485 -0
- executorch/include/executorch/extension/tensor/tensor_ptr_maker.h +687 -0
- executorch/include/executorch/extension/threadpool/cpuinfo_utils.h +24 -0
- executorch/include/executorch/extension/threadpool/threadpool.h +124 -0
- executorch/include/executorch/extension/threadpool/threadpool_guard.h +37 -0
- executorch/include/executorch/runtime/core/array_ref.h +262 -0
- executorch/include/executorch/runtime/core/data_loader.h +141 -0
- executorch/include/executorch/runtime/core/defines.h +20 -0
- executorch/include/executorch/runtime/core/error.h +257 -0
- executorch/include/executorch/runtime/core/evalue.h +608 -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 +175 -0
- executorch/include/executorch/runtime/core/exec_aten/testing_util/tensor_factory.h +1133 -0
- executorch/include/executorch/runtime/core/exec_aten/testing_util/tensor_util.h +378 -0
- executorch/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +278 -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 +21 -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 +1415 -0
- executorch/include/executorch/runtime/core/freeable_buffer.h +218 -0
- executorch/include/executorch/runtime/core/function_ref.h +108 -0
- executorch/include/executorch/runtime/core/hierarchical_allocator.h +125 -0
- executorch/include/executorch/runtime/core/memory_allocator.h +233 -0
- executorch/include/executorch/runtime/core/named_data_map.h +77 -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 +299 -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 +78 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +406 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_utils.h +46 -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 +123 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +905 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +100 -0
- executorch/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +114 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +153 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +694 -0
- executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +480 -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 +148 -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 +616 -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/complex.h +21 -0
- executorch/include/executorch/runtime/core/portable_type/device.h +74 -0
- executorch/include/executorch/runtime/core/portable_type/half.h +27 -0
- executorch/include/executorch/runtime/core/portable_type/optional.h +36 -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 +29 -0
- executorch/include/executorch/runtime/core/portable_type/tensor.h +175 -0
- executorch/include/executorch/runtime/core/portable_type/tensor_impl.h +304 -0
- executorch/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
- executorch/include/executorch/runtime/core/result.h +268 -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/core/testing_util/error_matchers.h +303 -0
- executorch/include/executorch/runtime/kernel/kernel_includes.h +23 -0
- executorch/include/executorch/runtime/kernel/kernel_runtime_context.h +131 -0
- executorch/include/executorch/runtime/kernel/operator_registry.h +298 -0
- executorch/include/executorch/runtime/kernel/test/test_util.h +40 -0
- executorch/include/executorch/runtime/kernel/thread_parallel_interface.h +107 -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 +214 -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 +289 -0
- executorch/include/executorch/runtime/platform/runtime.h +35 -0
- executorch/include/executorch/runtime/platform/system.h +49 -0
- executorch/include/executorch/runtime/platform/test/pal_spy.h +86 -0
- executorch/include/executorch/runtime/platform/test/stub_platform.h +76 -0
- executorch/include/executorch/runtime/platform/types.h +24 -0
- executorch/kernels/quantized/__init__.py +21 -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/kernels/quantized/test/test_out_variants.py +100 -0
- executorch/kernels/quantized/test/test_quant_dequant_per_token.py +149 -0
- executorch/runtime/__init__.py +334 -0
- executorch/runtime/kernel/test/functions.yaml +13 -0
- executorch/runtime/test/test_runtime.py +106 -0
- executorch/runtime/test/test_runtime_etdump_gen.py +163 -0
- executorch/schema/program.fbs +489 -0
- executorch/schema/scalar_type.fbs +43 -0
- executorch/share/cmake/executorch-config.cmake +77 -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.1.0.dist-info/METADATA +87 -0
- executorch-1.1.0.dist-info/RECORD +2784 -0
- executorch-1.1.0.dist-info/WHEEL +5 -0
- executorch-1.1.0.dist-info/entry_points.txt +2 -0
- executorch-1.1.0.dist-info/licenses/LICENSE +37 -0
- executorch-1.1.0.dist-info/top_level.txt +7 -0
|
@@ -0,0 +1,2405 @@
|
|
|
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-unsafe
|
|
8
|
+
|
|
9
|
+
import typing
|
|
10
|
+
import unittest
|
|
11
|
+
from contextlib import contextmanager
|
|
12
|
+
from copy import deepcopy
|
|
13
|
+
from typing import List, Optional, Tuple
|
|
14
|
+
|
|
15
|
+
import executorch.exir as exir
|
|
16
|
+
|
|
17
|
+
import executorch.exir.schema as schema
|
|
18
|
+
import executorch.exir.tests.models as models
|
|
19
|
+
import pytest
|
|
20
|
+
import torch
|
|
21
|
+
from executorch.exir import (
|
|
22
|
+
EdgeCompileConfig,
|
|
23
|
+
ExecutorchBackendConfig,
|
|
24
|
+
ExecutorchProgramManager,
|
|
25
|
+
to_edge,
|
|
26
|
+
)
|
|
27
|
+
from executorch.exir._serialize._program import deserialize_pte_binary
|
|
28
|
+
from executorch.exir.backend.backend_api import to_backend
|
|
29
|
+
from executorch.exir.backend.backend_details import BackendDetails, PreprocessResult
|
|
30
|
+
from executorch.exir.backend.test.demos.rpc.executor_backend_partitioner import (
|
|
31
|
+
ExecutorBackendPartitioner,
|
|
32
|
+
)
|
|
33
|
+
from executorch.exir.dialects._ops import ops as exir_ops
|
|
34
|
+
from executorch.exir.emit import emit_program # noqa
|
|
35
|
+
from executorch.exir.error import InternalError
|
|
36
|
+
from executorch.exir.passes import MemoryPlanningPass
|
|
37
|
+
from executorch.exir.passes.constant_prop_pass import constant_prop_pass
|
|
38
|
+
from executorch.exir.passes.init_mutable_pass import InitializedMutableBufferPass
|
|
39
|
+
from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
|
|
40
|
+
from executorch.exir.print_program import pretty_print, print_program # noqa
|
|
41
|
+
from executorch.exir.schema import (
|
|
42
|
+
Bool,
|
|
43
|
+
DelegateCall,
|
|
44
|
+
Double,
|
|
45
|
+
EValue,
|
|
46
|
+
ExecutionPlan,
|
|
47
|
+
Int,
|
|
48
|
+
IntList,
|
|
49
|
+
JumpFalseCall,
|
|
50
|
+
KernelCall,
|
|
51
|
+
KernelTypes,
|
|
52
|
+
MoveCall,
|
|
53
|
+
Null,
|
|
54
|
+
OptionalTensorList,
|
|
55
|
+
Program,
|
|
56
|
+
String,
|
|
57
|
+
Tensor,
|
|
58
|
+
)
|
|
59
|
+
from executorch.exir.tests.common import register_additional_test_aten_ops
|
|
60
|
+
from executorch.exir.tests.models import Mul
|
|
61
|
+
from executorch.extension.pybindings.portable_lib import (
|
|
62
|
+
_load_for_executorch_from_buffer,
|
|
63
|
+
)
|
|
64
|
+
from executorch.runtime import Runtime
|
|
65
|
+
from torch import nn
|
|
66
|
+
|
|
67
|
+
from torch._higher_order_ops import cond as torch_cond, map as torch_map
|
|
68
|
+
|
|
69
|
+
from torch.export import Dim, export
|
|
70
|
+
from torch.export.experimental import _export_forward_backward
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class WrapperModule(torch.nn.Module):
|
|
74
|
+
def __init__(self, fn):
|
|
75
|
+
super().__init__()
|
|
76
|
+
self.fn = fn
|
|
77
|
+
|
|
78
|
+
def forward(self, *args, **kwargs):
|
|
79
|
+
return self.fn(*args, **kwargs)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@contextmanager
|
|
83
|
+
def patch_forward(obj: torch.nn.Module, new_method):
|
|
84
|
+
"""Helper method to make it easier to cleanly torch.export() a method on a
|
|
85
|
+
module that is not `forward`.
|
|
86
|
+
|
|
87
|
+
TODO(suo): upstream this to torch.export.wrapper.
|
|
88
|
+
"""
|
|
89
|
+
# Save the original method
|
|
90
|
+
original_method = obj.forward
|
|
91
|
+
|
|
92
|
+
# Patch the method
|
|
93
|
+
obj.forward = new_method.__get__(obj, obj.__class__)
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
yield
|
|
97
|
+
finally:
|
|
98
|
+
# Restore the original method
|
|
99
|
+
obj.forward = original_method
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class TestEmit(unittest.TestCase):
|
|
103
|
+
@classmethod
|
|
104
|
+
def setUpClass(cls) -> None:
|
|
105
|
+
register_additional_test_aten_ops()
|
|
106
|
+
|
|
107
|
+
def setUp(self) -> None:
|
|
108
|
+
self.compile_config = EdgeCompileConfig(_check_ir_validity=False)
|
|
109
|
+
|
|
110
|
+
def check_tensor_buffer_loc(
|
|
111
|
+
self,
|
|
112
|
+
value_index: int,
|
|
113
|
+
values: List[EValue],
|
|
114
|
+
exp_buffer_idx: int,
|
|
115
|
+
exp_mem_id: Optional[int],
|
|
116
|
+
exp_mem_offset: Optional[int],
|
|
117
|
+
) -> None:
|
|
118
|
+
value = typing.cast(schema.Tensor, values[value_index].val)
|
|
119
|
+
self.assertIsInstance(value, schema.Tensor)
|
|
120
|
+
|
|
121
|
+
self.assertEqual(value.data_buffer_idx, exp_buffer_idx)
|
|
122
|
+
|
|
123
|
+
if not value.allocation_info:
|
|
124
|
+
self.assertIsNone(exp_mem_id)
|
|
125
|
+
self.assertIsNone(exp_mem_offset)
|
|
126
|
+
else:
|
|
127
|
+
self.assertEqual(value.allocation_info.memory_id, exp_mem_id)
|
|
128
|
+
assert value.allocation_info
|
|
129
|
+
self.assertEqual(value.allocation_info.memory_offset, exp_mem_offset)
|
|
130
|
+
|
|
131
|
+
def count_node(self, graph_module: torch.fx.GraphModule, opname: str) -> int:
|
|
132
|
+
return [
|
|
133
|
+
node.target._overloadpacket._qualified_op_name
|
|
134
|
+
for node in graph_module.graph.nodes
|
|
135
|
+
if node.op == "call_function"
|
|
136
|
+
].count(opname)
|
|
137
|
+
|
|
138
|
+
def run_dce(self, graph_module: torch.fx.GraphModule) -> None:
|
|
139
|
+
for submodule in graph_module.modules():
|
|
140
|
+
self.assertIsInstance(submodule, torch.fx.GraphModule)
|
|
141
|
+
typing.cast(torch.fx.GraphModule, submodule).graph.eliminate_dead_code()
|
|
142
|
+
|
|
143
|
+
def check_value_types(self, values: List[EValue]) -> None:
|
|
144
|
+
for value in values:
|
|
145
|
+
self.assertTrue(type(value.val) in KernelTypes.__args__)
|
|
146
|
+
|
|
147
|
+
def count_move_instructions(self, program: Program) -> int:
|
|
148
|
+
instructions = program.execution_plan[0].chains[0].instructions
|
|
149
|
+
assert instructions is not None
|
|
150
|
+
res = 0
|
|
151
|
+
for instr in instructions:
|
|
152
|
+
if isinstance(instr.instr_args, MoveCall):
|
|
153
|
+
res += 1
|
|
154
|
+
return res
|
|
155
|
+
|
|
156
|
+
def test_basic_api(self) -> None:
|
|
157
|
+
class Foo(torch.nn.Module):
|
|
158
|
+
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
159
|
+
return x * y + x
|
|
160
|
+
|
|
161
|
+
f = Foo()
|
|
162
|
+
|
|
163
|
+
program = (
|
|
164
|
+
to_edge(export(f, (torch.ones(3, 2), torch.zeros(3, 2)), strict=True))
|
|
165
|
+
.to_executorch()
|
|
166
|
+
.executorch_program
|
|
167
|
+
)
|
|
168
|
+
exec_plan = program.execution_plan[0]
|
|
169
|
+
ops = exec_plan.operators
|
|
170
|
+
for op in ops:
|
|
171
|
+
self.assertEqual(op.overload, "out")
|
|
172
|
+
|
|
173
|
+
self.assertEqual(ops[0].name, "aten::mul")
|
|
174
|
+
self.assertEqual(ops[1].name, "aten::add")
|
|
175
|
+
|
|
176
|
+
self.assertEqual(len(exec_plan.inputs), 2)
|
|
177
|
+
self.assertEqual(len(exec_plan.outputs), 1)
|
|
178
|
+
|
|
179
|
+
self.assertEqual(exec_plan.inputs[0], 0)
|
|
180
|
+
self.assertEqual(exec_plan.outputs[0], 3)
|
|
181
|
+
|
|
182
|
+
def test_basic_end_to_end(self) -> None:
|
|
183
|
+
f = models.BasicSinMax()
|
|
184
|
+
program = (
|
|
185
|
+
to_edge(export(f, f.get_random_inputs(), strict=True))
|
|
186
|
+
.to_executorch()
|
|
187
|
+
.executorch_program
|
|
188
|
+
)
|
|
189
|
+
exec_plan = program.execution_plan[0]
|
|
190
|
+
ops = exec_plan.operators
|
|
191
|
+
for op in ops:
|
|
192
|
+
self.assertIn(op.overload, {"out", "unary_out"})
|
|
193
|
+
|
|
194
|
+
self.assertEqual(ops[0].name, "aten::sin")
|
|
195
|
+
|
|
196
|
+
self.assertEqual(len(exec_plan.inputs), 1)
|
|
197
|
+
self.assertEqual(len(exec_plan.outputs), 1)
|
|
198
|
+
|
|
199
|
+
self.assertEqual(exec_plan.inputs[0], 0)
|
|
200
|
+
self.assertEqual(exec_plan.outputs[0], 1)
|
|
201
|
+
|
|
202
|
+
@pytest.mark.skip(reason="Test not working on OSS")
|
|
203
|
+
def test_nested_return(self) -> None:
|
|
204
|
+
class Foo(torch.nn.Module):
|
|
205
|
+
def forward(
|
|
206
|
+
self, x: torch.Tensor
|
|
207
|
+
) -> Tuple[torch.Tensor, torch.Tensor, List[torch.Tensor]]:
|
|
208
|
+
return (
|
|
209
|
+
torch.tensor(1),
|
|
210
|
+
torch.tensor(2),
|
|
211
|
+
[torch.sin(x).max(), torch.cos(x).max()],
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
f = Foo()
|
|
215
|
+
|
|
216
|
+
x = (torch.randn(100),)
|
|
217
|
+
program = to_edge(export(f, x, strict=True)).to_executorch().executorch_program
|
|
218
|
+
exec_plan = program.execution_plan[0]
|
|
219
|
+
self.assertEqual(len(exec_plan.outputs), 4)
|
|
220
|
+
self.assertEqual(len(exec_plan.inputs), 1)
|
|
221
|
+
|
|
222
|
+
self.assertEqual(
|
|
223
|
+
program.execution_plan[0].container_meta_type.encoded_out_str,
|
|
224
|
+
"T3#1#1#2($,$,L2#1#1($,$))",
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
self.assertEqual(
|
|
228
|
+
program.execution_plan[0].container_meta_type.encoded_inp_str,
|
|
229
|
+
"T2#1#0(T1#1($),D0())",
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
def test_constant_output(self):
|
|
233
|
+
class M(torch.nn.Module):
|
|
234
|
+
def forward(self, x):
|
|
235
|
+
return [((1, 3, 1.2), True, [x + x, x * x], None)]
|
|
236
|
+
|
|
237
|
+
ep = torch.export.export(M(), (torch.ones(2, 3),), strict=True)
|
|
238
|
+
res = ep.module()(torch.ones(2, 3))
|
|
239
|
+
self.assertEqual(res[0][0], (1, 3, 1.2))
|
|
240
|
+
program = to_edge(ep).to_executorch().executorch_program
|
|
241
|
+
outputs = program.execution_plan[0].outputs
|
|
242
|
+
self.assertEqual(len(outputs), 7)
|
|
243
|
+
self.assertEqual(program.execution_plan[0].values[outputs[0]].val.int_val, 1)
|
|
244
|
+
self.assertEqual(program.execution_plan[0].values[outputs[1]].val.int_val, 3)
|
|
245
|
+
self.assertEqual(
|
|
246
|
+
program.execution_plan[0].values[outputs[2]].val.double_val, 1.2
|
|
247
|
+
)
|
|
248
|
+
self.assertEqual(
|
|
249
|
+
program.execution_plan[0].values[outputs[3]].val.bool_val, True
|
|
250
|
+
)
|
|
251
|
+
self.assertIsInstance(program.execution_plan[0].values[outputs[6]].val, Null)
|
|
252
|
+
|
|
253
|
+
def test_initialized_mutable_buffer(self):
|
|
254
|
+
"""Test that mutable buffers can hold meaningful initialized state."""
|
|
255
|
+
|
|
256
|
+
class TestModule(torch.nn.Module):
|
|
257
|
+
def __init__(self):
|
|
258
|
+
super().__init__()
|
|
259
|
+
# Mutable buffer with non-empty initial state.
|
|
260
|
+
self.register_buffer("cache_pos", torch.arange(0, 10))
|
|
261
|
+
|
|
262
|
+
def forward(self, x):
|
|
263
|
+
self.cache_pos.add_(1)
|
|
264
|
+
return self.cache_pos
|
|
265
|
+
|
|
266
|
+
m = TestModule()
|
|
267
|
+
example_inputs = (torch.ones(10),)
|
|
268
|
+
ep = torch.export.export(m, example_inputs, strict=True)
|
|
269
|
+
edge = to_edge(
|
|
270
|
+
ep,
|
|
271
|
+
compile_config=EdgeCompileConfig(
|
|
272
|
+
_check_ir_validity=False,
|
|
273
|
+
),
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
# Save a copy of the edge program since to_executorch is
|
|
277
|
+
# stateful to some degree.
|
|
278
|
+
edge_copy = deepcopy(edge)
|
|
279
|
+
et_config = ExecutorchBackendConfig(
|
|
280
|
+
passes=[InitializedMutableBufferPass(["cache_pos"])],
|
|
281
|
+
)
|
|
282
|
+
et_program_init_pass = edge.to_executorch(config=et_config)
|
|
283
|
+
et_program_regular = edge_copy.to_executorch()
|
|
284
|
+
|
|
285
|
+
runtime = Runtime.get()
|
|
286
|
+
program_init_pass = runtime.load_program(et_program_init_pass.buffer)
|
|
287
|
+
method_init_pass = program_init_pass.load_method("forward")
|
|
288
|
+
|
|
289
|
+
program_regular = runtime.load_program(et_program_regular.buffer)
|
|
290
|
+
method_regular = program_regular.load_method("forward")
|
|
291
|
+
|
|
292
|
+
# Test that the mutable buffer is initialized.
|
|
293
|
+
torch.allclose(
|
|
294
|
+
method_init_pass.execute((example_inputs))[0], torch.arange(1, 11)
|
|
295
|
+
)
|
|
296
|
+
# Test that the mutable buffer is uninitialized and starts with default zeros,
|
|
297
|
+
# we test equality with torch.ones because of the mutation += 1 in the model forward.
|
|
298
|
+
torch.allclose(
|
|
299
|
+
method_regular.execute((example_inputs))[0],
|
|
300
|
+
torch.ones(10, dtype=torch.int64),
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
def test_int_list_input(self):
|
|
304
|
+
class M(torch.nn.Module):
|
|
305
|
+
def forward(self, x, y, z):
|
|
306
|
+
return x + y, x + x, x + y + z
|
|
307
|
+
|
|
308
|
+
ep = torch.export.export(M(), (torch.ones(2, 3), 2, True), strict=True)
|
|
309
|
+
ep.module()(torch.ones(2, 3), 2, True)
|
|
310
|
+
program = to_edge(ep).to_executorch().executorch_program
|
|
311
|
+
inputs = program.execution_plan[0].inputs
|
|
312
|
+
self.assertEqual(len(inputs), 3)
|
|
313
|
+
self.assertEqual(program.execution_plan[0].values[inputs[1]].val.int_val, 2)
|
|
314
|
+
self.assertEqual(program.execution_plan[0].values[inputs[2]].val.bool_val, True)
|
|
315
|
+
|
|
316
|
+
def test_inplace_ops(self) -> None:
|
|
317
|
+
class Foo(torch.nn.Module):
|
|
318
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
319
|
+
y = torch.sin(x)
|
|
320
|
+
z = y.view(100)
|
|
321
|
+
torch.relu_(z)
|
|
322
|
+
return z.max()
|
|
323
|
+
|
|
324
|
+
f = Foo()
|
|
325
|
+
|
|
326
|
+
inputs = (torch.ones((10, 10)),)
|
|
327
|
+
edge = to_edge(export(f, inputs, strict=True))
|
|
328
|
+
|
|
329
|
+
removed_ops = ["aten::relu_", "aten::view"]
|
|
330
|
+
expected_ops = [
|
|
331
|
+
"aten::sin",
|
|
332
|
+
"aten::relu",
|
|
333
|
+
"aten::max",
|
|
334
|
+
]
|
|
335
|
+
|
|
336
|
+
def expected_view_ops(config):
|
|
337
|
+
if config.remove_view_copy:
|
|
338
|
+
return []
|
|
339
|
+
else:
|
|
340
|
+
return ["aten::view_copy"]
|
|
341
|
+
|
|
342
|
+
for opname in removed_ops:
|
|
343
|
+
self.assertEqual(
|
|
344
|
+
self.count_node(edge.exported_program().graph_module, opname), 0
|
|
345
|
+
)
|
|
346
|
+
for opname in expected_ops:
|
|
347
|
+
self.assertTrue(
|
|
348
|
+
self.count_node(edge.exported_program().graph_module, opname) >= 1
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
for remove_view_copy in [True, False]:
|
|
352
|
+
config = exir.ExecutorchBackendConfig(remove_view_copy=remove_view_copy)
|
|
353
|
+
edge_copy = deepcopy(edge)
|
|
354
|
+
program = edge_copy.to_executorch(config=config).executorch_program
|
|
355
|
+
for opname in removed_ops:
|
|
356
|
+
self.assertTrue(
|
|
357
|
+
all(op.name != opname for op in program.execution_plan[0].operators)
|
|
358
|
+
)
|
|
359
|
+
for opname in expected_ops + expected_view_ops(config):
|
|
360
|
+
self.assertTrue(
|
|
361
|
+
any(op.name == opname for op in program.execution_plan[0].operators)
|
|
362
|
+
)
|
|
363
|
+
self.assertTrue(
|
|
364
|
+
len(program.execution_plan[0].operators)
|
|
365
|
+
== len(expected_ops + expected_view_ops(config))
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
def test_operators_unique(self) -> None:
|
|
369
|
+
class OpRepeatedModule(torch.nn.Module):
|
|
370
|
+
def __init__(self) -> None:
|
|
371
|
+
super().__init__()
|
|
372
|
+
self.a = torch.ones(2, 2)
|
|
373
|
+
self.b = 2 * torch.ones(2, 2)
|
|
374
|
+
|
|
375
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
376
|
+
for _ in range(10):
|
|
377
|
+
z = self.a * x
|
|
378
|
+
y = z + self.b
|
|
379
|
+
return y
|
|
380
|
+
|
|
381
|
+
model = OpRepeatedModule()
|
|
382
|
+
|
|
383
|
+
inputs = (torch.ones(2, 2),)
|
|
384
|
+
|
|
385
|
+
program = (
|
|
386
|
+
to_edge(export(model, inputs, strict=True))
|
|
387
|
+
.to_executorch()
|
|
388
|
+
.executorch_program
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
self.assertEqual(len(program.execution_plan[0].operators), 2)
|
|
392
|
+
|
|
393
|
+
def test_list_type(self) -> None:
|
|
394
|
+
"""Tests that the types of lists are correctly found"""
|
|
395
|
+
|
|
396
|
+
class Foo(torch.nn.Module):
|
|
397
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
398
|
+
return torch.permute(x, (2, 0, 1))
|
|
399
|
+
|
|
400
|
+
f = Foo()
|
|
401
|
+
|
|
402
|
+
program = (
|
|
403
|
+
to_edge(export(f, (torch.randn(2, 3, 5),), strict=True))
|
|
404
|
+
.to_executorch()
|
|
405
|
+
.executorch_program
|
|
406
|
+
)
|
|
407
|
+
exir.print_program.pretty_print(program)
|
|
408
|
+
|
|
409
|
+
deboxed_int_list = []
|
|
410
|
+
for item in program.execution_plan[0].values[5].val.items:
|
|
411
|
+
deboxed_int_list.append(program.execution_plan[0].values[item].val.int_val)
|
|
412
|
+
|
|
413
|
+
self.assertEqual(IntList(deboxed_int_list), IntList([2, 0, 1]))
|
|
414
|
+
|
|
415
|
+
def test_kwargs1(self) -> None:
|
|
416
|
+
"""Tests that the kwargs are placed in the order specified by
|
|
417
|
+
native_functions.yaml
|
|
418
|
+
"""
|
|
419
|
+
|
|
420
|
+
class Foo(torch.nn.Module):
|
|
421
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
422
|
+
batch1 = torch.randn(10, 3, 4)
|
|
423
|
+
batch2 = torch.randn(10, 4, 5)
|
|
424
|
+
return torch.addbmm(x, batch1, batch2, alpha=2, beta=3)
|
|
425
|
+
|
|
426
|
+
f = Foo()
|
|
427
|
+
|
|
428
|
+
program = (
|
|
429
|
+
to_edge(export(f, (torch.randn(3, 5),), strict=True))
|
|
430
|
+
.to_executorch()
|
|
431
|
+
.executorch_program
|
|
432
|
+
)
|
|
433
|
+
# The value for beta should appear before alpha
|
|
434
|
+
self.assertEqual(program.execution_plan[0].values[12].val, Int(3))
|
|
435
|
+
self.assertEqual(program.execution_plan[0].values[13].val, Int(2))
|
|
436
|
+
|
|
437
|
+
def test_kwargs2(self) -> None:
|
|
438
|
+
"""Tests that the kwargs are placed in the order specified by
|
|
439
|
+
native_functions.yaml
|
|
440
|
+
"""
|
|
441
|
+
|
|
442
|
+
class Foo(torch.nn.Module):
|
|
443
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
444
|
+
values = torch.randn(3, 2)
|
|
445
|
+
return torch.searchsorted(x, values, side="right", right=True)
|
|
446
|
+
|
|
447
|
+
f = Foo()
|
|
448
|
+
|
|
449
|
+
x, _ = torch.sort(torch.randn(3, 4))
|
|
450
|
+
program = (
|
|
451
|
+
to_edge(export(f, (x,), strict=True)).to_executorch().executorch_program
|
|
452
|
+
)
|
|
453
|
+
# The value for right should appear before side
|
|
454
|
+
self.assertEqual(program.execution_plan[0].values[6].val, Bool(False))
|
|
455
|
+
self.assertEqual(program.execution_plan[0].values[7].val, Bool(True))
|
|
456
|
+
self.assertEqual(program.execution_plan[0].values[8].val, String("right"))
|
|
457
|
+
self.assertEqual(program.execution_plan[0].values[9].val, Null())
|
|
458
|
+
|
|
459
|
+
def _assertCallLength(self, program: Program, idx: int, expected_len: int) -> None:
|
|
460
|
+
instr_args = program.execution_plan[0].chains[0].instructions[idx].instr_args
|
|
461
|
+
|
|
462
|
+
if isinstance(instr_args, KernelCall) or isinstance(instr_args, DelegateCall):
|
|
463
|
+
self.assertEqual(len(instr_args.args), expected_len)
|
|
464
|
+
else:
|
|
465
|
+
self.assertTrue(False)
|
|
466
|
+
|
|
467
|
+
def test_out(self) -> None:
|
|
468
|
+
class Foo(torch.nn.Module):
|
|
469
|
+
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
470
|
+
z = y.clone()
|
|
471
|
+
return torch.mul(x, y, out=z)
|
|
472
|
+
|
|
473
|
+
f = Foo()
|
|
474
|
+
|
|
475
|
+
program = (
|
|
476
|
+
to_edge(export(f, (torch.ones(3), torch.ones(3)), strict=True))
|
|
477
|
+
.to_executorch()
|
|
478
|
+
.executorch_program
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
self.assertEqual(len(program.execution_plan[0].chains[0].instructions), 1)
|
|
482
|
+
self._assertCallLength(program, 0, 4)
|
|
483
|
+
|
|
484
|
+
def test_model_out(self) -> None:
|
|
485
|
+
class Module_out(torch.nn.Module):
|
|
486
|
+
def __init__(self) -> None:
|
|
487
|
+
super().__init__()
|
|
488
|
+
self.a = 3 * torch.ones(2, 2, dtype=torch.int32)
|
|
489
|
+
self.b = 2 * torch.ones(2, 2, dtype=torch.int32)
|
|
490
|
+
|
|
491
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
492
|
+
z = x.clone()
|
|
493
|
+
torch.mul(self.a, x, out=z)
|
|
494
|
+
y = x.clone()
|
|
495
|
+
torch.add(z, self.b, alpha=2, out=y)
|
|
496
|
+
return y
|
|
497
|
+
|
|
498
|
+
model_out = Module_out()
|
|
499
|
+
|
|
500
|
+
inputs = (torch.ones(2, 2, dtype=torch.int32),)
|
|
501
|
+
|
|
502
|
+
# Trace to FX Graph.
|
|
503
|
+
program = (
|
|
504
|
+
to_edge(export(model_out, inputs, strict=True))
|
|
505
|
+
.to_executorch()
|
|
506
|
+
.executorch_program
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
self.assertEqual(len(program.execution_plan[0].chains[0].instructions), 2)
|
|
510
|
+
self._assertCallLength(program, 0, 4)
|
|
511
|
+
self._assertCallLength(program, 1, 5)
|
|
512
|
+
|
|
513
|
+
def test_stacktrace(self) -> None:
|
|
514
|
+
def f(x: torch.Tensor) -> torch.Tensor:
|
|
515
|
+
return torch.mul(x, torch.randn(3, 2))
|
|
516
|
+
|
|
517
|
+
def g(x: torch.Tensor) -> torch.Tensor:
|
|
518
|
+
return torch.sin(f(x))
|
|
519
|
+
|
|
520
|
+
class Foo(torch.nn.Module):
|
|
521
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
522
|
+
return torch.add(g(x), torch.randn(3, 2))
|
|
523
|
+
|
|
524
|
+
h = Foo()
|
|
525
|
+
|
|
526
|
+
x = (torch.randn(3, 2),)
|
|
527
|
+
exec_prog = to_edge(export(h, x, strict=True)).to_executorch(
|
|
528
|
+
exir.ExecutorchBackendConfig(emit_stacktrace=True)
|
|
529
|
+
)
|
|
530
|
+
program = exec_prog.executorch_program
|
|
531
|
+
|
|
532
|
+
# Check the mul operator's stack trace contains f -> g -> h
|
|
533
|
+
self.assertTrue(
|
|
534
|
+
"return torch.mul(x, torch.randn(3, 2))"
|
|
535
|
+
in program.execution_plan[0].chains[0].stacktrace[1].items[-1].context
|
|
536
|
+
)
|
|
537
|
+
self.assertEqual(
|
|
538
|
+
program.execution_plan[0].chains[0].stacktrace[1].items[-1].name, "f"
|
|
539
|
+
)
|
|
540
|
+
self.assertEqual(
|
|
541
|
+
program.execution_plan[0].chains[0].stacktrace[1].items[-2].name, "g"
|
|
542
|
+
)
|
|
543
|
+
self.assertEqual(
|
|
544
|
+
program.execution_plan[0].chains[0].stacktrace[1].items[-3].name, "forward"
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
# Check the sin operator's stack trace contains g -> h
|
|
548
|
+
self.assertEqual(
|
|
549
|
+
program.execution_plan[0].chains[0].stacktrace[2].items[-1].name, "g"
|
|
550
|
+
)
|
|
551
|
+
self.assertEqual(
|
|
552
|
+
program.execution_plan[0].chains[0].stacktrace[2].items[-2].name, "forward"
|
|
553
|
+
)
|
|
554
|
+
|
|
555
|
+
def test_stacktrace_off(self) -> None:
|
|
556
|
+
class Foo(torch.nn.Module):
|
|
557
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
558
|
+
return torch.mul(x, torch.randn(3, 2))
|
|
559
|
+
|
|
560
|
+
f = Foo()
|
|
561
|
+
|
|
562
|
+
class Goo(torch.nn.Module):
|
|
563
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
564
|
+
return torch.sin(f(x))
|
|
565
|
+
|
|
566
|
+
g = Goo()
|
|
567
|
+
|
|
568
|
+
class Hoo(torch.nn.Module):
|
|
569
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
570
|
+
return torch.add(g(x), torch.randn(3, 2))
|
|
571
|
+
|
|
572
|
+
h = Hoo()
|
|
573
|
+
|
|
574
|
+
x = (torch.randn(3, 2),)
|
|
575
|
+
program = to_edge(export(h, x, strict=True)).to_executorch().executorch_program
|
|
576
|
+
|
|
577
|
+
# Check the stacktrace is None since we did not specify to get the stacktrace
|
|
578
|
+
self.assertTrue(program.execution_plan[0].chains[0].stacktrace is None)
|
|
579
|
+
|
|
580
|
+
def test_positional_argument_default_value(self) -> None:
|
|
581
|
+
class Foo(torch.nn.Module):
|
|
582
|
+
def forward(self, x: torch.Tensor, n: torch.Tensor) -> torch.Tensor:
|
|
583
|
+
z = torch.ones(6, 2)
|
|
584
|
+
return torch.ops.aten.cat.out((x, n), out=z)
|
|
585
|
+
|
|
586
|
+
f = Foo()
|
|
587
|
+
|
|
588
|
+
x = torch.randn(3, 2)
|
|
589
|
+
program = (
|
|
590
|
+
to_edge(export(f, (x, x), strict=True))
|
|
591
|
+
# .to_edge(self.compile_config) # TODO(larryliu): fix cat
|
|
592
|
+
.to_executorch().executorch_program
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
self.assertEqual(len(program.execution_plan[0].chains[0].instructions), 1)
|
|
596
|
+
self._assertCallLength(program, 0, 4)
|
|
597
|
+
|
|
598
|
+
@pytest.mark.skip(reason="Test not working on OSS")
|
|
599
|
+
def test_emit_multiple_out(self) -> None:
|
|
600
|
+
class Foo(torch.nn.Module):
|
|
601
|
+
def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
602
|
+
return torch.topk(x, 5)
|
|
603
|
+
|
|
604
|
+
f = Foo()
|
|
605
|
+
|
|
606
|
+
x = (torch.randn(10),)
|
|
607
|
+
program = to_edge(export(f, x, strict=True)).to_executorch().executorch_program
|
|
608
|
+
self._assertCallLength(program, 0, 8)
|
|
609
|
+
|
|
610
|
+
def test_emit_layout(self) -> None:
|
|
611
|
+
class Foo(torch.nn.Module):
|
|
612
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
613
|
+
return torch.ones_like(x)
|
|
614
|
+
|
|
615
|
+
f = Foo()
|
|
616
|
+
|
|
617
|
+
x = (torch.randn(3, 2),)
|
|
618
|
+
program = to_edge(export(f, x, strict=True)).to_executorch().executorch_program
|
|
619
|
+
|
|
620
|
+
vals = program.execution_plan[0].values
|
|
621
|
+
for val in vals:
|
|
622
|
+
v = val.val
|
|
623
|
+
if isinstance(v, Tensor):
|
|
624
|
+
self.assertEqual(v.layout, 0)
|
|
625
|
+
|
|
626
|
+
def test_optional_tensor_list(self) -> None:
|
|
627
|
+
class Foo(torch.nn.Module):
|
|
628
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
629
|
+
a = torch.nonzero(x)
|
|
630
|
+
torch._constrain_as_size(a.shape[0], min=1)
|
|
631
|
+
b = torch.ops.aten.index.Tensor(x, [a])
|
|
632
|
+
return b
|
|
633
|
+
|
|
634
|
+
f = Foo()
|
|
635
|
+
x = (torch.triu(torch.ones(2, 2)),)
|
|
636
|
+
program = (
|
|
637
|
+
to_edge(
|
|
638
|
+
export(f, x, strict=True),
|
|
639
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
640
|
+
)
|
|
641
|
+
.to_executorch()
|
|
642
|
+
.executorch_program
|
|
643
|
+
)
|
|
644
|
+
self.assertTrue(
|
|
645
|
+
isinstance(program.execution_plan[0].values[3].val, OptionalTensorList)
|
|
646
|
+
)
|
|
647
|
+
self._assertCallLength(program, 0, 3)
|
|
648
|
+
self._assertCallLength(program, 1, 4)
|
|
649
|
+
|
|
650
|
+
def test_optional_float_list(self) -> None:
|
|
651
|
+
class M(torch.nn.Module):
|
|
652
|
+
def forward(self, x):
|
|
653
|
+
return torch.nn.functional.interpolate(x, scale_factor=2)
|
|
654
|
+
|
|
655
|
+
x = (torch.randn(1, 1, 2, 2, 2),)
|
|
656
|
+
program = (
|
|
657
|
+
to_edge(export(M(), x, strict=True)).to_executorch().executorch_program
|
|
658
|
+
)
|
|
659
|
+
self.assertIsInstance(
|
|
660
|
+
program.execution_plan[0].values[-1].val, schema.OptionalTensorList
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
def test_emit_cond(self) -> None:
|
|
664
|
+
class M(torch.nn.Module):
|
|
665
|
+
def __init__(self):
|
|
666
|
+
super().__init__()
|
|
667
|
+
|
|
668
|
+
def forward(self, pred, x):
|
|
669
|
+
def true_fn(y: torch.Tensor) -> torch.Tensor:
|
|
670
|
+
y = y + y
|
|
671
|
+
y = torch.mm(y, y)
|
|
672
|
+
return y
|
|
673
|
+
|
|
674
|
+
def false_fn(y: torch.Tensor) -> torch.Tensor:
|
|
675
|
+
return torch.mm(y, y)
|
|
676
|
+
|
|
677
|
+
ret = torch_cond(pred, true_fn, false_fn, [x])
|
|
678
|
+
return ret
|
|
679
|
+
|
|
680
|
+
module = to_edge(
|
|
681
|
+
export(M(), (torch.tensor(True), torch.ones(2, 2)), strict=True)
|
|
682
|
+
)
|
|
683
|
+
program = module.to_executorch().executorch_program
|
|
684
|
+
|
|
685
|
+
num_mm = 0
|
|
686
|
+
num_add = 0
|
|
687
|
+
num_other = 0
|
|
688
|
+
for inst in program.execution_plan[0].chains[0].instructions:
|
|
689
|
+
if not isinstance(inst.instr_args, KernelCall):
|
|
690
|
+
continue
|
|
691
|
+
|
|
692
|
+
op = program.execution_plan[0].operators[inst.instr_args.op_index].name
|
|
693
|
+
|
|
694
|
+
if "mm" in op:
|
|
695
|
+
num_mm += 1
|
|
696
|
+
elif "add" in op:
|
|
697
|
+
num_add += 1
|
|
698
|
+
else:
|
|
699
|
+
num_other += 1
|
|
700
|
+
|
|
701
|
+
self.assertEqual(num_mm, 2)
|
|
702
|
+
self.assertEqual(num_add, 1)
|
|
703
|
+
self.assertEqual(num_other, 0)
|
|
704
|
+
|
|
705
|
+
def test_emit_map(self) -> None:
|
|
706
|
+
class Foo(torch.nn.Module):
|
|
707
|
+
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
708
|
+
def map_fn(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
709
|
+
return x + y
|
|
710
|
+
|
|
711
|
+
return torch_map(map_fn, x, y)
|
|
712
|
+
|
|
713
|
+
f = Foo()
|
|
714
|
+
|
|
715
|
+
inputs = (torch.ones(4, 4), torch.ones(4))
|
|
716
|
+
module = to_edge(
|
|
717
|
+
export(f, inputs, strict=True),
|
|
718
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
719
|
+
)
|
|
720
|
+
program = module.to_executorch().executorch_program
|
|
721
|
+
|
|
722
|
+
op_table = program.execution_plan[0].operators
|
|
723
|
+
# The first two operators at the beginning of a map program should be sym_size
|
|
724
|
+
# and select_copy, which is what we verify here. The first operator is to generate
|
|
725
|
+
# the number of iterations and the second operator is to slice the input tensor to
|
|
726
|
+
# generate the tensor on which this iteration will operate on.
|
|
727
|
+
self.assertEqual(
|
|
728
|
+
op_table[
|
|
729
|
+
program.execution_plan[0].chains[0].instructions[0].instr_args.op_index
|
|
730
|
+
].name,
|
|
731
|
+
"aten::sym_size",
|
|
732
|
+
)
|
|
733
|
+
self.assertEqual(
|
|
734
|
+
op_table[
|
|
735
|
+
program.execution_plan[0].chains[0].instructions[1].instr_args.op_index
|
|
736
|
+
].name,
|
|
737
|
+
"aten::select_copy",
|
|
738
|
+
)
|
|
739
|
+
|
|
740
|
+
# The last three instructions in the map sub-program are:
|
|
741
|
+
# - Calling the custom op to append the output of this iteration to the accumulator tensor
|
|
742
|
+
# - Increment the iteration count.
|
|
743
|
+
# - Then checking if we've completed all the iterations.
|
|
744
|
+
# We check here that both of these have been generated.
|
|
745
|
+
self.assertEqual(
|
|
746
|
+
op_table[
|
|
747
|
+
program.execution_plan[0].chains[0].instructions[-5].instr_args.op_index
|
|
748
|
+
].name,
|
|
749
|
+
"executorch_prim::et_copy_index",
|
|
750
|
+
)
|
|
751
|
+
self.assertEqual(
|
|
752
|
+
op_table[
|
|
753
|
+
program.execution_plan[0].chains[0].instructions[-4].instr_args.op_index
|
|
754
|
+
].name,
|
|
755
|
+
"executorch_prim::add",
|
|
756
|
+
)
|
|
757
|
+
self.assertEqual(
|
|
758
|
+
op_table[
|
|
759
|
+
program.execution_plan[0].chains[0].instructions[-3].instr_args.op_index
|
|
760
|
+
].name,
|
|
761
|
+
"executorch_prim::eq",
|
|
762
|
+
)
|
|
763
|
+
# The last two instructions in the overall program check if we should jump back to the
|
|
764
|
+
# beginning of the loop and then resets the iteration counter if we fall through.
|
|
765
|
+
self.assertTrue(
|
|
766
|
+
isinstance(
|
|
767
|
+
program.execution_plan[0].chains[0].instructions[-2].instr_args,
|
|
768
|
+
JumpFalseCall,
|
|
769
|
+
)
|
|
770
|
+
)
|
|
771
|
+
self.assertEqual(
|
|
772
|
+
op_table[
|
|
773
|
+
program.execution_plan[0].chains[0].instructions[-1].instr_args.op_index
|
|
774
|
+
].name,
|
|
775
|
+
"executorch_prim::sub",
|
|
776
|
+
)
|
|
777
|
+
|
|
778
|
+
def test_load_emit_map(self) -> None:
|
|
779
|
+
class Foo(torch.nn.Module):
|
|
780
|
+
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
781
|
+
def map_fn(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
782
|
+
return x + y
|
|
783
|
+
|
|
784
|
+
return torch_map(map_fn, x, y)
|
|
785
|
+
|
|
786
|
+
f = Foo()
|
|
787
|
+
|
|
788
|
+
inputs = (torch.ones(4, 4), torch.ones(4))
|
|
789
|
+
module = to_edge(
|
|
790
|
+
export(f, inputs, strict=True),
|
|
791
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
792
|
+
)
|
|
793
|
+
_load_for_executorch_from_buffer(module.to_executorch().buffer)
|
|
794
|
+
|
|
795
|
+
def test_run_emit_map(self) -> None:
|
|
796
|
+
class Foo(torch.nn.Module):
|
|
797
|
+
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
798
|
+
def map_fn(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
|
|
799
|
+
return x + y
|
|
800
|
+
|
|
801
|
+
return torch_map(map_fn, x, y)
|
|
802
|
+
|
|
803
|
+
f = Foo()
|
|
804
|
+
|
|
805
|
+
inputs = (torch.ones(4, 4), torch.ones(4))
|
|
806
|
+
module = to_edge(
|
|
807
|
+
export(f, inputs, strict=True),
|
|
808
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
809
|
+
)
|
|
810
|
+
buffer = module.to_executorch().buffer
|
|
811
|
+
loaded_model = _load_for_executorch_from_buffer(buffer)
|
|
812
|
+
outputs = loaded_model(inputs)[0]
|
|
813
|
+
torch.allclose(outputs, f(*inputs))
|
|
814
|
+
|
|
815
|
+
def test_emit_scan_basic(self) -> None:
|
|
816
|
+
"""Test basic scan emission: verifies instruction structure for cumulative sum."""
|
|
817
|
+
from torch._higher_order_ops.scan import scan
|
|
818
|
+
|
|
819
|
+
class ScanCumSum(torch.nn.Module):
|
|
820
|
+
def forward(self, xs: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
821
|
+
def combine_fn(carry, x):
|
|
822
|
+
new_carry = carry + x
|
|
823
|
+
return new_carry, new_carry.clone()
|
|
824
|
+
|
|
825
|
+
init = torch.zeros_like(xs[0])
|
|
826
|
+
return scan(combine_fn, init, xs)
|
|
827
|
+
|
|
828
|
+
f = ScanCumSum()
|
|
829
|
+
# Use contiguous tensor to avoid stride=0 issue
|
|
830
|
+
inputs = (torch.arange(15).float().reshape(5, 3),)
|
|
831
|
+
|
|
832
|
+
module = to_edge(
|
|
833
|
+
export(f, inputs, strict=True),
|
|
834
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
835
|
+
)
|
|
836
|
+
program = module.to_executorch().executorch_program
|
|
837
|
+
|
|
838
|
+
op_table = program.execution_plan[0].operators
|
|
839
|
+
instructions = program.execution_plan[0].chains[0].instructions
|
|
840
|
+
|
|
841
|
+
# Collect all operator names in the program
|
|
842
|
+
op_names = [op.name for op in op_table]
|
|
843
|
+
|
|
844
|
+
# Verify the key operators are present for scan:
|
|
845
|
+
# 1. sym_size - to get scan length
|
|
846
|
+
self.assertIn(
|
|
847
|
+
"aten::sym_size", op_names, "Should have sym_size for scan length"
|
|
848
|
+
)
|
|
849
|
+
|
|
850
|
+
# 2. copy_ - for carry initialization and carry updates
|
|
851
|
+
self.assertIn("aten::copy_", op_names, "Should have copy_ for carry handling")
|
|
852
|
+
|
|
853
|
+
# 3. select_copy - to slice xs
|
|
854
|
+
self.assertIn(
|
|
855
|
+
"aten::select_copy", op_names, "Should have select_copy for xs slicing"
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
# 4. et_copy_index - to accumulate y outputs
|
|
859
|
+
self.assertIn(
|
|
860
|
+
"executorch_prim::et_copy_index",
|
|
861
|
+
op_names,
|
|
862
|
+
"Should have et_copy_index for y accumulation",
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
# 5. Loop control: add, eq for iteration control
|
|
866
|
+
self.assertIn(
|
|
867
|
+
"executorch_prim::add", op_names, "Should have add for iter increment"
|
|
868
|
+
)
|
|
869
|
+
self.assertIn(
|
|
870
|
+
"executorch_prim::eq", op_names, "Should have eq for completion check"
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
# 6. sub - to reset iter_idx for re-runs
|
|
874
|
+
self.assertIn(
|
|
875
|
+
"executorch_prim::sub", op_names, "Should have sub to reset iterator"
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
# 7. Should have JumpFalseCall for loop back
|
|
879
|
+
jump_false_found = False
|
|
880
|
+
for instr in instructions:
|
|
881
|
+
if isinstance(instr.instr_args, JumpFalseCall):
|
|
882
|
+
jump_false_found = True
|
|
883
|
+
break
|
|
884
|
+
self.assertTrue(jump_false_found, "Should have JumpFalseCall for loop control")
|
|
885
|
+
|
|
886
|
+
# 8. Verify we have the body operations (add from combine_fn)
|
|
887
|
+
self.assertIn("aten::add", op_names, "Should have add from combine_fn body")
|
|
888
|
+
|
|
889
|
+
def test_run_emit_scan_cumsum(self) -> None:
|
|
890
|
+
"""Test scan execution correctness: cumulative sum."""
|
|
891
|
+
from torch._higher_order_ops.scan import scan
|
|
892
|
+
|
|
893
|
+
class ScanCumSum(torch.nn.Module):
|
|
894
|
+
def forward(self, xs: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
895
|
+
def combine_fn(carry, x):
|
|
896
|
+
new_carry = carry + x
|
|
897
|
+
return new_carry, new_carry.clone()
|
|
898
|
+
|
|
899
|
+
init = torch.zeros_like(xs[0])
|
|
900
|
+
return scan(combine_fn, init, xs)
|
|
901
|
+
|
|
902
|
+
f = ScanCumSum()
|
|
903
|
+
# Use contiguous tensor to avoid stride=0 issue
|
|
904
|
+
inputs = (torch.arange(15).float().reshape(5, 3),)
|
|
905
|
+
|
|
906
|
+
module = to_edge(
|
|
907
|
+
export(f, inputs, strict=True),
|
|
908
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
909
|
+
)
|
|
910
|
+
et = module.to_executorch()
|
|
911
|
+
et.dump_executorch_program(False)
|
|
912
|
+
buffer = et.buffer
|
|
913
|
+
loaded_model = _load_for_executorch_from_buffer(buffer)
|
|
914
|
+
|
|
915
|
+
# Run through executorch
|
|
916
|
+
et_outputs = loaded_model(inputs)
|
|
917
|
+
|
|
918
|
+
# Run through eager PyTorch
|
|
919
|
+
eager_outputs = f(*inputs)
|
|
920
|
+
|
|
921
|
+
# Compare final carry
|
|
922
|
+
self.assertTrue(
|
|
923
|
+
torch.allclose(et_outputs[0], eager_outputs[0]),
|
|
924
|
+
f"Final carry mismatch: {et_outputs[0]} vs {eager_outputs[0]}",
|
|
925
|
+
)
|
|
926
|
+
|
|
927
|
+
# Compare stacked outputs
|
|
928
|
+
self.assertTrue(
|
|
929
|
+
torch.allclose(et_outputs[1], eager_outputs[1]),
|
|
930
|
+
f"Stacked outputs mismatch: {et_outputs[1]} vs {eager_outputs[1]}",
|
|
931
|
+
)
|
|
932
|
+
|
|
933
|
+
def test_emit_scan_add_mul(self) -> None:
|
|
934
|
+
"""Test scan with add operation in combine_fn."""
|
|
935
|
+
from torch._higher_order_ops.scan import scan
|
|
936
|
+
|
|
937
|
+
class ScanAddMul(torch.nn.Module):
|
|
938
|
+
def forward(
|
|
939
|
+
self, xs: torch.Tensor, y: torch.Tensor
|
|
940
|
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
941
|
+
def combine_fn(carry, x):
|
|
942
|
+
# Multiply carry by 2 and add x
|
|
943
|
+
new_carry = carry * 2 + x
|
|
944
|
+
return new_carry, new_carry.clone()
|
|
945
|
+
|
|
946
|
+
init = torch.zeros_like(xs[0])
|
|
947
|
+
return scan(combine_fn, init, xs)
|
|
948
|
+
|
|
949
|
+
f = ScanAddMul()
|
|
950
|
+
inputs = (torch.ones(4, 3), torch.ones(3))
|
|
951
|
+
|
|
952
|
+
module = to_edge(
|
|
953
|
+
export(f, inputs, strict=True),
|
|
954
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
955
|
+
)
|
|
956
|
+
program = module.to_executorch().executorch_program
|
|
957
|
+
|
|
958
|
+
# Verify we have the expected operators
|
|
959
|
+
op_names = [op.name for op in program.execution_plan[0].operators]
|
|
960
|
+
|
|
961
|
+
# Should have mul and add operations from the combine_fn body
|
|
962
|
+
self.assertIn("aten::mul", op_names)
|
|
963
|
+
self.assertIn("aten::add", op_names)
|
|
964
|
+
|
|
965
|
+
# Should have scan control flow operators
|
|
966
|
+
self.assertIn("aten::sym_size", op_names)
|
|
967
|
+
self.assertIn("aten::select_copy", op_names)
|
|
968
|
+
self.assertIn("executorch_prim::et_copy_index", op_names)
|
|
969
|
+
|
|
970
|
+
def test_emit_scan_gru(self) -> None:
|
|
971
|
+
"""Test scan with a simple GRU-like computation."""
|
|
972
|
+
from torch._higher_order_ops.scan import scan
|
|
973
|
+
|
|
974
|
+
class SimpleGRU(torch.nn.Module):
|
|
975
|
+
"""Simple single-layer unidirectional GRU using scan."""
|
|
976
|
+
|
|
977
|
+
def __init__(self, input_size: int, hidden_size: int):
|
|
978
|
+
super().__init__()
|
|
979
|
+
self.input_size = input_size
|
|
980
|
+
self.hidden_size = hidden_size
|
|
981
|
+
|
|
982
|
+
# GRU gates: reset, update, new
|
|
983
|
+
self.weight_ih = torch.nn.Parameter(
|
|
984
|
+
torch.randn(3 * hidden_size, input_size), requires_grad=False
|
|
985
|
+
)
|
|
986
|
+
self.weight_hh = torch.nn.Parameter(
|
|
987
|
+
torch.randn(3 * hidden_size, hidden_size), requires_grad=False
|
|
988
|
+
)
|
|
989
|
+
self.bias_ih = torch.nn.Parameter(
|
|
990
|
+
torch.randn(3 * hidden_size), requires_grad=False
|
|
991
|
+
)
|
|
992
|
+
self.bias_hh = torch.nn.Parameter(
|
|
993
|
+
torch.randn(3 * hidden_size), requires_grad=False
|
|
994
|
+
)
|
|
995
|
+
|
|
996
|
+
def forward(
|
|
997
|
+
self, x: torch.Tensor, h0: torch.Tensor
|
|
998
|
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
999
|
+
"""
|
|
1000
|
+
Args:
|
|
1001
|
+
x: Input tensor of shape [seq_len, batch, input_size]
|
|
1002
|
+
h0: Initial hidden state of shape [batch, hidden_size]
|
|
1003
|
+
Returns:
|
|
1004
|
+
output: Output tensor of shape [seq_len, batch, hidden_size]
|
|
1005
|
+
h_n: Final hidden state of shape [batch, hidden_size]
|
|
1006
|
+
"""
|
|
1007
|
+
weight_ih = self.weight_ih
|
|
1008
|
+
weight_hh = self.weight_hh
|
|
1009
|
+
bias_ih = self.bias_ih
|
|
1010
|
+
bias_hh = self.bias_hh
|
|
1011
|
+
|
|
1012
|
+
def gru_cell(
|
|
1013
|
+
h: torch.Tensor, x_t: torch.Tensor
|
|
1014
|
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
1015
|
+
# Compute gates
|
|
1016
|
+
gates_ih = torch.nn.functional.linear(x_t, weight_ih, bias_ih)
|
|
1017
|
+
gates_hh = torch.nn.functional.linear(h, weight_hh, bias_hh)
|
|
1018
|
+
|
|
1019
|
+
# Split into reset, update, new gates
|
|
1020
|
+
r_ih, z_ih, n_ih = gates_ih.chunk(3, dim=-1)
|
|
1021
|
+
r_hh, z_hh, n_hh = gates_hh.chunk(3, dim=-1)
|
|
1022
|
+
|
|
1023
|
+
r = torch.sigmoid(r_ih + r_hh)
|
|
1024
|
+
z = torch.sigmoid(z_ih + z_hh)
|
|
1025
|
+
n = torch.tanh(n_ih + r * n_hh)
|
|
1026
|
+
|
|
1027
|
+
h_new = (1 - z) * n + z * h
|
|
1028
|
+
return h_new, h_new.clone()
|
|
1029
|
+
|
|
1030
|
+
final_h, outputs = scan(gru_cell, h0, x)
|
|
1031
|
+
return outputs, final_h
|
|
1032
|
+
|
|
1033
|
+
# Create model and inputs
|
|
1034
|
+
input_size = 4
|
|
1035
|
+
hidden_size = 8
|
|
1036
|
+
seq_len = 5
|
|
1037
|
+
batch_size = 2
|
|
1038
|
+
|
|
1039
|
+
model = SimpleGRU(input_size, hidden_size)
|
|
1040
|
+
x = torch.randn(seq_len, batch_size, input_size)
|
|
1041
|
+
h0 = torch.randn(batch_size, hidden_size)
|
|
1042
|
+
inputs = (x, h0)
|
|
1043
|
+
|
|
1044
|
+
# Run through eager PyTorch
|
|
1045
|
+
eager_outputs = model(*inputs)
|
|
1046
|
+
|
|
1047
|
+
# Export and convert to edge
|
|
1048
|
+
module = to_edge(
|
|
1049
|
+
export(model, inputs, strict=True),
|
|
1050
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1051
|
+
)
|
|
1052
|
+
et = module.to_executorch()
|
|
1053
|
+
program = et.executorch_program
|
|
1054
|
+
|
|
1055
|
+
# Verify the program has expected operators
|
|
1056
|
+
op_names = [op.name for op in program.execution_plan[0].operators]
|
|
1057
|
+
|
|
1058
|
+
# Should have scan control flow operators
|
|
1059
|
+
self.assertIn("aten::sym_size", op_names)
|
|
1060
|
+
self.assertIn("aten::select_copy", op_names)
|
|
1061
|
+
self.assertIn("executorch_prim::et_copy_index", op_names)
|
|
1062
|
+
|
|
1063
|
+
# Verify we can load the program
|
|
1064
|
+
buffer = et.buffer
|
|
1065
|
+
loaded_model = _load_for_executorch_from_buffer(buffer)
|
|
1066
|
+
|
|
1067
|
+
# Run through executorch
|
|
1068
|
+
et_outputs = loaded_model(inputs)
|
|
1069
|
+
|
|
1070
|
+
# Compare outputs (with tolerance for floating point)
|
|
1071
|
+
self.assertTrue(
|
|
1072
|
+
torch.allclose(et_outputs[0], eager_outputs[0], atol=1e-5),
|
|
1073
|
+
f"Output mismatch: {et_outputs[0]} vs {eager_outputs[0]}",
|
|
1074
|
+
)
|
|
1075
|
+
self.assertTrue(
|
|
1076
|
+
torch.allclose(et_outputs[1], eager_outputs[1], atol=1e-5),
|
|
1077
|
+
f"Final hidden state mismatch: {et_outputs[1]} vs {eager_outputs[1]}",
|
|
1078
|
+
)
|
|
1079
|
+
|
|
1080
|
+
def test_run_emit_scan_dynamic_shape(self) -> None:
|
|
1081
|
+
"""Test scan execution with dynamic sequence length."""
|
|
1082
|
+
from torch._higher_order_ops.scan import scan
|
|
1083
|
+
|
|
1084
|
+
class ScanCumSum(torch.nn.Module):
|
|
1085
|
+
def forward(self, xs: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
|
1086
|
+
def combine_fn(carry, x):
|
|
1087
|
+
new_carry = carry + x
|
|
1088
|
+
return new_carry, new_carry.clone()
|
|
1089
|
+
|
|
1090
|
+
init = torch.zeros_like(xs[0])
|
|
1091
|
+
return scan(combine_fn, init, xs)
|
|
1092
|
+
|
|
1093
|
+
f = ScanCumSum()
|
|
1094
|
+
|
|
1095
|
+
upper_bound_inputs = (torch.arange(24).float().reshape(8, 3),)
|
|
1096
|
+
|
|
1097
|
+
seq_dim = Dim("seq", max=8)
|
|
1098
|
+
dynamic_shapes = {"xs": {0: seq_dim}}
|
|
1099
|
+
|
|
1100
|
+
module = to_edge(
|
|
1101
|
+
export(f, upper_bound_inputs, dynamic_shapes=dynamic_shapes, strict=True),
|
|
1102
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1103
|
+
)
|
|
1104
|
+
et = module.to_executorch(
|
|
1105
|
+
config=exir.ExecutorchBackendConfig(
|
|
1106
|
+
sym_shape_eval_pass=ConstraintBasedSymShapeEvalPass(),
|
|
1107
|
+
)
|
|
1108
|
+
)
|
|
1109
|
+
et.dump_executorch_program(True)
|
|
1110
|
+
buffer = et.buffer
|
|
1111
|
+
loaded_model = _load_for_executorch_from_buffer(buffer)
|
|
1112
|
+
|
|
1113
|
+
test_cases = [
|
|
1114
|
+
(torch.arange(15).float().reshape(5, 3),), # seq_len=5
|
|
1115
|
+
(torch.arange(9).float().reshape(3, 3),), # seq_len=3
|
|
1116
|
+
(torch.arange(21).float().reshape(7, 3),), # seq_len=7
|
|
1117
|
+
]
|
|
1118
|
+
|
|
1119
|
+
for test_inputs in test_cases:
|
|
1120
|
+
et_outputs = loaded_model(test_inputs)
|
|
1121
|
+
eager_outputs = f(*test_inputs)
|
|
1122
|
+
|
|
1123
|
+
self.assertTrue(
|
|
1124
|
+
torch.allclose(et_outputs[0], eager_outputs[0]),
|
|
1125
|
+
f"Final carry mismatch for shape {test_inputs[0].shape}: {et_outputs[0]} vs {eager_outputs[0]}",
|
|
1126
|
+
)
|
|
1127
|
+
self.assertTrue(
|
|
1128
|
+
torch.allclose(et_outputs[1], eager_outputs[1]),
|
|
1129
|
+
f"Stacked outputs mismatch for shape {test_inputs[0].shape}: {et_outputs[1]} vs {eager_outputs[1]}",
|
|
1130
|
+
)
|
|
1131
|
+
|
|
1132
|
+
def test_dim_order(self) -> None:
|
|
1133
|
+
class SimpleLinear(torch.nn.Module):
|
|
1134
|
+
def __init__(self) -> None:
|
|
1135
|
+
super().__init__()
|
|
1136
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
1137
|
+
|
|
1138
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1139
|
+
return torch.nn.functional.relu(self.linear(x))
|
|
1140
|
+
|
|
1141
|
+
model = SimpleLinear()
|
|
1142
|
+
inputs = (torch.ones(10, 5),)
|
|
1143
|
+
program = (
|
|
1144
|
+
to_edge(
|
|
1145
|
+
export(model, inputs, strict=True),
|
|
1146
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1147
|
+
)
|
|
1148
|
+
.to_executorch()
|
|
1149
|
+
.executorch_program
|
|
1150
|
+
)
|
|
1151
|
+
|
|
1152
|
+
addmm_found = False
|
|
1153
|
+
for inst in program.execution_plan[0].chains[0].instructions:
|
|
1154
|
+
kernel = inst.instr_args
|
|
1155
|
+
if isinstance(kernel, KernelCall):
|
|
1156
|
+
op_id = kernel.op_index
|
|
1157
|
+
op = program.execution_plan[0].operators[op_id]
|
|
1158
|
+
if op.name == "aten::addmm":
|
|
1159
|
+
addmm_found = True
|
|
1160
|
+
args = kernel.args
|
|
1161
|
+
bias_id = args[0]
|
|
1162
|
+
act_id = args[1]
|
|
1163
|
+
weight_id = args[2]
|
|
1164
|
+
bias_dim_order = [0]
|
|
1165
|
+
act_dim_order = [0, 1]
|
|
1166
|
+
weight_dim_order = [0, 1]
|
|
1167
|
+
bias_tensor = typing.cast(
|
|
1168
|
+
schema.Tensor, program.execution_plan[0].values[bias_id].val
|
|
1169
|
+
)
|
|
1170
|
+
act_tensor = typing.cast(
|
|
1171
|
+
schema.Tensor, program.execution_plan[0].values[act_id].val
|
|
1172
|
+
)
|
|
1173
|
+
weight_tensor = typing.cast(
|
|
1174
|
+
schema.Tensor, program.execution_plan[0].values[weight_id].val
|
|
1175
|
+
)
|
|
1176
|
+
self.assertTrue(bias_tensor.dim_order == bias_dim_order)
|
|
1177
|
+
self.assertTrue(act_tensor.dim_order == act_dim_order)
|
|
1178
|
+
self.assertTrue(weight_tensor.dim_order == weight_dim_order)
|
|
1179
|
+
self.assertTrue(addmm_found)
|
|
1180
|
+
|
|
1181
|
+
def test_non_const_buffer_sizes(self) -> None:
|
|
1182
|
+
class Add(torch.nn.Module):
|
|
1183
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1184
|
+
b = 3 + 1
|
|
1185
|
+
return x + torch.tensor(b)
|
|
1186
|
+
|
|
1187
|
+
f = Add()
|
|
1188
|
+
|
|
1189
|
+
edge_program_manager = to_edge(export(f, (torch.ones(3, 2),), strict=True))
|
|
1190
|
+
edge_program_manager._edge_programs["forward"] = constant_prop_pass(
|
|
1191
|
+
edge_program_manager.exported_program()
|
|
1192
|
+
)
|
|
1193
|
+
non_const_buffer_size_with_const_prop_pass = (
|
|
1194
|
+
edge_program_manager.to_executorch()
|
|
1195
|
+
.executorch_program.execution_plan[0]
|
|
1196
|
+
.non_const_buffer_sizes
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
edge_program_manager = to_edge(export(f, (torch.ones(3, 2),), strict=True))
|
|
1200
|
+
non_const_buffer_size_without_const_prop_pass = (
|
|
1201
|
+
edge_program_manager.to_executorch()
|
|
1202
|
+
.executorch_program.execution_plan[0]
|
|
1203
|
+
.non_const_buffer_sizes
|
|
1204
|
+
)
|
|
1205
|
+
self.assertTrue(
|
|
1206
|
+
non_const_buffer_size_with_const_prop_pass[1]
|
|
1207
|
+
< non_const_buffer_size_without_const_prop_pass[1]
|
|
1208
|
+
)
|
|
1209
|
+
|
|
1210
|
+
# cant compare plans directly with __eq__ because of the plan names, and data_buffer_idx in tensor values
|
|
1211
|
+
def _compare_execution_plans(
|
|
1212
|
+
self, plan_single: ExecutionPlan, plan_merged: ExecutionPlan
|
|
1213
|
+
) -> None:
|
|
1214
|
+
self.assertEqual(
|
|
1215
|
+
plan_single.container_meta_type,
|
|
1216
|
+
plan_merged.container_meta_type,
|
|
1217
|
+
)
|
|
1218
|
+
self.assertEqual(
|
|
1219
|
+
plan_single.inputs,
|
|
1220
|
+
plan_merged.inputs,
|
|
1221
|
+
)
|
|
1222
|
+
self.assertEqual(
|
|
1223
|
+
plan_single.outputs,
|
|
1224
|
+
plan_merged.outputs,
|
|
1225
|
+
)
|
|
1226
|
+
self.assertEqual(
|
|
1227
|
+
plan_single.chains,
|
|
1228
|
+
plan_merged.chains,
|
|
1229
|
+
)
|
|
1230
|
+
self.assertEqual(
|
|
1231
|
+
plan_single.operators,
|
|
1232
|
+
plan_merged.operators,
|
|
1233
|
+
)
|
|
1234
|
+
self.assertEqual(
|
|
1235
|
+
plan_single.non_const_buffer_sizes,
|
|
1236
|
+
plan_merged.non_const_buffer_sizes,
|
|
1237
|
+
)
|
|
1238
|
+
self.assertEqual(
|
|
1239
|
+
len(plan_single.values),
|
|
1240
|
+
len(plan_merged.values),
|
|
1241
|
+
)
|
|
1242
|
+
for i in range(0, len(plan_single.values)):
|
|
1243
|
+
single_val = plan_single.values[i].val
|
|
1244
|
+
merged_val = plan_merged.values[i].val
|
|
1245
|
+
if isinstance(single_val, Tensor):
|
|
1246
|
+
# constant buffer index might be different as the constant buffer is shared between plans
|
|
1247
|
+
self.assertTrue(isinstance(merged_val, Tensor))
|
|
1248
|
+
self.assertEqual(single_val.storage_offset, merged_val.storage_offset)
|
|
1249
|
+
self.assertEqual(single_val.scalar_type, merged_val.scalar_type)
|
|
1250
|
+
self.assertEqual(single_val.sizes, merged_val.sizes)
|
|
1251
|
+
self.assertEqual(single_val.dim_order, merged_val.dim_order)
|
|
1252
|
+
self.assertEqual(single_val.requires_grad, merged_val.requires_grad)
|
|
1253
|
+
self.assertEqual(single_val.layout, merged_val.layout)
|
|
1254
|
+
self.assertEqual(single_val.allocation_info, merged_val.allocation_info)
|
|
1255
|
+
self.assertEqual(single_val.shape_dynamism, merged_val.shape_dynamism)
|
|
1256
|
+
else:
|
|
1257
|
+
self.assertEqual(single_val, merged_val)
|
|
1258
|
+
|
|
1259
|
+
def test_emit_memory_format_valid(self) -> None:
|
|
1260
|
+
class SimpleLinear(torch.nn.Module):
|
|
1261
|
+
def __init__(self) -> None:
|
|
1262
|
+
super().__init__()
|
|
1263
|
+
|
|
1264
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1265
|
+
contiguous = x.to(
|
|
1266
|
+
dtype=torch.float32, memory_format=torch.contiguous_format
|
|
1267
|
+
)
|
|
1268
|
+
preserve = x.to(
|
|
1269
|
+
dtype=torch.float32, memory_format=torch.preserve_format
|
|
1270
|
+
)
|
|
1271
|
+
return contiguous + preserve
|
|
1272
|
+
|
|
1273
|
+
# Should succeed at exporting model with legal memory format (contiguous, preserve)
|
|
1274
|
+
model = SimpleLinear()
|
|
1275
|
+
inputs = (torch.ones(10, 5),)
|
|
1276
|
+
try:
|
|
1277
|
+
to_edge(
|
|
1278
|
+
export(model, inputs, strict=True),
|
|
1279
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1280
|
+
).to_executorch()
|
|
1281
|
+
except:
|
|
1282
|
+
self.fail("Failed to export model with legal memory format")
|
|
1283
|
+
|
|
1284
|
+
def test_emit_memory_format_invalid(self) -> None:
|
|
1285
|
+
class SimpleLinear(torch.nn.Module):
|
|
1286
|
+
def __init__(self) -> None:
|
|
1287
|
+
super().__init__()
|
|
1288
|
+
|
|
1289
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1290
|
+
return x.to(dtype=torch.float32, memory_format=torch.channels_last)
|
|
1291
|
+
|
|
1292
|
+
# Failure expected when exporting model with illegal memory format (channels_last) when not using dim_order
|
|
1293
|
+
model = SimpleLinear()
|
|
1294
|
+
inputs = (torch.ones(10, 5, 2, 1),)
|
|
1295
|
+
with self.assertRaises(InternalError):
|
|
1296
|
+
to_edge(
|
|
1297
|
+
export(model, inputs, strict=True),
|
|
1298
|
+
compile_config=exir.EdgeCompileConfig(
|
|
1299
|
+
_check_ir_validity=False, _skip_dim_order=True
|
|
1300
|
+
),
|
|
1301
|
+
).to_executorch()
|
|
1302
|
+
|
|
1303
|
+
# Success if you use dim_order
|
|
1304
|
+
to_edge(
|
|
1305
|
+
export(model, inputs, strict=True),
|
|
1306
|
+
compile_config=exir.EdgeCompileConfig(
|
|
1307
|
+
_check_ir_validity=False, _skip_dim_order=False
|
|
1308
|
+
),
|
|
1309
|
+
).to_executorch()
|
|
1310
|
+
|
|
1311
|
+
def test_emit_multiple_entry_points(self) -> None:
|
|
1312
|
+
class SimpleLinear(torch.nn.Module):
|
|
1313
|
+
def __init__(self) -> None:
|
|
1314
|
+
super().__init__()
|
|
1315
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
1316
|
+
self.linear2 = torch.nn.Linear(5, 5)
|
|
1317
|
+
|
|
1318
|
+
def forward_relu(self, x: torch.Tensor) -> torch.Tensor:
|
|
1319
|
+
return torch.nn.functional.relu(self.linear(x))
|
|
1320
|
+
|
|
1321
|
+
def forward_sigmoid(self, x: torch.Tensor) -> torch.Tensor:
|
|
1322
|
+
return torch.nn.functional.sigmoid(self.linear2(x))
|
|
1323
|
+
|
|
1324
|
+
model = SimpleLinear()
|
|
1325
|
+
inputs = (torch.ones(10, 5),)
|
|
1326
|
+
with patch_forward(model, model.forward_relu):
|
|
1327
|
+
program_relu = to_edge(
|
|
1328
|
+
export(model, inputs, strict=True),
|
|
1329
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1330
|
+
).to_executorch()
|
|
1331
|
+
with patch_forward(model, model.forward_sigmoid):
|
|
1332
|
+
program_sigmoid = to_edge(
|
|
1333
|
+
export(model, inputs, strict=True),
|
|
1334
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
1335
|
+
).to_executorch()
|
|
1336
|
+
exir_input = {
|
|
1337
|
+
"forward_relu": program_relu.exported_program(),
|
|
1338
|
+
"forward_sigmoid": program_sigmoid.exported_program(),
|
|
1339
|
+
}
|
|
1340
|
+
merged_program = emit_program(exir_input, False).program
|
|
1341
|
+
self.assertEqual(len(merged_program.execution_plan), 2)
|
|
1342
|
+
|
|
1343
|
+
self.assertEqual(
|
|
1344
|
+
merged_program.execution_plan[0].name,
|
|
1345
|
+
"forward_relu",
|
|
1346
|
+
)
|
|
1347
|
+
self.assertEqual(
|
|
1348
|
+
merged_program.execution_plan[1].name,
|
|
1349
|
+
"forward_sigmoid",
|
|
1350
|
+
)
|
|
1351
|
+
# reserved spot, weight, bias
|
|
1352
|
+
self.assertEqual(
|
|
1353
|
+
len(program_sigmoid._emitter_output.program.constant_buffer),
|
|
1354
|
+
3,
|
|
1355
|
+
)
|
|
1356
|
+
self.assertEqual(
|
|
1357
|
+
len(program_relu._emitter_output.program.constant_buffer),
|
|
1358
|
+
3,
|
|
1359
|
+
)
|
|
1360
|
+
# sum of the entry points minus 1 because we only have one reserved spot still
|
|
1361
|
+
self.assertEqual(
|
|
1362
|
+
len(merged_program.constant_buffer),
|
|
1363
|
+
len(program_sigmoid._emitter_output.program.constant_buffer)
|
|
1364
|
+
+ len(program_relu._emitter_output.program.constant_buffer)
|
|
1365
|
+
- 1,
|
|
1366
|
+
)
|
|
1367
|
+
|
|
1368
|
+
self._compare_execution_plans(
|
|
1369
|
+
merged_program.execution_plan[0],
|
|
1370
|
+
program_relu._emitter_output.program.execution_plan[0],
|
|
1371
|
+
)
|
|
1372
|
+
self._compare_execution_plans(
|
|
1373
|
+
merged_program.execution_plan[1],
|
|
1374
|
+
program_sigmoid._emitter_output.program.execution_plan[0],
|
|
1375
|
+
)
|
|
1376
|
+
|
|
1377
|
+
def test_emit_weight_deduplication(self) -> None:
|
|
1378
|
+
class SimpleLinear(torch.nn.Module):
|
|
1379
|
+
def __init__(self) -> None:
|
|
1380
|
+
super().__init__()
|
|
1381
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
1382
|
+
|
|
1383
|
+
def forward_relu(self, x: torch.Tensor) -> torch.Tensor:
|
|
1384
|
+
return torch.nn.functional.relu(self.linear(x))
|
|
1385
|
+
|
|
1386
|
+
def forward_sigmoid(self, x: torch.Tensor) -> torch.Tensor:
|
|
1387
|
+
return torch.nn.functional.sigmoid(self.linear(x))
|
|
1388
|
+
|
|
1389
|
+
model = SimpleLinear()
|
|
1390
|
+
inputs = (torch.ones(10, 5),)
|
|
1391
|
+
with patch_forward(model, model.forward_relu):
|
|
1392
|
+
program_relu = to_edge(export(model, inputs, strict=True)).to_executorch()
|
|
1393
|
+
with patch_forward(model, model.forward_sigmoid):
|
|
1394
|
+
program_sigmoid = to_edge(
|
|
1395
|
+
export(model, inputs, strict=True)
|
|
1396
|
+
).to_executorch()
|
|
1397
|
+
exir_input = {
|
|
1398
|
+
"forward_relu": program_relu.exported_program(),
|
|
1399
|
+
"forward_sigmoid": program_sigmoid.exported_program(),
|
|
1400
|
+
}
|
|
1401
|
+
merged_program = emit_program(exir_input, False).program
|
|
1402
|
+
self.assertEqual(len(merged_program.execution_plan), 2)
|
|
1403
|
+
|
|
1404
|
+
# reserved spot, weight, bias
|
|
1405
|
+
self.assertEqual(
|
|
1406
|
+
len(program_sigmoid._emitter_output.program.constant_buffer),
|
|
1407
|
+
3,
|
|
1408
|
+
)
|
|
1409
|
+
self.assertEqual(
|
|
1410
|
+
len(program_relu._emitter_output.program.constant_buffer),
|
|
1411
|
+
3,
|
|
1412
|
+
)
|
|
1413
|
+
# weights are shared between entry points so the merged one should deduplicate everything
|
|
1414
|
+
self.assertEqual(len(merged_program.constant_buffer), 3)
|
|
1415
|
+
|
|
1416
|
+
self._compare_execution_plans(
|
|
1417
|
+
merged_program.execution_plan[0],
|
|
1418
|
+
program_relu._emitter_output.program.execution_plan[0],
|
|
1419
|
+
)
|
|
1420
|
+
self._compare_execution_plans(
|
|
1421
|
+
merged_program.execution_plan[1],
|
|
1422
|
+
program_sigmoid._emitter_output.program.execution_plan[0],
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
def test_emit_execution_plans_sorted(self) -> None:
|
|
1426
|
+
class Simple(torch.nn.Module):
|
|
1427
|
+
def __init__(self) -> None:
|
|
1428
|
+
super().__init__()
|
|
1429
|
+
|
|
1430
|
+
def a(self, x: torch.Tensor) -> torch.Tensor:
|
|
1431
|
+
return x
|
|
1432
|
+
|
|
1433
|
+
def b(self, x: torch.Tensor) -> torch.Tensor:
|
|
1434
|
+
return x
|
|
1435
|
+
|
|
1436
|
+
def c(self, x: torch.Tensor) -> torch.Tensor:
|
|
1437
|
+
return x
|
|
1438
|
+
|
|
1439
|
+
model = Simple()
|
|
1440
|
+
inputs = (torch.ones(10, 5),)
|
|
1441
|
+
|
|
1442
|
+
def make_program(
|
|
1443
|
+
fn,
|
|
1444
|
+
inputs,
|
|
1445
|
+
) -> "ExecutorchProgramManager":
|
|
1446
|
+
return to_edge(
|
|
1447
|
+
export(WrapperModule(fn), inputs, strict=True)
|
|
1448
|
+
).to_executorch()
|
|
1449
|
+
|
|
1450
|
+
program_a = make_program(model.a, inputs)
|
|
1451
|
+
program_b = make_program(model.b, inputs)
|
|
1452
|
+
program_c = make_program(model.c, inputs)
|
|
1453
|
+
|
|
1454
|
+
exir_input = {
|
|
1455
|
+
"b": program_b.exported_program(),
|
|
1456
|
+
"c": program_c.exported_program(),
|
|
1457
|
+
"a": program_a.exported_program(),
|
|
1458
|
+
}
|
|
1459
|
+
merged_program = emit_program(exir_input, False).program
|
|
1460
|
+
self.assertEqual(len(merged_program.execution_plan), 3)
|
|
1461
|
+
self.assertEqual(merged_program.execution_plan[0].name, "a")
|
|
1462
|
+
self.assertEqual(merged_program.execution_plan[1].name, "b")
|
|
1463
|
+
self.assertEqual(merged_program.execution_plan[2].name, "c")
|
|
1464
|
+
|
|
1465
|
+
# Create a second program equivalent to the first, but the input is in a different order.
|
|
1466
|
+
# python dicts are instertion ordered
|
|
1467
|
+
exir_input2 = {
|
|
1468
|
+
"a": program_b.exported_program(),
|
|
1469
|
+
"b": program_c.exported_program(),
|
|
1470
|
+
"c": program_a.exported_program(),
|
|
1471
|
+
}
|
|
1472
|
+
merged_program2 = emit_program(exir_input2, False).program
|
|
1473
|
+
self.assertEqual(
|
|
1474
|
+
merged_program2.execution_plan[0], merged_program.execution_plan[0]
|
|
1475
|
+
)
|
|
1476
|
+
self.assertEqual(
|
|
1477
|
+
merged_program2.execution_plan[1], merged_program.execution_plan[1]
|
|
1478
|
+
)
|
|
1479
|
+
self.assertEqual(
|
|
1480
|
+
merged_program2.execution_plan[2], merged_program.execution_plan[2]
|
|
1481
|
+
)
|
|
1482
|
+
|
|
1483
|
+
def test_upper_bound_memory_planning_respect_input_constraints(self) -> None:
|
|
1484
|
+
class Foo(torch.nn.Module):
|
|
1485
|
+
def forward(self, k: torch.Tensor) -> torch.Tensor:
|
|
1486
|
+
k = torch.cat((k, torch.ones(1, 4)))
|
|
1487
|
+
return k
|
|
1488
|
+
|
|
1489
|
+
func = Foo()
|
|
1490
|
+
|
|
1491
|
+
k = torch.rand(2, 4)
|
|
1492
|
+
dim0_k = Dim("dim0_k", max=3)
|
|
1493
|
+
dynamic_shapes = {"k": {0: dim0_k}}
|
|
1494
|
+
captured = export(func, (k,), dynamic_shapes=dynamic_shapes, strict=True)
|
|
1495
|
+
edge = to_edge(captured)
|
|
1496
|
+
from executorch.exir.passes import MemoryPlanningPass
|
|
1497
|
+
|
|
1498
|
+
config = exir.ExecutorchBackendConfig(
|
|
1499
|
+
sym_shape_eval_pass=ConstraintBasedSymShapeEvalPass(),
|
|
1500
|
+
memory_planning_pass=MemoryPlanningPass(
|
|
1501
|
+
# allow_lifetime_and_storage_overlap: bool = False,
|
|
1502
|
+
alloc_graph_input=True,
|
|
1503
|
+
alloc_graph_output=False,
|
|
1504
|
+
),
|
|
1505
|
+
)
|
|
1506
|
+
|
|
1507
|
+
exe_prog = edge.to_executorch(config)
|
|
1508
|
+
program = exe_prog._emitter_output.program
|
|
1509
|
+
exir.print_program.pretty_print(exe_prog._emitter_output.program.execution_plan)
|
|
1510
|
+
execution_plan = program.execution_plan[0]
|
|
1511
|
+
self.check_tensor_buffer_loc(0, execution_plan.values, 0, 1, 0)
|
|
1512
|
+
self.check_tensor_buffer_loc(1, execution_plan.values, 0, 1, 48)
|
|
1513
|
+
|
|
1514
|
+
def test_emit_prims(self) -> None:
|
|
1515
|
+
tensor_output = torch.rand(1, 4)
|
|
1516
|
+
tensor_list_output = [torch.rand(1, 4), torch.rand(1, 4)]
|
|
1517
|
+
|
|
1518
|
+
class Simple(torch.nn.Module):
|
|
1519
|
+
def __init__(self) -> None:
|
|
1520
|
+
super().__init__()
|
|
1521
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
1522
|
+
self.x: int = 3
|
|
1523
|
+
self.y = 2
|
|
1524
|
+
|
|
1525
|
+
def get_ints(self) -> Tuple[int]:
|
|
1526
|
+
return (self.x, self.y)
|
|
1527
|
+
|
|
1528
|
+
def get_str(self) -> str:
|
|
1529
|
+
return "foo"
|
|
1530
|
+
|
|
1531
|
+
def get_tensor(self) -> torch.Tensor:
|
|
1532
|
+
return tensor_output
|
|
1533
|
+
|
|
1534
|
+
def get_tensor_list(self) -> List[torch.Tensor]:
|
|
1535
|
+
return tensor_list_output
|
|
1536
|
+
|
|
1537
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1538
|
+
return torch.nn.functional.sigmoid(self.linear(x))
|
|
1539
|
+
|
|
1540
|
+
model = Simple()
|
|
1541
|
+
inputs = (torch.ones(10, 5),)
|
|
1542
|
+
program = to_edge(export(model, inputs, strict=True)).to_executorch()
|
|
1543
|
+
exir_input = {
|
|
1544
|
+
"forward": program.exported_program(),
|
|
1545
|
+
}
|
|
1546
|
+
getters = {}
|
|
1547
|
+
getters["get_ints"] = model.get_ints()
|
|
1548
|
+
getters["get_str"] = model.get_str()
|
|
1549
|
+
getters["get_tensor"] = model.get_tensor()
|
|
1550
|
+
getters["get_tensor_list"] = model.get_tensor_list()
|
|
1551
|
+
|
|
1552
|
+
merged_program = emit_program(exir_input, False, getters).program
|
|
1553
|
+
|
|
1554
|
+
self.assertEqual(len(merged_program.execution_plan), 5)
|
|
1555
|
+
|
|
1556
|
+
self.assertEqual(
|
|
1557
|
+
merged_program.execution_plan[0].name,
|
|
1558
|
+
"forward",
|
|
1559
|
+
)
|
|
1560
|
+
self.assertEqual(
|
|
1561
|
+
merged_program.execution_plan[1].name,
|
|
1562
|
+
"get_ints",
|
|
1563
|
+
)
|
|
1564
|
+
self.assertEqual(
|
|
1565
|
+
merged_program.execution_plan[2].name,
|
|
1566
|
+
"get_str",
|
|
1567
|
+
)
|
|
1568
|
+
self.assertEqual(
|
|
1569
|
+
merged_program.execution_plan[3].name,
|
|
1570
|
+
"get_tensor",
|
|
1571
|
+
)
|
|
1572
|
+
self.assertEqual(
|
|
1573
|
+
merged_program.execution_plan[4].name,
|
|
1574
|
+
"get_tensor_list",
|
|
1575
|
+
)
|
|
1576
|
+
|
|
1577
|
+
# no instructions in a getter
|
|
1578
|
+
self.assertEqual(
|
|
1579
|
+
len(merged_program.execution_plan[1].chains[0].instructions),
|
|
1580
|
+
0,
|
|
1581
|
+
)
|
|
1582
|
+
# 2 outputs for the flattened tuple
|
|
1583
|
+
self.assertEqual(
|
|
1584
|
+
len(merged_program.execution_plan[1].outputs),
|
|
1585
|
+
2,
|
|
1586
|
+
)
|
|
1587
|
+
# outputs are 0 and 1 in the values table
|
|
1588
|
+
self.assertEqual(
|
|
1589
|
+
merged_program.execution_plan[1].outputs,
|
|
1590
|
+
[0, 1],
|
|
1591
|
+
)
|
|
1592
|
+
# value 0 is 3
|
|
1593
|
+
self.assertEqual(
|
|
1594
|
+
# pyre-ignore
|
|
1595
|
+
merged_program.execution_plan[1].values[0].val.int_val,
|
|
1596
|
+
3,
|
|
1597
|
+
)
|
|
1598
|
+
self.assertEqual(
|
|
1599
|
+
# pyre-ignore
|
|
1600
|
+
merged_program.execution_plan[1].values[1].val.int_val,
|
|
1601
|
+
2,
|
|
1602
|
+
)
|
|
1603
|
+
self.assertEqual(
|
|
1604
|
+
len(merged_program.execution_plan[2].outputs),
|
|
1605
|
+
1,
|
|
1606
|
+
)
|
|
1607
|
+
self.assertEqual(
|
|
1608
|
+
# pyre-ignore
|
|
1609
|
+
merged_program.execution_plan[2].values[0].val.string_val,
|
|
1610
|
+
"foo",
|
|
1611
|
+
)
|
|
1612
|
+
self.assertEqual(len(merged_program.execution_plan[3].outputs), 1)
|
|
1613
|
+
self.assertEqual(len(merged_program.execution_plan[4].outputs), 2)
|
|
1614
|
+
|
|
1615
|
+
merged_program = to_edge(
|
|
1616
|
+
export(model, inputs, strict=True), constant_methods=getters
|
|
1617
|
+
).to_executorch()
|
|
1618
|
+
executorch_module = _load_for_executorch_from_buffer(merged_program.buffer)
|
|
1619
|
+
torch.allclose(executorch_module.run_method("get_tensor", [])[0], tensor_output)
|
|
1620
|
+
model_output = executorch_module.run_method("get_tensor_list", [])
|
|
1621
|
+
for i in range(len(tensor_list_output)):
|
|
1622
|
+
torch.allclose(model_output[i], tensor_list_output[i])
|
|
1623
|
+
|
|
1624
|
+
def test_emit_debug_handle_map(self) -> None:
|
|
1625
|
+
mul_model = Mul()
|
|
1626
|
+
program_mul = to_edge(
|
|
1627
|
+
export(mul_model, mul_model.get_random_inputs(), strict=True)
|
|
1628
|
+
).to_executorch()
|
|
1629
|
+
# this triggers the actual emission of the graph
|
|
1630
|
+
program_mul._emitter_output.program
|
|
1631
|
+
self.assertIsNotNone(program_mul.debug_handle_map)
|
|
1632
|
+
|
|
1633
|
+
def test_final_graph_module_update_debug_handle(self) -> None:
|
|
1634
|
+
class SimpleAddMul(torch.nn.Module):
|
|
1635
|
+
def __init__(self) -> None:
|
|
1636
|
+
super().__init__()
|
|
1637
|
+
|
|
1638
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
1639
|
+
a = x + 1
|
|
1640
|
+
return a * 2
|
|
1641
|
+
|
|
1642
|
+
mul_model = SimpleAddMul()
|
|
1643
|
+
program_mul = to_edge(
|
|
1644
|
+
export(mul_model, (torch.ones(2, 2),), strict=True)
|
|
1645
|
+
).to_executorch()
|
|
1646
|
+
|
|
1647
|
+
# this triggers the actual emission of the graph
|
|
1648
|
+
program = program_mul._emitter_output.program
|
|
1649
|
+
node = None
|
|
1650
|
+
program.execution_plan[0].chains[0].instructions[0].instr_args.op_index
|
|
1651
|
+
|
|
1652
|
+
# Find the multiplication node in the graph that was emitted.
|
|
1653
|
+
for node in program_mul.exported_program().graph.nodes:
|
|
1654
|
+
if (
|
|
1655
|
+
node.target == torch.ops.aten.mul.out
|
|
1656
|
+
or node.target == torch.ops.aten.mul.Scalar_out
|
|
1657
|
+
):
|
|
1658
|
+
break
|
|
1659
|
+
self.assertIsNotNone(node)
|
|
1660
|
+
|
|
1661
|
+
idx = 0
|
|
1662
|
+
# Find the multiplication instruction in the program that was emitted.
|
|
1663
|
+
for idx in range(len(program.execution_plan[0].chains[0].instructions)):
|
|
1664
|
+
instruction = program.execution_plan[0].chains[0].instructions[idx]
|
|
1665
|
+
op_index = instruction.instr_args.op_index
|
|
1666
|
+
if "mul" in program.execution_plan[0].operators[op_index].name:
|
|
1667
|
+
break
|
|
1668
|
+
|
|
1669
|
+
# The instruction id of the multiplication instruction and the debug handle of the
|
|
1670
|
+
# multiplication node in the graph module (which was updated in the emitter to be
|
|
1671
|
+
# the same as the instruction id) must be the same.
|
|
1672
|
+
self.assertEqual(
|
|
1673
|
+
idx,
|
|
1674
|
+
node.meta.get("debug_handle"),
|
|
1675
|
+
)
|
|
1676
|
+
|
|
1677
|
+
def test_delegate_with_input_list(self) -> None:
|
|
1678
|
+
class BackendWithCompilerExample(BackendDetails):
|
|
1679
|
+
@staticmethod
|
|
1680
|
+
def preprocess(
|
|
1681
|
+
edge_program,
|
|
1682
|
+
compile_specs,
|
|
1683
|
+
) -> bytes:
|
|
1684
|
+
return PreprocessResult(
|
|
1685
|
+
processed_bytes=bytes(str("test"), encoding="utf8"),
|
|
1686
|
+
debug_handle_map=None,
|
|
1687
|
+
)
|
|
1688
|
+
|
|
1689
|
+
class TestModel(nn.Module):
|
|
1690
|
+
def __init__(self):
|
|
1691
|
+
super(TestModel, self).__init__()
|
|
1692
|
+
|
|
1693
|
+
def forward(self, x):
|
|
1694
|
+
return torch.cat(x)
|
|
1695
|
+
|
|
1696
|
+
inputs = ([torch.ones(2, 2), torch.ones(2, 2)],)
|
|
1697
|
+
model = TestModel()
|
|
1698
|
+
edgeir_m = to_edge(export(model, inputs, strict=True))
|
|
1699
|
+
lowered_module = to_backend(
|
|
1700
|
+
"BackendWithCompilerExample", edgeir_m.exported_program(), []
|
|
1701
|
+
)
|
|
1702
|
+
|
|
1703
|
+
class CompositeModule(torch.nn.Module):
|
|
1704
|
+
def __init__(self):
|
|
1705
|
+
super().__init__()
|
|
1706
|
+
self.lowered_module = lowered_module
|
|
1707
|
+
|
|
1708
|
+
def forward(self, list_a):
|
|
1709
|
+
return self.lowered_module(list_a)
|
|
1710
|
+
|
|
1711
|
+
composite_model = CompositeModule()
|
|
1712
|
+
exec_prog = to_edge(
|
|
1713
|
+
export(composite_model, inputs, strict=True),
|
|
1714
|
+
).to_executorch()
|
|
1715
|
+
exec_prog.buffer
|
|
1716
|
+
|
|
1717
|
+
def test_delegate_with_input_tuple(self) -> None:
|
|
1718
|
+
class BackendWithCompilerExample(BackendDetails):
|
|
1719
|
+
@staticmethod
|
|
1720
|
+
def preprocess(
|
|
1721
|
+
edge_program,
|
|
1722
|
+
compile_specs,
|
|
1723
|
+
) -> bytes:
|
|
1724
|
+
return PreprocessResult(
|
|
1725
|
+
processed_bytes=bytes(str("test"), encoding="utf8"),
|
|
1726
|
+
debug_handle_map=None,
|
|
1727
|
+
)
|
|
1728
|
+
|
|
1729
|
+
class AddMulModule(torch.nn.Module):
|
|
1730
|
+
def __init__(self):
|
|
1731
|
+
super().__init__()
|
|
1732
|
+
|
|
1733
|
+
def forward(self, input): # a, x, b):
|
|
1734
|
+
y = torch.mm(input[0], input[1])
|
|
1735
|
+
z = torch.add(y, input[2])
|
|
1736
|
+
return z
|
|
1737
|
+
|
|
1738
|
+
model_inputs = ((torch.ones(2, 2), 2 * torch.ones(2, 2), 3 * torch.ones(2, 2)),)
|
|
1739
|
+
model = AddMulModule()
|
|
1740
|
+
edgeir_m = to_edge(export(model, model_inputs, strict=True))
|
|
1741
|
+
lowered_module = to_backend(
|
|
1742
|
+
"BackendWithCompilerExample", edgeir_m.exported_program(), []
|
|
1743
|
+
)
|
|
1744
|
+
|
|
1745
|
+
class CompositeModule(torch.nn.Module):
|
|
1746
|
+
def __init__(self):
|
|
1747
|
+
super().__init__()
|
|
1748
|
+
self.lowered_module = lowered_module
|
|
1749
|
+
|
|
1750
|
+
def forward(self, list_a):
|
|
1751
|
+
return self.lowered_module(list_a)
|
|
1752
|
+
|
|
1753
|
+
composite_model = CompositeModule()
|
|
1754
|
+
exec_prog = to_edge(
|
|
1755
|
+
export(composite_model, model_inputs, strict=True),
|
|
1756
|
+
).to_executorch()
|
|
1757
|
+
exec_prog.buffer
|
|
1758
|
+
|
|
1759
|
+
def test_delegate_mapping(self) -> None:
|
|
1760
|
+
debug_handle_map = {1: [1, 2]}
|
|
1761
|
+
|
|
1762
|
+
class BackendWithCompilerExample(BackendDetails):
|
|
1763
|
+
@staticmethod
|
|
1764
|
+
def preprocess(
|
|
1765
|
+
edge_program,
|
|
1766
|
+
compile_specs,
|
|
1767
|
+
) -> bytes:
|
|
1768
|
+
return PreprocessResult(
|
|
1769
|
+
processed_bytes=bytes(str("test"), encoding="utf8"),
|
|
1770
|
+
debug_handle_map=debug_handle_map,
|
|
1771
|
+
)
|
|
1772
|
+
|
|
1773
|
+
class TestModel(nn.Module):
|
|
1774
|
+
def __init__(self):
|
|
1775
|
+
super(TestModel, self).__init__()
|
|
1776
|
+
|
|
1777
|
+
def forward(self, x, y):
|
|
1778
|
+
return torch.add(x, y)
|
|
1779
|
+
|
|
1780
|
+
inputs = (torch.ones(2, 2), torch.ones(2, 2))
|
|
1781
|
+
model = TestModel()
|
|
1782
|
+
edgeir_m = to_edge(export(model, inputs, strict=True))
|
|
1783
|
+
lowered_module = to_backend(
|
|
1784
|
+
"BackendWithCompilerExample", edgeir_m.exported_program(), []
|
|
1785
|
+
)
|
|
1786
|
+
|
|
1787
|
+
class CompositeModule(torch.nn.Module):
|
|
1788
|
+
def __init__(self):
|
|
1789
|
+
super().__init__()
|
|
1790
|
+
self.lowered_module = lowered_module
|
|
1791
|
+
|
|
1792
|
+
def forward(self, x, y):
|
|
1793
|
+
return self.lowered_module(x, y)
|
|
1794
|
+
|
|
1795
|
+
composite_model = CompositeModule()
|
|
1796
|
+
exec_prog = to_edge(
|
|
1797
|
+
export(composite_model, inputs, strict=True),
|
|
1798
|
+
).to_executorch()
|
|
1799
|
+
# Reading the program triggers the call to emit_program underneath which
|
|
1800
|
+
# we need to be done for our test to succeed.
|
|
1801
|
+
exec_prog._emitter_output.program
|
|
1802
|
+
self.assertIsNotNone(exec_prog.delegate_map)
|
|
1803
|
+
self.assertIsNotNone(exec_prog.delegate_map.get("forward"))
|
|
1804
|
+
self.assertIsNotNone(exec_prog.delegate_map.get("forward").get(0))
|
|
1805
|
+
self.assertEqual(
|
|
1806
|
+
exec_prog.delegate_map.get("forward").get(0).get("name"),
|
|
1807
|
+
"BackendWithCompilerExample",
|
|
1808
|
+
)
|
|
1809
|
+
self.assertTrue(
|
|
1810
|
+
len(exec_prog.delegate_map.get("forward").get(0).get("delegate_map")) != 0
|
|
1811
|
+
)
|
|
1812
|
+
|
|
1813
|
+
def test_emit_weight_view(self) -> None:
|
|
1814
|
+
class ModWithWeightViews(nn.Module):
|
|
1815
|
+
def __init__(self):
|
|
1816
|
+
super(ModWithWeightViews, self).__init__()
|
|
1817
|
+
self.W = torch.nn.Parameter(torch.randn(2))
|
|
1818
|
+
self.W1 = self.W[:1]
|
|
1819
|
+
self.W2 = self.W[1:]
|
|
1820
|
+
|
|
1821
|
+
def forward(self, x):
|
|
1822
|
+
return self.W1 + self.W2 + x
|
|
1823
|
+
|
|
1824
|
+
model = ModWithWeightViews()
|
|
1825
|
+
# each weight is a view of the same storage
|
|
1826
|
+
self.assertEqual(model.W1.nbytes, 4)
|
|
1827
|
+
self.assertEqual(model.W1.untyped_storage().nbytes(), 8)
|
|
1828
|
+
self.assertEqual(model.W2.nbytes, 4)
|
|
1829
|
+
self.assertEqual(model.W2.untyped_storage().nbytes(), 8)
|
|
1830
|
+
program = to_edge(export(model, (torch.ones(1),), strict=True)).to_executorch()
|
|
1831
|
+
|
|
1832
|
+
program = program._emitter_output.program
|
|
1833
|
+
# each emitted weight is not a view
|
|
1834
|
+
self.assertEqual(len(program.constant_buffer[1].storage), 4)
|
|
1835
|
+
self.assertEqual(len(program.constant_buffer[2].storage), 4)
|
|
1836
|
+
|
|
1837
|
+
def test_non_persistent_buffer(self) -> None:
|
|
1838
|
+
class NonPersistentBuffer(nn.Module):
|
|
1839
|
+
def __init__(self):
|
|
1840
|
+
super(NonPersistentBuffer, self).__init__()
|
|
1841
|
+
self.register_buffer("buf", torch.tensor([1]), persistent=False)
|
|
1842
|
+
|
|
1843
|
+
def forward(self, x):
|
|
1844
|
+
return x + self.buf
|
|
1845
|
+
|
|
1846
|
+
model = NonPersistentBuffer()
|
|
1847
|
+
program = to_edge(export(model, (torch.ones(1),), strict=True)).to_executorch()
|
|
1848
|
+
program = program._emitter_output.program
|
|
1849
|
+
# confirm that the buffer was emitted
|
|
1850
|
+
self.assertEqual(len(program.constant_buffer), 2)
|
|
1851
|
+
self.assertEqual(len(program.constant_buffer[1].storage), 8)
|
|
1852
|
+
|
|
1853
|
+
def test_emit_lifted_tensor_constant(self) -> None:
|
|
1854
|
+
class LiftedTensorConstants(nn.Module):
|
|
1855
|
+
def __init__(self):
|
|
1856
|
+
super().__init__()
|
|
1857
|
+
|
|
1858
|
+
def forward(self, x):
|
|
1859
|
+
x = x * torch.tensor([[4, 3], [1, 2], [5, 6]], dtype=torch.float)
|
|
1860
|
+
return x
|
|
1861
|
+
|
|
1862
|
+
model = LiftedTensorConstants()
|
|
1863
|
+
# Specify that we want to move non-lifted constants to external file
|
|
1864
|
+
et_cfg = ExecutorchBackendConfig(external_constants=True)
|
|
1865
|
+
program = to_edge(
|
|
1866
|
+
export(model, (torch.ones(3, 2),), strict=True)
|
|
1867
|
+
).to_executorch(et_cfg)
|
|
1868
|
+
program = program._emitter_output.program
|
|
1869
|
+
exec_plan = program.execution_plan[0]
|
|
1870
|
+
# There should only be 1 input to this model.
|
|
1871
|
+
self.assertEqual(len(exec_plan.inputs), 1)
|
|
1872
|
+
self.assertEqual(len(program.constant_buffer), 2)
|
|
1873
|
+
self.assertEqual(len(program.constant_buffer[1].storage), 24)
|
|
1874
|
+
|
|
1875
|
+
def test_emit_lifted_constant(self) -> None:
|
|
1876
|
+
class LiftedConstants(nn.Module):
|
|
1877
|
+
def __init__(self):
|
|
1878
|
+
super().__init__()
|
|
1879
|
+
|
|
1880
|
+
def forward(self, x):
|
|
1881
|
+
x = x + 1
|
|
1882
|
+
return x
|
|
1883
|
+
|
|
1884
|
+
model = LiftedConstants()
|
|
1885
|
+
# Specify that we want to move non-lifted constants to external file
|
|
1886
|
+
et_cfg = ExecutorchBackendConfig(external_constants=True)
|
|
1887
|
+
program = to_edge(
|
|
1888
|
+
export(model, (torch.ones(3, 2),), strict=True)
|
|
1889
|
+
).to_executorch(et_cfg)
|
|
1890
|
+
|
|
1891
|
+
program = program._emitter_output.program
|
|
1892
|
+
exec_plan = program.execution_plan[0]
|
|
1893
|
+
# There should only be 1 input to this model.
|
|
1894
|
+
self.assertEqual(len(exec_plan.inputs), 1)
|
|
1895
|
+
self.assertEqual(len(program.constant_buffer), 2)
|
|
1896
|
+
self.assertEqual(len(program.constant_buffer[1].storage), 8)
|
|
1897
|
+
|
|
1898
|
+
def test_mutable_buffers(self) -> None:
|
|
1899
|
+
def count_copies(gm: torch.fx.GraphModule) -> int:
|
|
1900
|
+
return sum(
|
|
1901
|
+
(
|
|
1902
|
+
node.target == torch.ops.aten.copy_
|
|
1903
|
+
or node.target == exir_ops.edge.aten.copy_.default
|
|
1904
|
+
)
|
|
1905
|
+
for node in gm.graph.nodes
|
|
1906
|
+
)
|
|
1907
|
+
|
|
1908
|
+
class MutableStateModule(torch.nn.Module):
|
|
1909
|
+
def __init__(self):
|
|
1910
|
+
super().__init__()
|
|
1911
|
+
self.register_buffer("state", torch.zeros(1))
|
|
1912
|
+
|
|
1913
|
+
def forward(self, x):
|
|
1914
|
+
y = x + self.state
|
|
1915
|
+
self.state.add_(1)
|
|
1916
|
+
return y
|
|
1917
|
+
|
|
1918
|
+
model = to_edge(export(MutableStateModule(), (torch.zeros(1),), strict=True))
|
|
1919
|
+
model = model.to_executorch()
|
|
1920
|
+
self.assertTrue(
|
|
1921
|
+
model.executorch_program.execution_plan[0].values[0].val.allocation_info
|
|
1922
|
+
is not None
|
|
1923
|
+
)
|
|
1924
|
+
executorch_module = _load_for_executorch_from_buffer(model.buffer)
|
|
1925
|
+
self.assertEqual(executorch_module(torch.zeros(1))[0], torch.zeros(1))
|
|
1926
|
+
self.assertEqual(executorch_module(torch.zeros(1))[0], torch.zeros(1) + 1)
|
|
1927
|
+
|
|
1928
|
+
def test_mutable_buffers_without_memplanned_inputs(self) -> None:
|
|
1929
|
+
def count_copies(gm: torch.fx.GraphModule) -> int:
|
|
1930
|
+
return sum(
|
|
1931
|
+
(
|
|
1932
|
+
node.target == torch.ops.aten.copy_
|
|
1933
|
+
or node.target == exir_ops.edge.aten.copy_.default
|
|
1934
|
+
)
|
|
1935
|
+
for node in gm.graph.nodes
|
|
1936
|
+
)
|
|
1937
|
+
|
|
1938
|
+
class MutableStateModule(torch.nn.Module):
|
|
1939
|
+
def __init__(self):
|
|
1940
|
+
super().__init__()
|
|
1941
|
+
self.register_buffer("state", torch.zeros(1))
|
|
1942
|
+
|
|
1943
|
+
def forward(self, x):
|
|
1944
|
+
y = x + self.state
|
|
1945
|
+
self.state.add_(1)
|
|
1946
|
+
return y
|
|
1947
|
+
|
|
1948
|
+
model = to_edge(export(MutableStateModule(), (torch.zeros(1),), strict=True))
|
|
1949
|
+
model = model.to_executorch(
|
|
1950
|
+
config=ExecutorchBackendConfig(
|
|
1951
|
+
memory_planning_pass=MemoryPlanningPass(alloc_graph_input=False),
|
|
1952
|
+
sym_shape_eval_pass=ConstraintBasedSymShapeEvalPass(),
|
|
1953
|
+
)
|
|
1954
|
+
)
|
|
1955
|
+
model.dump_executorch_program(True)
|
|
1956
|
+
self.assertTrue(
|
|
1957
|
+
model.executorch_program.execution_plan[0].values[0].val.allocation_info
|
|
1958
|
+
is not None
|
|
1959
|
+
)
|
|
1960
|
+
executorch_module = _load_for_executorch_from_buffer(model.buffer)
|
|
1961
|
+
self.assertEqual(executorch_module(torch.zeros(1))[0], torch.zeros(1))
|
|
1962
|
+
self.assertEqual(executorch_module(torch.zeros(1))[0], torch.zeros(1) + 1)
|
|
1963
|
+
|
|
1964
|
+
def test_infinity_in_model(self) -> None:
|
|
1965
|
+
class InfinityMaskModel(nn.Module):
|
|
1966
|
+
def __init__(self):
|
|
1967
|
+
super().__init__()
|
|
1968
|
+
self.mask = torch.tensor([[1, 0], [0, 1]], dtype=torch.float32)
|
|
1969
|
+
|
|
1970
|
+
def forward(self, x):
|
|
1971
|
+
masked_weights = x.masked_fill(self.mask == 0, float("-inf"))
|
|
1972
|
+
return masked_weights
|
|
1973
|
+
|
|
1974
|
+
model = to_edge(export(InfinityMaskModel(), (torch.randn(2, 2),), strict=True))
|
|
1975
|
+
|
|
1976
|
+
# Confirm that we can serialize the model with infinity in it.
|
|
1977
|
+
model = model.to_executorch()
|
|
1978
|
+
|
|
1979
|
+
# Assert that the infinity is stored as a string "-inf".
|
|
1980
|
+
values = model.executorch_program.execution_plan[0].values
|
|
1981
|
+
self.assertEqual(values[5].val, Double(double_val=float("-inf")))
|
|
1982
|
+
|
|
1983
|
+
# Confirm that we can also deserialize the model with infinity in it.
|
|
1984
|
+
deserialize = deserialize_pte_binary(model.buffer)
|
|
1985
|
+
self.assertEqual(
|
|
1986
|
+
deserialize.program.execution_plan,
|
|
1987
|
+
model.executorch_program.execution_plan,
|
|
1988
|
+
)
|
|
1989
|
+
|
|
1990
|
+
def test_mutate_input_tensor(self) -> None:
|
|
1991
|
+
class MutateInputTensorModule(torch.nn.Module):
|
|
1992
|
+
def __init__(self):
|
|
1993
|
+
super().__init__()
|
|
1994
|
+
|
|
1995
|
+
def forward(self, x):
|
|
1996
|
+
x.add_(1)
|
|
1997
|
+
|
|
1998
|
+
model = to_edge(
|
|
1999
|
+
export(MutateInputTensorModule(), (torch.zeros(1),), strict=True)
|
|
2000
|
+
).to_executorch(
|
|
2001
|
+
config=ExecutorchBackendConfig(
|
|
2002
|
+
memory_planning_pass=MemoryPlanningPass(alloc_graph_input=False)
|
|
2003
|
+
)
|
|
2004
|
+
)
|
|
2005
|
+
executorch_model = _load_for_executorch_from_buffer(model.buffer)
|
|
2006
|
+
input = torch.zeros(1)
|
|
2007
|
+
executorch_model(input)
|
|
2008
|
+
self.assertEqual(input, torch.ones(1))
|
|
2009
|
+
|
|
2010
|
+
def test_constant_tagged_tensors(self) -> None:
|
|
2011
|
+
class LinearModule(torch.nn.Module):
|
|
2012
|
+
def __init__(self):
|
|
2013
|
+
super().__init__()
|
|
2014
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
2015
|
+
|
|
2016
|
+
def forward(self, x):
|
|
2017
|
+
return self.linear(x)
|
|
2018
|
+
|
|
2019
|
+
model = to_edge(
|
|
2020
|
+
export(LinearModule(), (torch.ones(5, 5),), strict=True)
|
|
2021
|
+
).to_executorch(
|
|
2022
|
+
config=ExecutorchBackendConfig(
|
|
2023
|
+
external_constants=True,
|
|
2024
|
+
)
|
|
2025
|
+
)
|
|
2026
|
+
emitter_output = model._emitter_output
|
|
2027
|
+
# Check that constant_buffer is empty besides the non-constant placeholder 0.
|
|
2028
|
+
self.assertEqual(len(emitter_output.program.constant_buffer), 1)
|
|
2029
|
+
# Check that constant weights are in the external constant buffer.
|
|
2030
|
+
self.assertEqual(len(emitter_output.external_constant_buffer), 2)
|
|
2031
|
+
# Setting external_constants=True, saves all constants to the key
|
|
2032
|
+
# '_default_external_constant'.
|
|
2033
|
+
external_map = emitter_output.external_constant_map[
|
|
2034
|
+
"_default_external_constant"
|
|
2035
|
+
]
|
|
2036
|
+
self.assertEqual(len(external_map), 2)
|
|
2037
|
+
self.assertEqual(external_map["linear.weight"], 0)
|
|
2038
|
+
self.assertEqual(external_map["linear.bias"], 1)
|
|
2039
|
+
|
|
2040
|
+
def test_constant_tagged_tensors_custom(self) -> None:
|
|
2041
|
+
class LinearModule(torch.nn.Module):
|
|
2042
|
+
def __init__(self):
|
|
2043
|
+
super().__init__()
|
|
2044
|
+
self.linear = torch.nn.Linear(5, 5)
|
|
2045
|
+
|
|
2046
|
+
def forward(self, x):
|
|
2047
|
+
return self.linear(x)
|
|
2048
|
+
|
|
2049
|
+
model = to_edge(
|
|
2050
|
+
export(LinearModule(), (torch.ones(5, 5),), strict=True)
|
|
2051
|
+
).to_executorch(
|
|
2052
|
+
config=ExecutorchBackendConfig(
|
|
2053
|
+
external_constants=lambda x: (
|
|
2054
|
+
"linear_weight" if "weight" in x.name else None
|
|
2055
|
+
),
|
|
2056
|
+
)
|
|
2057
|
+
)
|
|
2058
|
+
emitter_output = model._emitter_output
|
|
2059
|
+
# constant_buffer contains placeholder and linear bias.
|
|
2060
|
+
self.assertEqual(len(emitter_output.program.constant_buffer), 2)
|
|
2061
|
+
# external constant buffer contains linear weight.
|
|
2062
|
+
self.assertEqual(len(emitter_output.external_constant_buffer), 1)
|
|
2063
|
+
# The lambda saves all constants to the key 'linear_weight'.
|
|
2064
|
+
external_map = emitter_output.external_constant_map["linear_weight"]
|
|
2065
|
+
self.assertEqual(len(external_map), 1)
|
|
2066
|
+
self.assertEqual(external_map["linear.weight"], 0)
|
|
2067
|
+
|
|
2068
|
+
def test_constant_tagged_tensor_dedup(self) -> None:
|
|
2069
|
+
class ConstantModule(nn.Module):
|
|
2070
|
+
def __init__(self):
|
|
2071
|
+
super().__init__()
|
|
2072
|
+
constant = torch.tensor([1.0, 2.0, 3.0])
|
|
2073
|
+
|
|
2074
|
+
# Register the same value with two different names as persistent buffers
|
|
2075
|
+
self.register_buffer("c0", constant.clone(), persistent=True)
|
|
2076
|
+
self.register_buffer("c1", constant.clone(), persistent=True)
|
|
2077
|
+
|
|
2078
|
+
def forward(self, x):
|
|
2079
|
+
return x + self.c0 + self.c1
|
|
2080
|
+
|
|
2081
|
+
model = to_edge(
|
|
2082
|
+
export(ConstantModule(), (torch.ones(1, 3),), strict=True)
|
|
2083
|
+
).to_executorch(
|
|
2084
|
+
config=ExecutorchBackendConfig(
|
|
2085
|
+
external_constants=True,
|
|
2086
|
+
)
|
|
2087
|
+
)
|
|
2088
|
+
emitter_output = model._emitter_output
|
|
2089
|
+
# constant_buffer is empty besides the non-constant placeholder 0.
|
|
2090
|
+
self.assertEqual(len(emitter_output.program.constant_buffer), 1)
|
|
2091
|
+
# only one item in the external constant buffer.
|
|
2092
|
+
self.assertEqual(len(emitter_output.external_constant_buffer), 1)
|
|
2093
|
+
# Setting external_constants=True, saves all constants to the key
|
|
2094
|
+
# '_default_external_constant'.
|
|
2095
|
+
external_map = emitter_output.external_constant_map[
|
|
2096
|
+
"_default_external_constant"
|
|
2097
|
+
]
|
|
2098
|
+
self.assertEqual(len(external_map), 2)
|
|
2099
|
+
self.assertEqual(external_map["c0"], 0)
|
|
2100
|
+
self.assertEqual(external_map["c1"], 0)
|
|
2101
|
+
|
|
2102
|
+
def test_constant_tagged_tensor_dedup_2(self) -> None:
|
|
2103
|
+
class ConstantModule(nn.Module):
|
|
2104
|
+
def __init__(self):
|
|
2105
|
+
super().__init__()
|
|
2106
|
+
constant0_4 = torch.tensor([1.0, 2.0, 3.0])
|
|
2107
|
+
constant4_5 = torch.tensor([2.0, 3.0, 4.0])
|
|
2108
|
+
|
|
2109
|
+
# Register the same value with two different names as persistent buffers
|
|
2110
|
+
self.register_buffer("c0", constant0_4.clone(), persistent=True)
|
|
2111
|
+
self.register_buffer("c1", constant0_4.clone(), persistent=True)
|
|
2112
|
+
self.register_buffer("c2", constant0_4.clone(), persistent=True)
|
|
2113
|
+
self.register_buffer("c3", constant0_4.clone(), persistent=True)
|
|
2114
|
+
self.register_buffer("c4", constant4_5.clone(), persistent=True)
|
|
2115
|
+
self.register_buffer("c5", constant4_5.clone(), persistent=True)
|
|
2116
|
+
|
|
2117
|
+
def forward(self, x):
|
|
2118
|
+
return x + self.c0 + self.c1 + self.c2 + self.c3 + self.c4 + self.c5
|
|
2119
|
+
|
|
2120
|
+
model = to_edge(
|
|
2121
|
+
export(ConstantModule(), (torch.ones(1, 3),), strict=True)
|
|
2122
|
+
).to_executorch(
|
|
2123
|
+
config=ExecutorchBackendConfig(
|
|
2124
|
+
external_constants=True,
|
|
2125
|
+
)
|
|
2126
|
+
)
|
|
2127
|
+
emitter_output = model._emitter_output
|
|
2128
|
+
# constant_buffer is empty besides the non-constant placeholder 0.
|
|
2129
|
+
self.assertEqual(len(emitter_output.program.constant_buffer), 1)
|
|
2130
|
+
# Two items in the external constant buffer.
|
|
2131
|
+
self.assertEqual(len(emitter_output.external_constant_buffer), 2)
|
|
2132
|
+
# Setting external_constants=True, saves all constants to the key
|
|
2133
|
+
# '_default_external_constant'.
|
|
2134
|
+
external_map = emitter_output.external_constant_map[
|
|
2135
|
+
"_default_external_constant"
|
|
2136
|
+
]
|
|
2137
|
+
self.assertEqual(len(external_map), 6)
|
|
2138
|
+
self.assertEqual(external_map["c0"], 0)
|
|
2139
|
+
self.assertEqual(external_map["c1"], 0)
|
|
2140
|
+
self.assertEqual(external_map["c2"], 0)
|
|
2141
|
+
self.assertEqual(external_map["c3"], 0)
|
|
2142
|
+
self.assertEqual(external_map["c4"], 1)
|
|
2143
|
+
self.assertEqual(external_map["c5"], 1)
|
|
2144
|
+
|
|
2145
|
+
def test_delegate_deduplicate(self) -> None:
|
|
2146
|
+
class SharedModule(torch.nn.Module):
|
|
2147
|
+
def __init__(self):
|
|
2148
|
+
super().__init__()
|
|
2149
|
+
self.linear = torch.nn.Linear(2, 2)
|
|
2150
|
+
|
|
2151
|
+
def forward(self, x):
|
|
2152
|
+
return self.linear(x)
|
|
2153
|
+
|
|
2154
|
+
class Module1(torch.nn.Module):
|
|
2155
|
+
def __init__(self, shared_module):
|
|
2156
|
+
super().__init__()
|
|
2157
|
+
self.shared_module = shared_module
|
|
2158
|
+
|
|
2159
|
+
def forward(self, x):
|
|
2160
|
+
return self.shared_module(x)
|
|
2161
|
+
|
|
2162
|
+
class Module2(torch.nn.Module):
|
|
2163
|
+
def __init__(self, shared_module):
|
|
2164
|
+
super().__init__()
|
|
2165
|
+
self.shared_module = shared_module
|
|
2166
|
+
|
|
2167
|
+
def forward(self, x):
|
|
2168
|
+
return self.shared_module(x)
|
|
2169
|
+
|
|
2170
|
+
shared_module = SharedModule()
|
|
2171
|
+
module_1 = Module1(shared_module)
|
|
2172
|
+
module_2 = Module2(shared_module)
|
|
2173
|
+
example_inputs = (torch.randn(2, 2),)
|
|
2174
|
+
module_1(*example_inputs)
|
|
2175
|
+
module_2(*example_inputs)
|
|
2176
|
+
|
|
2177
|
+
ep1 = export(module_1, example_inputs, strict=True)
|
|
2178
|
+
ep2 = export(module_2, example_inputs, strict=True)
|
|
2179
|
+
|
|
2180
|
+
edge_program_manager = exir.to_edge(
|
|
2181
|
+
{"forward1": ep1, "forward2": ep2},
|
|
2182
|
+
compile_config=exir.EdgeCompileConfig(
|
|
2183
|
+
_check_ir_validity=False, _use_edge_ops=True
|
|
2184
|
+
),
|
|
2185
|
+
)
|
|
2186
|
+
|
|
2187
|
+
edge_program_manager = edge_program_manager.to_backend(
|
|
2188
|
+
ExecutorBackendPartitioner()
|
|
2189
|
+
).to_executorch()
|
|
2190
|
+
|
|
2191
|
+
# Check that there is only one delegate because two methods are exactly the same
|
|
2192
|
+
self.assertEqual(
|
|
2193
|
+
len(edge_program_manager.executorch_program.backend_delegate_data), 1
|
|
2194
|
+
)
|
|
2195
|
+
|
|
2196
|
+
def test_delegate_deduplicate_with_different_compile_specs(self) -> None:
|
|
2197
|
+
class LowerableSubModel(torch.nn.Module):
|
|
2198
|
+
def __init__(self):
|
|
2199
|
+
super().__init__()
|
|
2200
|
+
|
|
2201
|
+
def forward(self, x):
|
|
2202
|
+
return torch.sin(x)
|
|
2203
|
+
|
|
2204
|
+
lowered = LowerableSubModel()
|
|
2205
|
+
example_input = (torch.ones(1),)
|
|
2206
|
+
|
|
2207
|
+
lowered_edge = to_edge(export(lowered, example_input))
|
|
2208
|
+
|
|
2209
|
+
from executorch.exir.backend.compile_spec_schema import CompileSpec
|
|
2210
|
+
|
|
2211
|
+
compile_specs1 = [CompileSpec("config", b"fast")]
|
|
2212
|
+
compile_specs2 = [CompileSpec("config", b"small")]
|
|
2213
|
+
lowered_module1 = to_backend(
|
|
2214
|
+
"BackendWithCompilerDemo", lowered_edge.exported_program(), compile_specs1
|
|
2215
|
+
)
|
|
2216
|
+
lowered_module2 = to_backend(
|
|
2217
|
+
"BackendWithCompilerDemo", lowered_edge.exported_program(), compile_specs2
|
|
2218
|
+
)
|
|
2219
|
+
|
|
2220
|
+
class CompositeModel(torch.nn.Module):
|
|
2221
|
+
def __init__(self):
|
|
2222
|
+
super().__init__()
|
|
2223
|
+
self.lowerable1 = lowered_module1
|
|
2224
|
+
self.lowerable2 = lowered_module2
|
|
2225
|
+
|
|
2226
|
+
def forward(self, x):
|
|
2227
|
+
a = self.lowerable1(x)
|
|
2228
|
+
b = self.lowerable2(a)
|
|
2229
|
+
return a, b
|
|
2230
|
+
|
|
2231
|
+
composite_model = CompositeModel()
|
|
2232
|
+
model_inputs = (torch.ones(1),)
|
|
2233
|
+
edge_prog = to_edge(export(composite_model, model_inputs)).to_executorch()
|
|
2234
|
+
|
|
2235
|
+
exported_program = edge_prog.exported_program()
|
|
2236
|
+
program = emit_program({"method1": exported_program}, False).program
|
|
2237
|
+
self.assertEqual(len(program.execution_plan), 1)
|
|
2238
|
+
|
|
2239
|
+
plan = program.execution_plan[0]
|
|
2240
|
+
# Two delegates that point to the same blob.
|
|
2241
|
+
self.assertEqual(len(plan.delegates), 2)
|
|
2242
|
+
self.assertEqual(plan.delegates[0].processed.index, 0)
|
|
2243
|
+
self.assertEqual(plan.delegates[1].processed.index, 0)
|
|
2244
|
+
# Compile specs are different.
|
|
2245
|
+
self.assertEqual(plan.delegates[0].compile_specs, compile_specs1)
|
|
2246
|
+
self.assertEqual(plan.delegates[1].compile_specs, compile_specs2)
|
|
2247
|
+
# Only one delegate blob in the backend_delegate_data.
|
|
2248
|
+
self.assertEqual(len(program.backend_delegate_data), 1)
|
|
2249
|
+
|
|
2250
|
+
def test_constant_tagged_mutable_tensors(self) -> None:
|
|
2251
|
+
class Net(nn.Module):
|
|
2252
|
+
def __init__(self):
|
|
2253
|
+
super().__init__()
|
|
2254
|
+
self.linear = nn.Linear(2, 2)
|
|
2255
|
+
|
|
2256
|
+
def forward(self, x):
|
|
2257
|
+
return self.linear(x)
|
|
2258
|
+
|
|
2259
|
+
# On device training requires the loss to be embedded in the model (and be the first output).
|
|
2260
|
+
# We wrap the original model here and add the loss calculation. This will be the model we export.
|
|
2261
|
+
class TrainingNet(nn.Module):
|
|
2262
|
+
def __init__(self, net):
|
|
2263
|
+
super().__init__()
|
|
2264
|
+
self.net = net
|
|
2265
|
+
self.loss = nn.CrossEntropyLoss()
|
|
2266
|
+
|
|
2267
|
+
def forward(self, input, label):
|
|
2268
|
+
pred = self.net(input)
|
|
2269
|
+
return self.loss(pred, label), pred.detach().argmax(dim=1)
|
|
2270
|
+
|
|
2271
|
+
net = TrainingNet(Net())
|
|
2272
|
+
|
|
2273
|
+
# Captures the forward graph. The graph will look similar to the model definition now.
|
|
2274
|
+
ep = export(
|
|
2275
|
+
net, (torch.randn(1, 2), torch.ones(1, dtype=torch.int64)), strict=True
|
|
2276
|
+
)
|
|
2277
|
+
# Captures the backward graph. The exported_program now contains the joint forward and backward graph.
|
|
2278
|
+
ep = _export_forward_backward(ep)
|
|
2279
|
+
# Lower the graph to edge dialect.
|
|
2280
|
+
ep = to_edge(ep)
|
|
2281
|
+
# Lower the graph to executorch.
|
|
2282
|
+
ep = ep.to_executorch(
|
|
2283
|
+
config=ExecutorchBackendConfig(external_mutable_weights=True)
|
|
2284
|
+
)
|
|
2285
|
+
|
|
2286
|
+
emitter_output = ep._emitter_output
|
|
2287
|
+
# Check that constant_buffer is empty besides the non-constant placeholder 0.
|
|
2288
|
+
self.assertEqual(len(emitter_output.program.constant_buffer), 1)
|
|
2289
|
+
# Check that constant weights are in the external constant buffer.
|
|
2290
|
+
self.assertEqual(len(emitter_output.external_constant_buffer), 2)
|
|
2291
|
+
# Setting external_mutable_weights=True, saves all constants with an associated gradient to the key
|
|
2292
|
+
# '_default_external_constant'.
|
|
2293
|
+
external_map = emitter_output.external_constant_map[
|
|
2294
|
+
"_default_external_constant"
|
|
2295
|
+
]
|
|
2296
|
+
self.assertEqual(external_map["net.linear.weight"], 0)
|
|
2297
|
+
self.assertEqual(external_map["net.linear.bias"], 1)
|
|
2298
|
+
|
|
2299
|
+
def test_emit_mutable_buffer_names(self) -> None:
|
|
2300
|
+
class Net(nn.Module):
|
|
2301
|
+
def __init__(self):
|
|
2302
|
+
super().__init__()
|
|
2303
|
+
self.linear = nn.Linear(2, 2)
|
|
2304
|
+
self.register_buffer("buffer", torch.zeros(1, 2))
|
|
2305
|
+
|
|
2306
|
+
def forward(self, x):
|
|
2307
|
+
self.buffer.add_(1)
|
|
2308
|
+
return self.linear(x) + self.buffer
|
|
2309
|
+
|
|
2310
|
+
net = Net()
|
|
2311
|
+
|
|
2312
|
+
ep = export(net, (torch.randn(1, 2),), strict=True)
|
|
2313
|
+
# Lower the graph to edge dialect.
|
|
2314
|
+
ep = to_edge(ep)
|
|
2315
|
+
# Lower the graph to executorch.
|
|
2316
|
+
ep = ep.to_executorch(
|
|
2317
|
+
config=ExecutorchBackendConfig(
|
|
2318
|
+
emit_mutable_buffer_names=True,
|
|
2319
|
+
memory_planning_pass=MemoryPlanningPass(alloc_mutable_buffers=False),
|
|
2320
|
+
)
|
|
2321
|
+
)
|
|
2322
|
+
for val in ep.executorch_program.execution_plan[0].values:
|
|
2323
|
+
if isinstance(val, Tensor) and val.extra_tensor_info:
|
|
2324
|
+
self.assertEqual(val.extra_tensor_info.fully_qualified_name, "buffer")
|
|
2325
|
+
self.assertEqual(val.allocation_info, None)
|
|
2326
|
+
|
|
2327
|
+
def test_emit_mutable_buffer_names_fails(self) -> None:
|
|
2328
|
+
class Net(nn.Module):
|
|
2329
|
+
def __init__(self):
|
|
2330
|
+
super().__init__()
|
|
2331
|
+
self.linear = nn.Linear(2, 2)
|
|
2332
|
+
self.register_buffer("buffer", torch.zeros(1, 2))
|
|
2333
|
+
|
|
2334
|
+
def forward(self, x):
|
|
2335
|
+
self.buffer.add_(1)
|
|
2336
|
+
return self.linear(x) + self.buffer
|
|
2337
|
+
|
|
2338
|
+
net = Net()
|
|
2339
|
+
|
|
2340
|
+
ep = export(net, (torch.randn(1, 2),), strict=True)
|
|
2341
|
+
# Lower the graph to edge dialect.
|
|
2342
|
+
ep = to_edge(ep)
|
|
2343
|
+
# Lower the graph to executorch.
|
|
2344
|
+
# Must emit mutable buffer names if we don't allocate mutable buffers
|
|
2345
|
+
with self.assertRaises(InternalError):
|
|
2346
|
+
ep.to_executorch(
|
|
2347
|
+
config=ExecutorchBackendConfig(
|
|
2348
|
+
emit_mutable_buffer_names=False,
|
|
2349
|
+
memory_planning_pass=MemoryPlanningPass(
|
|
2350
|
+
alloc_mutable_buffers=False
|
|
2351
|
+
),
|
|
2352
|
+
)
|
|
2353
|
+
)
|
|
2354
|
+
|
|
2355
|
+
def test_emit_sym_min_max(self) -> None:
|
|
2356
|
+
class SymMaxModel(nn.Module):
|
|
2357
|
+
def __init__(self, test_min=False):
|
|
2358
|
+
super().__init__()
|
|
2359
|
+
self.test_min = test_min
|
|
2360
|
+
|
|
2361
|
+
def forward(self, x):
|
|
2362
|
+
# Get size of 0th dimension - this creates sym_size op
|
|
2363
|
+
batch_size = x.shape[0]
|
|
2364
|
+
# Compute max of batch_size and 10 - this should create sym_max op
|
|
2365
|
+
if self.test_min:
|
|
2366
|
+
out_size = min(batch_size, 10)
|
|
2367
|
+
else:
|
|
2368
|
+
out_size = max(batch_size, 10)
|
|
2369
|
+
# Create a 1D tensor of zeros with the computed size
|
|
2370
|
+
result = torch.zeros(out_size, dtype=x.dtype, device=x.device)
|
|
2371
|
+
return result
|
|
2372
|
+
|
|
2373
|
+
for validate_min in [True, False]:
|
|
2374
|
+
model = SymMaxModel(test_min=validate_min)
|
|
2375
|
+
test_inputs = [
|
|
2376
|
+
torch.randn(5, 3), # should output zeros(10) for max zeros(5) for min
|
|
2377
|
+
torch.randn(15, 3), # should output zeros(15) for max zeros(10) for min
|
|
2378
|
+
torch.randn(10, 3), # should output zeros(10) for max zeros(10) for min
|
|
2379
|
+
]
|
|
2380
|
+
model.eval()
|
|
2381
|
+
reference_outputs = []
|
|
2382
|
+
with torch.no_grad():
|
|
2383
|
+
for _, inp in enumerate(test_inputs):
|
|
2384
|
+
output = model(inp)
|
|
2385
|
+
reference_outputs.append(output)
|
|
2386
|
+
|
|
2387
|
+
batch_dim = Dim("batch", min=1, max=20)
|
|
2388
|
+
dynamic_shapes = {"x": {0: batch_dim}} # 0th dimension is dynamic
|
|
2389
|
+
exported_program = torch.export.export(
|
|
2390
|
+
model, (test_inputs[0],), dynamic_shapes=dynamic_shapes
|
|
2391
|
+
)
|
|
2392
|
+
edge_program = to_edge(
|
|
2393
|
+
exported_program,
|
|
2394
|
+
compile_config=exir.EdgeCompileConfig(_check_ir_validity=False),
|
|
2395
|
+
)
|
|
2396
|
+
et_program = edge_program.to_executorch()
|
|
2397
|
+
program_buffer = et_program.buffer
|
|
2398
|
+
et_module = _load_for_executorch_from_buffer(program_buffer)
|
|
2399
|
+
for _, (inp, expected) in enumerate(zip(test_inputs, reference_outputs)):
|
|
2400
|
+
# Execute with ExecuTorch
|
|
2401
|
+
et_output = et_module.forward([inp])
|
|
2402
|
+
et_result = et_output[0] # Get first output
|
|
2403
|
+
# Compare results
|
|
2404
|
+
self.assertTrue(expected.shape == et_result.shape)
|
|
2405
|
+
self.assertTrue(torch.allclose(expected, et_result))
|