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.
Files changed (1020) hide show
  1. executorch/backends/apple/coreml/compiler/__init__.py +9 -0
  2. executorch/backends/apple/coreml/compiler/coreml_preprocess.py +376 -0
  3. executorch/backends/apple/coreml/partition/coreml_partitioner.py +95 -0
  4. executorch/backends/apple/coreml/quantizer/coreml_quantizer.py +7 -0
  5. executorch/backends/apple/coreml/runtime/inmemoryfs/setup.py +52 -0
  6. executorch/backends/apple/coreml/test/test_coreml_partitioner.py +78 -0
  7. executorch/backends/apple/coreml/test/test_coreml_quantizer.py +112 -0
  8. executorch/backends/apple/mps/mps_preprocess.py +195 -0
  9. executorch/backends/apple/mps/operators/__init__.py +70 -0
  10. executorch/backends/apple/mps/operators/activation_ops.py +99 -0
  11. executorch/backends/apple/mps/operators/binary_ops.py +156 -0
  12. executorch/backends/apple/mps/operators/clamp_ops.py +60 -0
  13. executorch/backends/apple/mps/operators/constant_ops.py +109 -0
  14. executorch/backends/apple/mps/operators/convolution_ops.py +70 -0
  15. executorch/backends/apple/mps/operators/indexing_ops.py +145 -0
  16. executorch/backends/apple/mps/operators/linear_algebra_ops.py +52 -0
  17. executorch/backends/apple/mps/operators/node_visitor.py +406 -0
  18. executorch/backends/apple/mps/operators/normalization_ops.py +97 -0
  19. executorch/backends/apple/mps/operators/op_clone.py +35 -0
  20. executorch/backends/apple/mps/operators/op_getitem.py +29 -0
  21. executorch/backends/apple/mps/operators/pad_ops.py +37 -0
  22. executorch/backends/apple/mps/operators/pooling_ops.py +142 -0
  23. executorch/backends/apple/mps/operators/range_ops.py +53 -0
  24. executorch/backends/apple/mps/operators/reduce_ops.py +39 -0
  25. executorch/backends/apple/mps/operators/shape_ops.py +260 -0
  26. executorch/backends/apple/mps/operators/unary_ops.py +130 -0
  27. executorch/backends/apple/mps/partition/mps_partitioner.py +140 -0
  28. executorch/backends/apple/mps/serialization/mps_graph_schema.py +769 -0
  29. executorch/backends/apple/mps/serialization/mps_graph_serialize.py +30 -0
  30. executorch/backends/apple/mps/serialization/schema.fbs +469 -0
  31. executorch/backends/apple/mps/test/test_mps.py +2449 -0
  32. executorch/backends/apple/mps/test/test_mps_binary_ops.py +296 -0
  33. executorch/backends/apple/mps/test/test_mps_indexing_ops.py +225 -0
  34. executorch/backends/apple/mps/test/test_mps_models.py +416 -0
  35. executorch/backends/apple/mps/test/test_mps_unary_ops.py +26 -0
  36. executorch/backends/apple/mps/test/test_mps_utils.py +306 -0
  37. executorch/backends/apple/mps/utils/mps_utils.py +81 -0
  38. executorch/backends/arm/arm_backend.py +226 -0
  39. executorch/backends/arm/arm_partitioner.py +94 -0
  40. executorch/backends/arm/arm_quantizer.py +464 -0
  41. executorch/backends/arm/arm_quantizer_utils.py +1040 -0
  42. executorch/backends/arm/arm_vela.py +95 -0
  43. executorch/backends/arm/operators/__init__.py +23 -0
  44. executorch/backends/arm/operators/node_visitor.py +46 -0
  45. executorch/backends/arm/operators/op_add.py +107 -0
  46. executorch/backends/arm/operators/op_addmm.py +164 -0
  47. executorch/backends/arm/operators/op_avg_pool2d.py +49 -0
  48. executorch/backends/arm/operators/op_batch_norm.py +101 -0
  49. executorch/backends/arm/operators/op_clone.py +34 -0
  50. executorch/backends/arm/operators/op_common.py +52 -0
  51. executorch/backends/arm/operators/op_conv2d.py +169 -0
  52. executorch/backends/arm/operators/op_dequant.py +34 -0
  53. executorch/backends/arm/operators/op_div.py +40 -0
  54. executorch/backends/arm/operators/op_get_item.py +34 -0
  55. executorch/backends/arm/operators/op_hardtanh.py +41 -0
  56. executorch/backends/arm/operators/op_mean_dim.py +58 -0
  57. executorch/backends/arm/operators/op_permute.py +45 -0
  58. executorch/backends/arm/operators/op_placeholder.py +171 -0
  59. executorch/backends/arm/operators/op_quant.py +34 -0
  60. executorch/backends/arm/operators/op_softmax.py +95 -0
  61. executorch/backends/arm/operators/op_view.py +38 -0
  62. executorch/backends/arm/test/arm_tosa_reference.py +319 -0
  63. executorch/backends/arm/test/common.py +15 -0
  64. executorch/backends/arm/test/misc/test_debug_feats.py +96 -0
  65. executorch/backends/arm/test/models/test_mobilenet_v2_arm.py +102 -0
  66. executorch/backends/arm/test/ops/test_add.py +163 -0
  67. executorch/backends/arm/test/ops/test_avg_pool.py +165 -0
  68. executorch/backends/arm/test/ops/test_conv.py +331 -0
  69. executorch/backends/arm/test/ops/test_conv_combos.py +272 -0
  70. executorch/backends/arm/test/ops/test_depthwise_conv.py +215 -0
  71. executorch/backends/arm/test/ops/test_linear.py +230 -0
  72. executorch/backends/arm/test/ops/test_mean_dim.py +155 -0
  73. executorch/backends/arm/test/ops/test_softmax.py +149 -0
  74. executorch/backends/arm/test/test_models.py +155 -0
  75. executorch/backends/arm/test/test_tosa.py +110 -0
  76. executorch/backends/arm/test/tester/__init__.py +6 -0
  77. executorch/backends/arm/test/tester/arm_tester.py +289 -0
  78. executorch/backends/arm/test/tosautil/__init__.py +6 -0
  79. executorch/backends/arm/test/tosautil/tosa_test_utils.py +218 -0
  80. executorch/backends/arm/third-party/serialization_lib/python/serializer/__init__.py +3 -0
  81. executorch/backends/arm/third-party/serialization_lib/python/serializer/tosa_serializer.py +965 -0
  82. executorch/backends/arm/third-party/serialization_lib/python/tosa/ArithmeticRightShiftAttribute.py +54 -0
  83. executorch/backends/arm/third-party/serialization_lib/python/tosa/Attribute.py +29 -0
  84. executorch/backends/arm/third-party/serialization_lib/python/tosa/AxisAttribute.py +54 -0
  85. executorch/backends/arm/third-party/serialization_lib/python/tosa/ClampAttribute.py +145 -0
  86. executorch/backends/arm/third-party/serialization_lib/python/tosa/CondIfAttribute.py +67 -0
  87. executorch/backends/arm/third-party/serialization_lib/python/tosa/ConvAttribute.py +197 -0
  88. executorch/backends/arm/third-party/serialization_lib/python/tosa/CustomAttribute.py +106 -0
  89. executorch/backends/arm/third-party/serialization_lib/python/tosa/DType.py +18 -0
  90. executorch/backends/arm/third-party/serialization_lib/python/tosa/FFTAttribute.py +67 -0
  91. executorch/backends/arm/third-party/serialization_lib/python/tosa/FullyConnectedAttribute.py +67 -0
  92. executorch/backends/arm/third-party/serialization_lib/python/tosa/MatMulAttribute.py +67 -0
  93. executorch/backends/arm/third-party/serialization_lib/python/tosa/MulAttribute.py +54 -0
  94. executorch/backends/arm/third-party/serialization_lib/python/tosa/NegateAttribute.py +67 -0
  95. executorch/backends/arm/third-party/serialization_lib/python/tosa/Op.py +78 -0
  96. executorch/backends/arm/third-party/serialization_lib/python/tosa/PadAttribute.py +132 -0
  97. executorch/backends/arm/third-party/serialization_lib/python/tosa/PoolAttribute.py +197 -0
  98. executorch/backends/arm/third-party/serialization_lib/python/tosa/RFFTAttribute.py +54 -0
  99. executorch/backends/arm/third-party/serialization_lib/python/tosa/RescaleAttribute.py +210 -0
  100. executorch/backends/arm/third-party/serialization_lib/python/tosa/ReshapeAttribute.py +80 -0
  101. executorch/backends/arm/third-party/serialization_lib/python/tosa/ResizeAttribute.py +171 -0
  102. executorch/backends/arm/third-party/serialization_lib/python/tosa/ResizeMode.py +8 -0
  103. executorch/backends/arm/third-party/serialization_lib/python/tosa/SliceAttribute.py +119 -0
  104. executorch/backends/arm/third-party/serialization_lib/python/tosa/TableAttribute.py +80 -0
  105. executorch/backends/arm/third-party/serialization_lib/python/tosa/TileAttribute.py +80 -0
  106. executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaBasicBlock.py +192 -0
  107. executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaGraph.py +95 -0
  108. executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaOperator.py +147 -0
  109. executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaRegion.py +91 -0
  110. executorch/backends/arm/third-party/serialization_lib/python/tosa/TosaTensor.py +184 -0
  111. executorch/backends/arm/third-party/serialization_lib/python/tosa/TransposeAttribute.py +80 -0
  112. executorch/backends/arm/third-party/serialization_lib/python/tosa/TransposeConvAttribute.py +197 -0
  113. executorch/backends/arm/third-party/serialization_lib/python/tosa/Version.py +93 -0
  114. executorch/backends/arm/third-party/serialization_lib/python/tosa/WhileLoopAttribute.py +67 -0
  115. executorch/backends/arm/third-party/serialization_lib/python/tosa/__init__.py +0 -0
  116. executorch/backends/arm/third-party/serialization_lib/schema/tosa.fbs +324 -0
  117. executorch/backends/arm/third-party/serialization_lib/setup.py +18 -0
  118. executorch/backends/arm/third-party/serialization_lib/test/scripts/test_npy_fileio.py +152 -0
  119. executorch/backends/arm/third-party/serialization_lib/test/scripts/xunit/xunit.py +109 -0
  120. executorch/backends/arm/tosa_mapping.py +109 -0
  121. executorch/backends/arm/tosa_quant_utils.py +217 -0
  122. executorch/backends/arm/tosa_utils.py +189 -0
  123. executorch/backends/example/example_backend.py +41 -0
  124. executorch/backends/example/example_backend_delegate_passes/merge_to_dim_pass.py +79 -0
  125. executorch/backends/example/example_backend_delegate_passes/permute_memory_formats_pass.py +143 -0
  126. executorch/backends/example/example_operators/adaptive_avg_pool2d.py +47 -0
  127. executorch/backends/example/example_operators/add.py +44 -0
  128. executorch/backends/example/example_operators/conv2d.py +52 -0
  129. executorch/backends/example/example_operators/conv_relu.py +49 -0
  130. executorch/backends/example/example_operators/dropout.py +44 -0
  131. executorch/backends/example/example_operators/flatten.py +40 -0
  132. executorch/backends/example/example_operators/linear.py +62 -0
  133. executorch/backends/example/example_operators/op_base.py +15 -0
  134. executorch/backends/example/example_operators/ops.py +32 -0
  135. executorch/backends/example/example_operators/utils.py +33 -0
  136. executorch/backends/example/example_partitioner.py +88 -0
  137. executorch/backends/example/example_quantizer.py +102 -0
  138. executorch/backends/example/test_example_delegate.py +110 -0
  139. executorch/backends/qualcomm/aot/ir/qcir.fbs +97 -0
  140. executorch/backends/qualcomm/builders/__init__.py +95 -0
  141. executorch/backends/qualcomm/builders/node_visitor.py +404 -0
  142. executorch/backends/qualcomm/builders/op_add.py +61 -0
  143. executorch/backends/qualcomm/builders/op_avg_pool2d.py +143 -0
  144. executorch/backends/qualcomm/builders/op_batch_norm.py +92 -0
  145. executorch/backends/qualcomm/builders/op_bmm.py +58 -0
  146. executorch/backends/qualcomm/builders/op_cast.py +57 -0
  147. executorch/backends/qualcomm/builders/op_cat.py +84 -0
  148. executorch/backends/qualcomm/builders/op_ceil.py +55 -0
  149. executorch/backends/qualcomm/builders/op_clamp.py +78 -0
  150. executorch/backends/qualcomm/builders/op_conv2d.py +363 -0
  151. executorch/backends/qualcomm/builders/op_depth_to_space.py +76 -0
  152. executorch/backends/qualcomm/builders/op_dequantize.py +75 -0
  153. executorch/backends/qualcomm/builders/op_div.py +61 -0
  154. executorch/backends/qualcomm/builders/op_embedding.py +77 -0
  155. executorch/backends/qualcomm/builders/op_expand.py +81 -0
  156. executorch/backends/qualcomm/builders/op_gelu.py +56 -0
  157. executorch/backends/qualcomm/builders/op_hardswish.py +56 -0
  158. executorch/backends/qualcomm/builders/op_hardtanh.py +77 -0
  159. executorch/backends/qualcomm/builders/op_layer_norm.py +105 -0
  160. executorch/backends/qualcomm/builders/op_linear.py +82 -0
  161. executorch/backends/qualcomm/builders/op_log_softmax.py +76 -0
  162. executorch/backends/qualcomm/builders/op_matmul.py +58 -0
  163. executorch/backends/qualcomm/builders/op_max_pool2d.py +140 -0
  164. executorch/backends/qualcomm/builders/op_mean_dim.py +83 -0
  165. executorch/backends/qualcomm/builders/op_mul.py +61 -0
  166. executorch/backends/qualcomm/builders/op_pad.py +95 -0
  167. executorch/backends/qualcomm/builders/op_pow.py +95 -0
  168. executorch/backends/qualcomm/builders/op_quantize.py +71 -0
  169. executorch/backends/qualcomm/builders/op_relu.py +57 -0
  170. executorch/backends/qualcomm/builders/op_reshape.py +54 -0
  171. executorch/backends/qualcomm/builders/op_rsqrt.py +57 -0
  172. executorch/backends/qualcomm/builders/op_select_copy.py +87 -0
  173. executorch/backends/qualcomm/builders/op_sigmoid.py +57 -0
  174. executorch/backends/qualcomm/builders/op_skip_ops.py +50 -0
  175. executorch/backends/qualcomm/builders/op_slice_copy.py +87 -0
  176. executorch/backends/qualcomm/builders/op_softmax.py +74 -0
  177. executorch/backends/qualcomm/builders/op_squeeze.py +56 -0
  178. executorch/backends/qualcomm/builders/op_sub.py +61 -0
  179. executorch/backends/qualcomm/builders/op_tanh.py +56 -0
  180. executorch/backends/qualcomm/builders/op_transpose.py +72 -0
  181. executorch/backends/qualcomm/builders/op_unsqueeze.py +56 -0
  182. executorch/backends/qualcomm/builders/op_upsample_bilinear2d.py +66 -0
  183. executorch/backends/qualcomm/builders/qnn_constants.py +279 -0
  184. executorch/backends/qualcomm/builders/utils.py +99 -0
  185. executorch/backends/qualcomm/partition/common_defs.py +22 -0
  186. executorch/backends/qualcomm/partition/qnn_partitioner.py +149 -0
  187. executorch/backends/qualcomm/passes/annotate_and_quant_scalar.py +120 -0
  188. executorch/backends/qualcomm/passes/annotate_decomposed.py +49 -0
  189. executorch/backends/qualcomm/passes/annotate_quant_attrs.py +110 -0
  190. executorch/backends/qualcomm/passes/convert_binary_op_with_scalar.py +41 -0
  191. executorch/backends/qualcomm/passes/convert_bmm_to_matmul.py +73 -0
  192. executorch/backends/qualcomm/passes/convert_hardsigmoid.py +102 -0
  193. executorch/backends/qualcomm/passes/convert_hardswish.py +40 -0
  194. executorch/backends/qualcomm/passes/convert_interpolate_with_upsample2d.py +47 -0
  195. executorch/backends/qualcomm/passes/convert_to_linear.py +171 -0
  196. executorch/backends/qualcomm/passes/decompose_scaled_dot_product_attention.py +87 -0
  197. executorch/backends/qualcomm/passes/decompose_silu.py +40 -0
  198. executorch/backends/qualcomm/passes/fold_qdq.py +63 -0
  199. executorch/backends/qualcomm/passes/i64_to_i32.py +47 -0
  200. executorch/backends/qualcomm/passes/insert_io_qdq.py +166 -0
  201. executorch/backends/qualcomm/passes/insert_requantize.py +61 -0
  202. executorch/backends/qualcomm/passes/layout_transform.py +238 -0
  203. executorch/backends/qualcomm/passes/recompose_pixel_shuffle.py +46 -0
  204. executorch/backends/qualcomm/passes/reduce_dynamic_range.py +60 -0
  205. executorch/backends/qualcomm/passes/remove_clone.py +40 -0
  206. executorch/backends/qualcomm/passes/replace_inf_buffer.py +22 -0
  207. executorch/backends/qualcomm/passes/utils.py +44 -0
  208. executorch/backends/qualcomm/qnn_preprocess.py +94 -0
  209. executorch/backends/qualcomm/quantizer/quantizer.py +385 -0
  210. executorch/backends/qualcomm/quantizer/utils.py +629 -0
  211. executorch/backends/qualcomm/serialization/qnn_compile_spec_schema.py +134 -0
  212. executorch/backends/qualcomm/serialization/qnn_compile_spec_serialize.py +49 -0
  213. executorch/backends/qualcomm/serialization/schema.fbs +180 -0
  214. executorch/backends/qualcomm/tests/models.py +796 -0
  215. executorch/backends/qualcomm/tests/test_qnn_delegate.py +1709 -0
  216. executorch/backends/qualcomm/tests/utils.py +301 -0
  217. executorch/backends/qualcomm/utils/utils.py +278 -0
  218. executorch/backends/transforms/__init__.py +12 -0
  219. executorch/backends/transforms/addmm_mm_to_linear.py +172 -0
  220. executorch/backends/transforms/duplicate_dynamic_quant_chain.py +196 -0
  221. executorch/backends/transforms/test/test_duplicate_dynamic_quant_chain.py +188 -0
  222. executorch/backends/vulkan/__init__.py +14 -0
  223. executorch/backends/vulkan/partitioner/vulkan_partitioner.py +103 -0
  224. executorch/backends/vulkan/runtime/api/gen_vulkan_spv.py +774 -0
  225. executorch/backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml +39 -0
  226. executorch/backends/vulkan/runtime/graph/ops/glsl/image_to_nchw.yaml +30 -0
  227. executorch/backends/vulkan/runtime/graph/ops/glsl/matmul.yaml +25 -0
  228. executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_image.yaml +30 -0
  229. executorch/backends/vulkan/runtime/graph/ops/glsl/pool.yaml +18 -0
  230. executorch/backends/vulkan/runtime/graph/ops/glsl/sum_dim.yaml +18 -0
  231. executorch/backends/vulkan/runtime/graph/ops/glsl/sum_dim_keepdim.yaml +18 -0
  232. executorch/backends/vulkan/runtime/graph/ops/glsl/unary_op.yaml +20 -0
  233. executorch/backends/vulkan/serialization/schema.fbs +143 -0
  234. executorch/backends/vulkan/serialization/vulkan_graph_builder.py +326 -0
  235. executorch/backends/vulkan/serialization/vulkan_graph_schema.py +141 -0
  236. executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +222 -0
  237. executorch/backends/vulkan/test/glsl/all_shaders.yaml +55 -0
  238. executorch/backends/vulkan/test/op_tests/cases.py +72 -0
  239. executorch/backends/vulkan/test/op_tests/generate_op_tests.py +79 -0
  240. executorch/backends/vulkan/test/op_tests/utils/codegen.py +450 -0
  241. executorch/backends/vulkan/test/op_tests/utils/codegen_base.py +220 -0
  242. executorch/backends/vulkan/test/test_serialization.py +95 -0
  243. executorch/backends/vulkan/test/test_vulkan_delegate.py +498 -0
  244. executorch/backends/vulkan/test/test_vulkan_delegate_header.py +104 -0
  245. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/apiconventions.py +11 -0
  246. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/cgenerator.py +424 -0
  247. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/conventions.py +358 -0
  248. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/generator.py +1225 -0
  249. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/genvk.py +817 -0
  250. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/reg.py +1575 -0
  251. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/util.py +58 -0
  252. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vkconventions.py +275 -0
  253. executorch/backends/vulkan/third-party/VulkanMemoryAllocator/tools/GpuMemDumpVis/GpuMemDumpVis.py +333 -0
  254. executorch/backends/vulkan/third-party/volk/generate.py +194 -0
  255. executorch/backends/vulkan/vulkan_preprocess.py +67 -0
  256. executorch/backends/xnnpack/__init__.py +35 -0
  257. executorch/backends/xnnpack/operators/__init__.py +51 -0
  258. executorch/backends/xnnpack/operators/node_visitor.py +673 -0
  259. executorch/backends/xnnpack/operators/op_abs.py +52 -0
  260. executorch/backends/xnnpack/operators/op_add.py +77 -0
  261. executorch/backends/xnnpack/operators/op_addmm.py +70 -0
  262. executorch/backends/xnnpack/operators/op_avg_pooling2d.py +74 -0
  263. executorch/backends/xnnpack/operators/op_cat.py +104 -0
  264. executorch/backends/xnnpack/operators/op_ceiling.py +52 -0
  265. executorch/backends/xnnpack/operators/op_clamp.py +64 -0
  266. executorch/backends/xnnpack/operators/op_conv2d.py +168 -0
  267. executorch/backends/xnnpack/operators/op_dequantize_per_tensor.py +68 -0
  268. executorch/backends/xnnpack/operators/op_div.py +56 -0
  269. executorch/backends/xnnpack/operators/op_dynamic_dequantize_ops.py +67 -0
  270. executorch/backends/xnnpack/operators/op_dynamic_quantize_ops.py +120 -0
  271. executorch/backends/xnnpack/operators/op_elu.py +56 -0
  272. executorch/backends/xnnpack/operators/op_floor.py +48 -0
  273. executorch/backends/xnnpack/operators/op_hardswish.py +52 -0
  274. executorch/backends/xnnpack/operators/op_hardtanh.py +67 -0
  275. executorch/backends/xnnpack/operators/op_leaky_relu.py +65 -0
  276. executorch/backends/xnnpack/operators/op_linear.py +105 -0
  277. executorch/backends/xnnpack/operators/op_matrix_multiplication.py +66 -0
  278. executorch/backends/xnnpack/operators/op_max_dim.py +206 -0
  279. executorch/backends/xnnpack/operators/op_max_pool2d.py +91 -0
  280. executorch/backends/xnnpack/operators/op_maximum.py +55 -0
  281. executorch/backends/xnnpack/operators/op_mean_dim.py +77 -0
  282. executorch/backends/xnnpack/operators/op_minimum.py +54 -0
  283. executorch/backends/xnnpack/operators/op_multiply.py +84 -0
  284. executorch/backends/xnnpack/operators/op_negate.py +51 -0
  285. executorch/backends/xnnpack/operators/op_permute.py +57 -0
  286. executorch/backends/xnnpack/operators/op_prelu.py +56 -0
  287. executorch/backends/xnnpack/operators/op_quantize_per_tensor.py +68 -0
  288. executorch/backends/xnnpack/operators/op_relu.py +61 -0
  289. executorch/backends/xnnpack/operators/op_sdpa.py +108 -0
  290. executorch/backends/xnnpack/operators/op_sigmoid.py +48 -0
  291. executorch/backends/xnnpack/operators/op_skip_ops.py +124 -0
  292. executorch/backends/xnnpack/operators/op_slice_copy.py +98 -0
  293. executorch/backends/xnnpack/operators/op_softmax.py +58 -0
  294. executorch/backends/xnnpack/operators/op_square.py +52 -0
  295. executorch/backends/xnnpack/operators/op_square_root.py +52 -0
  296. executorch/backends/xnnpack/operators/op_squeeze.py +116 -0
  297. executorch/backends/xnnpack/operators/op_static_constant_pad.py +130 -0
  298. executorch/backends/xnnpack/operators/op_static_resize_bilinear_2d.py +61 -0
  299. executorch/backends/xnnpack/operators/op_sub.py +77 -0
  300. executorch/backends/xnnpack/operators/op_to_copy.py +91 -0
  301. executorch/backends/xnnpack/operators/quant_params.py +346 -0
  302. executorch/backends/xnnpack/partition/configs.py +157 -0
  303. executorch/backends/xnnpack/partition/graphs/bilinear_2d.py +54 -0
  304. executorch/backends/xnnpack/partition/graphs/sdpa.py +85 -0
  305. executorch/backends/xnnpack/partition/xnnpack_partitioner.py +1203 -0
  306. executorch/backends/xnnpack/passes/__init__.py +87 -0
  307. executorch/backends/xnnpack/passes/channels_last_tagged_reshape_pass.py +408 -0
  308. executorch/backends/xnnpack/passes/conv1d_unsqueeze_pass.py +183 -0
  309. executorch/backends/xnnpack/passes/convert_to_linear.py +202 -0
  310. executorch/backends/xnnpack/passes/convert_to_sdpa.py +114 -0
  311. executorch/backends/xnnpack/passes/convert_to_upsample_bilinear2d.py +59 -0
  312. executorch/backends/xnnpack/passes/fuse_activation_pass.py +83 -0
  313. executorch/backends/xnnpack/passes/fuse_batch_norm_with_conv.py +159 -0
  314. executorch/backends/xnnpack/passes/prelu_reshape_pass.py +75 -0
  315. executorch/backends/xnnpack/passes/remove_getitem_op.py +90 -0
  316. executorch/backends/xnnpack/passes/tag_implicit_q_dq_pass.py +216 -0
  317. executorch/backends/xnnpack/passes/xnnpack_pass.py +22 -0
  318. executorch/backends/xnnpack/serialization/runtime_schema.fbs +354 -0
  319. executorch/backends/xnnpack/serialization/schema.fbs +346 -0
  320. executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +460 -0
  321. executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +342 -0
  322. executorch/backends/xnnpack/test/models/deeplab_v3.py +41 -0
  323. executorch/backends/xnnpack/test/models/edsr.py +43 -0
  324. executorch/backends/xnnpack/test/models/emformer_rnnt.py +100 -0
  325. executorch/backends/xnnpack/test/models/inception_v3.py +68 -0
  326. executorch/backends/xnnpack/test/models/inception_v4.py +65 -0
  327. executorch/backends/xnnpack/test/models/llama2_et_example.py +50 -0
  328. executorch/backends/xnnpack/test/models/mobilebert.py +43 -0
  329. executorch/backends/xnnpack/test/models/mobilenet_v2.py +66 -0
  330. executorch/backends/xnnpack/test/models/mobilenet_v3.py +68 -0
  331. executorch/backends/xnnpack/test/models/resnet.py +42 -0
  332. executorch/backends/xnnpack/test/models/torchvision_vit.py +62 -0
  333. executorch/backends/xnnpack/test/models/very_big_model.py +44 -0
  334. executorch/backends/xnnpack/test/models/w2l.py +59 -0
  335. executorch/backends/xnnpack/test/ops/abs.py +58 -0
  336. executorch/backends/xnnpack/test/ops/add.py +266 -0
  337. executorch/backends/xnnpack/test/ops/avgpool2d.py +106 -0
  338. executorch/backends/xnnpack/test/ops/bilinear2d.py +129 -0
  339. executorch/backends/xnnpack/test/ops/cat.py +214 -0
  340. executorch/backends/xnnpack/test/ops/ceil.py +58 -0
  341. executorch/backends/xnnpack/test/ops/clamp.py +82 -0
  342. executorch/backends/xnnpack/test/ops/conv1d.py +122 -0
  343. executorch/backends/xnnpack/test/ops/conv2d.py +371 -0
  344. executorch/backends/xnnpack/test/ops/div.py +69 -0
  345. executorch/backends/xnnpack/test/ops/elu.py +104 -0
  346. executorch/backends/xnnpack/test/ops/floor.py +58 -0
  347. executorch/backends/xnnpack/test/ops/hardswish.py +80 -0
  348. executorch/backends/xnnpack/test/ops/hardtanh.py +95 -0
  349. executorch/backends/xnnpack/test/ops/leaky_relu.py +148 -0
  350. executorch/backends/xnnpack/test/ops/linear.py +783 -0
  351. executorch/backends/xnnpack/test/ops/max_dim.py +70 -0
  352. executorch/backends/xnnpack/test/ops/maximum.py +69 -0
  353. executorch/backends/xnnpack/test/ops/maxpool2d.py +140 -0
  354. executorch/backends/xnnpack/test/ops/mean_dim.py +90 -0
  355. executorch/backends/xnnpack/test/ops/minimum.py +49 -0
  356. executorch/backends/xnnpack/test/ops/multiply.py +161 -0
  357. executorch/backends/xnnpack/test/ops/negate.py +58 -0
  358. executorch/backends/xnnpack/test/ops/permute.py +137 -0
  359. executorch/backends/xnnpack/test/ops/pow.py +68 -0
  360. executorch/backends/xnnpack/test/ops/prelu.py +53 -0
  361. executorch/backends/xnnpack/test/ops/quantize_per_tensor.py +81 -0
  362. executorch/backends/xnnpack/test/ops/relu.py +38 -0
  363. executorch/backends/xnnpack/test/ops/sdpa.py +125 -0
  364. executorch/backends/xnnpack/test/ops/sigmoid.py +45 -0
  365. executorch/backends/xnnpack/test/ops/slice_copy.py +148 -0
  366. executorch/backends/xnnpack/test/ops/softmax.py +74 -0
  367. executorch/backends/xnnpack/test/ops/sqrt.py +44 -0
  368. executorch/backends/xnnpack/test/ops/square.py +50 -0
  369. executorch/backends/xnnpack/test/ops/static_constant_pad.py +185 -0
  370. executorch/backends/xnnpack/test/ops/sub.py +171 -0
  371. executorch/backends/xnnpack/test/passes/test_activation_fusion.py +197 -0
  372. executorch/backends/xnnpack/test/passes/test_batch_norm_fusion.py +81 -0
  373. executorch/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py +180 -0
  374. executorch/backends/xnnpack/test/passes/test_convert_to_linear.py +40 -0
  375. executorch/backends/xnnpack/test/passes/test_remove_get_item_pass.py +100 -0
  376. executorch/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py +81 -0
  377. executorch/backends/xnnpack/test/serialization/test_serialization.py +50 -0
  378. executorch/backends/xnnpack/test/serialization/test_xnnheader.py +104 -0
  379. executorch/backends/xnnpack/test/test_xnnpack_utils.py +533 -0
  380. executorch/backends/xnnpack/test/test_xnnpack_utils_classes.py +42 -0
  381. executorch/backends/xnnpack/test/tester/__init__.py +28 -0
  382. executorch/backends/xnnpack/test/tester/tester.py +596 -0
  383. executorch/backends/xnnpack/third-party/FP16/configure.py +65 -0
  384. executorch/backends/xnnpack/third-party/FP16/confu.yaml +8 -0
  385. executorch/backends/xnnpack/third-party/FP16/include/fp16/__init__.py +0 -0
  386. executorch/backends/xnnpack/third-party/FP16/include/fp16/avx.py +50 -0
  387. executorch/backends/xnnpack/third-party/FP16/include/fp16/avx2.py +53 -0
  388. executorch/backends/xnnpack/third-party/FP16/test/peachpy/stubs.py +38 -0
  389. executorch/backends/xnnpack/third-party/FXdiv/configure.py +30 -0
  390. executorch/backends/xnnpack/third-party/FXdiv/confu.yaml +6 -0
  391. executorch/backends/xnnpack/third-party/XNNPACK/eval/f16-tanh.yaml +38 -0
  392. executorch/backends/xnnpack/third-party/XNNPACK/eval/f32-tanh.yaml +253 -0
  393. executorch/backends/xnnpack/third-party/XNNPACK/scripts/convert-assembly-to-jit.py +1443 -0
  394. executorch/backends/xnnpack/third-party/XNNPACK/scripts/sort-filenames.py +137 -0
  395. executorch/backends/xnnpack/third-party/XNNPACK/src/enums/microkernel-type.yaml +35 -0
  396. executorch/backends/xnnpack/third-party/XNNPACK/src/enums/node-type.yaml +125 -0
  397. executorch/backends/xnnpack/third-party/XNNPACK/src/enums/operator-type.yaml +325 -0
  398. executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-gemm-minmax.yaml +106 -0
  399. executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-bfly4.yaml +22 -0
  400. executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-fftr.yaml +15 -0
  401. executorch/backends/xnnpack/third-party/XNNPACK/test/cs16-vsquareabs.yaml +24 -0
  402. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-avgpool-minmax.yaml +16 -0
  403. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-conv-hwc2chw.yaml +8 -0
  404. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv-minmax-multipass.yaml +80 -0
  405. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv-minmax-unipass.yaml +104 -0
  406. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv2d-chw.yaml +88 -0
  407. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32-vcvt.yaml +123 -0
  408. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-gemm-minmax.yaml +42 -0
  409. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-igemm-minmax.yaml +42 -0
  410. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-rsum.yaml +30 -0
  411. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gavgpool-cw.yaml +8 -0
  412. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gavgpool-minmax.yaml +40 -0
  413. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-jit.yaml +36 -0
  414. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-minmax.yaml +130 -0
  415. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear-chw.yaml +9 -0
  416. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear.yaml +12 -0
  417. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-igemm-jit.yaml +36 -0
  418. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-igemm-minmax.yaml +114 -0
  419. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-maxpool-minmax.yaml +12 -0
  420. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-pavgpool-minmax.yaml +16 -0
  421. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-prelu.yaml +12 -0
  422. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-qs8-vcvt.yaml +34 -0
  423. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-raddstoreexpminusmax.yaml +92 -0
  424. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rmax.yaml +28 -0
  425. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rmin.yaml +25 -0
  426. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rminmax.yaml +25 -0
  427. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-rsum.yaml +16 -0
  428. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-spmm-minmax.yaml +42 -0
  429. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vabs.yaml +14 -0
  430. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vadd-minmax.yaml +24 -0
  431. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vaddc-minmax.yaml +24 -0
  432. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vclamp.yaml +26 -0
  433. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vcmul.yaml +9 -0
  434. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vdiv-minmax.yaml +24 -0
  435. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vdivc-minmax.yaml +24 -0
  436. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-velu.yaml +16 -0
  437. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vhswish.yaml +16 -0
  438. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vlrelu.yaml +16 -0
  439. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmax.yaml +17 -0
  440. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmaxc.yaml +17 -0
  441. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmin.yaml +17 -0
  442. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vminc.yaml +17 -0
  443. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmul-minmax.yaml +24 -0
  444. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmulc-minmax.yaml +24 -0
  445. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vmulcaddc-minmax.yaml +16 -0
  446. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vneg.yaml +14 -0
  447. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrdivc-minmax.yaml +24 -0
  448. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndd.yaml +12 -0
  449. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndne.yaml +12 -0
  450. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndu.yaml +12 -0
  451. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrndz.yaml +12 -0
  452. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vrsubc-minmax.yaml +24 -0
  453. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsigmoid.yaml +88 -0
  454. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqr.yaml +12 -0
  455. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrdiff.yaml +17 -0
  456. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrdiffc.yaml +17 -0
  457. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsqrt.yaml +28 -0
  458. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsub-minmax.yaml +24 -0
  459. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vsubc-minmax.yaml +24 -0
  460. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-vtanh.yaml +214 -0
  461. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-argmaxpool.yaml +29 -0
  462. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-avgpool-minmax.yaml +39 -0
  463. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc.yaml +44 -0
  464. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc2chw.yaml +24 -0
  465. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-minmax-multipass.yaml +190 -0
  466. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-minmax-unipass.yaml +436 -0
  467. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-multipass.yaml +24 -0
  468. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv-unipass.yaml +42 -0
  469. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv2d-chw.yaml +679 -0
  470. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-f16-vcvt.yaml +85 -0
  471. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gavgpool-cw.yaml +22 -0
  472. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gavgpool-minmax.yaml +39 -0
  473. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-goi-minmax.yaml +15 -0
  474. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-jit.yaml +317 -0
  475. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-minmax.yaml +953 -0
  476. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-relu.yaml +129 -0
  477. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm.yaml +120 -0
  478. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemminc-minmax.yaml +673 -0
  479. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear-chw.yaml +22 -0
  480. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear.yaml +23 -0
  481. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-jit.yaml +315 -0
  482. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-minmax.yaml +891 -0
  483. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-relu.yaml +129 -0
  484. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm.yaml +116 -0
  485. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-maxpool-minmax.yaml +22 -0
  486. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-pavgpool-minmax.yaml +39 -0
  487. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ppmm-minmax.yaml +122 -0
  488. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-prelu.yaml +72 -0
  489. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc4w-gemm-minmax.yaml +314 -0
  490. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-minmax.yaml +836 -0
  491. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-relu.yaml +80 -0
  492. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm.yaml +115 -0
  493. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qs8-vcvt.yaml +116 -0
  494. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qu8-vcvt.yaml +108 -0
  495. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddexpminusmax.yaml +31 -0
  496. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddextexp.yaml +31 -0
  497. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddstoreexpminusmax.yaml +257 -0
  498. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rmax.yaml +69 -0
  499. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rmin.yaml +69 -0
  500. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rminmax.yaml +69 -0
  501. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-rsum.yaml +76 -0
  502. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-spmm-minmax.yaml +400 -0
  503. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vabs.yaml +37 -0
  504. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd-minmax.yaml +56 -0
  505. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd-relu.yaml +19 -0
  506. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vadd.yaml +14 -0
  507. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc-minmax.yaml +61 -0
  508. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc-relu.yaml +19 -0
  509. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vaddc.yaml +14 -0
  510. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vclamp.yaml +66 -0
  511. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vcmul.yaml +28 -0
  512. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv-minmax.yaml +56 -0
  513. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv-relu.yaml +19 -0
  514. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdiv.yaml +14 -0
  515. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc-minmax.yaml +61 -0
  516. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc-relu.yaml +19 -0
  517. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vdivc.yaml +14 -0
  518. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-velu.yaml +401 -0
  519. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vhswish.yaml +62 -0
  520. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vlrelu.yaml +65 -0
  521. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmax.yaml +36 -0
  522. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmaxc.yaml +39 -0
  523. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmin.yaml +36 -0
  524. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vminc.yaml +39 -0
  525. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul-minmax.yaml +56 -0
  526. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul-relu.yaml +19 -0
  527. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmul.yaml +14 -0
  528. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc-minmax.yaml +61 -0
  529. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc-relu.yaml +19 -0
  530. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulc.yaml +17 -0
  531. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vmulcaddc-minmax.yaml +51 -0
  532. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vneg.yaml +37 -0
  533. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc-minmax.yaml +61 -0
  534. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc-relu.yaml +19 -0
  535. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrdivc.yaml +14 -0
  536. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrelu.yaml +34 -0
  537. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndd.yaml +32 -0
  538. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndne.yaml +32 -0
  539. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndu.yaml +32 -0
  540. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrndz.yaml +32 -0
  541. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsqrt.yaml +41 -0
  542. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc-minmax.yaml +61 -0
  543. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc-relu.yaml +19 -0
  544. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vrsubc.yaml +14 -0
  545. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vscaleexpminusmax.yaml +31 -0
  546. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vscaleextexp.yaml +31 -0
  547. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsigmoid.yaml +550 -0
  548. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqr.yaml +31 -0
  549. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrdiff.yaml +28 -0
  550. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrdiffc.yaml +31 -0
  551. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsqrt.yaml +60 -0
  552. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub-minmax.yaml +56 -0
  553. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub-relu.yaml +19 -0
  554. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsub.yaml +14 -0
  555. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc-minmax.yaml +61 -0
  556. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc-relu.yaml +19 -0
  557. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vsubc.yaml +14 -0
  558. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-vtanh.yaml +815 -0
  559. executorch/backends/xnnpack/third-party/XNNPACK/test/i16-vlshift.yaml +17 -0
  560. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc4w-gemm-minmax.yaml +447 -0
  561. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-gemm-minmax.yaml +362 -0
  562. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-igemm-minmax.yaml +326 -0
  563. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc4w-gemm-minmax.yaml +990 -0
  564. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-gemm-minmax.yaml +1035 -0
  565. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-igemm-minmax.yaml +920 -0
  566. executorch/backends/xnnpack/third-party/XNNPACK/test/qs16-qs8-vcvt.yaml +62 -0
  567. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-multipass-fp32.yaml +300 -0
  568. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-multipass-rndnu.yaml +60 -0
  569. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-unipass-fp32.yaml +224 -0
  570. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-dwconv-minmax-unipass-rndnu.yaml +49 -0
  571. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-f16-vcvt.yaml +24 -0
  572. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-f32-vcvt.yaml +66 -0
  573. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-gavgpool-minmax-fp32.yaml +117 -0
  574. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-gavgpool-minmax-rndnu.yaml +22 -0
  575. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-dwconv-minmax-multipass-fp32.yaml +372 -0
  576. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-dwconv-minmax-unipass-fp32.yaml +314 -0
  577. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-jit-fp32.yaml +21 -0
  578. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-minmax-fp32.yaml +1576 -0
  579. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-jit-fp32.yaml +21 -0
  580. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-minmax-fp32.yaml +1538 -0
  581. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vadd-minmax.yaml +100 -0
  582. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vaddc-minmax.yaml +100 -0
  583. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vcvt.yaml +76 -0
  584. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vhswish.yaml +56 -0
  585. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vlrelu.yaml +98 -0
  586. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmul-minmax-fp32.yaml +49 -0
  587. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmul-minmax-rndnu.yaml +12 -0
  588. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmulc-minmax-fp32.yaml +49 -0
  589. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-vmulc-minmax-rndnu.yaml +12 -0
  590. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-avgpool-minmax-fp32.yaml +23 -0
  591. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-multipass-fp32.yaml +228 -0
  592. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-multipass-rndnu.yaml +42 -0
  593. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-unipass-fp32.yaml +160 -0
  594. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-dwconv-minmax-unipass-rndnu.yaml +37 -0
  595. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-f32-vcvt.yaml +66 -0
  596. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gavgpool-minmax-fp32.yaml +117 -0
  597. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gavgpool-minmax-rndnu.yaml +22 -0
  598. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-fp32.yaml +821 -0
  599. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-rndnu.yaml +274 -0
  600. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-fp32.yaml +818 -0
  601. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-rndnu.yaml +232 -0
  602. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vadd-minmax.yaml +66 -0
  603. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vaddc-minmax.yaml +66 -0
  604. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vcvt.yaml +76 -0
  605. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vhswish.yaml +56 -0
  606. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vlrelu.yaml +98 -0
  607. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmul-minmax-fp32.yaml +49 -0
  608. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmul-minmax-rndnu.yaml +12 -0
  609. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmulc-minmax-fp32.yaml +49 -0
  610. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-vmulc-minmax-rndnu.yaml +12 -0
  611. executorch/backends/xnnpack/third-party/XNNPACK/test/s16-rmaxabs.yaml +17 -0
  612. executorch/backends/xnnpack/third-party/XNNPACK/test/s16-window.yaml +25 -0
  613. executorch/backends/xnnpack/third-party/XNNPACK/test/s8-ibilinear.yaml +22 -0
  614. executorch/backends/xnnpack/third-party/XNNPACK/test/s8-maxpool-minmax.yaml +23 -0
  615. executorch/backends/xnnpack/third-party/XNNPACK/test/s8-vclamp.yaml +19 -0
  616. executorch/backends/xnnpack/third-party/XNNPACK/test/u32-filterbank-accumulate.yaml +17 -0
  617. executorch/backends/xnnpack/third-party/XNNPACK/test/u32-filterbank-subtract.yaml +8 -0
  618. executorch/backends/xnnpack/third-party/XNNPACK/test/u32-vlog.yaml +11 -0
  619. executorch/backends/xnnpack/third-party/XNNPACK/test/u64-u32-vsqrtshift.yaml +7 -0
  620. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-ibilinear.yaml +22 -0
  621. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-lut32norm.yaml +7 -0
  622. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-maxpool-minmax.yaml +17 -0
  623. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-rmax.yaml +13 -0
  624. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-vclamp.yaml +17 -0
  625. executorch/backends/xnnpack/third-party/XNNPACK/test/x16-packw.yaml +33 -0
  626. executorch/backends/xnnpack/third-party/XNNPACK/test/x16-transpose.yaml +47 -0
  627. executorch/backends/xnnpack/third-party/XNNPACK/test/x24-transpose.yaml +26 -0
  628. executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packb.yaml +14 -0
  629. executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packw.yaml +76 -0
  630. executorch/backends/xnnpack/third-party/XNNPACK/test/x32-packx.yaml +38 -0
  631. executorch/backends/xnnpack/third-party/XNNPACK/test/x32-transpose.yaml +68 -0
  632. executorch/backends/xnnpack/third-party/XNNPACK/test/x32-zerob.yaml +14 -0
  633. executorch/backends/xnnpack/third-party/XNNPACK/test/x64-transpose.yaml +45 -0
  634. executorch/backends/xnnpack/third-party/XNNPACK/test/x8-lut.yaml +47 -0
  635. executorch/backends/xnnpack/third-party/XNNPACK/test/x8-packw.yaml +18 -0
  636. executorch/backends/xnnpack/third-party/XNNPACK/test/x8-transpose.yaml +36 -0
  637. executorch/backends/xnnpack/third-party/XNNPACK/test/xx-fill.yaml +16 -0
  638. executorch/backends/xnnpack/third-party/XNNPACK/test/xx-pad.yaml +16 -0
  639. executorch/backends/xnnpack/third-party/XNNPACK/test/xx-transposev.yaml +7 -0
  640. executorch/backends/xnnpack/third-party/XNNPACK/tools/check-assembly-and-jit-microkernels-in-sync.py +88 -0
  641. executorch/backends/xnnpack/third-party/XNNPACK/tools/dump-jit-output.py +84 -0
  642. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-argmaxpool-test.py +739 -0
  643. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-avgpool-test.py +2481 -0
  644. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-bfly4-test.py +190 -0
  645. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc-test.py +543 -0
  646. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc2chw-test.py +497 -0
  647. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-multipass-test.py +465 -0
  648. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-unipass-test.py +392 -0
  649. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv2d-chw-test.py +333 -0
  650. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-enum.py +193 -0
  651. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-fftr-test.py +114 -0
  652. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-fill-test.py +169 -0
  653. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-filterbank-accumulate-test.py +129 -0
  654. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-filterbank-subtract-test.py +155 -0
  655. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gavgpool-cw-test.py +189 -0
  656. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gavgpool-test.py +594 -0
  657. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gemm-test.py +1318 -0
  658. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-chw-test.py +220 -0
  659. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-test.py +222 -0
  660. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-norm-test.py +157 -0
  661. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-test.py +153 -0
  662. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-maxpool-test.py +1268 -0
  663. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-pack-test.py +224 -0
  664. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-packb-test.py +188 -0
  665. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-packw-test.py +340 -0
  666. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-pad-test.py +353 -0
  667. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-prelu-test.py +237 -0
  668. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddexpminusmax-test.py +144 -0
  669. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddextexp-test.py +144 -0
  670. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddstoreexpminusmax-test.py +188 -0
  671. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-test.py +225 -0
  672. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-rmaxabs-test.py +145 -0
  673. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-spmm-test.py +538 -0
  674. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-tanh-eval.py +123 -0
  675. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-transpose-test.py +369 -0
  676. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vbinary-test.py +529 -0
  677. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vcvt-test.py +450 -0
  678. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vhswish-test.py +228 -0
  679. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlog-test.py +178 -0
  680. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlrelu-test.py +226 -0
  681. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vlshift-test.py +168 -0
  682. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vmulcaddc-test.py +281 -0
  683. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vscaleexpminusmax-test.py +159 -0
  684. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vscaleextexp-test.py +144 -0
  685. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vsquareabs-test.py +145 -0
  686. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-benchmark.py +282 -0
  687. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-test.py +294 -0
  688. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-window-test.py +230 -0
  689. executorch/backends/xnnpack/third-party/XNNPACK/tools/primes.py +115 -0
  690. executorch/backends/xnnpack/third-party/XNNPACK/tools/update-microkernels.py +391 -0
  691. executorch/backends/xnnpack/third-party/XNNPACK/tools/xngen.py +148 -0
  692. executorch/backends/xnnpack/third-party/XNNPACK/tools/xnncommon.py +253 -0
  693. executorch/backends/xnnpack/third-party/cpuinfo/configure.py +104 -0
  694. executorch/backends/xnnpack/third-party/cpuinfo/confu.yaml +9 -0
  695. executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/configure.py +26 -0
  696. executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/confu.yaml +5 -0
  697. executorch/backends/xnnpack/third-party/cpuinfo/scripts/android-device-dump.py +400 -0
  698. executorch/backends/xnnpack/third-party/cpuinfo/scripts/arm-linux-filesystem-dump.py +107 -0
  699. executorch/backends/xnnpack/third-party/cpuinfo/scripts/parse-x86-cpuid-dump.py +47 -0
  700. executorch/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py +93 -0
  701. executorch/backends/xnnpack/third-party/generate-xnnpack-wrappers.py +198 -0
  702. executorch/backends/xnnpack/third-party/pthreadpool/configure.py +38 -0
  703. executorch/backends/xnnpack/third-party/pthreadpool/confu.yaml +8 -0
  704. executorch/backends/xnnpack/utils/configs.py +51 -0
  705. executorch/backends/xnnpack/utils/quant_utils.py +32 -0
  706. executorch/backends/xnnpack/utils/utils.py +130 -0
  707. executorch/backends/xnnpack/utils/xnnpack_constants.py +29 -0
  708. executorch/backends/xnnpack/xnnpack_preprocess.py +167 -0
  709. executorch/data/bin/__init__.py +42 -0
  710. executorch/data/bin/flatc +0 -0
  711. executorch/examples/models/__init__.py +34 -0
  712. executorch/examples/models/deeplab_v3/__init__.py +9 -0
  713. executorch/examples/models/deeplab_v3/model.py +50 -0
  714. executorch/examples/models/edsr/__init__.py +11 -0
  715. executorch/examples/models/edsr/model.py +28 -0
  716. executorch/examples/models/emformer_rnnt/__init__.py +17 -0
  717. executorch/examples/models/emformer_rnnt/model.py +132 -0
  718. executorch/examples/models/inception_v3/__init__.py +11 -0
  719. executorch/examples/models/inception_v3/model.py +30 -0
  720. executorch/examples/models/inception_v4/__init__.py +11 -0
  721. executorch/examples/models/inception_v4/model.py +26 -0
  722. executorch/examples/models/llama2/__init__.py +11 -0
  723. executorch/examples/models/llama2/builder.py +348 -0
  724. executorch/examples/models/llama2/custom_ops/custom_ops.yaml +14 -0
  725. executorch/examples/models/llama2/custom_ops/sdpa_with_kv_cache.py +199 -0
  726. executorch/examples/models/llama2/eval_llama.py +29 -0
  727. executorch/examples/models/llama2/eval_llama_lib.py +271 -0
  728. executorch/examples/models/llama2/experimental/generate.py +190 -0
  729. executorch/examples/models/llama2/experimental/load_gguf_q4_0.py +183 -0
  730. executorch/examples/models/llama2/experimental/subclass.py +242 -0
  731. executorch/examples/models/llama2/experimental/test_subclass.py +28 -0
  732. executorch/examples/models/llama2/export_llama.py +30 -0
  733. executorch/examples/models/llama2/export_llama_lib.py +893 -0
  734. executorch/examples/models/llama2/fairseq2.py +63 -0
  735. executorch/examples/models/llama2/install_requirement_helper.py +29 -0
  736. executorch/examples/models/llama2/llama_test.py +36 -0
  737. executorch/examples/models/llama2/llama_transformer.py +478 -0
  738. executorch/examples/models/llama2/model.py +193 -0
  739. executorch/examples/models/llama2/ops/quantized.yaml +11 -0
  740. executorch/examples/models/llama2/ops/quantized_ops.py +163 -0
  741. executorch/examples/models/llama2/quant_lib.py +136 -0
  742. executorch/examples/models/llama2/quantize.py +389 -0
  743. executorch/examples/models/llama2/tests/test_simple_sdpa.py +54 -0
  744. executorch/examples/models/llama2/tokenizer/__init__.py +0 -0
  745. executorch/examples/models/llama2/tokenizer/test/__init__.py +0 -0
  746. executorch/examples/models/llama2/tokenizer/test/test_tokenizer.py +39 -0
  747. executorch/examples/models/llama2/tokenizer/tokenizer.py +141 -0
  748. executorch/examples/models/llava_encoder/__init__.py +11 -0
  749. executorch/examples/models/llava_encoder/model.py +52 -0
  750. executorch/examples/models/mobilebert/__init__.py +11 -0
  751. executorch/examples/models/mobilebert/model.py +31 -0
  752. executorch/examples/models/mobilenet_v2/__init__.py +12 -0
  753. executorch/examples/models/mobilenet_v2/model.py +45 -0
  754. executorch/examples/models/mobilenet_v3/__init__.py +11 -0
  755. executorch/examples/models/mobilenet_v3/model.py +32 -0
  756. executorch/examples/models/model_base.py +47 -0
  757. executorch/examples/models/model_factory.py +56 -0
  758. executorch/examples/models/resnet/__init__.py +12 -0
  759. executorch/examples/models/resnet/model.py +51 -0
  760. executorch/examples/models/torchvision_vit/__init__.py +11 -0
  761. executorch/examples/models/torchvision_vit/model.py +30 -0
  762. executorch/examples/models/toy_model/__init__.py +15 -0
  763. executorch/examples/models/toy_model/model.py +93 -0
  764. executorch/examples/models/wav2letter/__init__.py +11 -0
  765. executorch/examples/models/wav2letter/model.py +29 -0
  766. executorch/exir/__init__.py +52 -0
  767. executorch/exir/_serialize/__init__.py +18 -0
  768. executorch/exir/_serialize/_cord.py +49 -0
  769. executorch/exir/_serialize/_dataclass.py +138 -0
  770. executorch/exir/_serialize/_flatbuffer.py +351 -0
  771. executorch/exir/_serialize/_program.py +563 -0
  772. executorch/exir/_serialize/program.fbs +407 -0
  773. executorch/exir/_serialize/scalar_type.fbs +32 -0
  774. executorch/exir/_serialize/test/test_cord.py +63 -0
  775. executorch/exir/_serialize/test/test_flatbuffer.py +331 -0
  776. executorch/exir/_serialize/test/test_program.py +938 -0
  777. executorch/exir/backend/backend_api.py +404 -0
  778. executorch/exir/backend/backend_details.py +68 -0
  779. executorch/exir/backend/canonical_partitioners/duplicate_constant_node_pass.py +152 -0
  780. executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
  781. executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +137 -0
  782. executorch/exir/backend/compile_spec_schema.py +17 -0
  783. executorch/exir/backend/partitioner.py +93 -0
  784. executorch/exir/backend/test/backend_with_compiler_demo.py +130 -0
  785. executorch/exir/backend/test/backend_with_delegate_mapping_demo.py +210 -0
  786. executorch/exir/backend/test/demos/rpc/executor_backend_partitioner.py +76 -0
  787. executorch/exir/backend/test/demos/rpc/executor_backend_preprocess.py +33 -0
  788. executorch/exir/backend/test/demos/rpc/test_rpc.py +194 -0
  789. executorch/exir/backend/test/demos/test_delegate_aten_mode.py +76 -0
  790. executorch/exir/backend/test/demos/test_xnnpack_qnnpack.py +134 -0
  791. executorch/exir/backend/test/hta_partitioner_demo.py +288 -0
  792. executorch/exir/backend/test/op_partitioner_demo.py +123 -0
  793. executorch/exir/backend/test/qnn_backend_demo.py +33 -0
  794. executorch/exir/backend/test/test_backends.py +1290 -0
  795. executorch/exir/backend/test/test_backends_lifted.py +1260 -0
  796. executorch/exir/backend/test/test_backends_nested.py +257 -0
  797. executorch/exir/backend/test/test_debug_handle_map.py +131 -0
  798. executorch/exir/backend/test/test_delegate_map_builder.py +243 -0
  799. executorch/exir/backend/test/test_graph_partition.py +243 -0
  800. executorch/exir/backend/test/test_lowered_backend_module.py +220 -0
  801. executorch/exir/backend/test/test_partitioner.py +607 -0
  802. executorch/exir/backend/test/test_passes.py +47 -0
  803. executorch/exir/backend/test/test_utils.py +341 -0
  804. executorch/exir/backend/utils.py +661 -0
  805. executorch/exir/capture/__init__.py +28 -0
  806. executorch/exir/capture/_capture.py +374 -0
  807. executorch/exir/capture/_config.py +77 -0
  808. executorch/exir/capture/_unlift.py +159 -0
  809. executorch/exir/common.py +140 -0
  810. executorch/exir/control_flow.py +203 -0
  811. executorch/exir/delegate.py +161 -0
  812. executorch/exir/dialects/__init__.py +0 -0
  813. executorch/exir/dialects/_ops.py +166 -0
  814. executorch/exir/dialects/backend/_ops.py +123 -0
  815. executorch/exir/dialects/backend/test/test_backend_ops.py +89 -0
  816. executorch/exir/dialects/edge/_ops.py +406 -0
  817. executorch/exir/dialects/edge/arg/model.py +238 -0
  818. executorch/exir/dialects/edge/arg/type.py +46 -0
  819. executorch/exir/dialects/edge/dtype/runner.py +120 -0
  820. executorch/exir/dialects/edge/dtype/supported.py +45 -0
  821. executorch/exir/dialects/edge/dtype/utils.py +36 -0
  822. executorch/exir/dialects/edge/edge.yaml +7623 -0
  823. executorch/exir/dialects/edge/op/api.py +86 -0
  824. executorch/exir/dialects/edge/op/sample_input.py +1274 -0
  825. executorch/exir/dialects/edge/op/test/test_api.py +51 -0
  826. executorch/exir/dialects/edge/spec/gen.py +542 -0
  827. executorch/exir/dialects/edge/spec/utils.py +328 -0
  828. executorch/exir/dialects/edge/test/test_edge_ops.py +457 -0
  829. executorch/exir/dialects/edge/test/test_edge_yaml.py +224 -0
  830. executorch/exir/dialects/test/test_exir_dialect_ops.py +22 -0
  831. executorch/exir/dim_order_utils.py +81 -0
  832. executorch/exir/dynamic_shape.py +12 -0
  833. executorch/exir/emit/__init__.py +11 -0
  834. executorch/exir/emit/_emit_program.py +238 -0
  835. executorch/exir/emit/_emitter.py +1445 -0
  836. executorch/exir/emit/test/test_emit.py +1489 -0
  837. executorch/exir/error.py +55 -0
  838. executorch/exir/experimental/__init__.py +131 -0
  839. executorch/exir/experimental/export_pt2.py +168 -0
  840. executorch/exir/graph.py +86 -0
  841. executorch/exir/graph_module.py +70 -0
  842. executorch/exir/lowered_backend_module.py +736 -0
  843. executorch/exir/memory.py +50 -0
  844. executorch/exir/memory_planning.py +792 -0
  845. executorch/exir/operator/convert.py +307 -0
  846. executorch/exir/operator/manip.py +89 -0
  847. executorch/exir/operator/test/test_operator.py +84 -0
  848. executorch/exir/operator/util.py +41 -0
  849. executorch/exir/pass_base.py +730 -0
  850. executorch/exir/pass_manager.py +78 -0
  851. executorch/exir/passes/__init__.py +508 -0
  852. executorch/exir/passes/_quant_patterns_and_replacements.py +741 -0
  853. executorch/exir/passes/const_prop_pass.py +84 -0
  854. executorch/exir/passes/constant_prop_pass.py +133 -0
  855. executorch/exir/passes/debug_handle_generator_pass.py +32 -0
  856. executorch/exir/passes/dim_order_ops_registry.py +47 -0
  857. executorch/exir/passes/dynamic_shape_prop_pass.py +301 -0
  858. executorch/exir/passes/executorch_prim_ops_registry.py +112 -0
  859. executorch/exir/passes/insert_write_back_for_buffers_pass.py +134 -0
  860. executorch/exir/passes/memory_format_ops_pass.py +63 -0
  861. executorch/exir/passes/memory_planning_pass.py +131 -0
  862. executorch/exir/passes/normalize_transpose_pass.py +24 -0
  863. executorch/exir/passes/normalize_view_copy_base_pass.py +64 -0
  864. executorch/exir/passes/pass_registry.py +89 -0
  865. executorch/exir/passes/quant_fusion_pass.py +128 -0
  866. executorch/exir/passes/remove_graph_asserts_pass.py +39 -0
  867. executorch/exir/passes/remove_mixed_type_operators.py +85 -0
  868. executorch/exir/passes/remove_noop_pass.py +92 -0
  869. executorch/exir/passes/replace_aten_with_edge_pass.py +46 -0
  870. executorch/exir/passes/replace_broken_ops_with_function_ops_pass.py +44 -0
  871. executorch/exir/passes/replace_edge_with_backend_pass.py +56 -0
  872. executorch/exir/passes/replace_sym_size_op_pass.py +35 -0
  873. executorch/exir/passes/replace_view_copy_with_view_pass.py +189 -0
  874. executorch/exir/passes/scalar_to_tensor_pass.py +32 -0
  875. executorch/exir/passes/spec_prop_pass.py +151 -0
  876. executorch/exir/passes/sym_shape_eval_pass.py +264 -0
  877. executorch/exir/passes/sym_to_tensor_pass.py +64 -0
  878. executorch/exir/print_program.py +413 -0
  879. executorch/exir/program/__init__.py +30 -0
  880. executorch/exir/program/_fake_program.py +64 -0
  881. executorch/exir/program/_program.py +1006 -0
  882. executorch/exir/program/test/test_fake_program.py +76 -0
  883. executorch/exir/program/test/test_program.py +434 -0
  884. executorch/exir/scalar_type.py +28 -0
  885. executorch/exir/schema.py +267 -0
  886. executorch/exir/serde/__init__.py +0 -0
  887. executorch/exir/serde/export_serialize.py +1854 -0
  888. executorch/exir/serde/schema.py +27 -0
  889. executorch/exir/serde/serialize.py +750 -0
  890. executorch/exir/sym_util.py +82 -0
  891. executorch/exir/tensor.py +359 -0
  892. executorch/exir/tests/asr_joiner.py +82 -0
  893. executorch/exir/tests/common.py +97 -0
  894. executorch/exir/tests/control_flow_models.py +110 -0
  895. executorch/exir/tests/dynamic_shape_models.py +51 -0
  896. executorch/exir/tests/models.py +557 -0
  897. executorch/exir/tests/test_arg_validator.py +72 -0
  898. executorch/exir/tests/test_capture.py +27 -0
  899. executorch/exir/tests/test_common.py +81 -0
  900. executorch/exir/tests/test_delegate.py +311 -0
  901. executorch/exir/tests/test_dim_order_utils.py +29 -0
  902. executorch/exir/tests/test_dynamic_shape_propagation.py +38 -0
  903. executorch/exir/tests/test_error.py +19 -0
  904. executorch/exir/tests/test_fixtures.py +110 -0
  905. executorch/exir/tests/test_memory_format_ops_pass.py +148 -0
  906. executorch/exir/tests/test_memory_planning.py +593 -0
  907. executorch/exir/tests/test_op_convert.py +88 -0
  908. executorch/exir/tests/test_pass_infra.py +179 -0
  909. executorch/exir/tests/test_passes.py +1573 -0
  910. executorch/exir/tests/test_print_program.py +54 -0
  911. executorch/exir/tests/test_quant_fusion_pass.py +371 -0
  912. executorch/exir/tests/test_quantization.py +120 -0
  913. executorch/exir/tests/test_serde.py +201 -0
  914. executorch/exir/tests/test_tensor.py +341 -0
  915. executorch/exir/tests/test_tracer.py +553 -0
  916. executorch/exir/tests/test_verification.py +272 -0
  917. executorch/exir/tests/transformer.py +122 -0
  918. executorch/exir/tracer.py +785 -0
  919. executorch/exir/types.py +18 -0
  920. executorch/exir/verification/arg_validator.py +129 -0
  921. executorch/exir/verification/dev_html.py +68 -0
  922. executorch/exir/verification/interpreter.py +425 -0
  923. executorch/exir/verification/test/test_verifier.py +30 -0
  924. executorch/exir/verification/verifier.py +219 -0
  925. executorch/exir/version.py +9 -0
  926. executorch/exir/wrap.py +32 -0
  927. executorch/extension/gguf_util/convert_main.py +53 -0
  928. executorch/extension/gguf_util/converter.py +27 -0
  929. executorch/extension/gguf_util/converters/llama_converter.py +123 -0
  930. executorch/extension/gguf_util/load_gguf.py +103 -0
  931. executorch/extension/pybindings/_portable_lib.cpython-39-darwin.so +0 -0
  932. executorch/extension/pybindings/portable_lib.py +34 -0
  933. executorch/extension/pybindings/pybindings.pyi +49 -0
  934. executorch/extension/pybindings/test/make_test.py +221 -0
  935. executorch/extension/pybindings/test/test_pybindings.py +38 -0
  936. executorch/extension/pytree/__init__.py +54 -0
  937. executorch/extension/pytree/test/test.py +331 -0
  938. executorch/schema/program.fbs +407 -0
  939. executorch/schema/scalar_type.fbs +32 -0
  940. executorch/sdk/__init__.py +19 -0
  941. executorch/sdk/bundled_program/config.py +120 -0
  942. executorch/sdk/bundled_program/core.py +372 -0
  943. executorch/sdk/bundled_program/schema/__init__.py +9 -0
  944. executorch/sdk/bundled_program/schema/bundled_program_schema.fbs +97 -0
  945. executorch/sdk/bundled_program/schema/bundled_program_schema.py +99 -0
  946. executorch/sdk/bundled_program/schema/scalar_type.fbs +32 -0
  947. executorch/sdk/bundled_program/schema/test/test_schema.py +21 -0
  948. executorch/sdk/bundled_program/serialize/__init__.py +122 -0
  949. executorch/sdk/bundled_program/serialize/bundled_program_schema.fbs +97 -0
  950. executorch/sdk/bundled_program/serialize/scalar_type.fbs +32 -0
  951. executorch/sdk/bundled_program/serialize/test/test_serialize.py +35 -0
  952. executorch/sdk/bundled_program/test/test_bundle_data.py +118 -0
  953. executorch/sdk/bundled_program/test/test_config.py +133 -0
  954. executorch/sdk/bundled_program/test/test_end2end.py +93 -0
  955. executorch/sdk/bundled_program/util/test_util.py +288 -0
  956. executorch/sdk/bundled_program/version.py +13 -0
  957. executorch/sdk/debug_format/base_schema.py +59 -0
  958. executorch/sdk/debug_format/et_schema.py +419 -0
  959. executorch/sdk/etdump/etdump_schema_flatcc.fbs +171 -0
  960. executorch/sdk/etdump/scalar_type.fbs +32 -0
  961. executorch/sdk/etdump/schema_flatcc.py +151 -0
  962. executorch/sdk/etdump/serialize.py +110 -0
  963. executorch/sdk/etdump/tests/serialize_test.py +139 -0
  964. executorch/sdk/etrecord/__init__.py +13 -0
  965. executorch/sdk/etrecord/_etrecord.py +324 -0
  966. executorch/sdk/etrecord/tests/etrecord_test.py +187 -0
  967. executorch/sdk/inspector/__init__.py +10 -0
  968. executorch/sdk/inspector/_inspector.py +1173 -0
  969. executorch/sdk/inspector/_inspector_utils.py +414 -0
  970. executorch/sdk/inspector/inspector_cli.py +51 -0
  971. executorch/sdk/inspector/tests/event_blocks_test.py +370 -0
  972. executorch/sdk/inspector/tests/inspector_test.py +289 -0
  973. executorch/sdk/inspector/tests/inspector_utils_test.py +194 -0
  974. executorch/sdk/size_analysis_tool/size_analysis_tool.py +180 -0
  975. executorch/sdk/size_analysis_tool/size_analysis_tool_test.py +115 -0
  976. executorch/util/activation_memory_profiler.py +146 -0
  977. executorch/util/python_profiler.py +88 -0
  978. executorch/version.py +4 -0
  979. executorch-0.2.1.dist-info/LICENSE +33 -0
  980. executorch-0.2.1.dist-info/METADATA +108 -0
  981. executorch-0.2.1.dist-info/RECORD +1020 -0
  982. executorch-0.2.1.dist-info/WHEEL +5 -0
  983. executorch-0.2.1.dist-info/entry_points.txt +2 -0
  984. executorch-0.2.1.dist-info/top_level.txt +12 -0
  985. serializer/__init__.py +3 -0
  986. serializer/tosa_serializer.py +965 -0
  987. tosa/ArithmeticRightShiftAttribute.py +54 -0
  988. tosa/Attribute.py +29 -0
  989. tosa/AxisAttribute.py +54 -0
  990. tosa/ClampAttribute.py +145 -0
  991. tosa/CondIfAttribute.py +67 -0
  992. tosa/ConvAttribute.py +197 -0
  993. tosa/CustomAttribute.py +106 -0
  994. tosa/DType.py +18 -0
  995. tosa/FFTAttribute.py +67 -0
  996. tosa/FullyConnectedAttribute.py +67 -0
  997. tosa/MatMulAttribute.py +67 -0
  998. tosa/MulAttribute.py +54 -0
  999. tosa/NegateAttribute.py +67 -0
  1000. tosa/Op.py +78 -0
  1001. tosa/PadAttribute.py +132 -0
  1002. tosa/PoolAttribute.py +197 -0
  1003. tosa/RFFTAttribute.py +54 -0
  1004. tosa/RescaleAttribute.py +210 -0
  1005. tosa/ReshapeAttribute.py +80 -0
  1006. tosa/ResizeAttribute.py +171 -0
  1007. tosa/ResizeMode.py +8 -0
  1008. tosa/SliceAttribute.py +119 -0
  1009. tosa/TableAttribute.py +80 -0
  1010. tosa/TileAttribute.py +80 -0
  1011. tosa/TosaBasicBlock.py +192 -0
  1012. tosa/TosaGraph.py +95 -0
  1013. tosa/TosaOperator.py +147 -0
  1014. tosa/TosaRegion.py +91 -0
  1015. tosa/TosaTensor.py +184 -0
  1016. tosa/TransposeAttribute.py +80 -0
  1017. tosa/TransposeConvAttribute.py +197 -0
  1018. tosa/Version.py +93 -0
  1019. tosa/WhileLoopAttribute.py +67 -0
  1020. tosa/__init__.py +0 -0
@@ -0,0 +1,9 @@
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
+ from .coreml_preprocess import CoreMLBackend
6
+
7
+ __all__ = [
8
+ CoreMLBackend,
9
+ ]
@@ -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()