executorch 0.2.1__cp39-cp39-macosx_11_0_arm64.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/apple/coreml/compiler/__init__.py +9 -0
- executorch/backends/apple/coreml/compiler/coreml_preprocess.py +376 -0
- executorch/backends/apple/coreml/partition/coreml_partitioner.py +95 -0
- executorch/backends/apple/coreml/quantizer/coreml_quantizer.py +7 -0
- executorch/backends/apple/coreml/runtime/inmemoryfs/setup.py +52 -0
- executorch/backends/apple/coreml/test/test_coreml_partitioner.py +78 -0
- executorch/backends/apple/coreml/test/test_coreml_quantizer.py +112 -0
- executorch/backends/apple/mps/mps_preprocess.py +195 -0
- executorch/backends/apple/mps/operators/__init__.py +70 -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 +109 -0
- executorch/backends/apple/mps/operators/convolution_ops.py +70 -0
- executorch/backends/apple/mps/operators/indexing_ops.py +145 -0
- executorch/backends/apple/mps/operators/linear_algebra_ops.py +52 -0
- executorch/backends/apple/mps/operators/node_visitor.py +406 -0
- executorch/backends/apple/mps/operators/normalization_ops.py +97 -0
- executorch/backends/apple/mps/operators/op_clone.py +35 -0
- executorch/backends/apple/mps/operators/op_getitem.py +29 -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 +260 -0
- executorch/backends/apple/mps/operators/unary_ops.py +130 -0
- executorch/backends/apple/mps/partition/mps_partitioner.py +140 -0
- executorch/backends/apple/mps/serialization/mps_graph_schema.py +769 -0
- executorch/backends/apple/mps/serialization/mps_graph_serialize.py +30 -0
- executorch/backends/apple/mps/serialization/schema.fbs +469 -0
- executorch/backends/apple/mps/test/test_mps.py +2449 -0
- executorch/backends/apple/mps/test/test_mps_binary_ops.py +296 -0
- executorch/backends/apple/mps/test/test_mps_indexing_ops.py +225 -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 +306 -0
- executorch/backends/apple/mps/utils/mps_utils.py +81 -0
- executorch/backends/arm/arm_backend.py +226 -0
- executorch/backends/arm/arm_partitioner.py +94 -0
- executorch/backends/arm/arm_quantizer.py +464 -0
- executorch/backends/arm/arm_quantizer_utils.py +1040 -0
- executorch/backends/arm/arm_vela.py +95 -0
- executorch/backends/arm/operators/__init__.py +23 -0
- executorch/backends/arm/operators/node_visitor.py +46 -0
- executorch/backends/arm/operators/op_add.py +107 -0
- executorch/backends/arm/operators/op_addmm.py +164 -0
- executorch/backends/arm/operators/op_avg_pool2d.py +49 -0
- executorch/backends/arm/operators/op_batch_norm.py +101 -0
- executorch/backends/arm/operators/op_clone.py +34 -0
- executorch/backends/arm/operators/op_common.py +52 -0
- executorch/backends/arm/operators/op_conv2d.py +169 -0
- executorch/backends/arm/operators/op_dequant.py +34 -0
- executorch/backends/arm/operators/op_div.py +40 -0
- executorch/backends/arm/operators/op_get_item.py +34 -0
- executorch/backends/arm/operators/op_hardtanh.py +41 -0
- executorch/backends/arm/operators/op_mean_dim.py +58 -0
- executorch/backends/arm/operators/op_permute.py +45 -0
- executorch/backends/arm/operators/op_placeholder.py +171 -0
- executorch/backends/arm/operators/op_quant.py +34 -0
- executorch/backends/arm/operators/op_softmax.py +95 -0
- executorch/backends/arm/operators/op_view.py +38 -0
- executorch/backends/arm/test/arm_tosa_reference.py +319 -0
- executorch/backends/arm/test/common.py +15 -0
- executorch/backends/arm/test/misc/test_debug_feats.py +96 -0
- executorch/backends/arm/test/models/test_mobilenet_v2_arm.py +102 -0
- executorch/backends/arm/test/ops/test_add.py +163 -0
- executorch/backends/arm/test/ops/test_avg_pool.py +165 -0
- executorch/backends/arm/test/ops/test_conv.py +331 -0
- executorch/backends/arm/test/ops/test_conv_combos.py +272 -0
- executorch/backends/arm/test/ops/test_depthwise_conv.py +215 -0
- executorch/backends/arm/test/ops/test_linear.py +230 -0
- executorch/backends/arm/test/ops/test_mean_dim.py +155 -0
- executorch/backends/arm/test/ops/test_softmax.py +149 -0
- executorch/backends/arm/test/test_models.py +155 -0
- executorch/backends/arm/test/test_tosa.py +110 -0
- executorch/backends/arm/test/tester/__init__.py +6 -0
- executorch/backends/arm/test/tester/arm_tester.py +289 -0
- executorch/backends/arm/test/tosautil/__init__.py +6 -0
- executorch/backends/arm/test/tosautil/tosa_test_utils.py +218 -0
- executorch/backends/arm/third-party/serialization_lib/python/serializer/__init__.py +3 -0
- executorch/backends/arm/third-party/serialization_lib/python/serializer/tosa_serializer.py +965 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ArithmeticRightShiftAttribute.py +54 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/Attribute.py +29 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/AxisAttribute.py +54 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ClampAttribute.py +145 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/CondIfAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ConvAttribute.py +197 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/CustomAttribute.py +106 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/DType.py +18 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/FFTAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/FullyConnectedAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/MatMulAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/MulAttribute.py +54 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/NegateAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/Op.py +78 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/PadAttribute.py +132 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/PoolAttribute.py +197 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/RFFTAttribute.py +54 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/RescaleAttribute.py +210 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ReshapeAttribute.py +80 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ResizeAttribute.py +171 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/ResizeMode.py +8 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/SliceAttribute.py +119 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TableAttribute.py +80 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TileAttribute.py +80 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaBasicBlock.py +192 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaGraph.py +95 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaOperator.py +147 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaRegion.py +91 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaTensor.py +184 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TransposeAttribute.py +80 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/TransposeConvAttribute.py +197 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/Version.py +93 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/WhileLoopAttribute.py +67 -0
- executorch/backends/arm/third-party/serialization_lib/python/tosa/__init__.py +0 -0
- executorch/backends/arm/third-party/serialization_lib/schema/tosa.fbs +324 -0
- executorch/backends/arm/third-party/serialization_lib/setup.py +18 -0
- executorch/backends/arm/third-party/serialization_lib/test/scripts/test_npy_fileio.py +152 -0
- executorch/backends/arm/third-party/serialization_lib/test/scripts/xunit/xunit.py +109 -0
- executorch/backends/arm/tosa_mapping.py +109 -0
- executorch/backends/arm/tosa_quant_utils.py +217 -0
- executorch/backends/arm/tosa_utils.py +189 -0
- executorch/backends/example/example_backend.py +41 -0
- executorch/backends/example/example_backend_delegate_passes/merge_to_dim_pass.py +79 -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 +33 -0
- executorch/backends/example/example_partitioner.py +88 -0
- executorch/backends/example/example_quantizer.py +102 -0
- executorch/backends/example/test_example_delegate.py +110 -0
- executorch/backends/qualcomm/aot/ir/qcir.fbs +97 -0
- executorch/backends/qualcomm/builders/__init__.py +95 -0
- executorch/backends/qualcomm/builders/node_visitor.py +404 -0
- executorch/backends/qualcomm/builders/op_add.py +61 -0
- executorch/backends/qualcomm/builders/op_avg_pool2d.py +143 -0
- executorch/backends/qualcomm/builders/op_batch_norm.py +92 -0
- executorch/backends/qualcomm/builders/op_bmm.py +58 -0
- executorch/backends/qualcomm/builders/op_cast.py +57 -0
- executorch/backends/qualcomm/builders/op_cat.py +84 -0
- executorch/backends/qualcomm/builders/op_ceil.py +55 -0
- executorch/backends/qualcomm/builders/op_clamp.py +78 -0
- executorch/backends/qualcomm/builders/op_conv2d.py +363 -0
- executorch/backends/qualcomm/builders/op_depth_to_space.py +76 -0
- executorch/backends/qualcomm/builders/op_dequantize.py +75 -0
- executorch/backends/qualcomm/builders/op_div.py +61 -0
- executorch/backends/qualcomm/builders/op_embedding.py +77 -0
- executorch/backends/qualcomm/builders/op_expand.py +81 -0
- executorch/backends/qualcomm/builders/op_gelu.py +56 -0
- executorch/backends/qualcomm/builders/op_hardswish.py +56 -0
- executorch/backends/qualcomm/builders/op_hardtanh.py +77 -0
- executorch/backends/qualcomm/builders/op_layer_norm.py +105 -0
- executorch/backends/qualcomm/builders/op_linear.py +82 -0
- executorch/backends/qualcomm/builders/op_log_softmax.py +76 -0
- executorch/backends/qualcomm/builders/op_matmul.py +58 -0
- executorch/backends/qualcomm/builders/op_max_pool2d.py +140 -0
- executorch/backends/qualcomm/builders/op_mean_dim.py +83 -0
- executorch/backends/qualcomm/builders/op_mul.py +61 -0
- executorch/backends/qualcomm/builders/op_pad.py +95 -0
- executorch/backends/qualcomm/builders/op_pow.py +95 -0
- executorch/backends/qualcomm/builders/op_quantize.py +71 -0
- executorch/backends/qualcomm/builders/op_relu.py +57 -0
- executorch/backends/qualcomm/builders/op_reshape.py +54 -0
- executorch/backends/qualcomm/builders/op_rsqrt.py +57 -0
- executorch/backends/qualcomm/builders/op_select_copy.py +87 -0
- executorch/backends/qualcomm/builders/op_sigmoid.py +57 -0
- executorch/backends/qualcomm/builders/op_skip_ops.py +50 -0
- executorch/backends/qualcomm/builders/op_slice_copy.py +87 -0
- executorch/backends/qualcomm/builders/op_softmax.py +74 -0
- executorch/backends/qualcomm/builders/op_squeeze.py +56 -0
- executorch/backends/qualcomm/builders/op_sub.py +61 -0
- executorch/backends/qualcomm/builders/op_tanh.py +56 -0
- executorch/backends/qualcomm/builders/op_transpose.py +72 -0
- executorch/backends/qualcomm/builders/op_unsqueeze.py +56 -0
- executorch/backends/qualcomm/builders/op_upsample_bilinear2d.py +66 -0
- executorch/backends/qualcomm/builders/qnn_constants.py +279 -0
- executorch/backends/qualcomm/builders/utils.py +99 -0
- executorch/backends/qualcomm/partition/common_defs.py +22 -0
- executorch/backends/qualcomm/partition/qnn_partitioner.py +149 -0
- executorch/backends/qualcomm/passes/annotate_and_quant_scalar.py +120 -0
- executorch/backends/qualcomm/passes/annotate_decomposed.py +49 -0
- executorch/backends/qualcomm/passes/annotate_quant_attrs.py +110 -0
- executorch/backends/qualcomm/passes/convert_binary_op_with_scalar.py +41 -0
- executorch/backends/qualcomm/passes/convert_bmm_to_matmul.py +73 -0
- executorch/backends/qualcomm/passes/convert_hardsigmoid.py +102 -0
- executorch/backends/qualcomm/passes/convert_hardswish.py +40 -0
- executorch/backends/qualcomm/passes/convert_interpolate_with_upsample2d.py +47 -0
- executorch/backends/qualcomm/passes/convert_to_linear.py +171 -0
- executorch/backends/qualcomm/passes/decompose_scaled_dot_product_attention.py +87 -0
- executorch/backends/qualcomm/passes/decompose_silu.py +40 -0
- executorch/backends/qualcomm/passes/fold_qdq.py +63 -0
- executorch/backends/qualcomm/passes/i64_to_i32.py +47 -0
- executorch/backends/qualcomm/passes/insert_io_qdq.py +166 -0
- executorch/backends/qualcomm/passes/insert_requantize.py +61 -0
- executorch/backends/qualcomm/passes/layout_transform.py +238 -0
- executorch/backends/qualcomm/passes/recompose_pixel_shuffle.py +46 -0
- executorch/backends/qualcomm/passes/reduce_dynamic_range.py +60 -0
- executorch/backends/qualcomm/passes/remove_clone.py +40 -0
- executorch/backends/qualcomm/passes/replace_inf_buffer.py +22 -0
- executorch/backends/qualcomm/passes/utils.py +44 -0
- executorch/backends/qualcomm/qnn_preprocess.py +94 -0
- executorch/backends/qualcomm/quantizer/quantizer.py +385 -0
- executorch/backends/qualcomm/quantizer/utils.py +629 -0
- executorch/backends/qualcomm/serialization/qnn_compile_spec_schema.py +134 -0
- executorch/backends/qualcomm/serialization/qnn_compile_spec_serialize.py +49 -0
- executorch/backends/qualcomm/serialization/schema.fbs +180 -0
- executorch/backends/qualcomm/tests/models.py +796 -0
- executorch/backends/qualcomm/tests/test_qnn_delegate.py +1709 -0
- executorch/backends/qualcomm/tests/utils.py +301 -0
- executorch/backends/qualcomm/utils/utils.py +278 -0
- executorch/backends/transforms/__init__.py +12 -0
- executorch/backends/transforms/addmm_mm_to_linear.py +172 -0
- executorch/backends/transforms/duplicate_dynamic_quant_chain.py +196 -0
- executorch/backends/transforms/test/test_duplicate_dynamic_quant_chain.py +188 -0
- executorch/backends/vulkan/__init__.py +14 -0
- executorch/backends/vulkan/partitioner/vulkan_partitioner.py +103 -0
- executorch/backends/vulkan/runtime/api/gen_vulkan_spv.py +774 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml +39 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/image_to_nchw.yaml +30 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/matmul.yaml +25 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_image.yaml +30 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/pool.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sum_dim.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/sum_dim_keepdim.yaml +18 -0
- executorch/backends/vulkan/runtime/graph/ops/glsl/unary_op.yaml +20 -0
- executorch/backends/vulkan/serialization/schema.fbs +143 -0
- executorch/backends/vulkan/serialization/vulkan_graph_builder.py +326 -0
- executorch/backends/vulkan/serialization/vulkan_graph_schema.py +141 -0
- executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +222 -0
- executorch/backends/vulkan/test/glsl/all_shaders.yaml +55 -0
- executorch/backends/vulkan/test/op_tests/cases.py +72 -0
- executorch/backends/vulkan/test/op_tests/generate_op_tests.py +79 -0
- executorch/backends/vulkan/test/op_tests/utils/codegen.py +450 -0
- executorch/backends/vulkan/test/op_tests/utils/codegen_base.py +220 -0
- executorch/backends/vulkan/test/test_serialization.py +95 -0
- executorch/backends/vulkan/test/test_vulkan_delegate.py +498 -0
- executorch/backends/vulkan/test/test_vulkan_delegate_header.py +104 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/apiconventions.py +11 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/cgenerator.py +424 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/conventions.py +358 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/generator.py +1225 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/genvk.py +817 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/reg.py +1575 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/util.py +58 -0
- executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vkconventions.py +275 -0
- executorch/backends/vulkan/third-party/VulkanMemoryAllocator/tools/GpuMemDumpVis/GpuMemDumpVis.py +333 -0
- executorch/backends/vulkan/third-party/volk/generate.py +194 -0
- executorch/backends/vulkan/vulkan_preprocess.py +67 -0
- executorch/backends/xnnpack/__init__.py +35 -0
- executorch/backends/xnnpack/operators/__init__.py +51 -0
- executorch/backends/xnnpack/operators/node_visitor.py +673 -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 +74 -0
- executorch/backends/xnnpack/operators/op_cat.py +104 -0
- executorch/backends/xnnpack/operators/op_ceiling.py +52 -0
- executorch/backends/xnnpack/operators/op_clamp.py +64 -0
- executorch/backends/xnnpack/operators/op_conv2d.py +168 -0
- executorch/backends/xnnpack/operators/op_dequantize_per_tensor.py +68 -0
- executorch/backends/xnnpack/operators/op_div.py +56 -0
- executorch/backends/xnnpack/operators/op_dynamic_dequantize_ops.py +67 -0
- executorch/backends/xnnpack/operators/op_dynamic_quantize_ops.py +120 -0
- executorch/backends/xnnpack/operators/op_elu.py +56 -0
- executorch/backends/xnnpack/operators/op_floor.py +48 -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 +105 -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 +91 -0
- executorch/backends/xnnpack/operators/op_maximum.py +55 -0
- executorch/backends/xnnpack/operators/op_mean_dim.py +77 -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 +57 -0
- executorch/backends/xnnpack/operators/op_prelu.py +56 -0
- executorch/backends/xnnpack/operators/op_quantize_per_tensor.py +68 -0
- executorch/backends/xnnpack/operators/op_relu.py +61 -0
- executorch/backends/xnnpack/operators/op_sdpa.py +108 -0
- executorch/backends/xnnpack/operators/op_sigmoid.py +48 -0
- executorch/backends/xnnpack/operators/op_skip_ops.py +124 -0
- executorch/backends/xnnpack/operators/op_slice_copy.py +98 -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 +116 -0
- executorch/backends/xnnpack/operators/op_static_constant_pad.py +130 -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_to_copy.py +91 -0
- executorch/backends/xnnpack/operators/quant_params.py +346 -0
- executorch/backends/xnnpack/partition/configs.py +157 -0
- executorch/backends/xnnpack/partition/graphs/bilinear_2d.py +54 -0
- executorch/backends/xnnpack/partition/graphs/sdpa.py +85 -0
- executorch/backends/xnnpack/partition/xnnpack_partitioner.py +1203 -0
- executorch/backends/xnnpack/passes/__init__.py +87 -0
- executorch/backends/xnnpack/passes/channels_last_tagged_reshape_pass.py +408 -0
- executorch/backends/xnnpack/passes/conv1d_unsqueeze_pass.py +183 -0
- executorch/backends/xnnpack/passes/convert_to_linear.py +202 -0
- executorch/backends/xnnpack/passes/convert_to_sdpa.py +114 -0
- executorch/backends/xnnpack/passes/convert_to_upsample_bilinear2d.py +59 -0
- executorch/backends/xnnpack/passes/fuse_activation_pass.py +83 -0
- executorch/backends/xnnpack/passes/fuse_batch_norm_with_conv.py +159 -0
- executorch/backends/xnnpack/passes/prelu_reshape_pass.py +75 -0
- executorch/backends/xnnpack/passes/remove_getitem_op.py +90 -0
- executorch/backends/xnnpack/passes/tag_implicit_q_dq_pass.py +216 -0
- executorch/backends/xnnpack/passes/xnnpack_pass.py +22 -0
- executorch/backends/xnnpack/serialization/runtime_schema.fbs +354 -0
- executorch/backends/xnnpack/serialization/schema.fbs +346 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +460 -0
- executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +342 -0
- executorch/backends/xnnpack/test/models/deeplab_v3.py +41 -0
- executorch/backends/xnnpack/test/models/edsr.py +43 -0
- executorch/backends/xnnpack/test/models/emformer_rnnt.py +100 -0
- executorch/backends/xnnpack/test/models/inception_v3.py +68 -0
- executorch/backends/xnnpack/test/models/inception_v4.py +65 -0
- executorch/backends/xnnpack/test/models/llama2_et_example.py +50 -0
- executorch/backends/xnnpack/test/models/mobilebert.py +43 -0
- executorch/backends/xnnpack/test/models/mobilenet_v2.py +66 -0
- executorch/backends/xnnpack/test/models/mobilenet_v3.py +68 -0
- executorch/backends/xnnpack/test/models/resnet.py +42 -0
- executorch/backends/xnnpack/test/models/torchvision_vit.py +62 -0
- executorch/backends/xnnpack/test/models/very_big_model.py +44 -0
- executorch/backends/xnnpack/test/models/w2l.py +59 -0
- executorch/backends/xnnpack/test/ops/abs.py +58 -0
- executorch/backends/xnnpack/test/ops/add.py +266 -0
- executorch/backends/xnnpack/test/ops/avgpool2d.py +106 -0
- executorch/backends/xnnpack/test/ops/bilinear2d.py +129 -0
- executorch/backends/xnnpack/test/ops/cat.py +214 -0
- executorch/backends/xnnpack/test/ops/ceil.py +58 -0
- executorch/backends/xnnpack/test/ops/clamp.py +82 -0
- executorch/backends/xnnpack/test/ops/conv1d.py +122 -0
- executorch/backends/xnnpack/test/ops/conv2d.py +371 -0
- executorch/backends/xnnpack/test/ops/div.py +69 -0
- executorch/backends/xnnpack/test/ops/elu.py +104 -0
- executorch/backends/xnnpack/test/ops/floor.py +58 -0
- executorch/backends/xnnpack/test/ops/hardswish.py +80 -0
- executorch/backends/xnnpack/test/ops/hardtanh.py +95 -0
- executorch/backends/xnnpack/test/ops/leaky_relu.py +148 -0
- executorch/backends/xnnpack/test/ops/linear.py +783 -0
- executorch/backends/xnnpack/test/ops/max_dim.py +70 -0
- executorch/backends/xnnpack/test/ops/maximum.py +69 -0
- executorch/backends/xnnpack/test/ops/maxpool2d.py +140 -0
- executorch/backends/xnnpack/test/ops/mean_dim.py +90 -0
- executorch/backends/xnnpack/test/ops/minimum.py +49 -0
- executorch/backends/xnnpack/test/ops/multiply.py +161 -0
- executorch/backends/xnnpack/test/ops/negate.py +58 -0
- executorch/backends/xnnpack/test/ops/permute.py +137 -0
- executorch/backends/xnnpack/test/ops/pow.py +68 -0
- executorch/backends/xnnpack/test/ops/prelu.py +53 -0
- executorch/backends/xnnpack/test/ops/quantize_per_tensor.py +81 -0
- executorch/backends/xnnpack/test/ops/relu.py +38 -0
- executorch/backends/xnnpack/test/ops/sdpa.py +125 -0
- executorch/backends/xnnpack/test/ops/sigmoid.py +45 -0
- executorch/backends/xnnpack/test/ops/slice_copy.py +148 -0
- executorch/backends/xnnpack/test/ops/softmax.py +74 -0
- executorch/backends/xnnpack/test/ops/sqrt.py +44 -0
- executorch/backends/xnnpack/test/ops/square.py +50 -0
- executorch/backends/xnnpack/test/ops/static_constant_pad.py +185 -0
- executorch/backends/xnnpack/test/ops/sub.py +171 -0
- executorch/backends/xnnpack/test/passes/test_activation_fusion.py +197 -0
- executorch/backends/xnnpack/test/passes/test_batch_norm_fusion.py +81 -0
- executorch/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py +180 -0
- executorch/backends/xnnpack/test/passes/test_convert_to_linear.py +40 -0
- executorch/backends/xnnpack/test/passes/test_remove_get_item_pass.py +100 -0
- executorch/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py +81 -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_utils.py +533 -0
- executorch/backends/xnnpack/test/test_xnnpack_utils_classes.py +42 -0
- executorch/backends/xnnpack/test/tester/__init__.py +28 -0
- executorch/backends/xnnpack/test/tester/tester.py +596 -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/eval/f16-tanh.yaml +38 -0
- executorch/backends/xnnpack/third-party/XNNPACK/eval/f32-tanh.yaml +253 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/convert-assembly-to-jit.py +1443 -0
- executorch/backends/xnnpack/third-party/XNNPACK/scripts/sort-filenames.py +137 -0
- executorch/backends/xnnpack/third-party/XNNPACK/src/enums/microkernel-type.yaml +35 -0
- executorch/backends/xnnpack/third-party/XNNPACK/src/enums/node-type.yaml +125 -0
- executorch/backends/xnnpack/third-party/XNNPACK/src/enums/operator-type.yaml +325 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-gemm-minmax.yaml +106 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-bfly4.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-fftr.yaml +15 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-vsquareabs.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-avgpool-minmax.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-conv-hwc2chw.yaml +8 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv-minmax-multipass.yaml +80 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv-minmax-unipass.yaml +104 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv2d-chw.yaml +88 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32-vcvt.yaml +123 -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-f32acc-rsum.yaml +30 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gavgpool-cw.yaml +8 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gavgpool-minmax.yaml +40 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-jit.yaml +36 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-minmax.yaml +130 -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-jit.yaml +36 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-igemm-minmax.yaml +114 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-maxpool-minmax.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-pavgpool-minmax.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-prelu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-qs8-vcvt.yaml +34 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-raddstoreexpminusmax.yaml +92 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rmax.yaml +28 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rmin.yaml +25 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rminmax.yaml +25 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rsum.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-spmm-minmax.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vabs.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vadd-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vaddc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vclamp.yaml +26 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vcmul.yaml +9 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vdiv-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vdivc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-velu.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vhswish.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vlrelu.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmax.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmaxc.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmin.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vminc.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmul-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmulc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmulcaddc-minmax.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vneg.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrdivc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndd.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndne.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndz.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrsubc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsigmoid.yaml +88 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqr.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrdiff.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrdiffc.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrt.yaml +28 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsub-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsubc-minmax.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vtanh.yaml +214 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-argmaxpool.yaml +29 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-avgpool-minmax.yaml +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc.yaml +44 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc2chw.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-minmax-multipass.yaml +190 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-minmax-unipass.yaml +436 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-multipass.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-unipass.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv2d-chw.yaml +679 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-f16-vcvt.yaml +85 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gavgpool-cw.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gavgpool-minmax.yaml +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-goi-minmax.yaml +15 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-jit.yaml +317 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-minmax.yaml +953 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-relu.yaml +129 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm.yaml +120 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemminc-minmax.yaml +673 -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-jit.yaml +315 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-minmax.yaml +891 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-relu.yaml +129 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm.yaml +116 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-maxpool-minmax.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-pavgpool-minmax.yaml +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ppmm-minmax.yaml +122 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-prelu.yaml +72 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc4w-gemm-minmax.yaml +314 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-minmax.yaml +836 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-relu.yaml +80 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm.yaml +115 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qs8-vcvt.yaml +116 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qu8-vcvt.yaml +108 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddexpminusmax.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddextexp.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddstoreexpminusmax.yaml +257 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rmax.yaml +69 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rmin.yaml +69 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rminmax.yaml +69 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rsum.yaml +76 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-spmm-minmax.yaml +400 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vabs.yaml +37 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd-minmax.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vclamp.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vcmul.yaml +28 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv-minmax.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-velu.yaml +401 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vhswish.yaml +62 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vlrelu.yaml +65 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmax.yaml +36 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmaxc.yaml +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmin.yaml +36 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vminc.yaml +39 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul-minmax.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulcaddc-minmax.yaml +51 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vneg.yaml +37 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrelu.yaml +34 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndd.yaml +32 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndne.yaml +32 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndu.yaml +32 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndz.yaml +32 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsqrt.yaml +41 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vscaleexpminusmax.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vscaleextexp.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsigmoid.yaml +550 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqr.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrdiff.yaml +28 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrdiffc.yaml +31 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrt.yaml +60 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub-minmax.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc-minmax.yaml +61 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc-relu.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vtanh.yaml +815 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/i16-vlshift.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc4w-gemm-minmax.yaml +447 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-gemm-minmax.yaml +362 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-igemm-minmax.yaml +326 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc4w-gemm-minmax.yaml +990 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-gemm-minmax.yaml +1035 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-igemm-minmax.yaml +920 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs16-qs8-vcvt.yaml +62 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-multipass-fp32.yaml +300 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-multipass-rndnu.yaml +60 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-unipass-fp32.yaml +224 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-unipass-rndnu.yaml +49 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-f16-vcvt.yaml +24 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-f32-vcvt.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-gavgpool-minmax-fp32.yaml +117 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-gavgpool-minmax-rndnu.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-dwconv-minmax-multipass-fp32.yaml +372 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-dwconv-minmax-unipass-fp32.yaml +314 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-jit-fp32.yaml +21 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-minmax-fp32.yaml +1576 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-jit-fp32.yaml +21 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-minmax-fp32.yaml +1538 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vadd-minmax.yaml +100 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vaddc-minmax.yaml +100 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vcvt.yaml +76 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vhswish.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vlrelu.yaml +98 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmul-minmax-fp32.yaml +49 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmul-minmax-rndnu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmulc-minmax-fp32.yaml +49 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmulc-minmax-rndnu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-avgpool-minmax-fp32.yaml +23 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-multipass-fp32.yaml +228 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-multipass-rndnu.yaml +42 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-unipass-fp32.yaml +160 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-unipass-rndnu.yaml +37 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-f32-vcvt.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gavgpool-minmax-fp32.yaml +117 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gavgpool-minmax-rndnu.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-fp32.yaml +821 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-rndnu.yaml +274 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-fp32.yaml +818 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-rndnu.yaml +232 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vadd-minmax.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vaddc-minmax.yaml +66 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vcvt.yaml +76 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vhswish.yaml +56 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vlrelu.yaml +98 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmul-minmax-fp32.yaml +49 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmul-minmax-rndnu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmulc-minmax-fp32.yaml +49 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmulc-minmax-rndnu.yaml +12 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s16-rmaxabs.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s16-window.yaml +25 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s8-ibilinear.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s8-maxpool-minmax.yaml +23 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/s8-vclamp.yaml +19 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u32-filterbank-accumulate.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u32-filterbank-subtract.yaml +8 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u32-vlog.yaml +11 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u64-u32-vsqrtshift.yaml +7 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-ibilinear.yaml +22 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-lut32norm.yaml +7 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-maxpool-minmax.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-rmax.yaml +13 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/u8-vclamp.yaml +17 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x16-packw.yaml +33 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x16-transpose.yaml +47 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x24-transpose.yaml +26 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packb.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packw.yaml +76 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packx.yaml +38 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x32-transpose.yaml +68 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x32-zerob.yaml +14 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x64-transpose.yaml +45 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x8-lut.yaml +47 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x8-packw.yaml +18 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/x8-transpose.yaml +36 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/xx-fill.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/xx-pad.yaml +16 -0
- executorch/backends/xnnpack/third-party/XNNPACK/test/xx-transposev.yaml +7 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/check-assembly-and-jit-microkernels-in-sync.py +88 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/dump-jit-output.py +84 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-argmaxpool-test.py +739 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-avgpool-test.py +2481 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-bfly4-test.py +190 -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 +497 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-multipass-test.py +465 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-unipass-test.py +392 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv2d-chw-test.py +333 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-enum.py +193 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-fftr-test.py +114 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-fill-test.py +169 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-filterbank-accumulate-test.py +129 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-filterbank-subtract-test.py +155 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gavgpool-cw-test.py +189 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gavgpool-test.py +594 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gemm-test.py +1318 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-chw-test.py +220 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-test.py +222 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-norm-test.py +157 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-test.py +153 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-maxpool-test.py +1268 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-pack-test.py +224 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-packb-test.py +188 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-packw-test.py +340 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-pad-test.py +353 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-prelu-test.py +237 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddexpminusmax-test.py +144 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddextexp-test.py +144 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddstoreexpminusmax-test.py +188 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-test.py +225 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-rmaxabs-test.py +145 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-spmm-test.py +538 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-tanh-eval.py +123 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-transpose-test.py +369 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vbinary-test.py +529 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vcvt-test.py +450 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vhswish-test.py +228 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlog-test.py +178 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlrelu-test.py +226 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlshift-test.py +168 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vmulcaddc-test.py +281 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vscaleexpminusmax-test.py +159 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vscaleextexp-test.py +144 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vsquareabs-test.py +145 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-benchmark.py +282 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-test.py +294 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-window-test.py +230 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/primes.py +115 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/update-microkernels.py +391 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/xngen.py +148 -0
- executorch/backends/xnnpack/third-party/XNNPACK/tools/xnncommon.py +253 -0
- executorch/backends/xnnpack/third-party/cpuinfo/configure.py +104 -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/generate-xnnpack-wrappers.py +198 -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 +51 -0
- executorch/backends/xnnpack/utils/quant_utils.py +32 -0
- executorch/backends/xnnpack/utils/utils.py +130 -0
- executorch/backends/xnnpack/utils/xnnpack_constants.py +29 -0
- executorch/backends/xnnpack/xnnpack_preprocess.py +167 -0
- executorch/data/bin/__init__.py +42 -0
- executorch/data/bin/flatc +0 -0
- executorch/examples/models/__init__.py +34 -0
- executorch/examples/models/deeplab_v3/__init__.py +9 -0
- executorch/examples/models/deeplab_v3/model.py +50 -0
- executorch/examples/models/edsr/__init__.py +11 -0
- executorch/examples/models/edsr/model.py +28 -0
- executorch/examples/models/emformer_rnnt/__init__.py +17 -0
- executorch/examples/models/emformer_rnnt/model.py +132 -0
- executorch/examples/models/inception_v3/__init__.py +11 -0
- executorch/examples/models/inception_v3/model.py +30 -0
- executorch/examples/models/inception_v4/__init__.py +11 -0
- executorch/examples/models/inception_v4/model.py +26 -0
- executorch/examples/models/llama2/__init__.py +11 -0
- executorch/examples/models/llama2/builder.py +348 -0
- executorch/examples/models/llama2/custom_ops/custom_ops.yaml +14 -0
- executorch/examples/models/llama2/custom_ops/sdpa_with_kv_cache.py +199 -0
- executorch/examples/models/llama2/eval_llama.py +29 -0
- executorch/examples/models/llama2/eval_llama_lib.py +271 -0
- executorch/examples/models/llama2/experimental/generate.py +190 -0
- executorch/examples/models/llama2/experimental/load_gguf_q4_0.py +183 -0
- executorch/examples/models/llama2/experimental/subclass.py +242 -0
- executorch/examples/models/llama2/experimental/test_subclass.py +28 -0
- executorch/examples/models/llama2/export_llama.py +30 -0
- executorch/examples/models/llama2/export_llama_lib.py +893 -0
- executorch/examples/models/llama2/fairseq2.py +63 -0
- executorch/examples/models/llama2/install_requirement_helper.py +29 -0
- executorch/examples/models/llama2/llama_test.py +36 -0
- executorch/examples/models/llama2/llama_transformer.py +478 -0
- executorch/examples/models/llama2/model.py +193 -0
- executorch/examples/models/llama2/ops/quantized.yaml +11 -0
- executorch/examples/models/llama2/ops/quantized_ops.py +163 -0
- executorch/examples/models/llama2/quant_lib.py +136 -0
- executorch/examples/models/llama2/quantize.py +389 -0
- executorch/examples/models/llama2/tests/test_simple_sdpa.py +54 -0
- executorch/examples/models/llama2/tokenizer/__init__.py +0 -0
- executorch/examples/models/llama2/tokenizer/test/__init__.py +0 -0
- executorch/examples/models/llama2/tokenizer/test/test_tokenizer.py +39 -0
- executorch/examples/models/llama2/tokenizer/tokenizer.py +141 -0
- executorch/examples/models/llava_encoder/__init__.py +11 -0
- executorch/examples/models/llava_encoder/model.py +52 -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 +45 -0
- executorch/examples/models/mobilenet_v3/__init__.py +11 -0
- executorch/examples/models/mobilenet_v3/model.py +32 -0
- executorch/examples/models/model_base.py +47 -0
- executorch/examples/models/model_factory.py +56 -0
- executorch/examples/models/resnet/__init__.py +12 -0
- executorch/examples/models/resnet/model.py +51 -0
- executorch/examples/models/torchvision_vit/__init__.py +11 -0
- executorch/examples/models/torchvision_vit/model.py +30 -0
- executorch/examples/models/toy_model/__init__.py +15 -0
- executorch/examples/models/toy_model/model.py +93 -0
- executorch/examples/models/wav2letter/__init__.py +11 -0
- executorch/examples/models/wav2letter/model.py +29 -0
- executorch/exir/__init__.py +52 -0
- executorch/exir/_serialize/__init__.py +18 -0
- executorch/exir/_serialize/_cord.py +49 -0
- executorch/exir/_serialize/_dataclass.py +138 -0
- executorch/exir/_serialize/_flatbuffer.py +351 -0
- executorch/exir/_serialize/_program.py +563 -0
- executorch/exir/_serialize/program.fbs +407 -0
- executorch/exir/_serialize/scalar_type.fbs +32 -0
- executorch/exir/_serialize/test/test_cord.py +63 -0
- executorch/exir/_serialize/test/test_flatbuffer.py +331 -0
- executorch/exir/_serialize/test/test_program.py +938 -0
- executorch/exir/backend/backend_api.py +404 -0
- executorch/exir/backend/backend_details.py +68 -0
- executorch/exir/backend/canonical_partitioners/duplicate_constant_node_pass.py +152 -0
- executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
- executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +137 -0
- executorch/exir/backend/compile_spec_schema.py +17 -0
- executorch/exir/backend/partitioner.py +93 -0
- executorch/exir/backend/test/backend_with_compiler_demo.py +130 -0
- executorch/exir/backend/test/backend_with_delegate_mapping_demo.py +210 -0
- executorch/exir/backend/test/demos/rpc/executor_backend_partitioner.py +76 -0
- executorch/exir/backend/test/demos/rpc/executor_backend_preprocess.py +33 -0
- executorch/exir/backend/test/demos/rpc/test_rpc.py +194 -0
- executorch/exir/backend/test/demos/test_delegate_aten_mode.py +76 -0
- executorch/exir/backend/test/demos/test_xnnpack_qnnpack.py +134 -0
- executorch/exir/backend/test/hta_partitioner_demo.py +288 -0
- executorch/exir/backend/test/op_partitioner_demo.py +123 -0
- executorch/exir/backend/test/qnn_backend_demo.py +33 -0
- executorch/exir/backend/test/test_backends.py +1290 -0
- executorch/exir/backend/test/test_backends_lifted.py +1260 -0
- executorch/exir/backend/test/test_backends_nested.py +257 -0
- executorch/exir/backend/test/test_debug_handle_map.py +131 -0
- executorch/exir/backend/test/test_delegate_map_builder.py +243 -0
- executorch/exir/backend/test/test_graph_partition.py +243 -0
- executorch/exir/backend/test/test_lowered_backend_module.py +220 -0
- executorch/exir/backend/test/test_partitioner.py +607 -0
- executorch/exir/backend/test/test_passes.py +47 -0
- executorch/exir/backend/test/test_utils.py +341 -0
- executorch/exir/backend/utils.py +661 -0
- executorch/exir/capture/__init__.py +28 -0
- executorch/exir/capture/_capture.py +374 -0
- executorch/exir/capture/_config.py +77 -0
- executorch/exir/capture/_unlift.py +159 -0
- executorch/exir/common.py +140 -0
- executorch/exir/control_flow.py +203 -0
- executorch/exir/delegate.py +161 -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 +89 -0
- executorch/exir/dialects/edge/_ops.py +406 -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 +120 -0
- executorch/exir/dialects/edge/dtype/supported.py +45 -0
- executorch/exir/dialects/edge/dtype/utils.py +36 -0
- executorch/exir/dialects/edge/edge.yaml +7623 -0
- executorch/exir/dialects/edge/op/api.py +86 -0
- executorch/exir/dialects/edge/op/sample_input.py +1274 -0
- executorch/exir/dialects/edge/op/test/test_api.py +51 -0
- executorch/exir/dialects/edge/spec/gen.py +542 -0
- executorch/exir/dialects/edge/spec/utils.py +328 -0
- executorch/exir/dialects/edge/test/test_edge_ops.py +457 -0
- executorch/exir/dialects/edge/test/test_edge_yaml.py +224 -0
- executorch/exir/dialects/test/test_exir_dialect_ops.py +22 -0
- executorch/exir/dim_order_utils.py +81 -0
- executorch/exir/dynamic_shape.py +12 -0
- executorch/exir/emit/__init__.py +11 -0
- executorch/exir/emit/_emit_program.py +238 -0
- executorch/exir/emit/_emitter.py +1445 -0
- executorch/exir/emit/test/test_emit.py +1489 -0
- executorch/exir/error.py +55 -0
- executorch/exir/experimental/__init__.py +131 -0
- executorch/exir/experimental/export_pt2.py +168 -0
- executorch/exir/graph.py +86 -0
- executorch/exir/graph_module.py +70 -0
- executorch/exir/lowered_backend_module.py +736 -0
- executorch/exir/memory.py +50 -0
- executorch/exir/memory_planning.py +792 -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 +41 -0
- executorch/exir/pass_base.py +730 -0
- executorch/exir/pass_manager.py +78 -0
- executorch/exir/passes/__init__.py +508 -0
- executorch/exir/passes/_quant_patterns_and_replacements.py +741 -0
- executorch/exir/passes/const_prop_pass.py +84 -0
- executorch/exir/passes/constant_prop_pass.py +133 -0
- executorch/exir/passes/debug_handle_generator_pass.py +32 -0
- executorch/exir/passes/dim_order_ops_registry.py +47 -0
- executorch/exir/passes/dynamic_shape_prop_pass.py +301 -0
- executorch/exir/passes/executorch_prim_ops_registry.py +112 -0
- executorch/exir/passes/insert_write_back_for_buffers_pass.py +134 -0
- executorch/exir/passes/memory_format_ops_pass.py +63 -0
- executorch/exir/passes/memory_planning_pass.py +131 -0
- executorch/exir/passes/normalize_transpose_pass.py +24 -0
- executorch/exir/passes/normalize_view_copy_base_pass.py +64 -0
- executorch/exir/passes/pass_registry.py +89 -0
- executorch/exir/passes/quant_fusion_pass.py +128 -0
- executorch/exir/passes/remove_graph_asserts_pass.py +39 -0
- executorch/exir/passes/remove_mixed_type_operators.py +85 -0
- executorch/exir/passes/remove_noop_pass.py +92 -0
- executorch/exir/passes/replace_aten_with_edge_pass.py +46 -0
- executorch/exir/passes/replace_broken_ops_with_function_ops_pass.py +44 -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 +189 -0
- executorch/exir/passes/scalar_to_tensor_pass.py +32 -0
- executorch/exir/passes/spec_prop_pass.py +151 -0
- executorch/exir/passes/sym_shape_eval_pass.py +264 -0
- executorch/exir/passes/sym_to_tensor_pass.py +64 -0
- executorch/exir/print_program.py +413 -0
- executorch/exir/program/__init__.py +30 -0
- executorch/exir/program/_fake_program.py +64 -0
- executorch/exir/program/_program.py +1006 -0
- executorch/exir/program/test/test_fake_program.py +76 -0
- executorch/exir/program/test/test_program.py +434 -0
- executorch/exir/scalar_type.py +28 -0
- executorch/exir/schema.py +267 -0
- executorch/exir/serde/__init__.py +0 -0
- executorch/exir/serde/export_serialize.py +1854 -0
- executorch/exir/serde/schema.py +27 -0
- executorch/exir/serde/serialize.py +750 -0
- executorch/exir/sym_util.py +82 -0
- executorch/exir/tensor.py +359 -0
- executorch/exir/tests/asr_joiner.py +82 -0
- executorch/exir/tests/common.py +97 -0
- executorch/exir/tests/control_flow_models.py +110 -0
- executorch/exir/tests/dynamic_shape_models.py +51 -0
- executorch/exir/tests/models.py +557 -0
- executorch/exir/tests/test_arg_validator.py +72 -0
- executorch/exir/tests/test_capture.py +27 -0
- executorch/exir/tests/test_common.py +81 -0
- executorch/exir/tests/test_delegate.py +311 -0
- executorch/exir/tests/test_dim_order_utils.py +29 -0
- executorch/exir/tests/test_dynamic_shape_propagation.py +38 -0
- executorch/exir/tests/test_error.py +19 -0
- executorch/exir/tests/test_fixtures.py +110 -0
- executorch/exir/tests/test_memory_format_ops_pass.py +148 -0
- executorch/exir/tests/test_memory_planning.py +593 -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 +1573 -0
- executorch/exir/tests/test_print_program.py +54 -0
- executorch/exir/tests/test_quant_fusion_pass.py +371 -0
- executorch/exir/tests/test_quantization.py +120 -0
- executorch/exir/tests/test_serde.py +201 -0
- executorch/exir/tests/test_tensor.py +341 -0
- executorch/exir/tests/test_tracer.py +553 -0
- executorch/exir/tests/test_verification.py +272 -0
- executorch/exir/tests/transformer.py +122 -0
- executorch/exir/tracer.py +785 -0
- executorch/exir/types.py +18 -0
- executorch/exir/verification/arg_validator.py +129 -0
- executorch/exir/verification/dev_html.py +68 -0
- executorch/exir/verification/interpreter.py +425 -0
- executorch/exir/verification/test/test_verifier.py +30 -0
- executorch/exir/verification/verifier.py +219 -0
- executorch/exir/version.py +9 -0
- executorch/exir/wrap.py +32 -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/pybindings/_portable_lib.cpython-39-darwin.so +0 -0
- executorch/extension/pybindings/portable_lib.py +34 -0
- executorch/extension/pybindings/pybindings.pyi +49 -0
- executorch/extension/pybindings/test/make_test.py +221 -0
- executorch/extension/pybindings/test/test_pybindings.py +38 -0
- executorch/extension/pytree/__init__.py +54 -0
- executorch/extension/pytree/test/test.py +331 -0
- executorch/schema/program.fbs +407 -0
- executorch/schema/scalar_type.fbs +32 -0
- executorch/sdk/__init__.py +19 -0
- executorch/sdk/bundled_program/config.py +120 -0
- executorch/sdk/bundled_program/core.py +372 -0
- executorch/sdk/bundled_program/schema/__init__.py +9 -0
- executorch/sdk/bundled_program/schema/bundled_program_schema.fbs +97 -0
- executorch/sdk/bundled_program/schema/bundled_program_schema.py +99 -0
- executorch/sdk/bundled_program/schema/scalar_type.fbs +32 -0
- executorch/sdk/bundled_program/schema/test/test_schema.py +21 -0
- executorch/sdk/bundled_program/serialize/__init__.py +122 -0
- executorch/sdk/bundled_program/serialize/bundled_program_schema.fbs +97 -0
- executorch/sdk/bundled_program/serialize/scalar_type.fbs +32 -0
- executorch/sdk/bundled_program/serialize/test/test_serialize.py +35 -0
- executorch/sdk/bundled_program/test/test_bundle_data.py +118 -0
- executorch/sdk/bundled_program/test/test_config.py +133 -0
- executorch/sdk/bundled_program/test/test_end2end.py +93 -0
- executorch/sdk/bundled_program/util/test_util.py +288 -0
- executorch/sdk/bundled_program/version.py +13 -0
- executorch/sdk/debug_format/base_schema.py +59 -0
- executorch/sdk/debug_format/et_schema.py +419 -0
- executorch/sdk/etdump/etdump_schema_flatcc.fbs +171 -0
- executorch/sdk/etdump/scalar_type.fbs +32 -0
- executorch/sdk/etdump/schema_flatcc.py +151 -0
- executorch/sdk/etdump/serialize.py +110 -0
- executorch/sdk/etdump/tests/serialize_test.py +139 -0
- executorch/sdk/etrecord/__init__.py +13 -0
- executorch/sdk/etrecord/_etrecord.py +324 -0
- executorch/sdk/etrecord/tests/etrecord_test.py +187 -0
- executorch/sdk/inspector/__init__.py +10 -0
- executorch/sdk/inspector/_inspector.py +1173 -0
- executorch/sdk/inspector/_inspector_utils.py +414 -0
- executorch/sdk/inspector/inspector_cli.py +51 -0
- executorch/sdk/inspector/tests/event_blocks_test.py +370 -0
- executorch/sdk/inspector/tests/inspector_test.py +289 -0
- executorch/sdk/inspector/tests/inspector_utils_test.py +194 -0
- executorch/sdk/size_analysis_tool/size_analysis_tool.py +180 -0
- executorch/sdk/size_analysis_tool/size_analysis_tool_test.py +115 -0
- executorch/util/activation_memory_profiler.py +146 -0
- executorch/util/python_profiler.py +88 -0
- executorch/version.py +4 -0
- executorch-0.2.1.dist-info/LICENSE +33 -0
- executorch-0.2.1.dist-info/METADATA +108 -0
- executorch-0.2.1.dist-info/RECORD +1020 -0
- executorch-0.2.1.dist-info/WHEEL +5 -0
- executorch-0.2.1.dist-info/entry_points.txt +2 -0
- executorch-0.2.1.dist-info/top_level.txt +12 -0
- serializer/__init__.py +3 -0
- serializer/tosa_serializer.py +965 -0
- tosa/ArithmeticRightShiftAttribute.py +54 -0
- tosa/Attribute.py +29 -0
- tosa/AxisAttribute.py +54 -0
- tosa/ClampAttribute.py +145 -0
- tosa/CondIfAttribute.py +67 -0
- tosa/ConvAttribute.py +197 -0
- tosa/CustomAttribute.py +106 -0
- tosa/DType.py +18 -0
- tosa/FFTAttribute.py +67 -0
- tosa/FullyConnectedAttribute.py +67 -0
- tosa/MatMulAttribute.py +67 -0
- tosa/MulAttribute.py +54 -0
- tosa/NegateAttribute.py +67 -0
- tosa/Op.py +78 -0
- tosa/PadAttribute.py +132 -0
- tosa/PoolAttribute.py +197 -0
- tosa/RFFTAttribute.py +54 -0
- tosa/RescaleAttribute.py +210 -0
- tosa/ReshapeAttribute.py +80 -0
- tosa/ResizeAttribute.py +171 -0
- tosa/ResizeMode.py +8 -0
- tosa/SliceAttribute.py +119 -0
- tosa/TableAttribute.py +80 -0
- tosa/TileAttribute.py +80 -0
- tosa/TosaBasicBlock.py +192 -0
- tosa/TosaGraph.py +95 -0
- tosa/TosaOperator.py +147 -0
- tosa/TosaRegion.py +91 -0
- tosa/TosaTensor.py +184 -0
- tosa/TransposeAttribute.py +80 -0
- tosa/TransposeConvAttribute.py +197 -0
- tosa/Version.py +93 -0
- tosa/WhileLoopAttribute.py +67 -0
- tosa/__init__.py +0 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# Copyright © 2023 Apple Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
# CoreML backend for delegating a EdgeProgram to CoreML.
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import shutil
|
|
8
|
+
import uuid
|
|
9
|
+
from dataclasses import asdict, dataclass
|
|
10
|
+
from enum import Enum
|
|
11
|
+
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from typing import Any, Dict, final, List, Optional, Tuple
|
|
15
|
+
|
|
16
|
+
import coremltools as ct
|
|
17
|
+
import executorchcoreml
|
|
18
|
+
|
|
19
|
+
from executorch.exir.backend.backend_details import (
|
|
20
|
+
BackendDetails,
|
|
21
|
+
ExportedProgram,
|
|
22
|
+
PreprocessResult,
|
|
23
|
+
)
|
|
24
|
+
from executorch.exir.backend.compile_spec_schema import CompileSpec
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class COMPILE_SPEC_KEYS(Enum):
|
|
28
|
+
COMPUTE_UNITS = "compute_units"
|
|
29
|
+
MODEL_TYPE = "model_type"
|
|
30
|
+
MIN_DEPLOYMENT_TARGET = "min_deployment_target"
|
|
31
|
+
MODEL_COMPUTE_PRECISION = "model_compute_precision"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MODEL_PATHS(Enum):
|
|
35
|
+
MODEL = "model.mlpackage"
|
|
36
|
+
COMPILED_MODEL = "model.mlmodelc"
|
|
37
|
+
METADATA = "metadata.json"
|
|
38
|
+
DEBUG_INFO = "debug_info.json"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class ModelMetadata:
|
|
43
|
+
# The model input names.
|
|
44
|
+
inputNames: List[str]
|
|
45
|
+
# The model output names.
|
|
46
|
+
outputNames: List[str]
|
|
47
|
+
# The model identifier.
|
|
48
|
+
identifier: str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class ModelDebugInfo:
|
|
53
|
+
# Version info.
|
|
54
|
+
versionInfo: Dict[str, str]
|
|
55
|
+
# Mapping from debug symbol to operation path.
|
|
56
|
+
debugSymbolToOperationPath: Dict[str, List[Dict[str, str]]]
|
|
57
|
+
# Mapping from debug symbol to handle.
|
|
58
|
+
debugSymbolToHandles: Dict[str, List[int]]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@final
|
|
62
|
+
class CoreMLBackend(BackendDetails):
|
|
63
|
+
class MODEL_TYPE(Enum):
|
|
64
|
+
MODEL = "model"
|
|
65
|
+
COMPILED_MODEL = "compiled_model"
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def generate_model_type_compile_spec(model_type: MODEL_TYPE) -> CompileSpec:
|
|
69
|
+
"""
|
|
70
|
+
Returns the compile spec representing the given model type.
|
|
71
|
+
|
|
72
|
+
If the model type is ``MODEL_TYPE.Model`` then the ``CoreMLBackend`` returns
|
|
73
|
+
the in-memory representation of the ``mlpackage`` contents.
|
|
74
|
+
|
|
75
|
+
If the model type is ``MODEL_TYPE.COMPILED_MODEL`` then the ``CoreMLBackend`` compiles the model
|
|
76
|
+
and returns the in-memory representation of ``mlmodelc`` (compiled model) contents.
|
|
77
|
+
"""
|
|
78
|
+
return CompileSpec(
|
|
79
|
+
COMPILE_SPEC_KEYS.MODEL_TYPE.value, model_type.value.encode("utf-8")
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def model_type_from_compile_specs(compile_specs: List[CompileSpec]) -> MODEL_TYPE:
|
|
84
|
+
"""
|
|
85
|
+
Returns the model type by parsing the list of compile specs.
|
|
86
|
+
"""
|
|
87
|
+
for compile_spec in compile_specs:
|
|
88
|
+
if compile_spec.key == COMPILE_SPEC_KEYS.MODEL_TYPE.value:
|
|
89
|
+
return CoreMLBackend.MODEL_TYPE(compile_spec.value.decode("utf-8"))
|
|
90
|
+
|
|
91
|
+
return CoreMLBackend.MODEL_TYPE.MODEL
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def generate_compute_precision_compile_spec(
|
|
95
|
+
compute_precision: ct.precision,
|
|
96
|
+
) -> CompileSpec:
|
|
97
|
+
"""
|
|
98
|
+
Returns the compile spec representing the model compute precision, for additional details
|
|
99
|
+
please refer to the documentation for ``coremltools.precision``.
|
|
100
|
+
"""
|
|
101
|
+
return CompileSpec(
|
|
102
|
+
COMPILE_SPEC_KEYS.MODEL_COMPUTE_PRECISION.value,
|
|
103
|
+
compute_precision.value.encode("utf-8"),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def model_compute_precision_from_compile_specs(
|
|
108
|
+
compile_specs: List[CompileSpec],
|
|
109
|
+
) -> ct.precision:
|
|
110
|
+
"""
|
|
111
|
+
Returns the model's compute precision by parsing the list of compile specs.
|
|
112
|
+
"""
|
|
113
|
+
for compile_spec in compile_specs:
|
|
114
|
+
if compile_spec.key == COMPILE_SPEC_KEYS.MODEL_COMPUTE_PRECISION.value:
|
|
115
|
+
return ct.precision(compile_spec.value.decode("utf-8"))
|
|
116
|
+
|
|
117
|
+
return ct.precision.FLOAT16
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def generate_minimum_deployment_target_compile_spec(
|
|
121
|
+
min_deployment_target: ct.target,
|
|
122
|
+
) -> CompileSpec:
|
|
123
|
+
"""
|
|
124
|
+
Returns the compile spec representing the minimum deployment target on which the model can run,
|
|
125
|
+
for additional details please refer to the documentation for ``coremltools.target``.
|
|
126
|
+
"""
|
|
127
|
+
return CompileSpec(
|
|
128
|
+
COMPILE_SPEC_KEYS.MIN_DEPLOYMENT_TARGET.value,
|
|
129
|
+
str(min_deployment_target.value).encode("utf-8"),
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def min_deployment_target_from_compile_specs(
|
|
134
|
+
compile_specs: List[CompileSpec],
|
|
135
|
+
) -> ct.target:
|
|
136
|
+
"""
|
|
137
|
+
Returns the minimum deployment target by parsing the list of compile specs.
|
|
138
|
+
"""
|
|
139
|
+
for compile_spec in compile_specs:
|
|
140
|
+
if compile_spec.key == COMPILE_SPEC_KEYS.MIN_DEPLOYMENT_TARGET.value:
|
|
141
|
+
compile_spec_value: int = int(compile_spec.value.decode("utf-8"))
|
|
142
|
+
return ct.target(compile_spec_value)
|
|
143
|
+
|
|
144
|
+
return ct.target.iOS15
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def generate_compute_unit_compile_spec(
|
|
148
|
+
compute_unit: ct.ComputeUnit,
|
|
149
|
+
) -> CompileSpec:
|
|
150
|
+
"""
|
|
151
|
+
Returns the compile spec representing the compute units on which the model can run, for additional details
|
|
152
|
+
please refer to the documentation for ``coremltools.ComputeUnit`.
|
|
153
|
+
"""
|
|
154
|
+
return CompileSpec(
|
|
155
|
+
COMPILE_SPEC_KEYS.COMPUTE_UNITS.value,
|
|
156
|
+
compute_unit.name.lower().encode("utf-8"),
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
@staticmethod
|
|
160
|
+
def generate_compile_specs(
|
|
161
|
+
compute_unit: ct.ComputeUnit = ct.ComputeUnit.ALL,
|
|
162
|
+
minimum_deployment_target: ct.target = ct.target.iOS15,
|
|
163
|
+
compute_precision: ct.precision = ct.precision.FLOAT16,
|
|
164
|
+
model_type: MODEL_TYPE = MODEL_TYPE.MODEL,
|
|
165
|
+
) -> List[CompileSpec]:
|
|
166
|
+
"""
|
|
167
|
+
Returns the list of compile specs that's used by CoreMLBackend to lower the module.
|
|
168
|
+
"""
|
|
169
|
+
compile_specs: List[CompileSpec] = []
|
|
170
|
+
compile_specs.append(
|
|
171
|
+
CoreMLBackend.generate_compute_unit_compile_spec(compute_unit)
|
|
172
|
+
)
|
|
173
|
+
compile_specs.append(
|
|
174
|
+
CoreMLBackend.generate_minimum_deployment_target_compile_spec(
|
|
175
|
+
minimum_deployment_target
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
compile_specs.append(
|
|
179
|
+
CoreMLBackend.generate_compute_precision_compile_spec(compute_precision)
|
|
180
|
+
)
|
|
181
|
+
compile_specs.append(CoreMLBackend.generate_model_type_compile_spec(model_type))
|
|
182
|
+
|
|
183
|
+
return compile_specs
|
|
184
|
+
|
|
185
|
+
@staticmethod
|
|
186
|
+
def model_metadata_from_spec(
|
|
187
|
+
model_spec: ct.proto.Model_pb2, identifier: str
|
|
188
|
+
) -> Dict[str, str]:
|
|
189
|
+
input_names: List[str] = [input.name for input in model_spec.description.input]
|
|
190
|
+
output_names = [output.name for output in model_spec.description.output]
|
|
191
|
+
|
|
192
|
+
return ModelMetadata(
|
|
193
|
+
inputNames=input_names, outputNames=output_names, identifier=identifier
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
@staticmethod
|
|
197
|
+
def get_debug_symbol(operation_path: List[Dict[str, str]]) -> Optional[str]:
|
|
198
|
+
if len(operation_path) == 0:
|
|
199
|
+
return None
|
|
200
|
+
|
|
201
|
+
operator_name: Optional[str] = operation_path[-1].get("Operator", None)
|
|
202
|
+
output_name: Optional[str] = operation_path[-1].get("Output", None)
|
|
203
|
+
if output_name is None or operator_name is None:
|
|
204
|
+
return None
|
|
205
|
+
|
|
206
|
+
return output_name + ":" + operator_name
|
|
207
|
+
|
|
208
|
+
@staticmethod
|
|
209
|
+
def get_model_debug_info(model_package_dir: Path) -> Optional[ModelDebugInfo]:
|
|
210
|
+
delegate_info_file = model_package_dir / "executorch_debug_handle_mapping.json"
|
|
211
|
+
|
|
212
|
+
if not delegate_info_file.is_file():
|
|
213
|
+
return None
|
|
214
|
+
|
|
215
|
+
delegate_info: Optional[Dict[str, Any]] = None
|
|
216
|
+
|
|
217
|
+
try:
|
|
218
|
+
with open(delegate_info_file) as f:
|
|
219
|
+
delegate_info = json.load(f)
|
|
220
|
+
except ValueError:
|
|
221
|
+
return None
|
|
222
|
+
|
|
223
|
+
if delegate_info is None:
|
|
224
|
+
return None
|
|
225
|
+
|
|
226
|
+
debug_handle_to_operation_path_mapping: Optional[Dict[str, Any]] = (
|
|
227
|
+
delegate_info.get("mapping", None)
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
if debug_handle_to_operation_path_mapping is None:
|
|
231
|
+
return None
|
|
232
|
+
|
|
233
|
+
debug_symbol_to_operation_path: Dict[str, List[Dict[str, str]]] = {}
|
|
234
|
+
debug_symbol_to_handles: Dict[str, List[int]] = {}
|
|
235
|
+
for (
|
|
236
|
+
debug_handle,
|
|
237
|
+
operation_paths,
|
|
238
|
+
) in debug_handle_to_operation_path_mapping.items():
|
|
239
|
+
debug_handle_value: Optional[int] = None
|
|
240
|
+
try:
|
|
241
|
+
debug_handle_value = int(debug_handle)
|
|
242
|
+
except ValueError:
|
|
243
|
+
debug_handle_value = None
|
|
244
|
+
|
|
245
|
+
if debug_handle_value is None:
|
|
246
|
+
continue
|
|
247
|
+
|
|
248
|
+
for operation_path in operation_paths:
|
|
249
|
+
debug_symbol: Optional[str] = CoreMLBackend.get_debug_symbol(
|
|
250
|
+
operation_path=operation_path
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
if debug_symbol is None:
|
|
254
|
+
continue
|
|
255
|
+
|
|
256
|
+
debug_handle_values: List[int] = debug_symbol_to_handles.get(
|
|
257
|
+
debug_symbol, []
|
|
258
|
+
)
|
|
259
|
+
debug_handle_values.append(debug_handle_value)
|
|
260
|
+
debug_symbol_to_handles[debug_symbol] = debug_handle_values
|
|
261
|
+
|
|
262
|
+
debug_symbol_to_operation_path[debug_symbol] = operation_path
|
|
263
|
+
|
|
264
|
+
version_info: Dict[str, str] = delegate_info.get("version", {})
|
|
265
|
+
|
|
266
|
+
return ModelDebugInfo(
|
|
267
|
+
versionInfo=version_info,
|
|
268
|
+
debugSymbolToOperationPath=debug_symbol_to_operation_path,
|
|
269
|
+
debugSymbolToHandles=debug_symbol_to_handles,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
@staticmethod
|
|
273
|
+
def save_model_metadata(model_metadata: ModelMetadata, model_dir_path: Path):
|
|
274
|
+
# Store model metadata.
|
|
275
|
+
model_metadata_path = Path(model_dir_path) / MODEL_PATHS.METADATA.value
|
|
276
|
+
model_metadata_json = json.dumps(asdict(model_metadata))
|
|
277
|
+
with open(model_metadata_path, "w") as outfile:
|
|
278
|
+
outfile.write(model_metadata_json)
|
|
279
|
+
|
|
280
|
+
@staticmethod
|
|
281
|
+
def save_model_debug_info(model_debug_info: ModelDebugInfo, model_dir_path: Path):
|
|
282
|
+
# Store model debug info.
|
|
283
|
+
model_debug_info_path = Path(model_dir_path) / MODEL_PATHS.DEBUG_INFO.value
|
|
284
|
+
model_debug_info_json = json.dumps(asdict(model_debug_info))
|
|
285
|
+
with open(model_debug_info_path, "w") as outfile:
|
|
286
|
+
outfile.write(model_debug_info_json)
|
|
287
|
+
|
|
288
|
+
@staticmethod
|
|
289
|
+
def preprocess_model(
|
|
290
|
+
mlmodel: ct.models.MLModel, model_type: MODEL_TYPE
|
|
291
|
+
) -> PreprocessResult:
|
|
292
|
+
identifier = str(uuid.uuid4())
|
|
293
|
+
dir_path: Path = Path("tmp") / identifier
|
|
294
|
+
model_dir_path: Path = dir_path / "lowered_module"
|
|
295
|
+
model_spec: ct.proto.Model_pb2 = mlmodel.get_spec()
|
|
296
|
+
model_metadata: ModelMetadata = CoreMLBackend.model_metadata_from_spec(
|
|
297
|
+
model_spec=model_spec,
|
|
298
|
+
identifier=identifier,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
# Save model.
|
|
302
|
+
model_path = model_dir_path / MODEL_PATHS.MODEL.value
|
|
303
|
+
mlmodel.save(model_path)
|
|
304
|
+
# Extract delegate mapping file.
|
|
305
|
+
model_debug_info: Optional[ModelDebugInfo] = CoreMLBackend.get_model_debug_info(
|
|
306
|
+
model_path
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
match model_type:
|
|
310
|
+
case CoreMLBackend.MODEL_TYPE.COMPILED_MODEL:
|
|
311
|
+
shutil.rmtree(str(model_path.resolve()))
|
|
312
|
+
model_path = model_dir_path / MODEL_PATHS.COMPILED_MODEL.value
|
|
313
|
+
compiled_model_path = mlmodel.get_compiled_model_path()
|
|
314
|
+
shutil.move(
|
|
315
|
+
compiled_model_path,
|
|
316
|
+
str(model_path.resolve()),
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
case _:
|
|
320
|
+
pass
|
|
321
|
+
|
|
322
|
+
CoreMLBackend.save_model_metadata(
|
|
323
|
+
model_metadata=model_metadata, model_dir_path=model_dir_path
|
|
324
|
+
)
|
|
325
|
+
if model_debug_info is not None:
|
|
326
|
+
CoreMLBackend.save_model_debug_info(
|
|
327
|
+
model_debug_info=model_debug_info, model_dir_path=model_dir_path
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
processed_bytes: bytes = executorchcoreml.flatten_directory_contents(
|
|
331
|
+
str(model_dir_path.resolve())
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
debug_handle_map: Optional[Dict[str, Tuple[int]]] = None
|
|
335
|
+
if model_debug_info is not None:
|
|
336
|
+
debug_handle_map = model_debug_info.debugSymbolToHandles
|
|
337
|
+
|
|
338
|
+
shutil.rmtree(str(dir_path.resolve()))
|
|
339
|
+
return PreprocessResult(
|
|
340
|
+
processed_bytes=processed_bytes,
|
|
341
|
+
debug_handle_map=debug_handle_map,
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
@classmethod
|
|
345
|
+
def preprocess(
|
|
346
|
+
cls,
|
|
347
|
+
edge_program: ExportedProgram,
|
|
348
|
+
module_compile_specs: List[CompileSpec],
|
|
349
|
+
) -> PreprocessResult:
|
|
350
|
+
model_type: CoreMLBackend.MODEL_TYPE = (
|
|
351
|
+
CoreMLBackend.model_type_from_compile_specs(
|
|
352
|
+
module_compile_specs,
|
|
353
|
+
)
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
model_compute_precision: ct.precision = (
|
|
357
|
+
CoreMLBackend.model_compute_precision_from_compile_specs(
|
|
358
|
+
module_compile_specs
|
|
359
|
+
)
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
minimum_deployment_target: ct.target = (
|
|
363
|
+
CoreMLBackend.min_deployment_target_from_compile_specs(module_compile_specs)
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
mlmodel = ct.convert(
|
|
367
|
+
model=edge_program,
|
|
368
|
+
source="pytorch",
|
|
369
|
+
convert_to="mlprogram",
|
|
370
|
+
pass_pipeline=ct.PassPipeline.DEFAULT,
|
|
371
|
+
skip_model_load=False,
|
|
372
|
+
compute_precision=model_compute_precision,
|
|
373
|
+
minimum_deployment_target=minimum_deployment_target,
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
return CoreMLBackend.preprocess_model(mlmodel, model_type=model_type)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Copyright © 2023 Apple Inc. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Please refer to the license found in the LICENSE file in the root directory of the source tree.
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
|
|
8
|
+
import coremltools as ct
|
|
9
|
+
|
|
10
|
+
import torch
|
|
11
|
+
|
|
12
|
+
from executorch.backends.apple.coreml.compiler import CoreMLBackend
|
|
13
|
+
from executorch.exir.backend.compile_spec_schema import CompileSpec
|
|
14
|
+
|
|
15
|
+
from executorch.exir.backend.partitioner import (
|
|
16
|
+
DelegationSpec,
|
|
17
|
+
Partitioner,
|
|
18
|
+
PartitionResult,
|
|
19
|
+
)
|
|
20
|
+
from executorch.exir.backend.utils import tag_constant_data
|
|
21
|
+
from torch.export.exported_program import ExportedProgram
|
|
22
|
+
from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner
|
|
23
|
+
from torch.fx.passes.operator_support import OperatorSupportBase
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
logger.setLevel(logging.WARNING)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class OperatorsSupportedForCoreMLBackend(OperatorSupportBase):
|
|
30
|
+
def __init__(
|
|
31
|
+
self, skip_ops_for_coreml_delegation: Optional[List[str]] = None
|
|
32
|
+
) -> None:
|
|
33
|
+
if skip_ops_for_coreml_delegation is None:
|
|
34
|
+
skip_ops_for_coreml_delegation = []
|
|
35
|
+
super().__init__()
|
|
36
|
+
self.skip_ops_for_coreml_delegation = skip_ops_for_coreml_delegation
|
|
37
|
+
|
|
38
|
+
def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
|
|
39
|
+
# get_attr node can always be supported on any backend
|
|
40
|
+
if node.op == "get_attr":
|
|
41
|
+
return True
|
|
42
|
+
# check if the PyTorch op get called is supported in Core ML
|
|
43
|
+
elif node.op == "call_function":
|
|
44
|
+
# skip ops if specified by user
|
|
45
|
+
node_target_name = node.target.__name__.lower()
|
|
46
|
+
if node_target_name in self.skip_ops_for_coreml_delegation:
|
|
47
|
+
return False
|
|
48
|
+
# query coremltools to see if node is supported
|
|
49
|
+
return ct.converters.mil.frontend.torch.is_torch_fx_node_supported(node)
|
|
50
|
+
# cowardly refuse to support all other types of node:
|
|
51
|
+
# 1. placeholder / output nodes should not be tagged
|
|
52
|
+
# reference: https://github.com/pytorch/executorch/pull/1398
|
|
53
|
+
# 2. call_module / call_method should have been replaced with call_function?
|
|
54
|
+
else:
|
|
55
|
+
return False
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CoreMLPartitioner(Partitioner):
|
|
59
|
+
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
skip_ops_for_coreml_delegation: Optional[List[str]] = None,
|
|
63
|
+
compile_specs: Optional[List[CompileSpec]] = None,
|
|
64
|
+
) -> None:
|
|
65
|
+
if skip_ops_for_coreml_delegation is None:
|
|
66
|
+
skip_ops_for_coreml_delegation = []
|
|
67
|
+
self.skip_ops_for_coreml_delegation = skip_ops_for_coreml_delegation
|
|
68
|
+
self.delegation_spec = DelegationSpec(
|
|
69
|
+
backend_id=CoreMLBackend.__name__,
|
|
70
|
+
compile_specs=compile_specs if compile_specs is not None else [],
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def partition(self, exported_program: ExportedProgram) -> PartitionResult:
|
|
74
|
+
# Run the CapabilityBasedPartitioner to return the largest possible
|
|
75
|
+
# subgraphs containing the nodes with the tags
|
|
76
|
+
logger.info("CoreMLPartitioner::partition")
|
|
77
|
+
partition_tags = {}
|
|
78
|
+
|
|
79
|
+
capability_partitioner = CapabilityBasedPartitioner(
|
|
80
|
+
exported_program.graph_module,
|
|
81
|
+
OperatorsSupportedForCoreMLBackend(self.skip_ops_for_coreml_delegation),
|
|
82
|
+
allows_single_node_partition=True,
|
|
83
|
+
)
|
|
84
|
+
partition_list = capability_partitioner.propose_partitions()
|
|
85
|
+
for partition in partition_list:
|
|
86
|
+
for node in partition.nodes:
|
|
87
|
+
tag = f"tag{partition.id}"
|
|
88
|
+
node.meta["delegation_tag"] = tag
|
|
89
|
+
partition_tags[tag] = self.delegation_spec
|
|
90
|
+
|
|
91
|
+
tag_constant_data(exported_program)
|
|
92
|
+
|
|
93
|
+
return PartitionResult(
|
|
94
|
+
tagged_exported_program=exported_program, partition_tags=partition_tags
|
|
95
|
+
)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Copyright © 2024 Apple Inc. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Please refer to the license found in the LICENSE file in the root directory of the source tree.
|
|
4
|
+
|
|
5
|
+
from coremltools.optimize.torch.quantization._coreml_quantizer import ( # noqa: FLAKE8 F401
|
|
6
|
+
CoreMLQuantizer,
|
|
7
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import pathlib
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent.parent.parent
|
|
7
|
+
PYBIND11_DIR_PATH = REPO_ROOT / "third-party" / "pybind11"
|
|
8
|
+
sys.path.append(str(PYBIND11_DIR_PATH.absolute()))
|
|
9
|
+
|
|
10
|
+
from pybind11.setup_helpers import build_ext, Pybind11Extension
|
|
11
|
+
from setuptools import setup
|
|
12
|
+
|
|
13
|
+
__version__ = "0.0.1"
|
|
14
|
+
|
|
15
|
+
cxx_std = int(os.environ.get("CMAKE_CXX_STANDARD", "17"))
|
|
16
|
+
|
|
17
|
+
ext_modules = [
|
|
18
|
+
Pybind11Extension(
|
|
19
|
+
"executorchcoreml",
|
|
20
|
+
[
|
|
21
|
+
"../util/json_util.cpp",
|
|
22
|
+
"inmemory_filesystem.cpp",
|
|
23
|
+
"inmemory_filesystem_py.cpp",
|
|
24
|
+
"inmemory_filesystem_utils.cpp",
|
|
25
|
+
"memory_buffer.cpp",
|
|
26
|
+
"memory_stream.cpp",
|
|
27
|
+
"reversed_memory_stream.cpp",
|
|
28
|
+
],
|
|
29
|
+
define_macros=[("VERSION_INFO", __version__)],
|
|
30
|
+
cxx_std=cxx_std,
|
|
31
|
+
extra_compile_args=["-mmacosx-version-min=10.15", "-g"],
|
|
32
|
+
include_dirs=[
|
|
33
|
+
"../../third-party/nlohmann_json/single_include/nlohmann",
|
|
34
|
+
".",
|
|
35
|
+
"../util",
|
|
36
|
+
],
|
|
37
|
+
),
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
setup(
|
|
41
|
+
name="executorchcoreml",
|
|
42
|
+
version=__version__,
|
|
43
|
+
description="CoreML extension for executorch",
|
|
44
|
+
long_description="",
|
|
45
|
+
author="Apple Inc.",
|
|
46
|
+
ext_modules=ext_modules,
|
|
47
|
+
extras_require={"test": "pytest"},
|
|
48
|
+
cmdclass={"build_ext": build_ext},
|
|
49
|
+
include_package_data=True,
|
|
50
|
+
zip_safe=False,
|
|
51
|
+
python_requires=">=3.9",
|
|
52
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright © 2023 Apple Inc. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Please refer to the license found in the LICENSE file in the root directory of the source tree.
|
|
4
|
+
|
|
5
|
+
import unittest
|
|
6
|
+
|
|
7
|
+
import executorch.exir
|
|
8
|
+
|
|
9
|
+
import torch
|
|
10
|
+
import torchvision
|
|
11
|
+
|
|
12
|
+
from executorch.backends.apple.coreml.partition.coreml_partitioner import (
|
|
13
|
+
CoreMLPartitioner,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestCoreMLPartitioner(unittest.TestCase):
|
|
18
|
+
def test_add_sub_skip_mm(self):
|
|
19
|
+
class Model(torch.nn.Module):
|
|
20
|
+
def forward(self, a, x, b):
|
|
21
|
+
y = torch.mm(a, x)
|
|
22
|
+
z = y + b
|
|
23
|
+
a = z - a
|
|
24
|
+
y = torch.mm(a, x)
|
|
25
|
+
z = y + b
|
|
26
|
+
return z
|
|
27
|
+
|
|
28
|
+
model = Model()
|
|
29
|
+
model.eval()
|
|
30
|
+
|
|
31
|
+
example_inputs = (torch.randn(2, 2), torch.randn(2, 2), torch.randn(2, 2))
|
|
32
|
+
exir_program_aten = torch.export.export(model, example_inputs)
|
|
33
|
+
edge_program_manager = executorch.exir.to_edge(exir_program_aten)
|
|
34
|
+
delegated_program_manager = edge_program_manager.to_backend(
|
|
35
|
+
CoreMLPartitioner(skip_ops_for_coreml_delegation=["aten.mm.default"])
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
assert [
|
|
39
|
+
node.target.__name__
|
|
40
|
+
for node in delegated_program_manager.exported_program().graph.nodes
|
|
41
|
+
if node.op == "call_function"
|
|
42
|
+
] == [
|
|
43
|
+
"aten.mm.default",
|
|
44
|
+
"executorch_call_delegate",
|
|
45
|
+
"getitem",
|
|
46
|
+
"aten.mm.default",
|
|
47
|
+
"executorch_call_delegate",
|
|
48
|
+
"getitem",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
def test_vit_skip_conv(self):
|
|
52
|
+
model = torchvision.models.vit_b_16(weights="IMAGENET1K_V1")
|
|
53
|
+
model.eval()
|
|
54
|
+
|
|
55
|
+
example_inputs = (torch.randn(1, 3, 224, 224),)
|
|
56
|
+
exir_program_aten = torch.export.export(model, example_inputs)
|
|
57
|
+
edge_program_manager = executorch.exir.to_edge(exir_program_aten)
|
|
58
|
+
delegated_program_manager = edge_program_manager.to_backend(
|
|
59
|
+
CoreMLPartitioner(
|
|
60
|
+
skip_ops_for_coreml_delegation=["aten.convolution.default"]
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
assert [
|
|
65
|
+
node.target.__name__
|
|
66
|
+
for node in delegated_program_manager.exported_program().graph.nodes
|
|
67
|
+
if node.op == "call_function"
|
|
68
|
+
] == [
|
|
69
|
+
"aten.convolution.default",
|
|
70
|
+
"executorch_call_delegate",
|
|
71
|
+
"getitem",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
test_runner = TestCoreMLPartitioner()
|
|
77
|
+
test_runner.test_add_sub_skip_mm()
|
|
78
|
+
test_runner.test_vit_skip_conv()
|