executorch 1.6.0__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3166) hide show
  1. executorch/backends/__init__.py +0 -0
  2. executorch/backends/aoti/aoti_backend.py +493 -0
  3. executorch/backends/aoti/aoti_partitioner.py +141 -0
  4. executorch/backends/aoti/passes/replace_view_copy_with_view.py +137 -0
  5. executorch/backends/apple/__init__.py +0 -0
  6. executorch/backends/apple/coreai/__init__.py +52 -0
  7. executorch/backends/apple/coreai/compiler/__init__.py +5 -0
  8. executorch/backends/apple/coreai/compiler/constants.py +12 -0
  9. executorch/backends/apple/coreai/compiler/enumerated_shapes.py +246 -0
  10. executorch/backends/apple/coreai/compiler/io_compat.py +258 -0
  11. executorch/backends/apple/coreai/compiler/preprocess.py +550 -0
  12. executorch/backends/apple/coreai/palettizer/__init__.py +11 -0
  13. executorch/backends/apple/coreai/palettizer/palettizer.py +115 -0
  14. executorch/backends/apple/coreai/partition/__init__.py +5 -0
  15. executorch/backends/apple/coreai/partition/partitioner.py +324 -0
  16. executorch/backends/apple/coreai/passes/__init__.py +11 -0
  17. executorch/backends/apple/coreai/passes/narrow_dtypes.py +105 -0
  18. executorch/backends/apple/coreai/passes/replace_copy_ops.py +66 -0
  19. executorch/backends/apple/coreai/passes/test/__init__.py +5 -0
  20. executorch/backends/apple/coreai/quantizer/__init__.py +11 -0
  21. executorch/backends/apple/coreai/quantizer/quantizer.py +92 -0
  22. executorch/backends/apple/coreai/recipes/__init__.py +18 -0
  23. executorch/backends/apple/coreai/recipes/recipe_provider.py +97 -0
  24. executorch/backends/apple/coreai/recipes/recipe_types.py +26 -0
  25. executorch/backends/apple/coreai/test/__init__.py +5 -0
  26. executorch/backends/apple/coreml/compiler/__init__.py +9 -0
  27. executorch/backends/apple/coreml/compiler/coreml_preprocess.py +993 -0
  28. executorch/backends/apple/coreml/compiler/enumerated_shape_utils.py +244 -0
  29. executorch/backends/apple/coreml/compiler/torch_ops.py +240 -0
  30. executorch/backends/apple/coreml/executorchcoreml.pyi +10 -0
  31. executorch/backends/apple/coreml/logging.py +24 -0
  32. executorch/backends/apple/coreml/partition/__init__.py +9 -0
  33. executorch/backends/apple/coreml/partition/coreml_partitioner.py +477 -0
  34. executorch/backends/apple/coreml/quantizer/__init__.py +9 -0
  35. executorch/backends/apple/coreml/quantizer/_annotation_config.py +130 -0
  36. executorch/backends/apple/coreml/quantizer/_coreml_quantizer.py +628 -0
  37. executorch/backends/apple/coreml/quantizer/_coreml_quantizer_utils.py +800 -0
  38. executorch/backends/apple/coreml/quantizer/coreml_quantizer.py +7 -0
  39. executorch/backends/apple/coreml/recipes/__init__.py +17 -0
  40. executorch/backends/apple/coreml/recipes/coreml_recipe_provider.py +413 -0
  41. executorch/backends/apple/coreml/recipes/coreml_recipe_types.py +53 -0
  42. executorch/backends/apple/coreml/test/test_coreml_utils.py +19 -0
  43. executorch/backends/apple/coreml/test/tester.py +121 -0
  44. executorch/backends/apple/metal/metal_backend.py +127 -0
  45. executorch/backends/apple/metal/metal_partitioner.py +25 -0
  46. executorch/backends/apple/metal/ops/__init__.py +5 -0
  47. executorch/backends/apple/metal/ops/gated_delta_rule.py +92 -0
  48. executorch/backends/apple/metal/ops/gather_qmv.py +117 -0
  49. executorch/backends/apple/metal/passes/__init__.py +11 -0
  50. executorch/backends/apple/metal/passes/decompose_linear_pass.py +115 -0
  51. executorch/backends/apple/metal/tests/__init__.py +5 -0
  52. executorch/backends/arm/__init__.py +59 -0
  53. executorch/backends/arm/_passes/__init__.py +251 -0
  54. executorch/backends/arm/_passes/_debug_passes.py +59 -0
  55. executorch/backends/arm/_passes/accumulate_index_put_pass.py +65 -0
  56. executorch/backends/arm/_passes/arm_pass.py +305 -0
  57. executorch/backends/arm/_passes/arm_pass_manager.py +891 -0
  58. executorch/backends/arm/_passes/arm_pass_utils.py +830 -0
  59. executorch/backends/arm/_passes/aten_to_tosa_activation_functions.py +148 -0
  60. executorch/backends/arm/_passes/aten_to_tosa_comparison.py +27 -0
  61. executorch/backends/arm/_passes/aten_to_tosa_data_layout.py +98 -0
  62. executorch/backends/arm/_passes/aten_to_tosa_reduction.py +110 -0
  63. executorch/backends/arm/_passes/aten_to_tosa_tensor_operators.py +112 -0
  64. executorch/backends/arm/_passes/aten_to_tosa_ternary.py +25 -0
  65. executorch/backends/arm/_passes/broadcast_args_pass.py +90 -0
  66. executorch/backends/arm/_passes/canonicalize_gather_pass.py +203 -0
  67. executorch/backends/arm/_passes/canonicalize_view_copy_permute_pass.py +22 -0
  68. executorch/backends/arm/_passes/cast_int64_pass.py +100 -0
  69. executorch/backends/arm/_passes/cast_int_comparison_inputs_pass.py +61 -0
  70. executorch/backends/arm/_passes/cast_to_int32_pass.py +69 -0
  71. executorch/backends/arm/_passes/constant_folding_pass.py +70 -0
  72. executorch/backends/arm/_passes/control_flow_const_inline.py +78 -0
  73. executorch/backends/arm/_passes/convert_bool_sum_pass.py +81 -0
  74. executorch/backends/arm/_passes/convert_elu_params.py +88 -0
  75. executorch/backends/arm/_passes/convert_expand_copy_to_repeat.py +91 -0
  76. executorch/backends/arm/_passes/convert_full_like_to_full_pass.py +51 -0
  77. executorch/backends/arm/_passes/convert_int64_const_ops_to_int32.py +85 -0
  78. executorch/backends/arm/_passes/convert_int64_output_ops_to_int32.py +512 -0
  79. executorch/backends/arm/_passes/convert_minmax_pass.py +166 -0
  80. executorch/backends/arm/_passes/convert_split_to_slice.py +134 -0
  81. executorch/backends/arm/_passes/convert_squeezes_to_view.py +41 -0
  82. executorch/backends/arm/_passes/convert_to_clamp_pass.py +47 -0
  83. executorch/backends/arm/_passes/decompose_acosh_pass.py +75 -0
  84. executorch/backends/arm/_passes/decompose_adaptive_avg_pool2d_pass.py +457 -0
  85. executorch/backends/arm/_passes/decompose_adaptive_max_pool2d_pass.py +202 -0
  86. executorch/backends/arm/_passes/decompose_add_sub_alpha_pass.py +102 -0
  87. executorch/backends/arm/_passes/decompose_addmm_pass.py +75 -0
  88. executorch/backends/arm/_passes/decompose_any_pass.py +117 -0
  89. executorch/backends/arm/_passes/decompose_as_strided_copy_pass.py +116 -0
  90. executorch/backends/arm/_passes/decompose_asin_and_acos_pass.py +233 -0
  91. executorch/backends/arm/_passes/decompose_asinh_pass.py +72 -0
  92. executorch/backends/arm/_passes/decompose_atan_pass.py +149 -0
  93. executorch/backends/arm/_passes/decompose_atanh_pass.py +84 -0
  94. executorch/backends/arm/_passes/decompose_avg_pool2d_pass.py +178 -0
  95. executorch/backends/arm/_passes/decompose_batch_norm_no_stats.py +259 -0
  96. executorch/backends/arm/_passes/decompose_bool_equality_pass.py +31 -0
  97. executorch/backends/arm/_passes/decompose_choose_qparams_symmetric_pass.py +285 -0
  98. executorch/backends/arm/_passes/decompose_cosh_pass.py +69 -0
  99. executorch/backends/arm/_passes/decompose_cosine_similarity_pass.py +98 -0
  100. executorch/backends/arm/_passes/decompose_cumsum_pass.py +167 -0
  101. executorch/backends/arm/_passes/decompose_div_pass.py +59 -0
  102. executorch/backends/arm/_passes/decompose_div_tensor_mode.py +283 -0
  103. executorch/backends/arm/_passes/decompose_dynamic_adaptive_avg_pool2d_pass.py +57 -0
  104. executorch/backends/arm/_passes/decompose_dynamic_full_pass.py +56 -0
  105. executorch/backends/arm/_passes/decompose_einsum_pass.py +66 -0
  106. executorch/backends/arm/_passes/decompose_elu_pass.py +187 -0
  107. executorch/backends/arm/_passes/decompose_embedding_pass.py +132 -0
  108. executorch/backends/arm/_passes/decompose_erfinv_pass.py +374 -0
  109. executorch/backends/arm/_passes/decompose_expm1_pass.py +160 -0
  110. executorch/backends/arm/_passes/decompose_flip_pass.py +35 -0
  111. executorch/backends/arm/_passes/decompose_floor_divide_pass.py +76 -0
  112. executorch/backends/arm/_passes/decompose_gelu_pass.py +144 -0
  113. executorch/backends/arm/_passes/decompose_glu_pass.py +84 -0
  114. executorch/backends/arm/_passes/decompose_grouped_conv_pass.py +319 -0
  115. executorch/backends/arm/_passes/decompose_groupnorm_pass.py +223 -0
  116. executorch/backends/arm/_passes/decompose_gru_pass.py +337 -0
  117. executorch/backends/arm/_passes/decompose_index_copy_pass.py +33 -0
  118. executorch/backends/arm/_passes/decompose_index_select_to_gather_pass.py +237 -0
  119. executorch/backends/arm/_passes/decompose_index_tensor_to_gather_pass.py +553 -0
  120. executorch/backends/arm/_passes/decompose_int_pow_pass.py +87 -0
  121. executorch/backends/arm/_passes/decompose_isinf_isnan_pass.py +48 -0
  122. executorch/backends/arm/_passes/decompose_large_stride_maxpool2d_pass.py +207 -0
  123. executorch/backends/arm/_passes/decompose_layernorm_pass.py +214 -0
  124. executorch/backends/arm/_passes/decompose_leaky_relu_pass.py +80 -0
  125. executorch/backends/arm/_passes/decompose_linalg_vector_norm_pass.py +93 -0
  126. executorch/backends/arm/_passes/decompose_linear_pass.py +147 -0
  127. executorch/backends/arm/_passes/decompose_log1p_pass.py +110 -0
  128. executorch/backends/arm/_passes/decompose_logit_pass.py +119 -0
  129. executorch/backends/arm/_passes/decompose_lstm_pass.py +466 -0
  130. executorch/backends/arm/_passes/decompose_masked_fill_pass.py +60 -0
  131. executorch/backends/arm/_passes/decompose_matmul.py +47 -0
  132. executorch/backends/arm/_passes/decompose_max_pool1d_pass.py +106 -0
  133. executorch/backends/arm/_passes/decompose_maxpool2d_with_dilation_pass.py +241 -0
  134. executorch/backends/arm/_passes/decompose_meandim_pass.py +263 -0
  135. executorch/backends/arm/_passes/decompose_ne_pass.py +75 -0
  136. executorch/backends/arm/_passes/decompose_permute_for_u55_pass.py +370 -0
  137. executorch/backends/arm/_passes/decompose_pow_tensor_tensor_pass.py +186 -0
  138. executorch/backends/arm/_passes/decompose_prelu_pass.py +107 -0
  139. executorch/backends/arm/_passes/decompose_prod_pass.py +50 -0
  140. executorch/backends/arm/_passes/decompose_quant_nodes.py +184 -0
  141. executorch/backends/arm/_passes/decompose_remainder_pass.py +74 -0
  142. executorch/backends/arm/_passes/decompose_rnn_pass.py +300 -0
  143. executorch/backends/arm/_passes/decompose_roll_pass.py +131 -0
  144. executorch/backends/arm/_passes/decompose_round_pass.py +67 -0
  145. executorch/backends/arm/_passes/decompose_sdpa_pass.py +41 -0
  146. executorch/backends/arm/_passes/decompose_sdpa_with_regular_softmax_pass.py +111 -0
  147. executorch/backends/arm/_passes/decompose_select.py +88 -0
  148. executorch/backends/arm/_passes/decompose_select_scatter_pass.py +146 -0
  149. executorch/backends/arm/_passes/decompose_sign_pass.py +83 -0
  150. executorch/backends/arm/_passes/decompose_sinh_pass.py +74 -0
  151. executorch/backends/arm/_passes/decompose_slice_scatter_pass.py +201 -0
  152. executorch/backends/arm/_passes/decompose_softmax_pass.py +126 -0
  153. executorch/backends/arm/_passes/decompose_sqrt_pass.py +46 -0
  154. executorch/backends/arm/_passes/decompose_strided_slice_copy_pass.py +147 -0
  155. executorch/backends/arm/_passes/decompose_sum_pass.py +94 -0
  156. executorch/backends/arm/_passes/decompose_tan_pass.py +44 -0
  157. executorch/backends/arm/_passes/decompose_topk_pass.py +320 -0
  158. executorch/backends/arm/_passes/decompose_tosa_unsupported_clamp_pass.py +99 -0
  159. executorch/backends/arm/_passes/decompose_tril_pass.py +112 -0
  160. executorch/backends/arm/_passes/decompose_unfold_to_gather_pass.py +417 -0
  161. executorch/backends/arm/_passes/decompose_unsupported_bilinear_resize_pass.py +159 -0
  162. executorch/backends/arm/_passes/decompose_var_pass.py +107 -0
  163. executorch/backends/arm/_passes/decompose_where_scalar_other_pass.py +62 -0
  164. executorch/backends/arm/_passes/decorate_fp32_to_int32_casting_pass.py +90 -0
  165. executorch/backends/arm/_passes/deduplicate_const_shapes_pass.py +47 -0
  166. executorch/backends/arm/_passes/deduplicate_get_attr_pass.py +96 -0
  167. executorch/backends/arm/_passes/detect_dynamic_w8a8_linear_pass.py +588 -0
  168. executorch/backends/arm/_passes/ensure_unique_output_nodes_pass.py +82 -0
  169. executorch/backends/arm/_passes/exir_to_tosa_pass.py +176 -0
  170. executorch/backends/arm/_passes/fold_dyt_affine_into_conv_pass.py +890 -0
  171. executorch/backends/arm/_passes/fold_dyt_alpha_into_lut_pass.py +379 -0
  172. executorch/backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py +521 -0
  173. executorch/backends/arm/_passes/fold_scalar_mul_into_conv_pass.py +335 -0
  174. executorch/backends/arm/_passes/fuse_batch_norm2d_pass.py +341 -0
  175. executorch/backends/arm/_passes/fuse_consecutive_clamps_pass.py +185 -0
  176. executorch/backends/arm/_passes/fuse_consecutive_concat_shapes.py +64 -0
  177. executorch/backends/arm/_passes/fuse_consecutive_concats_pass.py +107 -0
  178. executorch/backends/arm/_passes/fuse_consecutive_rescales_pass.py +175 -0
  179. executorch/backends/arm/_passes/fuse_consecutive_slices_pass.py +112 -0
  180. executorch/backends/arm/_passes/fuse_constant_ops_pass.py +374 -0
  181. executorch/backends/arm/_passes/fuse_duplicate_users_pass.py +27 -0
  182. executorch/backends/arm/_passes/fuse_equal_placeholders_pass.py +137 -0
  183. executorch/backends/arm/_passes/fuse_identical_input_transforms_pass.py +28 -0
  184. executorch/backends/arm/_passes/fuse_quantized_activation_pass.py +93 -0
  185. executorch/backends/arm/_passes/fuse_view_copy_transform_pass.py +14 -0
  186. executorch/backends/arm/_passes/get_decomposition_pass.py +149 -0
  187. executorch/backends/arm/_passes/insert_const_shapes.py +78 -0
  188. executorch/backends/arm/_passes/insert_data_layout_casts_pass.py +134 -0
  189. executorch/backends/arm/_passes/insert_dynamic_padding.py +77 -0
  190. executorch/backends/arm/_passes/insert_int32_casts_after_int64_placeholders.py +133 -0
  191. executorch/backends/arm/_passes/insert_rescales_pass.py +682 -0
  192. executorch/backends/arm/_passes/insert_table_ops.py +430 -0
  193. executorch/backends/arm/_passes/int32_range_analysis.py +455 -0
  194. executorch/backends/arm/_passes/lower_dynamic_w8a8_linear_pass.py +353 -0
  195. executorch/backends/arm/_passes/match_arg_dtype_pass.py +105 -0
  196. executorch/backends/arm/_passes/match_arg_ranks_pass.py +133 -0
  197. executorch/backends/arm/_passes/mm_to_bmm_pass.py +114 -0
  198. executorch/backends/arm/_passes/move_data_movement_ops_to_smaller_dtype_pass.py +158 -0
  199. executorch/backends/arm/_passes/mutable_buffer_utils.py +231 -0
  200. executorch/backends/arm/_passes/normalize_delegate_io_layout_pass.py +138 -0
  201. executorch/backends/arm/_passes/normalize_index_put_bool_index_tensor_pass.py +102 -0
  202. executorch/backends/arm/_passes/normalize_index_put_none_indices_pass.py +144 -0
  203. executorch/backends/arm/_passes/normalize_max_pool2d_input_rank_pass.py +97 -0
  204. executorch/backends/arm/_passes/normalize_while_initial_args_pass.py +115 -0
  205. executorch/backends/arm/_passes/prepare_gather_indices_pass.py +174 -0
  206. executorch/backends/arm/_passes/promote_bool_operands_pass.py +84 -0
  207. executorch/backends/arm/_passes/propagate_view_copy_permute_pass.py +152 -0
  208. executorch/backends/arm/_passes/quant_args.py +131 -0
  209. executorch/backends/arm/_passes/remove_getitem_pass.py +25 -0
  210. executorch/backends/arm/_passes/remove_graph_asserts_pass.py +18 -0
  211. executorch/backends/arm/_passes/remove_noop_pass.py +260 -0
  212. executorch/backends/arm/_passes/remove_permutes_around_elementwise_tosa_ops.py +54 -0
  213. executorch/backends/arm/_passes/remove_redundant_type_as_pass.py +53 -0
  214. executorch/backends/arm/_passes/remove_safe_softmax_guard_pass.py +173 -0
  215. executorch/backends/arm/_passes/replace_inf_and_limit_values_pass.py +81 -0
  216. executorch/backends/arm/_passes/replace_scalar_with_tensor_pass.py +150 -0
  217. executorch/backends/arm/_passes/resolve_view_copy_inferred_dim_pass.py +76 -0
  218. executorch/backends/arm/_passes/rewrite_adaptive_avg_pool2d.py +170 -0
  219. executorch/backends/arm/_passes/rewrite_avg_pool2d_pass.py +106 -0
  220. executorch/backends/arm/_passes/rewrite_bool_bitwise_to_logical_pass.py +50 -0
  221. executorch/backends/arm/_passes/rewrite_bool_to_fp32_cast_via_int8_pass.py +77 -0
  222. executorch/backends/arm/_passes/rewrite_cat_slice_pass.py +304 -0
  223. executorch/backends/arm/_passes/rewrite_conv_pass.py +1285 -0
  224. executorch/backends/arm/_passes/rewrite_high_rank_singleton_permute_pass.py +114 -0
  225. executorch/backends/arm/_passes/rewrite_index_put_pass.py +198 -0
  226. executorch/backends/arm/_passes/rewrite_inplace_arithmetic_pass.py +41 -0
  227. executorch/backends/arm/_passes/rewrite_le_lt_to_ge_gt_pass.py +44 -0
  228. executorch/backends/arm/_passes/rewrite_matmul.py +125 -0
  229. executorch/backends/arm/_passes/rewrite_max_pool2d_pass.py +187 -0
  230. executorch/backends/arm/_passes/rewrite_mxfp_conv2d.py +407 -0
  231. executorch/backends/arm/_passes/rewrite_mxfp_linear.py +390 -0
  232. executorch/backends/arm/_passes/rewrite_pad.py +213 -0
  233. executorch/backends/arm/_passes/rewrite_slice.py +114 -0
  234. executorch/backends/arm/_passes/rewrite_upsample.py +306 -0
  235. executorch/backends/arm/_passes/scalars_to_attribute_pass.py +144 -0
  236. executorch/backends/arm/_passes/size_adjust_input_pass.py +409 -0
  237. executorch/backends/arm/_passes/symbolic_materialization_helper.py +109 -0
  238. executorch/backends/arm/_passes/symbolic_shape_utils.py +27 -0
  239. executorch/backends/arm/_passes/symbolic_to_tosa_shape_pass.py +239 -0
  240. executorch/backends/arm/_passes/symbolic_value_range.py +196 -0
  241. executorch/backends/arm/_passes/unsqueeze_before_repeat_pass.py +66 -0
  242. executorch/backends/arm/_passes/unsqueeze_scalar_placeholders_pass.py +101 -0
  243. executorch/backends/arm/ao_ext/__init__.py +12 -0
  244. executorch/backends/arm/ao_ext/mxfp.py +137 -0
  245. executorch/backends/arm/ao_ext/mxfp_tosa_lib.py +12 -0
  246. executorch/backends/arm/ao_ext/mxfp_transform.py +27 -0
  247. executorch/backends/arm/ao_ext/ops/__init__.py +12 -0
  248. executorch/backends/arm/ao_ext/ops/mxfp_conv2d_op.py +325 -0
  249. executorch/backends/arm/ao_ext/ops/mxfp_linear_op.py +236 -0
  250. executorch/backends/arm/arm_vela.py +331 -0
  251. executorch/backends/arm/cmsis_pack/scripts/generate_components.py +487 -0
  252. executorch/backends/arm/cmsis_pack/scripts/generate_register_all_kernels.py +485 -0
  253. executorch/backends/arm/cmsis_pack/scripts/op_guards.py +144 -0
  254. executorch/backends/arm/common/__init__.py +4 -0
  255. executorch/backends/arm/common/annotation_meta.py +39 -0
  256. executorch/backends/arm/common/arm_compile_spec.py +335 -0
  257. executorch/backends/arm/common/as_strided_utils.py +72 -0
  258. executorch/backends/arm/common/debug.py +79 -0
  259. executorch/backends/arm/common/pipeline_config.py +138 -0
  260. executorch/backends/arm/common/type.py +28 -0
  261. executorch/backends/arm/constants.py +54 -0
  262. executorch/backends/arm/debug/__init__.py +4 -0
  263. executorch/backends/arm/debug/schema.py +145 -0
  264. executorch/backends/arm/ethosu/__init__.py +16 -0
  265. executorch/backends/arm/ethosu/backend.py +150 -0
  266. executorch/backends/arm/ethosu/compile_spec.py +281 -0
  267. executorch/backends/arm/ethosu/partitioner.py +40 -0
  268. executorch/backends/arm/operator_support/__init__.py +32 -0
  269. executorch/backends/arm/operator_support/as_strided_copy_support.py +113 -0
  270. executorch/backends/arm/operator_support/bool_bitwise_support.py +45 -0
  271. executorch/backends/arm/operator_support/clone_dim_order_support.py +77 -0
  272. executorch/backends/arm/operator_support/control_flow_support.py +197 -0
  273. executorch/backends/arm/operator_support/convolution_support.py +326 -0
  274. executorch/backends/arm/operator_support/embedding_support.py +56 -0
  275. executorch/backends/arm/operator_support/ethos_u55_support.py +588 -0
  276. executorch/backends/arm/operator_support/gather_support.py +172 -0
  277. executorch/backends/arm/operator_support/index_put_support.py +86 -0
  278. executorch/backends/arm/operator_support/index_select_support.py +128 -0
  279. executorch/backends/arm/operator_support/index_tensor_support.py +235 -0
  280. executorch/backends/arm/operator_support/minmax_support.py +59 -0
  281. executorch/backends/arm/operator_support/pool_2d_support.py +289 -0
  282. executorch/backends/arm/operator_support/reduce_sum_support.py +71 -0
  283. executorch/backends/arm/operator_support/right_shift_support.py +47 -0
  284. executorch/backends/arm/operator_support/roll_support.py +59 -0
  285. executorch/backends/arm/operator_support/slice_copy_support.py +148 -0
  286. executorch/backends/arm/operator_support/symint_arithmetic_support.py +44 -0
  287. executorch/backends/arm/operator_support/to_dim_order_copy_support.py +124 -0
  288. executorch/backends/arm/operator_support/topk_support.py +40 -0
  289. executorch/backends/arm/operator_support/tosa_profile_supported_op_lists.py +373 -0
  290. executorch/backends/arm/operator_support/tosa_supported_operators.py +1738 -0
  291. executorch/backends/arm/operator_support/unfold_copy_support.py +146 -0
  292. executorch/backends/arm/operator_support/upsample_support.py +124 -0
  293. executorch/backends/arm/operator_support/where_support.py +76 -0
  294. executorch/backends/arm/operators/__init__.py +81 -0
  295. executorch/backends/arm/operators/node_visitor.py +259 -0
  296. executorch/backends/arm/operators/op_cond_if.py +67 -0
  297. executorch/backends/arm/operators/op_flip.py +76 -0
  298. executorch/backends/arm/operators/op_to_dim_order_copy.py +47 -0
  299. executorch/backends/arm/operators/op_tosa_abs.py +26 -0
  300. executorch/backends/arm/operators/op_tosa_add.py +26 -0
  301. executorch/backends/arm/operators/op_tosa_argmax.py +62 -0
  302. executorch/backends/arm/operators/op_tosa_avg_pool2d.py +73 -0
  303. executorch/backends/arm/operators/op_tosa_avg_pool2d_adaptive.py +69 -0
  304. executorch/backends/arm/operators/op_tosa_binary_ops.py +93 -0
  305. executorch/backends/arm/operators/op_tosa_bitwise_not.py +30 -0
  306. executorch/backends/arm/operators/op_tosa_cast_to_block_scaled.py +140 -0
  307. executorch/backends/arm/operators/op_tosa_ceil.py +30 -0
  308. executorch/backends/arm/operators/op_tosa_clamp.py +70 -0
  309. executorch/backends/arm/operators/op_tosa_clz.py +30 -0
  310. executorch/backends/arm/operators/op_tosa_concat.py +60 -0
  311. executorch/backends/arm/operators/op_tosa_conv2d.py +127 -0
  312. executorch/backends/arm/operators/op_tosa_conv2d_block_scaled.py +111 -0
  313. executorch/backends/arm/operators/op_tosa_conv3d.py +23 -0
  314. executorch/backends/arm/operators/op_tosa_cos.py +30 -0
  315. executorch/backends/arm/operators/op_tosa_custom.py +186 -0
  316. executorch/backends/arm/operators/op_tosa_depthwise_conv2d.py +25 -0
  317. executorch/backends/arm/operators/op_tosa_eq.py +29 -0
  318. executorch/backends/arm/operators/op_tosa_erf.py +30 -0
  319. executorch/backends/arm/operators/op_tosa_exp.py +30 -0
  320. executorch/backends/arm/operators/op_tosa_fft.py +76 -0
  321. executorch/backends/arm/operators/op_tosa_floor.py +30 -0
  322. executorch/backends/arm/operators/op_tosa_gather.py +72 -0
  323. executorch/backends/arm/operators/op_tosa_ge.py +31 -0
  324. executorch/backends/arm/operators/op_tosa_gt.py +31 -0
  325. executorch/backends/arm/operators/op_tosa_identity.py +38 -0
  326. executorch/backends/arm/operators/op_tosa_log.py +30 -0
  327. executorch/backends/arm/operators/op_tosa_logical_not.py +26 -0
  328. executorch/backends/arm/operators/op_tosa_matmul.py +108 -0
  329. executorch/backends/arm/operators/op_tosa_matmul_t_block_scaled.py +97 -0
  330. executorch/backends/arm/operators/op_tosa_max_pool2d.py +70 -0
  331. executorch/backends/arm/operators/op_tosa_max_pool2d_adaptive.py +58 -0
  332. executorch/backends/arm/operators/op_tosa_maximum.py +27 -0
  333. executorch/backends/arm/operators/op_tosa_minimum.py +27 -0
  334. executorch/backends/arm/operators/op_tosa_mul.py +59 -0
  335. executorch/backends/arm/operators/op_tosa_neg.py +79 -0
  336. executorch/backends/arm/operators/op_tosa_pad.py +68 -0
  337. executorch/backends/arm/operators/op_tosa_pow.py +30 -0
  338. executorch/backends/arm/operators/op_tosa_reciprocal.py +30 -0
  339. executorch/backends/arm/operators/op_tosa_reduce_all.py +47 -0
  340. executorch/backends/arm/operators/op_tosa_reduce_any.py +49 -0
  341. executorch/backends/arm/operators/op_tosa_reduce_max.py +68 -0
  342. executorch/backends/arm/operators/op_tosa_reduce_min.py +68 -0
  343. executorch/backends/arm/operators/op_tosa_reduce_product.py +51 -0
  344. executorch/backends/arm/operators/op_tosa_reduce_sum.py +55 -0
  345. executorch/backends/arm/operators/op_tosa_rescale.py +304 -0
  346. executorch/backends/arm/operators/op_tosa_reshape.py +59 -0
  347. executorch/backends/arm/operators/op_tosa_resize.py +57 -0
  348. executorch/backends/arm/operators/op_tosa_reverse.py +54 -0
  349. executorch/backends/arm/operators/op_tosa_rshift_tensor.py +56 -0
  350. executorch/backends/arm/operators/op_tosa_rsqrt.py +30 -0
  351. executorch/backends/arm/operators/op_tosa_scatter.py +59 -0
  352. executorch/backends/arm/operators/op_tosa_shapes.py +260 -0
  353. executorch/backends/arm/operators/op_tosa_sigmoid.py +30 -0
  354. executorch/backends/arm/operators/op_tosa_sin.py +30 -0
  355. executorch/backends/arm/operators/op_tosa_slice.py +56 -0
  356. executorch/backends/arm/operators/op_tosa_sub.py +26 -0
  357. executorch/backends/arm/operators/op_tosa_table.py +64 -0
  358. executorch/backends/arm/operators/op_tosa_tanh.py +30 -0
  359. executorch/backends/arm/operators/op_tosa_tile.py +55 -0
  360. executorch/backends/arm/operators/op_tosa_transpose.py +58 -0
  361. executorch/backends/arm/operators/op_tosa_transpose_conv2d.py +123 -0
  362. executorch/backends/arm/operators/op_where.py +68 -0
  363. executorch/backends/arm/operators/op_while.py +105 -0
  364. executorch/backends/arm/operators/operator_validation_utils.py +239 -0
  365. executorch/backends/arm/operators/ops_quant_utils.py +35 -0
  366. executorch/backends/arm/operators/simple_node_visitor.py +70 -0
  367. executorch/backends/arm/process_node.py +427 -0
  368. executorch/backends/arm/quantizer/__init__.py +38 -0
  369. executorch/backends/arm/quantizer/arm_quantizer.py +1545 -0
  370. executorch/backends/arm/quantizer/arm_quantizer_utils.py +806 -0
  371. executorch/backends/arm/quantizer/quantization_annotator.py +1072 -0
  372. executorch/backends/arm/quantizer/quantization_config.py +600 -0
  373. executorch/backends/arm/quantizer/quantizer_support.py +283 -0
  374. executorch/backends/arm/recipes/__init__.py +15 -0
  375. executorch/backends/arm/recipes/arm_recipe_provider.py +287 -0
  376. executorch/backends/arm/recipes/arm_recipe_types.py +52 -0
  377. executorch/backends/arm/scripts/aot_arm_compiler.py +1193 -0
  378. executorch/backends/arm/scripts/check_model_support.py +467 -0
  379. executorch/backends/arm/scripts/docgen/__init__.py +4 -0
  380. executorch/backends/arm/scripts/docgen/docgen.py +276 -0
  381. executorch/backends/arm/scripts/docgen/generate_op_support.py +3269 -0
  382. executorch/backends/arm/scripts/etdump_to_chrome_trace.py +109 -0
  383. executorch/backends/arm/scripts/evaluate_model.py +402 -0
  384. executorch/backends/arm/scripts/examples/fast_model_support_demo.py +26 -0
  385. executorch/backends/arm/scripts/generate_grid_sampler_spirv.py +81 -0
  386. executorch/backends/arm/scripts/generate_neural_graphics_test_data.py +738 -0
  387. executorch/backends/arm/scripts/get_ethosu_scratch_from_pte.py +77 -0
  388. executorch/backends/arm/scripts/neural_graphics_test_data.py +490 -0
  389. executorch/backends/arm/scripts/public_api_manifest/__init__.py +4 -0
  390. executorch/backends/arm/scripts/public_api_manifest/generate_public_api_manifest.py +209 -0
  391. executorch/backends/arm/scripts/public_api_manifest/validate_public_api_manifest.py +410 -0
  392. executorch/backends/arm/test/_custom_vgf_test_utils.py +999 -0
  393. executorch/backends/arm/test/common.py +487 -0
  394. executorch/backends/arm/test/conftest.py +265 -0
  395. executorch/backends/arm/test/misc/test_dw_convs_with_shared_weights.py +46 -0
  396. executorch/backends/arm/test/models/DeepSeek_R1_Distill_Qwen/deepseek_r1_distill_qwen_test_config.py +42 -0
  397. executorch/backends/arm/test/models/Gemma3n/gemma3n_test_config.py +37 -0
  398. executorch/backends/arm/test/models/Qwen3_VL/qwen3_vl_test_config.py +64 -0
  399. executorch/backends/arm/test/models/model_test_utils.py +73 -0
  400. executorch/backends/arm/test/models/phi3/phi3_module_test_configs.py +24 -0
  401. executorch/backends/arm/test/models/stable_diffusion/stable_diffusion_module_test_configs.py +113 -0
  402. executorch/backends/arm/test/models/stable_diffusion_3_5_large/test_configs_sd35_large.py +311 -0
  403. executorch/backends/arm/test/ops/mxfp/__init__.py +4 -0
  404. executorch/backends/arm/test/ops/mxfp/common.py +122 -0
  405. executorch/backends/arm/test/ops/test_conv1d.py +500 -0
  406. executorch/backends/arm/test/ops/test_conv2d.py +873 -0
  407. executorch/backends/arm/test/runner_utils.py +1332 -0
  408. executorch/backends/arm/test/runtime/_vgf_runtime_test_utils.py +364 -0
  409. executorch/backends/arm/test/tester/__init__.py +6 -0
  410. executorch/backends/arm/test/tester/analyze_output_utils.py +478 -0
  411. executorch/backends/arm/test/tester/arm_tester.py +1409 -0
  412. executorch/backends/arm/test/tester/pte_diff_utils.py +421 -0
  413. executorch/backends/arm/test/tester/quantize.py +67 -0
  414. executorch/backends/arm/test/tester/serialize.py +96 -0
  415. executorch/backends/arm/test/tester/test_pipeline.py +1539 -0
  416. executorch/backends/arm/tosa/__init__.py +16 -0
  417. executorch/backends/arm/tosa/backend.py +424 -0
  418. executorch/backends/arm/tosa/cast_support.py +175 -0
  419. executorch/backends/arm/tosa/compile_spec.py +35 -0
  420. executorch/backends/arm/tosa/constant_pool.py +59 -0
  421. executorch/backends/arm/tosa/dialect/__init__.py +35 -0
  422. executorch/backends/arm/tosa/dialect/lib.py +83 -0
  423. executorch/backends/arm/tosa/dialect/ops/_common.py +134 -0
  424. executorch/backends/arm/tosa/dialect/ops/activation.py +118 -0
  425. executorch/backends/arm/tosa/dialect/ops/argmax.py +65 -0
  426. executorch/backends/arm/tosa/dialect/ops/avg_pool2d.py +133 -0
  427. executorch/backends/arm/tosa/dialect/ops/avg_pool2d_adaptive.py +82 -0
  428. executorch/backends/arm/tosa/dialect/ops/binary_elementwise.py +296 -0
  429. executorch/backends/arm/tosa/dialect/ops/comparison.py +78 -0
  430. executorch/backends/arm/tosa/dialect/ops/conv2d.py +139 -0
  431. executorch/backends/arm/tosa/dialect/ops/conv2d_block_scaled.py +218 -0
  432. executorch/backends/arm/tosa/dialect/ops/conv3d.py +69 -0
  433. executorch/backends/arm/tosa/dialect/ops/conversion_ops.py +213 -0
  434. executorch/backends/arm/tosa/dialect/ops/custom.py +159 -0
  435. executorch/backends/arm/tosa/dialect/ops/data_layout_ops.py +284 -0
  436. executorch/backends/arm/tosa/dialect/ops/depthwise_conv2d.py +49 -0
  437. executorch/backends/arm/tosa/dialect/ops/fft.py +144 -0
  438. executorch/backends/arm/tosa/dialect/ops/gather.py +101 -0
  439. executorch/backends/arm/tosa/dialect/ops/identity.py +16 -0
  440. executorch/backends/arm/tosa/dialect/ops/matmul.py +76 -0
  441. executorch/backends/arm/tosa/dialect/ops/matmul_t_block_scaled.py +162 -0
  442. executorch/backends/arm/tosa/dialect/ops/max_pool2d.py +89 -0
  443. executorch/backends/arm/tosa/dialect/ops/max_pool2d_adaptive.py +70 -0
  444. executorch/backends/arm/tosa/dialect/ops/reduction_ops.py +186 -0
  445. executorch/backends/arm/tosa/dialect/ops/resize.py +118 -0
  446. executorch/backends/arm/tosa/dialect/ops/scatter.py +23 -0
  447. executorch/backends/arm/tosa/dialect/ops/shape_ops.py +506 -0
  448. executorch/backends/arm/tosa/dialect/ops/table.py +51 -0
  449. executorch/backends/arm/tosa/dialect/ops/ternary_elementwise.py +77 -0
  450. executorch/backends/arm/tosa/dialect/ops/transpose_conv2d.py +58 -0
  451. executorch/backends/arm/tosa/dialect/ops/unary_elementwise.py +187 -0
  452. executorch/backends/arm/tosa/dialect/ops_registration.py +92 -0
  453. executorch/backends/arm/tosa/dialect/real_impl.py +174 -0
  454. executorch/backends/arm/tosa/dialect/shape.py +21 -0
  455. executorch/backends/arm/tosa/mapping.py +336 -0
  456. executorch/backends/arm/tosa/partitioner.py +1050 -0
  457. executorch/backends/arm/tosa/resize_utils.py +341 -0
  458. executorch/backends/arm/tosa/schemas/__init__.py +4 -0
  459. executorch/backends/arm/tosa/schemas/tosa_1.0.fbs +559 -0
  460. executorch/backends/arm/tosa/schemas/tosa_1.1.fbs +701 -0
  461. executorch/backends/arm/tosa/specification.py +514 -0
  462. executorch/backends/arm/tosa/utils.py +173 -0
  463. executorch/backends/arm/util/_factory.py +59 -0
  464. executorch/backends/arm/util/arm_model_evaluator.py +277 -0
  465. executorch/backends/arm/vgf/__init__.py +11 -0
  466. executorch/backends/arm/vgf/_passes/__init__.py +13 -0
  467. executorch/backends/arm/vgf/_passes/fuse_grid_sampler_flow_offset.py +548 -0
  468. executorch/backends/arm/vgf/_passes/group_independent_custom_shaders.py +87 -0
  469. executorch/backends/arm/vgf/_passes/insert_grid_sampler_grid_dequant_pass.py +151 -0
  470. executorch/backends/arm/vgf/_passes/rewrite_grid_sampler_to_tosa_custom.py +488 -0
  471. executorch/backends/arm/vgf/backend.py +491 -0
  472. executorch/backends/arm/vgf/check_env.py +707 -0
  473. executorch/backends/arm/vgf/compile_spec.py +132 -0
  474. executorch/backends/arm/vgf/model_converter.py +420 -0
  475. executorch/backends/arm/vgf/partitioner.py +42 -0
  476. executorch/backends/arm/vgf/quantization_assessment.py +824 -0
  477. executorch/backends/arm/vgf/quantization_quality.py +170 -0
  478. executorch/backends/arm/vgf/quantization_sensitivity.py +847 -0
  479. executorch/backends/arm/vgf/quantization_visualization.py +320 -0
  480. executorch/backends/arm/vgf/shaders/__init__.py +4 -0
  481. executorch/backends/arm/vgf/shaders/flow_offset_grid_sampler_int8_align_corners.glsl +60 -0
  482. executorch/backends/arm/vgf/shaders/grid_sampler.glsl +41 -0
  483. executorch/backends/arm/vgf/shaders/grid_sampler.py +504 -0
  484. executorch/backends/arm/vgf/shaders/grid_sampler.spirv.b64 +1 -0
  485. executorch/backends/arm/vgf/shaders/grid_sampler_sampler.glsl +35 -0
  486. executorch/backends/arm/vgf/shaders/grid_sampler_sampler.spirv.b64 +1 -0
  487. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_align_corners.glsl +40 -0
  488. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_align_corners.spirv.b64 +1 -0
  489. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8.glsl +44 -0
  490. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8.spirv.b64 +1 -0
  491. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8_align_corners.glsl +49 -0
  492. executorch/backends/arm/vgf/shaders/grid_sampler_sampler_int8_align_corners.spirv.b64 +1 -0
  493. executorch/backends/cadence/aot/__init__.py +5 -0
  494. executorch/backends/cadence/aot/compiler.py +547 -0
  495. executorch/backends/cadence/aot/compiler_funcs.py +758 -0
  496. executorch/backends/cadence/aot/compiler_utils.py +271 -0
  497. executorch/backends/cadence/aot/decompose_ops.py +115 -0
  498. executorch/backends/cadence/aot/export_example.py +123 -0
  499. executorch/backends/cadence/aot/functions.yaml +510 -0
  500. executorch/backends/cadence/aot/functions_fusion_g3.yaml +191 -0
  501. executorch/backends/cadence/aot/functions_hifi.yaml +607 -0
  502. executorch/backends/cadence/aot/functions_vision.yaml +275 -0
  503. executorch/backends/cadence/aot/fuse_ops.py +1170 -0
  504. executorch/backends/cadence/aot/graph_builder.py +32 -0
  505. executorch/backends/cadence/aot/memory_constraints.py +759 -0
  506. executorch/backends/cadence/aot/memory_planning.py +562 -0
  507. executorch/backends/cadence/aot/memory_planning_algo.py +342 -0
  508. executorch/backends/cadence/aot/ops_registrations.py +3533 -0
  509. executorch/backends/cadence/aot/pass_utils.py +172 -0
  510. executorch/backends/cadence/aot/passes.py +226 -0
  511. executorch/backends/cadence/aot/program_builder.py +28 -0
  512. executorch/backends/cadence/aot/quantizer/fusion_pass.py +843 -0
  513. executorch/backends/cadence/aot/quantizer/passes/fuse_ops.py +391 -0
  514. executorch/backends/cadence/aot/quantizer/pattern_utils.py +460 -0
  515. executorch/backends/cadence/aot/quantizer/patterns.py +1567 -0
  516. executorch/backends/cadence/aot/quantizer/quantizer.py +555 -0
  517. executorch/backends/cadence/aot/quantizer/utils.py +286 -0
  518. executorch/backends/cadence/aot/ref_implementations.py +3126 -0
  519. executorch/backends/cadence/aot/remove_ops.py +1025 -0
  520. executorch/backends/cadence/aot/reorder_ops.py +1463 -0
  521. executorch/backends/cadence/aot/replace_ops.py +2657 -0
  522. executorch/backends/cadence/aot/simplify_ops.py +218 -0
  523. executorch/backends/cadence/aot/to_out_var_pass.py +24 -0
  524. executorch/backends/cadence/aot/type_dispatch.py +179 -0
  525. executorch/backends/cadence/aot/typing_stubs.py +22 -0
  526. executorch/backends/cadence/aot/utils.py +372 -0
  527. executorch/backends/cadence/aot/weight_packing.py +390 -0
  528. executorch/backends/cadence/runtime/__init__.py +13 -0
  529. executorch/backends/cadence/runtime/etdump.py +173 -0
  530. executorch/backends/cadence/runtime/executor.py +208 -0
  531. executorch/backends/cadence/runtime/runtime.py +167 -0
  532. executorch/backends/cadence/runtime/utils.py +100 -0
  533. executorch/backends/cadence/utils/facto_util.py +612 -0
  534. executorch/backends/cadence/utils/gen_header.py +49 -0
  535. executorch/backends/cadence/utils/post_compilation.py +173 -0
  536. executorch/backends/cortex_m/edge_compile_config.py +40 -0
  537. executorch/backends/cortex_m/library/__init__.py +4 -0
  538. executorch/backends/cortex_m/library/_cmsis_nn/cmsis_nn.cp315-win_amd64.pyd +0 -0
  539. executorch/backends/cortex_m/library/cmsis_nn.py +281 -0
  540. executorch/backends/cortex_m/ops/operators.py +1985 -0
  541. executorch/backends/cortex_m/ops/operators.yaml +145 -0
  542. executorch/backends/cortex_m/passes/__init__.py +15 -0
  543. executorch/backends/cortex_m/passes/activation_fusion_pass.py +210 -0
  544. executorch/backends/cortex_m/passes/aten_to_cortex_m_pass.py +1300 -0
  545. executorch/backends/cortex_m/passes/clamp_hardswish_pass.py +37 -0
  546. executorch/backends/cortex_m/passes/cortex_m_pass.py +35 -0
  547. executorch/backends/cortex_m/passes/cortex_m_pass_manager.py +221 -0
  548. executorch/backends/cortex_m/passes/decompose_hardswish_pass.py +128 -0
  549. executorch/backends/cortex_m/passes/decompose_mean_pass.py +104 -0
  550. executorch/backends/cortex_m/passes/decompose_sdpa_pass.py +92 -0
  551. executorch/backends/cortex_m/passes/explicit_layout_pass.py +157 -0
  552. executorch/backends/cortex_m/passes/fuse_conv_padding_pass.py +81 -0
  553. executorch/backends/cortex_m/passes/initialize_scratch_buffers_pass.py +37 -0
  554. executorch/backends/cortex_m/passes/matmul_to_bmm_pass.py +82 -0
  555. executorch/backends/cortex_m/passes/quantized_clamp_activation_pass.py +126 -0
  556. executorch/backends/cortex_m/passes/replace_quant_nodes_pass.py +76 -0
  557. executorch/backends/cortex_m/passes/scratch_buffer_sizes.py +328 -0
  558. executorch/backends/cortex_m/quantizer/__init__.py +19 -0
  559. executorch/backends/cortex_m/quantizer/node_finders.py +165 -0
  560. executorch/backends/cortex_m/quantizer/pattern_checkers.py +409 -0
  561. executorch/backends/cortex_m/quantizer/pattern_matcher.py +214 -0
  562. executorch/backends/cortex_m/quantizer/quantization_configs.py +226 -0
  563. executorch/backends/cortex_m/quantizer/quantizer.py +121 -0
  564. executorch/backends/cortex_m/quantizer/quantizer_support.py +260 -0
  565. executorch/backends/cortex_m/quantizer_reporter.py +443 -0
  566. executorch/backends/cortex_m/target_config.py +117 -0
  567. executorch/backends/cortex_m/test/models/__init__.py +4 -0
  568. executorch/backends/cortex_m/test/ops/__init__.py +4 -0
  569. executorch/backends/cortex_m/test/ops/nhwc_test_utils.py +42 -0
  570. executorch/backends/cortex_m/test/test_helpers_passes_utils.py +103 -0
  571. executorch/backends/cortex_m/test/tester.py +256 -0
  572. executorch/backends/cortex_m/utils.py +428 -0
  573. executorch/backends/cpu/__init__.py +5 -0
  574. executorch/backends/cpu/partitioner.py +110 -0
  575. executorch/backends/cpu/preprocess.py +89 -0
  576. executorch/backends/cpu/recipes/__init__.py +14 -0
  577. executorch/backends/cpu/recipes/cpu_recipe_provider.py +37 -0
  578. executorch/backends/cpu/recipes/cpu_recipe_types.py +15 -0
  579. executorch/backends/cpu/test/tester.py +43 -0
  580. executorch/backends/cuda/__init__.py +5 -0
  581. executorch/backends/cuda/aoti_packed_int4_tensor.py +178 -0
  582. executorch/backends/cuda/autotune/__init__.py +8 -0
  583. executorch/backends/cuda/autotune/cuda_graph_timing.py +367 -0
  584. executorch/backends/cuda/autotune/inputs.py +214 -0
  585. executorch/backends/cuda/autotune/launch_params.py +413 -0
  586. executorch/backends/cuda/batching/__init__.py +0 -0
  587. executorch/backends/cuda/batching/test/__init__.py +0 -0
  588. executorch/backends/cuda/batching/test/export_toy_decoder.py +346 -0
  589. executorch/backends/cuda/benchmarks/benchmark_moe.py +423 -0
  590. executorch/backends/cuda/benchmarks/benchmark_sdpa.py +308 -0
  591. executorch/backends/cuda/coalesced_int4_tensor.py +243 -0
  592. executorch/backends/cuda/cuda_backend.py +1578 -0
  593. executorch/backends/cuda/cuda_partitioner.py +53 -0
  594. executorch/backends/cuda/cuda_weight_collector.py +641 -0
  595. executorch/backends/cuda/dp4a_planar_int5_tensor.py +323 -0
  596. executorch/backends/cuda/dp4a_planar_int6_tensor.py +307 -0
  597. executorch/backends/cuda/merge_ptes.py +750 -0
  598. executorch/backends/cuda/passes/__init__.py +0 -0
  599. executorch/backends/cuda/passes/lower_offgraph_kv.py +689 -0
  600. executorch/backends/cuda/passes/move_cond_predicate_to_cpu.py +94 -0
  601. executorch/backends/cuda/passes/remove_assert_async.py +50 -0
  602. executorch/backends/cuda/passes/replace_complex_with_real.py +398 -0
  603. executorch/backends/cuda/passes/replace_fused_sdpa.py +136 -0
  604. executorch/backends/cuda/passes/replace_int64_floordiv.py +153 -0
  605. executorch/backends/cuda/passes/replace_masked_copy_with_where.py +220 -0
  606. executorch/backends/cuda/passes/tests/__init__.py +0 -0
  607. executorch/backends/cuda/passes/tests/test_replace_fused_sdpa.py +124 -0
  608. executorch/backends/cuda/quantize_op_dispatch/__init__.py +31 -0
  609. executorch/backends/cuda/quantize_op_dispatch/_gemm_family_dispatch.py +118 -0
  610. executorch/backends/cuda/quantize_op_dispatch/int4_dispatch.py +121 -0
  611. executorch/backends/cuda/quantize_op_dispatch/int5_dispatch.py +127 -0
  612. executorch/backends/cuda/quantize_op_dispatch/int6_dispatch.py +115 -0
  613. executorch/backends/cuda/quantize_op_dispatch/int8_dispatch.py +113 -0
  614. executorch/backends/cuda/target_smem.py +63 -0
  615. executorch/backends/cuda/tests/__init__.py +5 -0
  616. executorch/backends/cuda/tests/autotune_test_utils.py +236 -0
  617. executorch/backends/cuda/tests/test_int5_dispatch.py +432 -0
  618. executorch/backends/cuda/tests/test_int6_dispatch.py +462 -0
  619. executorch/backends/cuda/triton/__init__.py +17 -0
  620. executorch/backends/cuda/triton/kernels/__init__.py +64 -0
  621. executorch/backends/cuda/triton/kernels/chunk_gated_delta_rule.py +273 -0
  622. executorch/backends/cuda/triton/kernels/fused_deltanet_decode.py +358 -0
  623. executorch/backends/cuda/triton/kernels/fused_moe.py +1604 -0
  624. executorch/backends/cuda/triton/kernels/int4_matmul.py +558 -0
  625. executorch/backends/cuda/triton/kernels/int4_quantized_gemm.py +1964 -0
  626. executorch/backends/cuda/triton/kernels/int5_quantized_gemm.py +1675 -0
  627. executorch/backends/cuda/triton/kernels/int6_quantized_gemm.py +1501 -0
  628. executorch/backends/cuda/triton/kernels/int8_quantized_gemm.py +1275 -0
  629. executorch/backends/cuda/triton/kernels/quantized_gemm_family.py +579 -0
  630. executorch/backends/cuda/triton/kernels/quantized_gemm_utils.py +505 -0
  631. executorch/backends/cuda/triton/kernels/sdpa.py +2496 -0
  632. executorch/backends/cuda/triton/kernels/topk.py +220 -0
  633. executorch/backends/cuda/triton/kernels/tq4_sdpa.py +1216 -0
  634. executorch/backends/cuda/triton/kernels/triton_mutation_cache.py +131 -0
  635. executorch/backends/cuda/triton/replacement_pass.py +232 -0
  636. executorch/backends/example/example_backend.py +41 -0
  637. executorch/backends/example/example_backend_delegate_passes/merge_to_dim_pass.py +83 -0
  638. executorch/backends/example/example_backend_delegate_passes/permute_memory_formats_pass.py +143 -0
  639. executorch/backends/example/example_operators/adaptive_avg_pool2d.py +47 -0
  640. executorch/backends/example/example_operators/add.py +44 -0
  641. executorch/backends/example/example_operators/conv2d.py +52 -0
  642. executorch/backends/example/example_operators/conv_relu.py +49 -0
  643. executorch/backends/example/example_operators/dropout.py +44 -0
  644. executorch/backends/example/example_operators/flatten.py +40 -0
  645. executorch/backends/example/example_operators/linear.py +62 -0
  646. executorch/backends/example/example_operators/op_base.py +15 -0
  647. executorch/backends/example/example_operators/ops.py +32 -0
  648. executorch/backends/example/example_operators/utils.py +34 -0
  649. executorch/backends/example/example_partitioner.py +88 -0
  650. executorch/backends/example/example_quantizer.py +108 -0
  651. executorch/backends/example/test_example_delegate.py +112 -0
  652. executorch/backends/mediatek/__init__.py +5 -0
  653. executorch/backends/mediatek/_passes/__init__.py +0 -0
  654. executorch/backends/mediatek/_passes/decompose_scaled_dot_product_attention.py +79 -0
  655. executorch/backends/mediatek/partitioner.py +107 -0
  656. executorch/backends/mediatek/preprocess.py +214 -0
  657. executorch/backends/mediatek/quantizer/__init__.py +4 -0
  658. executorch/backends/mediatek/quantizer/annotator.py +263 -0
  659. executorch/backends/mediatek/quantizer/qconfig.py +174 -0
  660. executorch/backends/mediatek/quantizer/quantizer.py +45 -0
  661. executorch/backends/mlx/__init__.py +17 -0
  662. executorch/backends/mlx/_logging.py +40 -0
  663. executorch/backends/mlx/_memprofile.py +188 -0
  664. executorch/backends/mlx/builder/__init__.py +16 -0
  665. executorch/backends/mlx/builder/op_helpers.py +885 -0
  666. executorch/backends/mlx/builder/op_registry.py +223 -0
  667. executorch/backends/mlx/builder/pattern_matcher.py +64 -0
  668. executorch/backends/mlx/builder/program_builder.py +1281 -0
  669. executorch/backends/mlx/builder/slot_manager.py +252 -0
  670. executorch/backends/mlx/custom_kernel_ops/__init__.py +7 -0
  671. executorch/backends/mlx/custom_kernel_ops/gated_delta_rule.py +596 -0
  672. executorch/backends/mlx/custom_kernel_ops/gguf/__init__.py +18 -0
  673. executorch/backends/mlx/custom_kernel_ops/gguf/patterns.py +209 -0
  674. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/__init__.py +32 -0
  675. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/common.py +151 -0
  676. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/embedding.py +147 -0
  677. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/embedding_mlx_native.py +57 -0
  678. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/linear.py +500 -0
  679. executorch/backends/mlx/custom_kernel_ops/gguf/q4k/linear_mlx_native.py +85 -0
  680. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/__init__.py +37 -0
  681. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/common.py +167 -0
  682. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/embedding.py +144 -0
  683. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/embedding_mlx_native.py +57 -0
  684. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/linear.py +534 -0
  685. executorch/backends/mlx/custom_kernel_ops/gguf/q5k/linear_mlx_native.py +85 -0
  686. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/__init__.py +40 -0
  687. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/common.py +142 -0
  688. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/embedding.py +151 -0
  689. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/embedding_mlx_native.py +61 -0
  690. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/linear.py +511 -0
  691. executorch/backends/mlx/custom_kernel_ops/gguf/q6k/linear_mlx_native.py +86 -0
  692. executorch/backends/mlx/custom_kernel_ops/gguf/repack_mlx.py +132 -0
  693. executorch/backends/mlx/custom_kernel_ops/gguf/test/__init__.py +5 -0
  694. executorch/backends/mlx/custom_kernel_ops/gguf/test/test_embedding.py +270 -0
  695. executorch/backends/mlx/custom_kernel_ops/gguf/test/test_linear.py +647 -0
  696. executorch/backends/mlx/custom_kernel_ops/test/__init__.py +5 -0
  697. executorch/backends/mlx/custom_kernel_ops/test/test_gated_delta_rule.py +1037 -0
  698. executorch/backends/mlx/custom_kernel_ops/test/test_tq4_compress.py +183 -0
  699. executorch/backends/mlx/custom_kernel_ops/test/test_tq_dequant.py +166 -0
  700. executorch/backends/mlx/custom_kernel_ops/test/test_tq_norm.py +150 -0
  701. executorch/backends/mlx/custom_kernel_ops/tq4_compress.py +189 -0
  702. executorch/backends/mlx/custom_kernel_ops/tq_dequant.py +216 -0
  703. executorch/backends/mlx/custom_kernel_ops/tq_norm.py +170 -0
  704. executorch/backends/mlx/custom_ops.py +546 -0
  705. executorch/backends/mlx/examples/__init__.py +6 -0
  706. executorch/backends/mlx/examples/llm/__init__.py +6 -0
  707. executorch/backends/mlx/examples/llm/dflash/__init__.py +26 -0
  708. executorch/backends/mlx/examples/llm/dflash/adapters.py +71 -0
  709. executorch/backends/mlx/examples/llm/dflash/arch.py +109 -0
  710. executorch/backends/mlx/examples/llm/dflash/cache.py +60 -0
  711. executorch/backends/mlx/examples/llm/dflash/export.py +270 -0
  712. executorch/backends/mlx/examples/llm/dflash/model.py +368 -0
  713. executorch/backends/mlx/examples/llm/dflash/run.py +305 -0
  714. executorch/backends/mlx/examples/llm/export_llm_hf.py +758 -0
  715. executorch/backends/mlx/examples/llm/run_llm_hf.py +217 -0
  716. executorch/backends/mlx/examples/llm/runtime_meta.py +238 -0
  717. executorch/backends/mlx/examples/voxtral/__init__.py +5 -0
  718. executorch/backends/mlx/examples/voxtral/export_voxtral_hf.py +201 -0
  719. executorch/backends/mlx/examples/whisper/__init__.py +7 -0
  720. executorch/backends/mlx/examples/whisper/args.py +151 -0
  721. executorch/backends/mlx/examples/whisper/export_whisper.py +620 -0
  722. executorch/backends/mlx/examples/whisper/run_whisper.py +276 -0
  723. executorch/backends/mlx/llm/__init__.py +6 -0
  724. executorch/backends/mlx/llm/cache.py +721 -0
  725. executorch/backends/mlx/llm/et_attention.py +252 -0
  726. executorch/backends/mlx/llm/exportable.py +379 -0
  727. executorch/backends/mlx/llm/hf_attention.py +413 -0
  728. executorch/backends/mlx/llm/quantization.py +57 -0
  729. executorch/backends/mlx/llm/sampling.py +44 -0
  730. executorch/backends/mlx/llm/source_transformation.py +309 -0
  731. executorch/backends/mlx/llm/switch.py +329 -0
  732. executorch/backends/mlx/llm/turboquant_cache.py +244 -0
  733. executorch/backends/mlx/ops.py +5759 -0
  734. executorch/backends/mlx/partitioner.py +386 -0
  735. executorch/backends/mlx/passes.py +360 -0
  736. executorch/backends/mlx/pattern_utils.py +360 -0
  737. executorch/backends/mlx/patterns.py +1423 -0
  738. executorch/backends/mlx/preprocess.py +226 -0
  739. executorch/backends/mlx/pte_inspector.py +902 -0
  740. executorch/backends/mlx/serialization/__init__.py +32 -0
  741. executorch/backends/mlx/serialization/generate.py +1581 -0
  742. executorch/backends/mlx/serialization/mlx_graph_serialize.py +417 -0
  743. executorch/backends/mlx/serialization/schema.fbs +1314 -0
  744. executorch/backends/mlx/test/__init__.py +5 -0
  745. executorch/backends/mlx/test/run_all_tests.py +496 -0
  746. executorch/backends/mlx/test/test_ops.py +9052 -0
  747. executorch/backends/mlx/test/test_sample.py +295 -0
  748. executorch/backends/mlx/test/test_slot_recycling.py +198 -0
  749. executorch/backends/mlx/test/test_utils.py +1184 -0
  750. executorch/backends/mlx/test/tester.py +78 -0
  751. executorch/backends/native/__init__.py +23 -0
  752. executorch/backends/native/custom_ops.py +107 -0
  753. executorch/backends/native/examples/hf_llm/convert_meta_llama.py +93 -0
  754. executorch/backends/native/examples/hf_llm/export_hf_llm.py +316 -0
  755. executorch/backends/native/examples/hf_llm/gguf_hf.py +145 -0
  756. executorch/backends/native/examples/hf_llm/test_export_hf_llm.py +235 -0
  757. executorch/backends/native/partitioner.py +294 -0
  758. executorch/backends/native/passes/__init__.py +86 -0
  759. executorch/backends/native/passes/_utils.py +34 -0
  760. executorch/backends/native/passes/fuse_rope.py +488 -0
  761. executorch/backends/native/passes/reinplace.py +74 -0
  762. executorch/backends/native/passes/remove_runtime_asserts.py +114 -0
  763. executorch/backends/native/passes/replace_copy_with_alias.py +185 -0
  764. executorch/backends/native/preprocess.py +157 -0
  765. executorch/backends/native/serialization/__init__.py +27 -0
  766. executorch/backends/native/serialization/graph_serialize.py +1705 -0
  767. executorch/backends/native/serialization/native_graph.fbs +448 -0
  768. executorch/backends/native/serialization/schema.py +343 -0
  769. executorch/backends/native/test/__init__.py +0 -0
  770. executorch/backends/native/test/utils.py +44 -0
  771. executorch/backends/nxp/__init__.py +0 -0
  772. executorch/backends/nxp/aten_passes/add_batch_size_for_3d_input_pool_2d_ops.py +116 -0
  773. executorch/backends/nxp/aten_passes/convert_1d_conv_to_2d.py +489 -0
  774. executorch/backends/nxp/aten_passes/convert_div_to_mul.py +177 -0
  775. executorch/backends/nxp/aten_passes/convert_scalar_to_attr.py +119 -0
  776. executorch/backends/nxp/aten_passes/decompose_split_to_slices_pass.py +196 -0
  777. executorch/backends/nxp/aten_passes/fuse_batch_norm_with_conv_pass.py +145 -0
  778. executorch/backends/nxp/aten_passes/fuse_batch_norm_with_linear_pass.py +188 -0
  779. executorch/backends/nxp/aten_passes/fuse_linear_and_add_pass.py +202 -0
  780. executorch/backends/nxp/aten_passes/move_activation_before_concat.py +101 -0
  781. executorch/backends/nxp/aten_passes/neutron_aten_pass_manager.py +90 -0
  782. executorch/backends/nxp/aten_passes/remove_nodes_with_known_outputs.py +196 -0
  783. executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/__init__.py +16 -0
  784. executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/add_simulated_linear_bn_fusion_qat_pass.py +395 -0
  785. executorch/backends/nxp/aten_passes/simulated_linear_bn_fusion_passes/remove_simulated_linear_bn_fusion_qat_pass.py +245 -0
  786. executorch/backends/nxp/aten_passes/split_group_convolution.py +300 -0
  787. executorch/backends/nxp/aten_passes/split_gru_based_on_num_layers.py +307 -0
  788. executorch/backends/nxp/backend/custom_delegation_options.py +17 -0
  789. executorch/backends/nxp/backend/data_format.py +49 -0
  790. executorch/backends/nxp/backend/edge_helper.py +527 -0
  791. executorch/backends/nxp/backend/edge_program_converter.py +363 -0
  792. executorch/backends/nxp/backend/graph_utils.py +129 -0
  793. executorch/backends/nxp/backend/ir/conversion_config.py +54 -0
  794. executorch/backends/nxp/backend/ir/conversion_context.py +43 -0
  795. executorch/backends/nxp/backend/ir/converter/__init__.py +0 -0
  796. executorch/backends/nxp/backend/ir/converter/builder/__init__.py +0 -0
  797. executorch/backends/nxp/backend/ir/converter/builder/aten_model_builder_director.py +156 -0
  798. executorch/backends/nxp/backend/ir/converter/builder/model_builder.py +1806 -0
  799. executorch/backends/nxp/backend/ir/converter/builder/quantization_verification.py +387 -0
  800. executorch/backends/nxp/backend/ir/converter/conversion/__init__.py +0 -0
  801. executorch/backends/nxp/backend/ir/converter/conversion/aten_translator.py +71 -0
  802. executorch/backends/nxp/backend/ir/converter/conversion/common.py +177 -0
  803. executorch/backends/nxp/backend/ir/converter/conversion/translator.py +689 -0
  804. executorch/backends/nxp/backend/ir/converter/node_converter.py +538 -0
  805. executorch/backends/nxp/backend/ir/converter/node_converters/__init__.py +4 -0
  806. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/__init__.py +179 -0
  807. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/abs_converter.py +53 -0
  808. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/adaptive_avg_pool_2d_converter.py +113 -0
  809. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/add_tensor_converter.py +67 -0
  810. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/addmm_converter.py +160 -0
  811. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/amax_converter.py +82 -0
  812. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/amin_converter.py +82 -0
  813. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/avg_pool_2d_converter.py +144 -0
  814. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/bmm_converter.py +102 -0
  815. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/cat_converter.py +123 -0
  816. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/clamp_converter.py +290 -0
  817. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/clone_converter.py +118 -0
  818. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/constant_pad_nd_converter.py +163 -0
  819. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/convolution_converter.py +548 -0
  820. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/exp_converter.py +60 -0
  821. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/getitem_converter.py +60 -0
  822. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardswish_converter.py +51 -0
  823. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardtanh_converter.py +37 -0
  824. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/leaky_relu_converter.py +64 -0
  825. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/log_converter.py +60 -0
  826. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/max_pool2d_with_indices_converter.py +183 -0
  827. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/maximum_converter.py +69 -0
  828. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mean_dim_converter.py +108 -0
  829. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/minimum_converter.py +69 -0
  830. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mm_converter.py +95 -0
  831. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py +64 -0
  832. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/neg_converter.py +77 -0
  833. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/pad_converter.py +118 -0
  834. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/permute_copy_converter.py +435 -0
  835. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/prelu_converter.py +67 -0
  836. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_dequantize_converter.py +127 -0
  837. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_quantize_converter.py +46 -0
  838. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/relu_converter.py +67 -0
  839. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/rsqrt_converter.py +63 -0
  840. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sigmoid_converter.py +63 -0
  841. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_copy_tensor_converter.py +116 -0
  842. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/softmax_converter.py +143 -0
  843. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sub_tensor_converter.py +72 -0
  844. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sum_dim_int_list_converter.py +84 -0
  845. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/tanh_converter.py +61 -0
  846. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/upsample_bilinear2d_converter.py +153 -0
  847. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/upsample_nearest2d_converter.py +137 -0
  848. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/view_copy_converter.py +99 -0
  849. executorch/backends/nxp/backend/ir/converter/node_converters/shared/__init__.py +0 -0
  850. executorch/backends/nxp/backend/ir/converter/node_converters/shared/conv_utils.py +123 -0
  851. executorch/backends/nxp/backend/ir/converter/node_converters/shared/recurrent_utils.py +64 -0
  852. executorch/backends/nxp/backend/ir/converter/node_converters/shared/reduce_utils.py +173 -0
  853. executorch/backends/nxp/backend/ir/converter/node_converters/shared/reshape_transposition.py +233 -0
  854. executorch/backends/nxp/backend/ir/converter/quantization_utils.py +161 -0
  855. executorch/backends/nxp/backend/ir/converter/tensor_utils.py +55 -0
  856. executorch/backends/nxp/backend/ir/lib/__init__.py +0 -0
  857. executorch/backends/nxp/backend/ir/lib/tflite/ATan2Options.py +50 -0
  858. executorch/backends/nxp/backend/ir/lib/tflite/AbsOptions.py +50 -0
  859. executorch/backends/nxp/backend/ir/lib/tflite/ActivationFunctionType.py +12 -0
  860. executorch/backends/nxp/backend/ir/lib/tflite/AddNOptions.py +50 -0
  861. executorch/backends/nxp/backend/ir/lib/tflite/AddOptions.py +82 -0
  862. executorch/backends/nxp/backend/ir/lib/tflite/ArgMaxOptions.py +65 -0
  863. executorch/backends/nxp/backend/ir/lib/tflite/ArgMinOptions.py +65 -0
  864. executorch/backends/nxp/backend/ir/lib/tflite/AssignVariableOptions.py +50 -0
  865. executorch/backends/nxp/backend/ir/lib/tflite/BatchMatMulOptions.py +101 -0
  866. executorch/backends/nxp/backend/ir/lib/tflite/BatchToSpaceNDOptions.py +50 -0
  867. executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceLSTMOptions.py +160 -0
  868. executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceRNNOptions.py +126 -0
  869. executorch/backends/nxp/backend/ir/lib/tflite/BitcastOptions.py +50 -0
  870. executorch/backends/nxp/backend/ir/lib/tflite/BitwiseXorOptions.py +50 -0
  871. executorch/backends/nxp/backend/ir/lib/tflite/BroadcastToOptions.py +50 -0
  872. executorch/backends/nxp/backend/ir/lib/tflite/BucketizeOptions.py +98 -0
  873. executorch/backends/nxp/backend/ir/lib/tflite/Buffer.py +132 -0
  874. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOperator.py +212 -0
  875. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions.py +133 -0
  876. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions2.py +27 -0
  877. executorch/backends/nxp/backend/ir/lib/tflite/CallOnceOptions.py +65 -0
  878. executorch/backends/nxp/backend/ir/lib/tflite/CallOptions.py +67 -0
  879. executorch/backends/nxp/backend/ir/lib/tflite/CastOptions.py +80 -0
  880. executorch/backends/nxp/backend/ir/lib/tflite/CombinerType.py +9 -0
  881. executorch/backends/nxp/backend/ir/lib/tflite/ConcatEmbeddingsOptions.py +163 -0
  882. executorch/backends/nxp/backend/ir/lib/tflite/ConcatenationOptions.py +80 -0
  883. executorch/backends/nxp/backend/ir/lib/tflite/Conv2DOptions.py +155 -0
  884. executorch/backends/nxp/backend/ir/lib/tflite/Conv3DOptions.py +170 -0
  885. executorch/backends/nxp/backend/ir/lib/tflite/CosOptions.py +50 -0
  886. executorch/backends/nxp/backend/ir/lib/tflite/CumsumOptions.py +84 -0
  887. executorch/backends/nxp/backend/ir/lib/tflite/CustomOptionsFormat.py +7 -0
  888. executorch/backends/nxp/backend/ir/lib/tflite/CustomQuantization.py +98 -0
  889. executorch/backends/nxp/backend/ir/lib/tflite/DensifyOptions.py +50 -0
  890. executorch/backends/nxp/backend/ir/lib/tflite/DepthToSpaceOptions.py +65 -0
  891. executorch/backends/nxp/backend/ir/lib/tflite/DepthwiseConv2DOptions.py +157 -0
  892. executorch/backends/nxp/backend/ir/lib/tflite/DequantizeOptions.py +50 -0
  893. executorch/backends/nxp/backend/ir/lib/tflite/DilateOptions.py +50 -0
  894. executorch/backends/nxp/backend/ir/lib/tflite/DimensionMetadata.py +152 -0
  895. executorch/backends/nxp/backend/ir/lib/tflite/DimensionType.py +8 -0
  896. executorch/backends/nxp/backend/ir/lib/tflite/DivOptions.py +65 -0
  897. executorch/backends/nxp/backend/ir/lib/tflite/DynamicUpdateSliceOptions.py +52 -0
  898. executorch/backends/nxp/backend/ir/lib/tflite/EmbeddingLookupSparseOptions.py +67 -0
  899. executorch/backends/nxp/backend/ir/lib/tflite/EqualOptions.py +50 -0
  900. executorch/backends/nxp/backend/ir/lib/tflite/ExpOptions.py +50 -0
  901. executorch/backends/nxp/backend/ir/lib/tflite/ExpandDimsOptions.py +50 -0
  902. executorch/backends/nxp/backend/ir/lib/tflite/FakeQuantOptions.py +116 -0
  903. executorch/backends/nxp/backend/ir/lib/tflite/FillOptions.py +50 -0
  904. executorch/backends/nxp/backend/ir/lib/tflite/FloorDivOptions.py +50 -0
  905. executorch/backends/nxp/backend/ir/lib/tflite/FloorModOptions.py +50 -0
  906. executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptions.py +129 -0
  907. executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptionsWeightsFormat.py +8 -0
  908. executorch/backends/nxp/backend/ir/lib/tflite/GatherNdOptions.py +50 -0
  909. executorch/backends/nxp/backend/ir/lib/tflite/GatherOptions.py +80 -0
  910. executorch/backends/nxp/backend/ir/lib/tflite/GeluOptions.py +67 -0
  911. executorch/backends/nxp/backend/ir/lib/tflite/GreaterEqualOptions.py +50 -0
  912. executorch/backends/nxp/backend/ir/lib/tflite/GreaterOptions.py +50 -0
  913. executorch/backends/nxp/backend/ir/lib/tflite/HardSwishOptions.py +50 -0
  914. executorch/backends/nxp/backend/ir/lib/tflite/HashtableFindOptions.py +50 -0
  915. executorch/backends/nxp/backend/ir/lib/tflite/HashtableImportOptions.py +52 -0
  916. executorch/backends/nxp/backend/ir/lib/tflite/HashtableOptions.py +95 -0
  917. executorch/backends/nxp/backend/ir/lib/tflite/HashtableSizeOptions.py +50 -0
  918. executorch/backends/nxp/backend/ir/lib/tflite/IfOptions.py +80 -0
  919. executorch/backends/nxp/backend/ir/lib/tflite/Int32Vector.py +98 -0
  920. executorch/backends/nxp/backend/ir/lib/tflite/L2NormOptions.py +65 -0
  921. executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionOptions.py +65 -0
  922. executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionType.py +9 -0
  923. executorch/backends/nxp/backend/ir/lib/tflite/LSTMKernelType.py +8 -0
  924. executorch/backends/nxp/backend/ir/lib/tflite/LSTMOptions.py +131 -0
  925. executorch/backends/nxp/backend/ir/lib/tflite/LeakyReluOptions.py +67 -0
  926. executorch/backends/nxp/backend/ir/lib/tflite/LessEqualOptions.py +50 -0
  927. executorch/backends/nxp/backend/ir/lib/tflite/LessOptions.py +50 -0
  928. executorch/backends/nxp/backend/ir/lib/tflite/LocalResponseNormalizationOptions.py +118 -0
  929. executorch/backends/nxp/backend/ir/lib/tflite/LogSoftmaxOptions.py +50 -0
  930. executorch/backends/nxp/backend/ir/lib/tflite/LogicalAndOptions.py +50 -0
  931. executorch/backends/nxp/backend/ir/lib/tflite/LogicalNotOptions.py +50 -0
  932. executorch/backends/nxp/backend/ir/lib/tflite/LogicalOrOptions.py +50 -0
  933. executorch/backends/nxp/backend/ir/lib/tflite/MatrixDiagOptions.py +50 -0
  934. executorch/backends/nxp/backend/ir/lib/tflite/MatrixSetDiagOptions.py +50 -0
  935. executorch/backends/nxp/backend/ir/lib/tflite/MaximumMinimumOptions.py +50 -0
  936. executorch/backends/nxp/backend/ir/lib/tflite/Metadata.py +84 -0
  937. executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadMode.py +8 -0
  938. executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadOptions.py +65 -0
  939. executorch/backends/nxp/backend/ir/lib/tflite/Model.py +352 -0
  940. executorch/backends/nxp/backend/ir/lib/tflite/MulOptions.py +65 -0
  941. executorch/backends/nxp/backend/ir/lib/tflite/NegOptions.py +50 -0
  942. executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV4Options.py +52 -0
  943. executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV5Options.py +52 -0
  944. executorch/backends/nxp/backend/ir/lib/tflite/NotEqualOptions.py +50 -0
  945. executorch/backends/nxp/backend/ir/lib/tflite/OneHotOptions.py +65 -0
  946. executorch/backends/nxp/backend/ir/lib/tflite/Operator.py +428 -0
  947. executorch/backends/nxp/backend/ir/lib/tflite/OperatorCode.py +112 -0
  948. executorch/backends/nxp/backend/ir/lib/tflite/PackOptions.py +80 -0
  949. executorch/backends/nxp/backend/ir/lib/tflite/PadOptions.py +50 -0
  950. executorch/backends/nxp/backend/ir/lib/tflite/PadV2Options.py +50 -0
  951. executorch/backends/nxp/backend/ir/lib/tflite/Padding.py +8 -0
  952. executorch/backends/nxp/backend/ir/lib/tflite/Pool2DOptions.py +140 -0
  953. executorch/backends/nxp/backend/ir/lib/tflite/PowOptions.py +50 -0
  954. executorch/backends/nxp/backend/ir/lib/tflite/QuantizationDetails.py +8 -0
  955. executorch/backends/nxp/backend/ir/lib/tflite/QuantizationParameters.py +295 -0
  956. executorch/backends/nxp/backend/ir/lib/tflite/QuantizeOptions.py +50 -0
  957. executorch/backends/nxp/backend/ir/lib/tflite/RNNOptions.py +82 -0
  958. executorch/backends/nxp/backend/ir/lib/tflite/RandomOptions.py +80 -0
  959. executorch/backends/nxp/backend/ir/lib/tflite/RangeOptions.py +50 -0
  960. executorch/backends/nxp/backend/ir/lib/tflite/RankOptions.py +50 -0
  961. executorch/backends/nxp/backend/ir/lib/tflite/ReadVariableOptions.py +50 -0
  962. executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowFunction.py +13 -0
  963. executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowOptions.py +65 -0
  964. executorch/backends/nxp/backend/ir/lib/tflite/ReducerOptions.py +67 -0
  965. executorch/backends/nxp/backend/ir/lib/tflite/ReshapeOptions.py +98 -0
  966. executorch/backends/nxp/backend/ir/lib/tflite/ResizeBilinearOptions.py +84 -0
  967. executorch/backends/nxp/backend/ir/lib/tflite/ResizeNearestNeighborOptions.py +86 -0
  968. executorch/backends/nxp/backend/ir/lib/tflite/ReverseSequenceOptions.py +82 -0
  969. executorch/backends/nxp/backend/ir/lib/tflite/ReverseV2Options.py +50 -0
  970. executorch/backends/nxp/backend/ir/lib/tflite/Rfft2dOptions.py +50 -0
  971. executorch/backends/nxp/backend/ir/lib/tflite/RightShiftOptions.py +50 -0
  972. executorch/backends/nxp/backend/ir/lib/tflite/RngAlgorithm.py +9 -0
  973. executorch/backends/nxp/backend/ir/lib/tflite/SVDFOptions.py +97 -0
  974. executorch/backends/nxp/backend/ir/lib/tflite/ScatterNdOptions.py +50 -0
  975. executorch/backends/nxp/backend/ir/lib/tflite/SegmentSumOptions.py +50 -0
  976. executorch/backends/nxp/backend/ir/lib/tflite/SelectOptions.py +50 -0
  977. executorch/backends/nxp/backend/ir/lib/tflite/SelectV2Options.py +50 -0
  978. executorch/backends/nxp/backend/ir/lib/tflite/SequenceRNNOptions.py +99 -0
  979. executorch/backends/nxp/backend/ir/lib/tflite/ShapeOptions.py +65 -0
  980. executorch/backends/nxp/backend/ir/lib/tflite/SignOptions.py +50 -0
  981. executorch/backends/nxp/backend/ir/lib/tflite/SignatureDef.py +172 -0
  982. executorch/backends/nxp/backend/ir/lib/tflite/SkipGramOptions.py +97 -0
  983. executorch/backends/nxp/backend/ir/lib/tflite/SliceOptions.py +50 -0
  984. executorch/backends/nxp/backend/ir/lib/tflite/SoftmaxOptions.py +67 -0
  985. executorch/backends/nxp/backend/ir/lib/tflite/SpaceToBatchNDOptions.py +50 -0
  986. executorch/backends/nxp/backend/ir/lib/tflite/SpaceToDepthOptions.py +65 -0
  987. executorch/backends/nxp/backend/ir/lib/tflite/SparseIndexVector.py +10 -0
  988. executorch/backends/nxp/backend/ir/lib/tflite/SparseToDenseOptions.py +67 -0
  989. executorch/backends/nxp/backend/ir/lib/tflite/SparsityParameters.py +190 -0
  990. executorch/backends/nxp/backend/ir/lib/tflite/SplitOptions.py +65 -0
  991. executorch/backends/nxp/backend/ir/lib/tflite/SplitVOptions.py +65 -0
  992. executorch/backends/nxp/backend/ir/lib/tflite/SquareOptions.py +50 -0
  993. executorch/backends/nxp/backend/ir/lib/tflite/SquaredDifferenceOptions.py +52 -0
  994. executorch/backends/nxp/backend/ir/lib/tflite/SqueezeOptions.py +98 -0
  995. executorch/backends/nxp/backend/ir/lib/tflite/StablehloBroadcastInDimOptions.py +102 -0
  996. executorch/backends/nxp/backend/ir/lib/tflite/StablehloCompareOptions.py +86 -0
  997. executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonDirection.py +12 -0
  998. executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonType.py +11 -0
  999. executorch/backends/nxp/backend/ir/lib/tflite/StablehloConcatenateOptions.py +67 -0
  1000. executorch/backends/nxp/backend/ir/lib/tflite/StablehloConvolutionOptions.py +634 -0
  1001. executorch/backends/nxp/backend/ir/lib/tflite/StablehloCustomCallOptions.py +214 -0
  1002. executorch/backends/nxp/backend/ir/lib/tflite/StablehloDotGeneralOptions.py +304 -0
  1003. executorch/backends/nxp/backend/ir/lib/tflite/StablehloDynamicSliceOptions.py +100 -0
  1004. executorch/backends/nxp/backend/ir/lib/tflite/StablehloGatherOptions.py +276 -0
  1005. executorch/backends/nxp/backend/ir/lib/tflite/StablehloIotaOptions.py +65 -0
  1006. executorch/backends/nxp/backend/ir/lib/tflite/StablehloPadOptions.py +194 -0
  1007. executorch/backends/nxp/backend/ir/lib/tflite/StablehloPrecisionConfig.py +9 -0
  1008. executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceOptions.py +115 -0
  1009. executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceWindowOptions.py +307 -0
  1010. executorch/backends/nxp/backend/ir/lib/tflite/StablehloRngBitGeneratorOptions.py +67 -0
  1011. executorch/backends/nxp/backend/ir/lib/tflite/StablehloScatterOptions.py +268 -0
  1012. executorch/backends/nxp/backend/ir/lib/tflite/StablehloSliceOptions.py +194 -0
  1013. executorch/backends/nxp/backend/ir/lib/tflite/StablehloSortOptions.py +97 -0
  1014. executorch/backends/nxp/backend/ir/lib/tflite/StablehloTransposeOptions.py +100 -0
  1015. executorch/backends/nxp/backend/ir/lib/tflite/StablehloWhileOptions.py +80 -0
  1016. executorch/backends/nxp/backend/ir/lib/tflite/StridedSliceOptions.py +142 -0
  1017. executorch/backends/nxp/backend/ir/lib/tflite/SubGraph.py +251 -0
  1018. executorch/backends/nxp/backend/ir/lib/tflite/SubOptions.py +82 -0
  1019. executorch/backends/nxp/backend/ir/lib/tflite/Tensor.py +317 -0
  1020. executorch/backends/nxp/backend/ir/lib/tflite/TensorMap.py +84 -0
  1021. executorch/backends/nxp/backend/ir/lib/tflite/TensorType.py +24 -0
  1022. executorch/backends/nxp/backend/ir/lib/tflite/TileOptions.py +50 -0
  1023. executorch/backends/nxp/backend/ir/lib/tflite/TopKV2Options.py +50 -0
  1024. executorch/backends/nxp/backend/ir/lib/tflite/TransposeConvOptions.py +125 -0
  1025. executorch/backends/nxp/backend/ir/lib/tflite/TransposeOptions.py +50 -0
  1026. executorch/backends/nxp/backend/ir/lib/tflite/Uint16Vector.py +98 -0
  1027. executorch/backends/nxp/backend/ir/lib/tflite/Uint8Vector.py +98 -0
  1028. executorch/backends/nxp/backend/ir/lib/tflite/UnidirectionalSequenceLSTMOptions.py +164 -0
  1029. executorch/backends/nxp/backend/ir/lib/tflite/UniqueOptions.py +65 -0
  1030. executorch/backends/nxp/backend/ir/lib/tflite/UnpackOptions.py +80 -0
  1031. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMaxOptions.py +52 -0
  1032. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMinOptions.py +52 -0
  1033. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentProdOptions.py +52 -0
  1034. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentSumOptions.py +52 -0
  1035. executorch/backends/nxp/backend/ir/lib/tflite/VarHandleOptions.py +84 -0
  1036. executorch/backends/nxp/backend/ir/lib/tflite/VariantSubType.py +130 -0
  1037. executorch/backends/nxp/backend/ir/lib/tflite/WhereOptions.py +50 -0
  1038. executorch/backends/nxp/backend/ir/lib/tflite/WhileOptions.py +80 -0
  1039. executorch/backends/nxp/backend/ir/lib/tflite/ZerosLikeOptions.py +50 -0
  1040. executorch/backends/nxp/backend/ir/lib/tflite/__init__.py +0 -0
  1041. executorch/backends/nxp/backend/ir/logger.py +341 -0
  1042. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/__init__.py +0 -0
  1043. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/graph_utils.py +115 -0
  1044. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/operator_rules.py +102 -0
  1045. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/__init__.py +0 -0
  1046. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/base_optimization.py +41 -0
  1047. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/permute_fully_connected_weights_after_reshape.py +121 -0
  1048. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/prune_transpose_operators.py +177 -0
  1049. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizer.py +127 -0
  1050. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/pattern_matcher.py +925 -0
  1051. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/tensor_rules.py +710 -0
  1052. executorch/backends/nxp/backend/ir/tflite_generator/__init__.py +0 -0
  1053. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/__init__.py +0 -0
  1054. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/abs_options.py +25 -0
  1055. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_n_options.py +32 -0
  1056. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_options.py +46 -0
  1057. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_max_options.py +28 -0
  1058. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_min_options.py +28 -0
  1059. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/average_pool_2d_options.py +63 -0
  1060. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/batch_mat_mul_options.py +45 -0
  1061. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_lstm_options.py +65 -0
  1062. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_rnn_options.py +53 -0
  1063. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bitwise_xor_options.py +23 -0
  1064. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/broadcast_to_options.py +25 -0
  1065. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cast_options.py +32 -0
  1066. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/concatenation_options.py +38 -0
  1067. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_2d_options.py +59 -0
  1068. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_3d_options.py +67 -0
  1069. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cum_sum_options.py +30 -0
  1070. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depth_to_space_options.py +29 -0
  1071. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depthwise_conv_2d_options.py +69 -0
  1072. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/dequantize_options.py +24 -0
  1073. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/div_options.py +43 -0
  1074. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/equal_options.py +23 -0
  1075. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/exp_options.py +23 -0
  1076. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/floor_mod_options.py +23 -0
  1077. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/fully_connected_options.py +57 -0
  1078. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_nd_options.py +23 -0
  1079. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_options.py +30 -0
  1080. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gelu_options.py +27 -0
  1081. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_equal_options.py +25 -0
  1082. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_options.py +23 -0
  1083. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/hard_swish_options.py +23 -0
  1084. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/leaky_relu_options.py +32 -0
  1085. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_equal_options.py +23 -0
  1086. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_options.py +23 -0
  1087. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/log_softmax_options.py +30 -0
  1088. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_and_options.py +23 -0
  1089. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_not_options.py +23 -0
  1090. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_or_options.py +23 -0
  1091. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lrn_options.py +45 -0
  1092. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lstm_options.py +60 -0
  1093. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/max_pool_2d_options.py +63 -0
  1094. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/maximum_options.py +21 -0
  1095. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mean_options.py +28 -0
  1096. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/minimum_options.py +21 -0
  1097. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mirror_pad_options.py +60 -0
  1098. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mul_options.py +36 -0
  1099. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/multinomial_options.py +30 -0
  1100. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/neg_options.py +23 -0
  1101. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/not_equal_options.py +23 -0
  1102. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/one_hot_options.py +27 -0
  1103. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_options.py +27 -0
  1104. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_v2_options.py +27 -0
  1105. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pow_options.py +24 -0
  1106. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/quantize_options.py +30 -0
  1107. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/range_options.py +23 -0
  1108. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_max_options.py +28 -0
  1109. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_min_options.py +28 -0
  1110. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_prod_options.py +28 -0
  1111. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reshape_options.py +53 -0
  1112. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_bilinear_options.py +34 -0
  1113. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_nearest_neighbor_options.py +37 -0
  1114. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reverse_sequence_options.py +32 -0
  1115. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/scatter_nd_options.py +23 -0
  1116. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/select_v2_options.py +24 -0
  1117. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/shape_options.py +34 -0
  1118. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sign_options.py +22 -0
  1119. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/slice_options.py +29 -0
  1120. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/softmax_options.py +36 -0
  1121. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/space_to_depth_options.py +29 -0
  1122. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_options.py +27 -0
  1123. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_v_options.py +27 -0
  1124. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/square_options.py +23 -0
  1125. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squared_difference_options.py +25 -0
  1126. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squeeze_options.py +42 -0
  1127. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/strided_slice_options.py +35 -0
  1128. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sub_options.py +46 -0
  1129. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sum_options.py +28 -0
  1130. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/tile_options.py +23 -0
  1131. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_conv_options.py +50 -0
  1132. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_options.py +30 -0
  1133. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_lstm_options.py +67 -0
  1134. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_rnn_options.py +49 -0
  1135. executorch/backends/nxp/backend/ir/tflite_generator/custom_options/flex_transpose_options.py +78 -0
  1136. executorch/backends/nxp/backend/ir/tflite_generator/meta/__init__.py +0 -0
  1137. executorch/backends/nxp/backend/ir/tflite_generator/meta/meta.py +255 -0
  1138. executorch/backends/nxp/backend/ir/tflite_generator/meta/types.py +198 -0
  1139. executorch/backends/nxp/backend/ir/tflite_generator/tflite_model.py +819 -0
  1140. executorch/backends/nxp/backend/neutron_compiler_manager.py +213 -0
  1141. executorch/backends/nxp/backend/neutron_map.py +877 -0
  1142. executorch/backends/nxp/backend/neutron_operator_support.py +57 -0
  1143. executorch/backends/nxp/backend/neutron_target_spec.py +161 -0
  1144. executorch/backends/nxp/backend/node_format_inference.py +396 -0
  1145. executorch/backends/nxp/backend/ops_aliases.py +83 -0
  1146. executorch/backends/nxp/edge_passes/convert_reshaping_nodes_to_view.py +103 -0
  1147. executorch/backends/nxp/edge_passes/move_auxiliary_operator_into_separate_qdq_cluster_pass.py +310 -0
  1148. executorch/backends/nxp/edge_passes/neutron_edge_pass.py +55 -0
  1149. executorch/backends/nxp/edge_passes/neutron_edge_pass_manager.py +38 -0
  1150. executorch/backends/nxp/edge_passes/remove_additional_quantize_dequantize_nodes_pass.py +120 -0
  1151. executorch/backends/nxp/edge_passes/remove_as_strided_copy_nodes.py +66 -0
  1152. executorch/backends/nxp/edge_passes/remove_io_quant_ops_pass.py +76 -0
  1153. executorch/backends/nxp/neutron_node_extraction.py +152 -0
  1154. executorch/backends/nxp/neutron_partitioner.py +570 -0
  1155. executorch/backends/nxp/nxp_backend.py +484 -0
  1156. executorch/backends/nxp/quantizer/neutron_quantizer.py +406 -0
  1157. executorch/backends/nxp/quantizer/patterns.py +1429 -0
  1158. executorch/backends/nxp/quantizer/utils.py +300 -0
  1159. executorch/backends/nxp/recipes/__init__.py +18 -0
  1160. executorch/backends/nxp/recipes/nxp_recipe_provider.py +424 -0
  1161. executorch/backends/nxp/recipes/nxp_recipe_types.py +40 -0
  1162. executorch/backends/nxp/tests/__init__.py +0 -0
  1163. executorch/backends/nxp/tests/calibration_dataset.py +77 -0
  1164. executorch/backends/nxp/tests/config.py +56 -0
  1165. executorch/backends/nxp/tests/config_importer.py +17 -0
  1166. executorch/backends/nxp/tests/cortex_m_benchmarking.py +79 -0
  1167. executorch/backends/nxp/tests/dataset_creator.py +432 -0
  1168. executorch/backends/nxp/tests/executorch_pipeline.py +320 -0
  1169. executorch/backends/nxp/tests/executors.py +433 -0
  1170. executorch/backends/nxp/tests/generic_tests/__init__.py +0 -0
  1171. executorch/backends/nxp/tests/graph_verifier.py +264 -0
  1172. executorch/backends/nxp/tests/ir/__init__.py +0 -0
  1173. executorch/backends/nxp/tests/ir/converter/__init__.py +0 -0
  1174. executorch/backends/nxp/tests/ir/converter/node_converter/__init__.py +0 -0
  1175. executorch/backends/nxp/tests/ir/edge_passes/__init__.py +0 -0
  1176. executorch/backends/nxp/tests/ir/edge_passes/test_remove_io_quant_ops_pass.py +128 -0
  1177. executorch/backends/nxp/tests/model_output_comparator.py +576 -0
  1178. executorch/backends/nxp/tests/models/__init__.py +0 -0
  1179. executorch/backends/nxp/tests/nsys_testing.py +940 -0
  1180. executorch/backends/nxp/tests/outputs_dir.py +10 -0
  1181. executorch/backends/nxp/tests/outputs_dir_importer.py +17 -0
  1182. executorch/backends/nxp/tests/profiling_utils.py +139 -0
  1183. executorch/backends/nxp/tests/simple_models.py +1156 -0
  1184. executorch/backends/nxp/tests/tester/__init__.py +8 -0
  1185. executorch/backends/nxp/tests/tester/tester.py +637 -0
  1186. executorch/backends/nxp/tests/use_qat.py +22 -0
  1187. executorch/backends/nxp/tests/utils.py +232 -0
  1188. executorch/backends/openvino/__init__.py +5 -0
  1189. executorch/backends/openvino/_passes/__init__.py +15 -0
  1190. executorch/backends/openvino/_passes/cast_reduction_input_pass.py +45 -0
  1191. executorch/backends/openvino/_passes/decompose_floor_divide_pass.py +106 -0
  1192. executorch/backends/openvino/_passes/fold_constant_cumsum_pass.py +161 -0
  1193. executorch/backends/openvino/partitioner.py +334 -0
  1194. executorch/backends/openvino/preprocess.py +174 -0
  1195. executorch/backends/openvino/quantizer/__init__.py +9 -0
  1196. executorch/backends/openvino/quantizer/llm_compression.py +133 -0
  1197. executorch/backends/openvino/quantizer/observers.py +206 -0
  1198. executorch/backends/openvino/quantizer/quantizer.py +675 -0
  1199. executorch/backends/openvino/test/tester/__init__.py +19 -0
  1200. executorch/backends/openvino/test/tester/tester.py +94 -0
  1201. executorch/backends/openvino/tests/ops/base_openvino_op_test.py +109 -0
  1202. executorch/backends/qualcomm/__init__.py +11 -0
  1203. executorch/backends/qualcomm/_passes/__init__.py +153 -0
  1204. executorch/backends/qualcomm/_passes/annotate_avg_pool1d.py +64 -0
  1205. executorch/backends/qualcomm/_passes/annotate_get_attr.py +54 -0
  1206. executorch/backends/qualcomm/_passes/annotate_quant_attrs.py +139 -0
  1207. executorch/backends/qualcomm/_passes/annotate_stack.py +42 -0
  1208. executorch/backends/qualcomm/_passes/annotate_unbind.py +40 -0
  1209. executorch/backends/qualcomm/_passes/backends/__init__.py +5 -0
  1210. executorch/backends/qualcomm/_passes/backends/gpu/__init__.py +11 -0
  1211. executorch/backends/qualcomm/_passes/backends/gpu/qnn_gpu_pass_manager.py +46 -0
  1212. executorch/backends/qualcomm/_passes/backends/htp/__init__.py +11 -0
  1213. executorch/backends/qualcomm/_passes/backends/htp/qnn_htp_pass_manager.py +54 -0
  1214. executorch/backends/qualcomm/_passes/backends/lpai/__init__.py +11 -0
  1215. executorch/backends/qualcomm/_passes/backends/lpai/qnn_lpai_pass_manager.py +97 -0
  1216. executorch/backends/qualcomm/_passes/build_quant_io.py +53 -0
  1217. executorch/backends/qualcomm/_passes/canonicalize_conv.py +201 -0
  1218. executorch/backends/qualcomm/_passes/convert_bmm_to_matmul.py +83 -0
  1219. executorch/backends/qualcomm/_passes/convert_complex_stft.py +116 -0
  1220. executorch/backends/qualcomm/_passes/convert_linear_to_conv2d.py +301 -0
  1221. executorch/backends/qualcomm/_passes/convert_mha_to_sha.py +626 -0
  1222. executorch/backends/qualcomm/_passes/convert_square_to_pow.py +38 -0
  1223. executorch/backends/qualcomm/_passes/decompose_acos.py +75 -0
  1224. executorch/backends/qualcomm/_passes/decompose_addmm.py +115 -0
  1225. executorch/backends/qualcomm/_passes/decompose_any.py +69 -0
  1226. executorch/backends/qualcomm/_passes/decompose_as_strided.py +226 -0
  1227. executorch/backends/qualcomm/_passes/decompose_atan2.py +210 -0
  1228. executorch/backends/qualcomm/_passes/decompose_binary_alpha.py +61 -0
  1229. executorch/backends/qualcomm/_passes/decompose_cdist.py +86 -0
  1230. executorch/backends/qualcomm/_passes/decompose_col_im.py +273 -0
  1231. executorch/backends/qualcomm/_passes/decompose_diagonal.py +234 -0
  1232. executorch/backends/qualcomm/_passes/decompose_div_mode.py +91 -0
  1233. executorch/backends/qualcomm/_passes/decompose_einsum.py +51 -0
  1234. executorch/backends/qualcomm/_passes/decompose_empty.py +128 -0
  1235. executorch/backends/qualcomm/_passes/decompose_expm1.py +49 -0
  1236. executorch/backends/qualcomm/_passes/decompose_fill.py +61 -0
  1237. executorch/backends/qualcomm/_passes/decompose_floor_divide.py +62 -0
  1238. executorch/backends/qualcomm/_passes/decompose_glu.py +55 -0
  1239. executorch/backends/qualcomm/_passes/decompose_hardsigmoid.py +59 -0
  1240. executorch/backends/qualcomm/_passes/decompose_hyperbolic_variants.py +202 -0
  1241. executorch/backends/qualcomm/_passes/decompose_linalg_vector_norm.py +81 -0
  1242. executorch/backends/qualcomm/_passes/decompose_log_variants.py +114 -0
  1243. executorch/backends/qualcomm/_passes/decompose_maxpool3d.py +145 -0
  1244. executorch/backends/qualcomm/_passes/decompose_minmaxdim.py +109 -0
  1245. executorch/backends/qualcomm/_passes/decompose_pad.py +128 -0
  1246. executorch/backends/qualcomm/_passes/decompose_pdist.py +123 -0
  1247. executorch/backends/qualcomm/_passes/decompose_reciprocal.py +39 -0
  1248. executorch/backends/qualcomm/_passes/decompose_remainder.py +118 -0
  1249. executorch/backends/qualcomm/_passes/decompose_roll.py +78 -0
  1250. executorch/backends/qualcomm/_passes/decompose_select_scatter.py +96 -0
  1251. executorch/backends/qualcomm/_passes/decompose_silu.py +45 -0
  1252. executorch/backends/qualcomm/_passes/decompose_tan.py +71 -0
  1253. executorch/backends/qualcomm/_passes/decompose_threshold.py +61 -0
  1254. executorch/backends/qualcomm/_passes/decompose_triu.py +71 -0
  1255. executorch/backends/qualcomm/_passes/decompose_trunc.py +93 -0
  1256. executorch/backends/qualcomm/_passes/decompose_var.py +139 -0
  1257. executorch/backends/qualcomm/_passes/decompose_wrap_with_autocast.py +95 -0
  1258. executorch/backends/qualcomm/_passes/expand_broadcast_tensor_shape.py +80 -0
  1259. executorch/backends/qualcomm/_passes/fixed_linear_keep_dim.py +94 -0
  1260. executorch/backends/qualcomm/_passes/fold_qdq.py +85 -0
  1261. executorch/backends/qualcomm/_passes/fuse_batch_norm_with_conv.py +36 -0
  1262. executorch/backends/qualcomm/_passes/fuse_consecutive_cast.py +115 -0
  1263. executorch/backends/qualcomm/_passes/fuse_consecutive_reshape.py +53 -0
  1264. executorch/backends/qualcomm/_passes/fuse_consecutive_transpose.py +108 -0
  1265. executorch/backends/qualcomm/_passes/i64_to_i32.py +204 -0
  1266. executorch/backends/qualcomm/_passes/insert_cast_for_fp_act_quantized_weight.py +141 -0
  1267. executorch/backends/qualcomm/_passes/insert_io_qdq.py +85 -0
  1268. executorch/backends/qualcomm/_passes/insert_requantize.py +111 -0
  1269. executorch/backends/qualcomm/_passes/insert_reshape_for_reduce_ops.py +58 -0
  1270. executorch/backends/qualcomm/_passes/layout_transform.py +373 -0
  1271. executorch/backends/qualcomm/_passes/lift_constant_scalar_operands.py +202 -0
  1272. executorch/backends/qualcomm/_passes/lpai_partition_fallback_support.py +336 -0
  1273. executorch/backends/qualcomm/_passes/qnn_pass_manager.py +554 -0
  1274. executorch/backends/qualcomm/_passes/recompose_hadamard.py +185 -0
  1275. executorch/backends/qualcomm/_passes/recompose_pad_maxpool2d.py +144 -0
  1276. executorch/backends/qualcomm/_passes/recompose_pixel_unshuffle.py +81 -0
  1277. executorch/backends/qualcomm/_passes/recompose_rms_norm.py +170 -0
  1278. executorch/backends/qualcomm/_passes/remove_0d_tensor.py +62 -0
  1279. executorch/backends/qualcomm/_passes/remove_redundancy.py +72 -0
  1280. executorch/backends/qualcomm/_passes/replace_arange_args.py +48 -0
  1281. executorch/backends/qualcomm/_passes/resolve_debug_handle.py +47 -0
  1282. executorch/backends/qualcomm/_passes/seq_mse.py +240 -0
  1283. executorch/backends/qualcomm/_passes/tag_quant_io.py +45 -0
  1284. executorch/backends/qualcomm/_passes/utils.py +407 -0
  1285. executorch/backends/qualcomm/builders/__init__.py +243 -0
  1286. executorch/backends/qualcomm/builders/custom_ops.py +69 -0
  1287. executorch/backends/qualcomm/builders/node_visitor.py +612 -0
  1288. executorch/backends/qualcomm/builders/node_visitor_manager.py +81 -0
  1289. executorch/backends/qualcomm/builders/op_abs.py +57 -0
  1290. executorch/backends/qualcomm/builders/op_adaptive_avg_pool2d.py +126 -0
  1291. executorch/backends/qualcomm/builders/op_adaptive_max_pool2d.py +151 -0
  1292. executorch/backends/qualcomm/builders/op_add.py +62 -0
  1293. executorch/backends/qualcomm/builders/op_amax.py +90 -0
  1294. executorch/backends/qualcomm/builders/op_amin.py +90 -0
  1295. executorch/backends/qualcomm/builders/op_and.py +60 -0
  1296. executorch/backends/qualcomm/builders/op_arange.py +41 -0
  1297. executorch/backends/qualcomm/builders/op_argmax.py +78 -0
  1298. executorch/backends/qualcomm/builders/op_argmin.py +78 -0
  1299. executorch/backends/qualcomm/builders/op_asin.py +56 -0
  1300. executorch/backends/qualcomm/builders/op_atan.py +55 -0
  1301. executorch/backends/qualcomm/builders/op_avg_pool2d.py +151 -0
  1302. executorch/backends/qualcomm/builders/op_avg_pool3d.py +293 -0
  1303. executorch/backends/qualcomm/builders/op_batch_norm.py +156 -0
  1304. executorch/backends/qualcomm/builders/op_binary.py +84 -0
  1305. executorch/backends/qualcomm/builders/op_bmm.py +59 -0
  1306. executorch/backends/qualcomm/builders/op_cat.py +89 -0
  1307. executorch/backends/qualcomm/builders/op_ceil.py +56 -0
  1308. executorch/backends/qualcomm/builders/op_channel_shuffle.py +73 -0
  1309. executorch/backends/qualcomm/builders/op_clamp.py +80 -0
  1310. executorch/backends/qualcomm/builders/op_conv.py +263 -0
  1311. executorch/backends/qualcomm/builders/op_copy.py +112 -0
  1312. executorch/backends/qualcomm/builders/op_cos.py +56 -0
  1313. executorch/backends/qualcomm/builders/op_cum_sum.py +87 -0
  1314. executorch/backends/qualcomm/builders/op_custom_op.py +138 -0
  1315. executorch/backends/qualcomm/builders/op_depth_to_space.py +78 -0
  1316. executorch/backends/qualcomm/builders/op_dequantize.py +72 -0
  1317. executorch/backends/qualcomm/builders/op_div.py +62 -0
  1318. executorch/backends/qualcomm/builders/op_elu.py +68 -0
  1319. executorch/backends/qualcomm/builders/op_embedding.py +252 -0
  1320. executorch/backends/qualcomm/builders/op_eq.py +62 -0
  1321. executorch/backends/qualcomm/builders/op_exp.py +60 -0
  1322. executorch/backends/qualcomm/builders/op_expand.py +84 -0
  1323. executorch/backends/qualcomm/builders/op_flip.py +80 -0
  1324. executorch/backends/qualcomm/builders/op_floor.py +56 -0
  1325. executorch/backends/qualcomm/builders/op_full.py +42 -0
  1326. executorch/backends/qualcomm/builders/op_full_like.py +41 -0
  1327. executorch/backends/qualcomm/builders/op_gather.py +75 -0
  1328. executorch/backends/qualcomm/builders/op_ge.py +62 -0
  1329. executorch/backends/qualcomm/builders/op_gelu.py +57 -0
  1330. executorch/backends/qualcomm/builders/op_grid_sampler_2d.py +162 -0
  1331. executorch/backends/qualcomm/builders/op_group_norm.py +96 -0
  1332. executorch/backends/qualcomm/builders/op_gt.py +62 -0
  1333. executorch/backends/qualcomm/builders/op_hadamard_transform.py +66 -0
  1334. executorch/backends/qualcomm/builders/op_hardsigmoid.py +78 -0
  1335. executorch/backends/qualcomm/builders/op_hardswish.py +57 -0
  1336. executorch/backends/qualcomm/builders/op_hardtanh.py +79 -0
  1337. executorch/backends/qualcomm/builders/op_index.py +85 -0
  1338. executorch/backends/qualcomm/builders/op_index_put.py +481 -0
  1339. executorch/backends/qualcomm/builders/op_index_select.py +80 -0
  1340. executorch/backends/qualcomm/builders/op_instance_norm.py +112 -0
  1341. executorch/backends/qualcomm/builders/op_is_inf.py +71 -0
  1342. executorch/backends/qualcomm/builders/op_is_nan.py +66 -0
  1343. executorch/backends/qualcomm/builders/op_layer_norm.py +139 -0
  1344. executorch/backends/qualcomm/builders/op_le.py +62 -0
  1345. executorch/backends/qualcomm/builders/op_linear.py +98 -0
  1346. executorch/backends/qualcomm/builders/op_log.py +58 -0
  1347. executorch/backends/qualcomm/builders/op_log_softmax.py +81 -0
  1348. executorch/backends/qualcomm/builders/op_logical_not.py +56 -0
  1349. executorch/backends/qualcomm/builders/op_lt.py +62 -0
  1350. executorch/backends/qualcomm/builders/op_matmul.py +59 -0
  1351. executorch/backends/qualcomm/builders/op_max.py +62 -0
  1352. executorch/backends/qualcomm/builders/op_max_dim.py +89 -0
  1353. executorch/backends/qualcomm/builders/op_max_pool2d.py +145 -0
  1354. executorch/backends/qualcomm/builders/op_mean_dim.py +100 -0
  1355. executorch/backends/qualcomm/builders/op_min.py +62 -0
  1356. executorch/backends/qualcomm/builders/op_min_dim.py +89 -0
  1357. executorch/backends/qualcomm/builders/op_mul.py +62 -0
  1358. executorch/backends/qualcomm/builders/op_ne.py +62 -0
  1359. executorch/backends/qualcomm/builders/op_neg.py +54 -0
  1360. executorch/backends/qualcomm/builders/op_or.py +60 -0
  1361. executorch/backends/qualcomm/builders/op_pad.py +107 -0
  1362. executorch/backends/qualcomm/builders/op_pow.py +75 -0
  1363. executorch/backends/qualcomm/builders/op_prelu.py +69 -0
  1364. executorch/backends/qualcomm/builders/op_quantize.py +73 -0
  1365. executorch/backends/qualcomm/builders/op_rand.py +79 -0
  1366. executorch/backends/qualcomm/builders/op_randn.py +79 -0
  1367. executorch/backends/qualcomm/builders/op_relu.py +58 -0
  1368. executorch/backends/qualcomm/builders/op_repeat.py +68 -0
  1369. executorch/backends/qualcomm/builders/op_reshape.py +55 -0
  1370. executorch/backends/qualcomm/builders/op_resize.py +85 -0
  1371. executorch/backends/qualcomm/builders/op_rms_norm.py +149 -0
  1372. executorch/backends/qualcomm/builders/op_round.py +58 -0
  1373. executorch/backends/qualcomm/builders/op_rsqrt.py +58 -0
  1374. executorch/backends/qualcomm/builders/op_scalar_tensor.py +51 -0
  1375. executorch/backends/qualcomm/builders/op_scatter_elements.py +183 -0
  1376. executorch/backends/qualcomm/builders/op_select_copy.py +89 -0
  1377. executorch/backends/qualcomm/builders/op_sigmoid.py +58 -0
  1378. executorch/backends/qualcomm/builders/op_sign.py +56 -0
  1379. executorch/backends/qualcomm/builders/op_sin.py +56 -0
  1380. executorch/backends/qualcomm/builders/op_skip_ops.py +55 -0
  1381. executorch/backends/qualcomm/builders/op_slice_copy.py +95 -0
  1382. executorch/backends/qualcomm/builders/op_slice_scatter.py +122 -0
  1383. executorch/backends/qualcomm/builders/op_softmax.py +79 -0
  1384. executorch/backends/qualcomm/builders/op_sort.py +124 -0
  1385. executorch/backends/qualcomm/builders/op_space_to_depth.py +83 -0
  1386. executorch/backends/qualcomm/builders/op_split_with_sizes.py +99 -0
  1387. executorch/backends/qualcomm/builders/op_sqrt.py +60 -0
  1388. executorch/backends/qualcomm/builders/op_squeeze.py +57 -0
  1389. executorch/backends/qualcomm/builders/op_stack.py +71 -0
  1390. executorch/backends/qualcomm/builders/op_stft.py +183 -0
  1391. executorch/backends/qualcomm/builders/op_sub.py +62 -0
  1392. executorch/backends/qualcomm/builders/op_sum_int_list.py +84 -0
  1393. executorch/backends/qualcomm/builders/op_tanh.py +57 -0
  1394. executorch/backends/qualcomm/builders/op_to.py +149 -0
  1395. executorch/backends/qualcomm/builders/op_topk.py +112 -0
  1396. executorch/backends/qualcomm/builders/op_transpose.py +76 -0
  1397. executorch/backends/qualcomm/builders/op_unary.py +66 -0
  1398. executorch/backends/qualcomm/builders/op_unbind.py +73 -0
  1399. executorch/backends/qualcomm/builders/op_unsqueeze.py +57 -0
  1400. executorch/backends/qualcomm/builders/op_upsample_bilinear2d.py +68 -0
  1401. executorch/backends/qualcomm/builders/op_upsample_nearest2d.py +68 -0
  1402. executorch/backends/qualcomm/builders/op_where.py +82 -0
  1403. executorch/backends/qualcomm/builders/op_xor.py +60 -0
  1404. executorch/backends/qualcomm/builders/qnn_constants.py +720 -0
  1405. executorch/backends/qualcomm/builders/utils.py +196 -0
  1406. executorch/backends/qualcomm/custom_op/annotator.py +137 -0
  1407. executorch/backends/qualcomm/custom_op/interface.py +115 -0
  1408. executorch/backends/qualcomm/debugger/format_outputs.py +235 -0
  1409. executorch/backends/qualcomm/debugger/qcom_numerical_comparator_base.py +194 -0
  1410. executorch/backends/qualcomm/debugger/qcom_numerical_comparator_sample.py +75 -0
  1411. executorch/backends/qualcomm/debugger/qnn_intermediate_debugger.py +101 -0
  1412. executorch/backends/qualcomm/debugger/utils.py +708 -0
  1413. executorch/backends/qualcomm/export_utils.py +1053 -0
  1414. executorch/backends/qualcomm/genai_pipeline/__init__.py +99 -0
  1415. executorch/backends/qualcomm/genai_pipeline/artifact_keys.py +69 -0
  1416. executorch/backends/qualcomm/genai_pipeline/compilation/__init__.py +17 -0
  1417. executorch/backends/qualcomm/genai_pipeline/compilation/compile_spec_builder.py +311 -0
  1418. executorch/backends/qualcomm/genai_pipeline/configs/__init__.py +41 -0
  1419. executorch/backends/qualcomm/genai_pipeline/configs/compilation_input_config.py +71 -0
  1420. executorch/backends/qualcomm/genai_pipeline/configs/compilation_output_config.py +32 -0
  1421. executorch/backends/qualcomm/genai_pipeline/configs/inference_input_config.py +38 -0
  1422. executorch/backends/qualcomm/genai_pipeline/configs/inference_output_config.py +35 -0
  1423. executorch/backends/qualcomm/genai_pipeline/configs/model_preparation_input_config.py +23 -0
  1424. executorch/backends/qualcomm/genai_pipeline/configs/model_preparation_output_config.py +48 -0
  1425. executorch/backends/qualcomm/genai_pipeline/configs/quantization_input_config.py +65 -0
  1426. executorch/backends/qualcomm/genai_pipeline/configs/quantization_output_config.py +19 -0
  1427. executorch/backends/qualcomm/genai_pipeline/control_args.py +419 -0
  1428. executorch/backends/qualcomm/genai_pipeline/datasets/__init__.py +34 -0
  1429. executorch/backends/qualcomm/genai_pipeline/datasets/calibration_data_adapter.py +54 -0
  1430. executorch/backends/qualcomm/genai_pipeline/datasets/default_calibration_data_adapter.py +89 -0
  1431. executorch/backends/qualcomm/genai_pipeline/datasets/default_training_data_adapter.py +65 -0
  1432. executorch/backends/qualcomm/genai_pipeline/datasets/training_data_adapter.py +44 -0
  1433. executorch/backends/qualcomm/genai_pipeline/engine_proxy.py +77 -0
  1434. executorch/backends/qualcomm/genai_pipeline/exceptions.py +52 -0
  1435. executorch/backends/qualcomm/genai_pipeline/genai_pipeline.py +302 -0
  1436. executorch/backends/qualcomm/genai_pipeline/graph_bundle.py +131 -0
  1437. executorch/backends/qualcomm/genai_pipeline/graph_names.py +56 -0
  1438. executorch/backends/qualcomm/genai_pipeline/pipeline_context.py +116 -0
  1439. executorch/backends/qualcomm/genai_pipeline/pipeline_stage.py +33 -0
  1440. executorch/backends/qualcomm/genai_pipeline/pipeline_types.py +29 -0
  1441. executorch/backends/qualcomm/genai_pipeline/stages/__init__.py +25 -0
  1442. executorch/backends/qualcomm/genai_pipeline/stages/compilation_stage.py +35 -0
  1443. executorch/backends/qualcomm/genai_pipeline/stages/inference_stage.py +35 -0
  1444. executorch/backends/qualcomm/genai_pipeline/stages/model_preparation_stage.py +37 -0
  1445. executorch/backends/qualcomm/genai_pipeline/stages/quantization_stage.py +37 -0
  1446. executorch/backends/qualcomm/genai_pipeline/strategies/__init__.py +25 -0
  1447. executorch/backends/qualcomm/genai_pipeline/strategies/compilation/__init__.py +23 -0
  1448. executorch/backends/qualcomm/genai_pipeline/strategies/compilation/compilation_strategy.py +34 -0
  1449. executorch/backends/qualcomm/genai_pipeline/strategies/compilation/compiler_adapter.py +115 -0
  1450. executorch/backends/qualcomm/genai_pipeline/strategies/compilation/default_compiler_adapter.py +299 -0
  1451. executorch/backends/qualcomm/genai_pipeline/strategies/compilation/executorch_compilation_strategy.py +218 -0
  1452. executorch/backends/qualcomm/genai_pipeline/strategies/inference/__init__.py +23 -0
  1453. executorch/backends/qualcomm/genai_pipeline/strategies/inference/default_device_runner_adapter.py +154 -0
  1454. executorch/backends/qualcomm/genai_pipeline/strategies/inference/device_runner_adapter.py +88 -0
  1455. executorch/backends/qualcomm/genai_pipeline/strategies/inference/executorch_inference_strategy.py +159 -0
  1456. executorch/backends/qualcomm/genai_pipeline/strategies/inference/inference_strategy.py +34 -0
  1457. executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/__init__.py +21 -0
  1458. executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/default_model_loader_adapter.py +222 -0
  1459. executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/executorch_model_preparation_strategy.py +240 -0
  1460. executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/model_loader_adapter.py +130 -0
  1461. executorch/backends/qualcomm/genai_pipeline/strategies/model_preparation/model_preparation_strategy.py +34 -0
  1462. executorch/backends/qualcomm/genai_pipeline/strategies/quantization/__init__.py +21 -0
  1463. executorch/backends/qualcomm/genai_pipeline/strategies/quantization/default_quantizer_adapter.py +167 -0
  1464. executorch/backends/qualcomm/genai_pipeline/strategies/quantization/executorch_quantization_strategy.py +233 -0
  1465. executorch/backends/qualcomm/genai_pipeline/strategies/quantization/quantization_strategy.py +34 -0
  1466. executorch/backends/qualcomm/genai_pipeline/strategies/quantization/quantizer_adapter.py +130 -0
  1467. executorch/backends/qualcomm/genai_pipeline/tests/compilation/__init__.py +5 -0
  1468. executorch/backends/qualcomm/genai_pipeline/tests/test_utils.py +44 -0
  1469. executorch/backends/qualcomm/partition/common_defs.py +40 -0
  1470. executorch/backends/qualcomm/partition/qnn_partitioner.py +402 -0
  1471. executorch/backends/qualcomm/partition/utils.py +274 -0
  1472. executorch/backends/qualcomm/qnn_preprocess.py +347 -0
  1473. executorch/backends/qualcomm/quantizer/annotators/__init__.py +0 -0
  1474. executorch/backends/qualcomm/quantizer/annotators/htp_rules.py +1929 -0
  1475. executorch/backends/qualcomm/quantizer/annotators/lpai_rules.py +1088 -0
  1476. executorch/backends/qualcomm/quantizer/backend_opinfo_adapter.py +184 -0
  1477. executorch/backends/qualcomm/quantizer/conv_bn.py +222 -0
  1478. executorch/backends/qualcomm/quantizer/custom_annotation.py +466 -0
  1479. executorch/backends/qualcomm/quantizer/observers/concat_observer.py +76 -0
  1480. executorch/backends/qualcomm/quantizer/observers/per_block_param_observer.py +146 -0
  1481. executorch/backends/qualcomm/quantizer/observers/per_channel_param_observer.py +157 -0
  1482. executorch/backends/qualcomm/quantizer/qconfig.py +1051 -0
  1483. executorch/backends/qualcomm/quantizer/quant_recipe.py +514 -0
  1484. executorch/backends/qualcomm/quantizer/quantizer.py +819 -0
  1485. executorch/backends/qualcomm/quantizer/registry_loader.py +26 -0
  1486. executorch/backends/qualcomm/quantizer/rules.py +258 -0
  1487. executorch/backends/qualcomm/quantizer/validators.py +461 -0
  1488. executorch/backends/qualcomm/recipes/__init__.py +16 -0
  1489. executorch/backends/qualcomm/recipes/qnn_recipe_provider.py +198 -0
  1490. executorch/backends/qualcomm/recipes/qnn_recipe_types.py +28 -0
  1491. executorch/backends/qualcomm/scripts/download_qnn_sdk.py +863 -0
  1492. executorch/backends/qualcomm/serialization/qc_compiler_spec.fbs +399 -0
  1493. executorch/backends/qualcomm/serialization/qc_schema.py +337 -0
  1494. executorch/backends/qualcomm/serialization/qc_schema_serialize.py +59 -0
  1495. executorch/backends/qualcomm/tests/models.py +3244 -0
  1496. executorch/backends/qualcomm/tests/rework/conftest.py +637 -0
  1497. executorch/backends/qualcomm/tests/rework/gpu/conftest.py +42 -0
  1498. executorch/backends/qualcomm/tests/rework/htp/conftest.py +102 -0
  1499. executorch/backends/qualcomm/tests/rework/lpai/conftest.py +102 -0
  1500. executorch/backends/qualcomm/tests/rework/passes/__init__.py +0 -0
  1501. executorch/backends/qualcomm/tests/rework/passes/conftest.py +183 -0
  1502. executorch/backends/qualcomm/tests/rework/passes/passes_helper.py +317 -0
  1503. executorch/backends/qualcomm/tests/rework/src/fcb_utils.py +60 -0
  1504. executorch/backends/qualcomm/tests/rework/src/feature.py +1048 -0
  1505. executorch/backends/qualcomm/tests/rework/src/op.py +5757 -0
  1506. executorch/backends/qualcomm/tests/rework/src/pattern.py +5207 -0
  1507. executorch/backends/qualcomm/tests/rework/src/utils.py +831 -0
  1508. executorch/backends/qualcomm/tests/test_qnn_delegate.py +12439 -0
  1509. executorch/backends/qualcomm/tests/tester.py +117 -0
  1510. executorch/backends/qualcomm/tests/utils.py +972 -0
  1511. executorch/backends/qualcomm/utils/check_qnn_version.py +110 -0
  1512. executorch/backends/qualcomm/utils/constants.py +64 -0
  1513. executorch/backends/qualcomm/utils/qnn_manager_lifecycle.py +139 -0
  1514. executorch/backends/qualcomm/utils/qnn_sdk_setup.py +199 -0
  1515. executorch/backends/qualcomm/utils/utils.py +1585 -0
  1516. executorch/backends/samsung/_passes/__init__.py +43 -0
  1517. executorch/backends/samsung/_passes/annotate_qparams.py +394 -0
  1518. executorch/backends/samsung/_passes/annotate_scalar_parameters.py +74 -0
  1519. executorch/backends/samsung/_passes/compose_rms_norm.py +99 -0
  1520. executorch/backends/samsung/_passes/compute_const_attrs.py +138 -0
  1521. executorch/backends/samsung/_passes/conv1d_to_conv2d.py +110 -0
  1522. executorch/backends/samsung/_passes/customized_constant_prop.py +113 -0
  1523. executorch/backends/samsung/_passes/decompose_einsum.py +52 -0
  1524. executorch/backends/samsung/_passes/decompose_glu.py +56 -0
  1525. executorch/backends/samsung/_passes/decompose_linalg_vector_norm.py +83 -0
  1526. executorch/backends/samsung/_passes/decompose_remainder.py +126 -0
  1527. executorch/backends/samsung/_passes/decompose_roll.py +84 -0
  1528. executorch/backends/samsung/_passes/enn_pass_manager.py +85 -0
  1529. executorch/backends/samsung/_passes/fold_qdq.py +36 -0
  1530. executorch/backends/samsung/_passes/fuse_activation.py +77 -0
  1531. executorch/backends/samsung/_passes/insert_qdq.py +185 -0
  1532. executorch/backends/samsung/_passes/remove_useless_ops.py +95 -0
  1533. executorch/backends/samsung/_passes/replace_inf_values.py +67 -0
  1534. executorch/backends/samsung/_passes/replace_scalar_ops.py +53 -0
  1535. executorch/backends/samsung/_passes/utils.py +96 -0
  1536. executorch/backends/samsung/builders/__init__.py +147 -0
  1537. executorch/backends/samsung/builders/node_visitor.py +118 -0
  1538. executorch/backends/samsung/builders/op_add.py +48 -0
  1539. executorch/backends/samsung/builders/op_amax.py +49 -0
  1540. executorch/backends/samsung/builders/op_avg_pool2d.py +68 -0
  1541. executorch/backends/samsung/builders/op_batch_norm.py +70 -0
  1542. executorch/backends/samsung/builders/op_bmm.py +45 -0
  1543. executorch/backends/samsung/builders/op_cat.py +52 -0
  1544. executorch/backends/samsung/builders/op_clamp.py +55 -0
  1545. executorch/backends/samsung/builders/op_constant_pad_nd.py +58 -0
  1546. executorch/backends/samsung/builders/op_conv2d.py +107 -0
  1547. executorch/backends/samsung/builders/op_cos.py +33 -0
  1548. executorch/backends/samsung/builders/op_dequantize.py +19 -0
  1549. executorch/backends/samsung/builders/op_div.py +44 -0
  1550. executorch/backends/samsung/builders/op_embedding.py +44 -0
  1551. executorch/backends/samsung/builders/op_exp.py +33 -0
  1552. executorch/backends/samsung/builders/op_expand_copy.py +86 -0
  1553. executorch/backends/samsung/builders/op_flip.py +51 -0
  1554. executorch/backends/samsung/builders/op_floor_divide.py +45 -0
  1555. executorch/backends/samsung/builders/op_gather.py +46 -0
  1556. executorch/backends/samsung/builders/op_gelu.py +42 -0
  1557. executorch/backends/samsung/builders/op_getitem.py +32 -0
  1558. executorch/backends/samsung/builders/op_group_norm.py +48 -0
  1559. executorch/backends/samsung/builders/op_hardsigmoid.py +37 -0
  1560. executorch/backends/samsung/builders/op_hardswish.py +37 -0
  1561. executorch/backends/samsung/builders/op_hardtanh.py +44 -0
  1562. executorch/backends/samsung/builders/op_index.py +47 -0
  1563. executorch/backends/samsung/builders/op_layer_norm.py +55 -0
  1564. executorch/backends/samsung/builders/op_leaky_relu.py +45 -0
  1565. executorch/backends/samsung/builders/op_linear.py +53 -0
  1566. executorch/backends/samsung/builders/op_log.py +34 -0
  1567. executorch/backends/samsung/builders/op_log_softmax.py +41 -0
  1568. executorch/backends/samsung/builders/op_max_dim.py +56 -0
  1569. executorch/backends/samsung/builders/op_max_pool2d.py +94 -0
  1570. executorch/backends/samsung/builders/op_maximum.py +39 -0
  1571. executorch/backends/samsung/builders/op_mean_dim.py +60 -0
  1572. executorch/backends/samsung/builders/op_minimum.py +41 -0
  1573. executorch/backends/samsung/builders/op_mul.py +45 -0
  1574. executorch/backends/samsung/builders/op_neg.py +34 -0
  1575. executorch/backends/samsung/builders/op_pad.py +76 -0
  1576. executorch/backends/samsung/builders/op_permute.py +41 -0
  1577. executorch/backends/samsung/builders/op_pixel_shuffle.py +40 -0
  1578. executorch/backends/samsung/builders/op_pixel_unshuffle.py +44 -0
  1579. executorch/backends/samsung/builders/op_placeholder.py +39 -0
  1580. executorch/backends/samsung/builders/op_pow.py +41 -0
  1581. executorch/backends/samsung/builders/op_prelu.py +43 -0
  1582. executorch/backends/samsung/builders/op_quantize.py +67 -0
  1583. executorch/backends/samsung/builders/op_relu.py +39 -0
  1584. executorch/backends/samsung/builders/op_reshape.py +50 -0
  1585. executorch/backends/samsung/builders/op_rms_norm.py +63 -0
  1586. executorch/backends/samsung/builders/op_rsqrt.py +37 -0
  1587. executorch/backends/samsung/builders/op_select.py +55 -0
  1588. executorch/backends/samsung/builders/op_sigmoid.py +37 -0
  1589. executorch/backends/samsung/builders/op_silu.py +36 -0
  1590. executorch/backends/samsung/builders/op_sin.py +33 -0
  1591. executorch/backends/samsung/builders/op_skip.py +32 -0
  1592. executorch/backends/samsung/builders/op_slice_copy.py +65 -0
  1593. executorch/backends/samsung/builders/op_softmax.py +41 -0
  1594. executorch/backends/samsung/builders/op_split_with_sizes_copy.py +78 -0
  1595. executorch/backends/samsung/builders/op_sqrt.py +37 -0
  1596. executorch/backends/samsung/builders/op_squeeze.py +39 -0
  1597. executorch/backends/samsung/builders/op_sub.py +50 -0
  1598. executorch/backends/samsung/builders/op_sum_int_list.py +42 -0
  1599. executorch/backends/samsung/builders/op_tanh.py +34 -0
  1600. executorch/backends/samsung/builders/op_to_copy.py +46 -0
  1601. executorch/backends/samsung/builders/op_topk.py +96 -0
  1602. executorch/backends/samsung/builders/op_unsqueeze.py +37 -0
  1603. executorch/backends/samsung/builders/op_upsample_bilinear2d.py +60 -0
  1604. executorch/backends/samsung/builders/op_upsample_nearest2d.py +54 -0
  1605. executorch/backends/samsung/builders/utils.py +64 -0
  1606. executorch/backends/samsung/enn_preprocess.py +178 -0
  1607. executorch/backends/samsung/partition/enn_partitioner.py +206 -0
  1608. executorch/backends/samsung/quantizer/__init__.py +10 -0
  1609. executorch/backends/samsung/quantizer/annotator.py +920 -0
  1610. executorch/backends/samsung/quantizer/qconfig.py +142 -0
  1611. executorch/backends/samsung/quantizer/quantizer.py +64 -0
  1612. executorch/backends/samsung/serialization/compile_options.py +231 -0
  1613. executorch/backends/samsung/serialization/compile_options_def.fbs +37 -0
  1614. executorch/backends/samsung/serialization/enn_graph_schema.py +145 -0
  1615. executorch/backends/samsung/test/tester/__init__.py +11 -0
  1616. executorch/backends/samsung/test/tester/samsung_tester.py +182 -0
  1617. executorch/backends/samsung/test/utils/__init__.py +11 -0
  1618. executorch/backends/samsung/test/utils/quant_checkers.py +241 -0
  1619. executorch/backends/samsung/test/utils/run_tests.py +58 -0
  1620. executorch/backends/samsung/test/utils/runtime_executor.py +186 -0
  1621. executorch/backends/samsung/test/utils/utils.py +42 -0
  1622. executorch/backends/samsung/utils/constants.py +45 -0
  1623. executorch/backends/samsung/utils/export_utils.py +82 -0
  1624. executorch/backends/samsung/utils/utils.py +125 -0
  1625. executorch/backends/test/facto/__init__.py +0 -0
  1626. executorch/backends/test/facto/facto_specs.py +59 -0
  1627. executorch/backends/test/facto/test_facto.py +850 -0
  1628. executorch/backends/test/graph_builder.py +158 -0
  1629. executorch/backends/test/harness/__init__.py +3 -0
  1630. executorch/backends/test/harness/error_statistics.py +99 -0
  1631. executorch/backends/test/harness/stages/__init__.py +23 -0
  1632. executorch/backends/test/harness/stages/export.py +32 -0
  1633. executorch/backends/test/harness/stages/partition.py +26 -0
  1634. executorch/backends/test/harness/stages/quantize.py +130 -0
  1635. executorch/backends/test/harness/stages/run_passes.py +68 -0
  1636. executorch/backends/test/harness/stages/serialize.py +59 -0
  1637. executorch/backends/test/harness/stages/stage.py +91 -0
  1638. executorch/backends/test/harness/stages/to_edge.py +27 -0
  1639. executorch/backends/test/harness/stages/to_edge_transform_and_lower.py +50 -0
  1640. executorch/backends/test/harness/stages/to_executorch.py +54 -0
  1641. executorch/backends/test/harness/tester.py +548 -0
  1642. executorch/backends/test/program_builder.py +138 -0
  1643. executorch/backends/test/suite/__init__.py +74 -0
  1644. executorch/backends/test/suite/buck_runner.py +66 -0
  1645. executorch/backends/test/suite/conftest.py +228 -0
  1646. executorch/backends/test/suite/context.py +34 -0
  1647. executorch/backends/test/suite/discovery.py +100 -0
  1648. executorch/backends/test/suite/flow.py +250 -0
  1649. executorch/backends/test/suite/flows/__init__.py +7 -0
  1650. executorch/backends/test/suite/flows/arm.py +98 -0
  1651. executorch/backends/test/suite/flows/coreml.py +31 -0
  1652. executorch/backends/test/suite/flows/cortex_m.py +127 -0
  1653. executorch/backends/test/suite/flows/cpu.py +10 -0
  1654. executorch/backends/test/suite/flows/mlx.py +14 -0
  1655. executorch/backends/test/suite/flows/nxp.py +86 -0
  1656. executorch/backends/test/suite/flows/openvino.py +60 -0
  1657. executorch/backends/test/suite/flows/portable.py +19 -0
  1658. executorch/backends/test/suite/flows/qualcomm.py +61 -0
  1659. executorch/backends/test/suite/flows/samsung.py +43 -0
  1660. executorch/backends/test/suite/flows/vulkan.py +44 -0
  1661. executorch/backends/test/suite/flows/webgpu.py +26 -0
  1662. executorch/backends/test/suite/flows/xnnpack.py +79 -0
  1663. executorch/backends/test/suite/generate_markdown_summary.py +249 -0
  1664. executorch/backends/test/suite/generate_markdown_summary_json.py +229 -0
  1665. executorch/backends/test/suite/models/__init__.py +7 -0
  1666. executorch/backends/test/suite/models/test_torchaudio.py +110 -0
  1667. executorch/backends/test/suite/models/test_torchvision.py +194 -0
  1668. executorch/backends/test/suite/operators/__init__.py +108 -0
  1669. executorch/backends/test/suite/operators/test_abs.py +60 -0
  1670. executorch/backends/test/suite/operators/test_adaptive_avgpool1d.py +102 -0
  1671. executorch/backends/test/suite/operators/test_adaptive_avgpool2d.py +112 -0
  1672. executorch/backends/test/suite/operators/test_adaptive_avgpool3d.py +112 -0
  1673. executorch/backends/test/suite/operators/test_adaptive_maxpool1d.py +125 -0
  1674. executorch/backends/test/suite/operators/test_adaptive_maxpool2d.py +135 -0
  1675. executorch/backends/test/suite/operators/test_adaptive_maxpool3d.py +135 -0
  1676. executorch/backends/test/suite/operators/test_add.py +76 -0
  1677. executorch/backends/test/suite/operators/test_amax.py +257 -0
  1678. executorch/backends/test/suite/operators/test_amin.py +259 -0
  1679. executorch/backends/test/suite/operators/test_argmax.py +201 -0
  1680. executorch/backends/test/suite/operators/test_argmin.py +201 -0
  1681. executorch/backends/test/suite/operators/test_avgpool1d.py +155 -0
  1682. executorch/backends/test/suite/operators/test_avgpool2d.py +168 -0
  1683. executorch/backends/test/suite/operators/test_avgpool3d.py +163 -0
  1684. executorch/backends/test/suite/operators/test_cat.py +176 -0
  1685. executorch/backends/test/suite/operators/test_ceil.py +60 -0
  1686. executorch/backends/test/suite/operators/test_clamp.py +86 -0
  1687. executorch/backends/test/suite/operators/test_conv1d.py +144 -0
  1688. executorch/backends/test/suite/operators/test_conv2d.py +167 -0
  1689. executorch/backends/test/suite/operators/test_conv3d.py +162 -0
  1690. executorch/backends/test/suite/operators/test_convtranspose1d.py +144 -0
  1691. executorch/backends/test/suite/operators/test_convtranspose2d.py +171 -0
  1692. executorch/backends/test/suite/operators/test_convtranspose3d.py +166 -0
  1693. executorch/backends/test/suite/operators/test_div.py +110 -0
  1694. executorch/backends/test/suite/operators/test_elu.py +49 -0
  1695. executorch/backends/test/suite/operators/test_embedding.py +89 -0
  1696. executorch/backends/test/suite/operators/test_embedding_bag.py +118 -0
  1697. executorch/backends/test/suite/operators/test_exp.py +65 -0
  1698. executorch/backends/test/suite/operators/test_expand.py +122 -0
  1699. executorch/backends/test/suite/operators/test_floor.py +57 -0
  1700. executorch/backends/test/suite/operators/test_floor_divide.py +216 -0
  1701. executorch/backends/test/suite/operators/test_gelu.py +52 -0
  1702. executorch/backends/test/suite/operators/test_glu.py +52 -0
  1703. executorch/backends/test/suite/operators/test_hardsigmoid.py +50 -0
  1704. executorch/backends/test/suite/operators/test_hardswish.py +50 -0
  1705. executorch/backends/test/suite/operators/test_hardtanh.py +57 -0
  1706. executorch/backends/test/suite/operators/test_index_put.py +455 -0
  1707. executorch/backends/test/suite/operators/test_index_select.py +128 -0
  1708. executorch/backends/test/suite/operators/test_leaky_relu.py +56 -0
  1709. executorch/backends/test/suite/operators/test_linear.py +124 -0
  1710. executorch/backends/test/suite/operators/test_log.py +80 -0
  1711. executorch/backends/test/suite/operators/test_log10.py +60 -0
  1712. executorch/backends/test/suite/operators/test_log1p.py +60 -0
  1713. executorch/backends/test/suite/operators/test_log2.py +60 -0
  1714. executorch/backends/test/suite/operators/test_logsigmoid.py +40 -0
  1715. executorch/backends/test/suite/operators/test_lstm.py +247 -0
  1716. executorch/backends/test/suite/operators/test_masked_fill.py +101 -0
  1717. executorch/backends/test/suite/operators/test_maxpool1d.py +185 -0
  1718. executorch/backends/test/suite/operators/test_maxpool2d.py +191 -0
  1719. executorch/backends/test/suite/operators/test_maxpool3d.py +189 -0
  1720. executorch/backends/test/suite/operators/test_mean.py +305 -0
  1721. executorch/backends/test/suite/operators/test_median.py +188 -0
  1722. executorch/backends/test/suite/operators/test_mul.py +66 -0
  1723. executorch/backends/test/suite/operators/test_neg.py +70 -0
  1724. executorch/backends/test/suite/operators/test_permute.py +109 -0
  1725. executorch/backends/test/suite/operators/test_pow.py +149 -0
  1726. executorch/backends/test/suite/operators/test_prelu.py +55 -0
  1727. executorch/backends/test/suite/operators/test_relu.py +45 -0
  1728. executorch/backends/test/suite/operators/test_reshape.py +82 -0
  1729. executorch/backends/test/suite/operators/test_round.py +129 -0
  1730. executorch/backends/test/suite/operators/test_rsqrt.py +76 -0
  1731. executorch/backends/test/suite/operators/test_select.py +89 -0
  1732. executorch/backends/test/suite/operators/test_sigmoid.py +40 -0
  1733. executorch/backends/test/suite/operators/test_silu.py +50 -0
  1734. executorch/backends/test/suite/operators/test_slice.py +146 -0
  1735. executorch/backends/test/suite/operators/test_split.py +119 -0
  1736. executorch/backends/test/suite/operators/test_sqrt.py +71 -0
  1737. executorch/backends/test/suite/operators/test_square.py +67 -0
  1738. executorch/backends/test/suite/operators/test_squeeze.py +86 -0
  1739. executorch/backends/test/suite/operators/test_stack.py +114 -0
  1740. executorch/backends/test/suite/operators/test_sub.py +84 -0
  1741. executorch/backends/test/suite/operators/test_tanh.py +40 -0
  1742. executorch/backends/test/suite/operators/test_threshold.py +72 -0
  1743. executorch/backends/test/suite/operators/test_transpose.py +143 -0
  1744. executorch/backends/test/suite/operators/test_trunc.py +73 -0
  1745. executorch/backends/test/suite/operators/test_unsqueeze.py +110 -0
  1746. executorch/backends/test/suite/operators/test_upsample_bilinear2d.py +273 -0
  1747. executorch/backends/test/suite/operators/test_upsample_nearest2d.py +137 -0
  1748. executorch/backends/test/suite/operators/test_view.py +82 -0
  1749. executorch/backends/test/suite/reporting.py +427 -0
  1750. executorch/backends/test/suite/runner.py +331 -0
  1751. executorch/backends/test/suite/tests/__init__.py +0 -0
  1752. executorch/backends/test/suite/tests/test_reporting.py +144 -0
  1753. executorch/backends/transforms/__init__.py +12 -0
  1754. executorch/backends/transforms/addmm_mm_to_linear.py +170 -0
  1755. executorch/backends/transforms/aten_to_dialect_pass.py +121 -0
  1756. executorch/backends/transforms/canonicalize_view_copy_permute_pass.py +443 -0
  1757. executorch/backends/transforms/channels_last_layout.py +22 -0
  1758. executorch/backends/transforms/channels_last_ops.py +187 -0
  1759. executorch/backends/transforms/collapse_view_copy.py +74 -0
  1760. executorch/backends/transforms/convert_conv1d_to_conv2d_pass.py +322 -0
  1761. executorch/backends/transforms/convert_dtype_pass.py +139 -0
  1762. executorch/backends/transforms/decompose_channels_last_pass.py +97 -0
  1763. executorch/backends/transforms/decompose_sdpa.py +208 -0
  1764. executorch/backends/transforms/dim_maps.py +1088 -0
  1765. executorch/backends/transforms/duplicate_dynamic_quant_chain.py +195 -0
  1766. executorch/backends/transforms/enforce_contiguous_dim_order.py +216 -0
  1767. executorch/backends/transforms/fuse_batch_norm_with_conv.py +220 -0
  1768. executorch/backends/transforms/fuse_cascaded_transpose_or_permute_ops.py +185 -0
  1769. executorch/backends/transforms/fuse_cascaded_view_ops.py +43 -0
  1770. executorch/backends/transforms/fuse_conv_with_clamp.py +78 -0
  1771. executorch/backends/transforms/fuse_duplicate_users_pass.py +218 -0
  1772. executorch/backends/transforms/fuse_gqa_with_sdpa.py +217 -0
  1773. executorch/backends/transforms/fuse_identical_input_transforms_pass.py +461 -0
  1774. executorch/backends/transforms/fuse_rms_norm.py +540 -0
  1775. executorch/backends/transforms/fuse_transpose_or_permute_op_pairs_pass.py +111 -0
  1776. executorch/backends/transforms/fuse_view_copy.py +209 -0
  1777. executorch/backends/transforms/mean_to_sum_div.py +41 -0
  1778. executorch/backends/transforms/merge_split_concat_chain.py +153 -0
  1779. executorch/backends/transforms/normalize_sdpa_input_rank.py +100 -0
  1780. executorch/backends/transforms/permute_pass_utils.py +282 -0
  1781. executorch/backends/transforms/permute_view_meta.py +56 -0
  1782. executorch/backends/transforms/postpone_permute_below_squeeze_view.py +208 -0
  1783. executorch/backends/transforms/propagate_view_copy_permute_pass.py +1418 -0
  1784. executorch/backends/transforms/quantize_fused_convbn_bias_pass.py +363 -0
  1785. executorch/backends/transforms/rank_0_to_rank_1.py +18 -0
  1786. executorch/backends/transforms/remove_clone_ops.py +109 -0
  1787. executorch/backends/transforms/remove_getitem_op.py +109 -0
  1788. executorch/backends/transforms/remove_permutes_around_elementwise_ops.py +1059 -0
  1789. executorch/backends/transforms/remove_unused_constants_pass.py +79 -0
  1790. executorch/backends/transforms/replace_channels_last_input_clones.py +133 -0
  1791. executorch/backends/transforms/replace_nop_transpose_or_permute_with_view.py +91 -0
  1792. executorch/backends/transforms/replace_ops_with_channels_last_variants.py +283 -0
  1793. executorch/backends/transforms/replace_scalar_with_tensor.py +99 -0
  1794. executorch/backends/transforms/replace_squeeze_unsqueeze_with_view.py +53 -0
  1795. executorch/backends/transforms/test/common.py +69 -0
  1796. executorch/backends/transforms/utils.py +474 -0
  1797. executorch/backends/transforms/view_copy_to_squeeze_unsqueeze.py +135 -0
  1798. executorch/backends/vulkan/__init__.py +14 -0
  1799. executorch/backends/vulkan/_passes/__init__.py +43 -0
  1800. executorch/backends/vulkan/_passes/conv1d_as_conv2d.py +169 -0
  1801. executorch/backends/vulkan/_passes/fold_qdq.py +40 -0
  1802. executorch/backends/vulkan/_passes/fuse_patterns.py +34 -0
  1803. executorch/backends/vulkan/_passes/fuse_quantized_ops.py +236 -0
  1804. executorch/backends/vulkan/_passes/insert_dtype_promotion.py +102 -0
  1805. executorch/backends/vulkan/_passes/insert_prepack_nodes.py +105 -0
  1806. executorch/backends/vulkan/_passes/remove_asserts.py +52 -0
  1807. executorch/backends/vulkan/_passes/remove_redundant_ops.py +89 -0
  1808. executorch/backends/vulkan/_passes/squeeze_unsqueeze_inputs.py +93 -0
  1809. executorch/backends/vulkan/_passes/tag_memory_meta_pass.py +549 -0
  1810. executorch/backends/vulkan/custom_ops_lib.py +1333 -0
  1811. executorch/backends/vulkan/op_registry.py +2023 -0
  1812. executorch/backends/vulkan/partitioner/vulkan_partitioner.py +515 -0
  1813. executorch/backends/vulkan/patterns/__init__.py +153 -0
  1814. executorch/backends/vulkan/patterns/pattern_registry.py +135 -0
  1815. executorch/backends/vulkan/patterns/quantized_binary.py +161 -0
  1816. executorch/backends/vulkan/patterns/quantized_convolution.py +347 -0
  1817. executorch/backends/vulkan/patterns/quantized_embedding.py +342 -0
  1818. executorch/backends/vulkan/patterns/quantized_linear.py +645 -0
  1819. executorch/backends/vulkan/patterns/quantized_pixel_shuffle.py +180 -0
  1820. executorch/backends/vulkan/patterns/quantized_unary.py +121 -0
  1821. executorch/backends/vulkan/patterns/rms_norm.py +280 -0
  1822. executorch/backends/vulkan/patterns/rope.py +173 -0
  1823. executorch/backends/vulkan/patterns/rope_hf.py +188 -0
  1824. executorch/backends/vulkan/patterns/sdpa.py +155 -0
  1825. executorch/backends/vulkan/patterns/select_as_symint.py +104 -0
  1826. executorch/backends/vulkan/patterns/swiglu.py +65 -0
  1827. executorch/backends/vulkan/patterns/weight_packing_utils.py +51 -0
  1828. executorch/backends/vulkan/quantizer/vulkan_quantizer.py +198 -0
  1829. executorch/backends/vulkan/quantizer/vulkan_quantizer_utils.py +228 -0
  1830. executorch/backends/vulkan/runtime/gen_vulkan_spv.py +1747 -0
  1831. executorch/backends/vulkan/serialization/schema.fbs +162 -0
  1832. executorch/backends/vulkan/serialization/vulkan_graph_builder.py +608 -0
  1833. executorch/backends/vulkan/serialization/vulkan_graph_schema.py +165 -0
  1834. executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +348 -0
  1835. executorch/backends/vulkan/test/op_tests/cases.py +2444 -0
  1836. executorch/backends/vulkan/test/op_tests/utils/aten_types.py +31 -0
  1837. executorch/backends/vulkan/test/op_tests/utils/gen_benchmark_vk.py +363 -0
  1838. executorch/backends/vulkan/test/op_tests/utils/gen_computegraph.py +836 -0
  1839. executorch/backends/vulkan/test/op_tests/utils/gen_correctness_base.py +427 -0
  1840. executorch/backends/vulkan/test/op_tests/utils/gen_correctness_vk.py +177 -0
  1841. executorch/backends/vulkan/test/op_tests/utils/test_suite.py +53 -0
  1842. executorch/backends/vulkan/test/tester.py +91 -0
  1843. executorch/backends/vulkan/test/utils.py +1172 -0
  1844. executorch/backends/vulkan/utils.py +2056 -0
  1845. executorch/backends/vulkan/vulkan_preprocess.py +293 -0
  1846. executorch/backends/webgpu/__init__.py +5 -0
  1847. executorch/backends/webgpu/partitioner/__init__.py +9 -0
  1848. executorch/backends/webgpu/partitioner/partitioner.py +66 -0
  1849. executorch/backends/webgpu/scripts/gen_wgsl_headers.py +859 -0
  1850. executorch/backends/webgpu/test/conftest.py +28 -0
  1851. executorch/backends/webgpu/test/op_tests/__init__.py +5 -0
  1852. executorch/backends/webgpu/test/op_tests/cases.py +2548 -0
  1853. executorch/backends/webgpu/test/op_tests/generate_op_tests.py +278 -0
  1854. executorch/backends/webgpu/test/op_tests/test_generator.py +248 -0
  1855. executorch/backends/webgpu/test/op_tests/test_schema.py +84 -0
  1856. executorch/backends/webgpu/test/op_tests/test_suite.py +101 -0
  1857. executorch/backends/webgpu/test/ops/__init__.py +0 -0
  1858. executorch/backends/webgpu/test/ops/dynamic_shape/test_dynamic_shape_export.py +1708 -0
  1859. executorch/backends/webgpu/test/ops/index/__init__.py +0 -0
  1860. executorch/backends/webgpu/test/ops/index/test_index.py +109 -0
  1861. executorch/backends/webgpu/test/ops/test_adamw.py +142 -0
  1862. executorch/backends/webgpu/test/ops/test_add.py +116 -0
  1863. executorch/backends/webgpu/test/ops/test_addmm.py +28 -0
  1864. executorch/backends/webgpu/test/ops/test_arange.py +103 -0
  1865. executorch/backends/webgpu/test/ops/test_argmax.py +46 -0
  1866. executorch/backends/webgpu/test/ops/test_avg_pool2d.py +98 -0
  1867. executorch/backends/webgpu/test/ops/test_batch_norm.py +42 -0
  1868. executorch/backends/webgpu/test/ops/test_bitwise.py +95 -0
  1869. executorch/backends/webgpu/test/ops/test_bmm.py +104 -0
  1870. executorch/backends/webgpu/test/ops/test_cat.py +82 -0
  1871. executorch/backends/webgpu/test/ops/test_compare.py +169 -0
  1872. executorch/backends/webgpu/test/ops/test_constant_pad_nd.py +23 -0
  1873. executorch/backends/webgpu/test/ops/test_conv1d_dw.py +102 -0
  1874. executorch/backends/webgpu/test/ops/test_conv1d_pw.py +162 -0
  1875. executorch/backends/webgpu/test/ops/test_conv2d.py +95 -0
  1876. executorch/backends/webgpu/test/ops/test_conv_with_clamp.py +106 -0
  1877. executorch/backends/webgpu/test/ops/test_dim_order.py +95 -0
  1878. executorch/backends/webgpu/test/ops/test_dispatch_order.py +119 -0
  1879. executorch/backends/webgpu/test/ops/test_div.py +94 -0
  1880. executorch/backends/webgpu/test/ops/test_embedding.py +103 -0
  1881. executorch/backends/webgpu/test/ops/test_embedding_q4gsw.py +161 -0
  1882. executorch/backends/webgpu/test/ops/test_et_vk_sdpa.py +131 -0
  1883. executorch/backends/webgpu/test/ops/test_expand_copy.py +120 -0
  1884. executorch/backends/webgpu/test/ops/test_fill.py +91 -0
  1885. executorch/backends/webgpu/test/ops/test_flip.py +76 -0
  1886. executorch/backends/webgpu/test/ops/test_floor_divide.py +21 -0
  1887. executorch/backends/webgpu/test/ops/test_fused_ce.py +130 -0
  1888. executorch/backends/webgpu/test/ops/test_gather.py +123 -0
  1889. executorch/backends/webgpu/test/ops/test_gelu.py +59 -0
  1890. executorch/backends/webgpu/test/ops/test_grid_priors.py +80 -0
  1891. executorch/backends/webgpu/test/ops/test_grid_sampler_2d.py +76 -0
  1892. executorch/backends/webgpu/test/ops/test_group_norm.py +83 -0
  1893. executorch/backends/webgpu/test/ops/test_index_select.py +79 -0
  1894. executorch/backends/webgpu/test/ops/test_layer_norm.py +78 -0
  1895. executorch/backends/webgpu/test/ops/test_leaky_relu.py +21 -0
  1896. executorch/backends/webgpu/test/ops/test_linear.py +116 -0
  1897. executorch/backends/webgpu/test/ops/test_linear_dW.py +88 -0
  1898. executorch/backends/webgpu/test/ops/test_linear_dq8ca_q4gsw.py +38 -0
  1899. executorch/backends/webgpu/test/ops/test_linear_fp32.py +77 -0
  1900. executorch/backends/webgpu/test/ops/test_linear_q8ta_q8csw.py +65 -0
  1901. executorch/backends/webgpu/test/ops/test_linear_qcs4w.py +60 -0
  1902. executorch/backends/webgpu/test/ops/test_log_softmax.py +97 -0
  1903. executorch/backends/webgpu/test/ops/test_logical_and.py +79 -0
  1904. executorch/backends/webgpu/test/ops/test_logical_not.py +116 -0
  1905. executorch/backends/webgpu/test/ops/test_logical_or.py +67 -0
  1906. executorch/backends/webgpu/test/ops/test_matmul.py +67 -0
  1907. executorch/backends/webgpu/test/ops/test_max_pool2d.py +42 -0
  1908. executorch/backends/webgpu/test/ops/test_minimum.py +18 -0
  1909. executorch/backends/webgpu/test/ops/test_mul.py +69 -0
  1910. executorch/backends/webgpu/test/ops/test_permute.py +76 -0
  1911. executorch/backends/webgpu/test/ops/test_pixel_shuffle.py +76 -0
  1912. executorch/backends/webgpu/test/ops/test_pow.py +18 -0
  1913. executorch/backends/webgpu/test/ops/test_prepack.py +142 -0
  1914. executorch/backends/webgpu/test/ops/test_q4gsw_requant.py +123 -0
  1915. executorch/backends/webgpu/test/ops/test_q8ta_add.py +70 -0
  1916. executorch/backends/webgpu/test/ops/test_q8ta_conv2d.py +62 -0
  1917. executorch/backends/webgpu/test/ops/test_q8ta_conv2d_dw.py +63 -0
  1918. executorch/backends/webgpu/test/ops/test_q8ta_conv2d_pw.py +58 -0
  1919. executorch/backends/webgpu/test/ops/test_q8ta_conv2d_transposed.py +68 -0
  1920. executorch/backends/webgpu/test/ops/test_q8ta_linear.py +61 -0
  1921. executorch/backends/webgpu/test/ops/test_q8ta_pixel_shuffle.py +64 -0
  1922. executorch/backends/webgpu/test/ops/test_q8ta_relu.py +60 -0
  1923. executorch/backends/webgpu/test/ops/test_quant.py +70 -0
  1924. executorch/backends/webgpu/test/ops/test_quantized_linear.py +406 -0
  1925. executorch/backends/webgpu/test/ops/test_quantized_linear_backward.py +157 -0
  1926. executorch/backends/webgpu/test/ops/test_reduce.py +249 -0
  1927. executorch/backends/webgpu/test/ops/test_relu.py +27 -0
  1928. executorch/backends/webgpu/test/ops/test_repeat.py +77 -0
  1929. executorch/backends/webgpu/test/ops/test_rms_norm.py +192 -0
  1930. executorch/backends/webgpu/test/ops/test_rope.py +129 -0
  1931. executorch/backends/webgpu/test/ops/test_rope_hf.py +388 -0
  1932. executorch/backends/webgpu/test/ops/test_rope_interleaved.py +77 -0
  1933. executorch/backends/webgpu/test/ops/test_sdpa.py +637 -0
  1934. executorch/backends/webgpu/test/ops/test_select.py +67 -0
  1935. executorch/backends/webgpu/test/ops/test_sigmoid.py +80 -0
  1936. executorch/backends/webgpu/test/ops/test_slice.py +66 -0
  1937. executorch/backends/webgpu/test/ops/test_softmax.py +116 -0
  1938. executorch/backends/webgpu/test/ops/test_split_with_sizes_copy.py +39 -0
  1939. executorch/backends/webgpu/test/ops/test_squeeze.py +75 -0
  1940. executorch/backends/webgpu/test/ops/test_sub.py +114 -0
  1941. executorch/backends/webgpu/test/ops/test_to_copy.py +196 -0
  1942. executorch/backends/webgpu/test/ops/test_unary_activations.py +110 -0
  1943. executorch/backends/webgpu/test/ops/test_unsqueeze.py +75 -0
  1944. executorch/backends/webgpu/test/ops/test_update_cache.py +196 -0
  1945. executorch/backends/webgpu/test/ops/test_upsample_bilinear2d.py +29 -0
  1946. executorch/backends/webgpu/test/ops/test_upsample_nearest2d.py +33 -0
  1947. executorch/backends/webgpu/test/ops/test_view_copy.py +66 -0
  1948. executorch/backends/webgpu/test/ops/test_where.py +86 -0
  1949. executorch/backends/webgpu/test/test_cmake_configuration.py +87 -0
  1950. executorch/backends/webgpu/test/test_native_ci_contract.py +79 -0
  1951. executorch/backends/webgpu/test/test_webgpu_partitioner.py +240 -0
  1952. executorch/backends/webgpu/test/test_wgsl_codegen.py +1178 -0
  1953. executorch/backends/webgpu/test/tester.py +145 -0
  1954. executorch/backends/xnnpack/__init__.py +28 -0
  1955. executorch/backends/xnnpack/_passes/__init__.py +116 -0
  1956. executorch/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py +642 -0
  1957. executorch/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py +206 -0
  1958. executorch/backends/xnnpack/_passes/convert_to_linear.py +202 -0
  1959. executorch/backends/xnnpack/_passes/convert_to_sdpa.py +114 -0
  1960. executorch/backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py +65 -0
  1961. executorch/backends/xnnpack/_passes/decompose_batch_norm.py +294 -0
  1962. executorch/backends/xnnpack/_passes/decompose_cat.py +109 -0
  1963. executorch/backends/xnnpack/_passes/fuse_activation_pass.py +87 -0
  1964. executorch/backends/xnnpack/_passes/fuse_batch_norm.py +294 -0
  1965. executorch/backends/xnnpack/_passes/insert_pad_qdq.py +88 -0
  1966. executorch/backends/xnnpack/_passes/prelu_reshape_pass.py +75 -0
  1967. executorch/backends/xnnpack/_passes/propagate_custom_meta_pass.py +44 -0
  1968. executorch/backends/xnnpack/_passes/remove_noop_expand_copy_pass.py +59 -0
  1969. executorch/backends/xnnpack/_passes/remove_redundant_copy_pass.py +158 -0
  1970. executorch/backends/xnnpack/_passes/rewrite_fp16_silu.py +44 -0
  1971. executorch/backends/xnnpack/_passes/xnnpack_pass.py +22 -0
  1972. executorch/backends/xnnpack/operators/__init__.py +61 -0
  1973. executorch/backends/xnnpack/operators/node_visitor.py +780 -0
  1974. executorch/backends/xnnpack/operators/op_abs.py +52 -0
  1975. executorch/backends/xnnpack/operators/op_add.py +77 -0
  1976. executorch/backends/xnnpack/operators/op_addmm.py +70 -0
  1977. executorch/backends/xnnpack/operators/op_avg_pooling2d.py +70 -0
  1978. executorch/backends/xnnpack/operators/op_bmm.py +54 -0
  1979. executorch/backends/xnnpack/operators/op_cat.py +121 -0
  1980. executorch/backends/xnnpack/operators/op_ceiling.py +52 -0
  1981. executorch/backends/xnnpack/operators/op_clamp.py +64 -0
  1982. executorch/backends/xnnpack/operators/op_clone.py +71 -0
  1983. executorch/backends/xnnpack/operators/op_conv2d.py +189 -0
  1984. executorch/backends/xnnpack/operators/op_cos.py +52 -0
  1985. executorch/backends/xnnpack/operators/op_div.py +56 -0
  1986. executorch/backends/xnnpack/operators/op_dynamic_dequantize_ops.py +114 -0
  1987. executorch/backends/xnnpack/operators/op_dynamic_quantize_ops.py +179 -0
  1988. executorch/backends/xnnpack/operators/op_elu.py +58 -0
  1989. executorch/backends/xnnpack/operators/op_exp.py +52 -0
  1990. executorch/backends/xnnpack/operators/op_floor.py +48 -0
  1991. executorch/backends/xnnpack/operators/op_gelu.py +60 -0
  1992. executorch/backends/xnnpack/operators/op_hardswish.py +52 -0
  1993. executorch/backends/xnnpack/operators/op_hardtanh.py +67 -0
  1994. executorch/backends/xnnpack/operators/op_leaky_relu.py +65 -0
  1995. executorch/backends/xnnpack/operators/op_linear.py +115 -0
  1996. executorch/backends/xnnpack/operators/op_log.py +52 -0
  1997. executorch/backends/xnnpack/operators/op_matrix_multiplication.py +66 -0
  1998. executorch/backends/xnnpack/operators/op_max_dim.py +206 -0
  1999. executorch/backends/xnnpack/operators/op_max_pool2d.py +124 -0
  2000. executorch/backends/xnnpack/operators/op_maximum.py +55 -0
  2001. executorch/backends/xnnpack/operators/op_mean_dim.py +87 -0
  2002. executorch/backends/xnnpack/operators/op_minimum.py +54 -0
  2003. executorch/backends/xnnpack/operators/op_multiply.py +77 -0
  2004. executorch/backends/xnnpack/operators/op_negate.py +51 -0
  2005. executorch/backends/xnnpack/operators/op_permute.py +87 -0
  2006. executorch/backends/xnnpack/operators/op_prelu.py +56 -0
  2007. executorch/backends/xnnpack/operators/op_quant_dequant.py +196 -0
  2008. executorch/backends/xnnpack/operators/op_relu.py +61 -0
  2009. executorch/backends/xnnpack/operators/op_rsqrt.py +52 -0
  2010. executorch/backends/xnnpack/operators/op_sigmoid.py +48 -0
  2011. executorch/backends/xnnpack/operators/op_sin.py +52 -0
  2012. executorch/backends/xnnpack/operators/op_skip_ops.py +89 -0
  2013. executorch/backends/xnnpack/operators/op_slice_copy.py +100 -0
  2014. executorch/backends/xnnpack/operators/op_softmax.py +58 -0
  2015. executorch/backends/xnnpack/operators/op_square.py +52 -0
  2016. executorch/backends/xnnpack/operators/op_square_root.py +52 -0
  2017. executorch/backends/xnnpack/operators/op_squeeze.py +147 -0
  2018. executorch/backends/xnnpack/operators/op_static_constant_pad.py +145 -0
  2019. executorch/backends/xnnpack/operators/op_static_resize_bilinear_2d.py +61 -0
  2020. executorch/backends/xnnpack/operators/op_sub.py +77 -0
  2021. executorch/backends/xnnpack/operators/op_tanh.py +52 -0
  2022. executorch/backends/xnnpack/operators/op_to_copy.py +91 -0
  2023. executorch/backends/xnnpack/operators/op_view_copy.py +96 -0
  2024. executorch/backends/xnnpack/operators/quant_params.py +412 -0
  2025. executorch/backends/xnnpack/partition/config/__init__.py +136 -0
  2026. executorch/backends/xnnpack/partition/config/gemm_configs.py +621 -0
  2027. executorch/backends/xnnpack/partition/config/generic_node_configs.py +925 -0
  2028. executorch/backends/xnnpack/partition/config/node_configs.py +151 -0
  2029. executorch/backends/xnnpack/partition/config/quant_affine_configs.py +56 -0
  2030. executorch/backends/xnnpack/partition/config/xnnpack_config.py +310 -0
  2031. executorch/backends/xnnpack/partition/graphs/bilinear_2d.py +55 -0
  2032. executorch/backends/xnnpack/partition/graphs/sdpa.py +86 -0
  2033. executorch/backends/xnnpack/partition/xnnpack_partitioner.py +166 -0
  2034. executorch/backends/xnnpack/quantizer/xnnpack_quantizer.py +461 -0
  2035. executorch/backends/xnnpack/quantizer/xnnpack_quantizer_utils.py +1214 -0
  2036. executorch/backends/xnnpack/recipes/__init__.py +19 -0
  2037. executorch/backends/xnnpack/recipes/xnnpack_recipe_provider.py +200 -0
  2038. executorch/backends/xnnpack/recipes/xnnpack_recipe_types.py +37 -0
  2039. executorch/backends/xnnpack/serialization/runtime_schema.fbs +390 -0
  2040. executorch/backends/xnnpack/serialization/schema.fbs +382 -0
  2041. executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +548 -0
  2042. executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +393 -0
  2043. executorch/backends/xnnpack/test/__init__.py +0 -0
  2044. executorch/backends/xnnpack/test/passes/__init__.py +0 -0
  2045. executorch/backends/xnnpack/test/test_xnnpack_utils.py +533 -0
  2046. executorch/backends/xnnpack/test/test_xnnpack_utils_classes.py +44 -0
  2047. executorch/backends/xnnpack/test/tester/__init__.py +29 -0
  2048. executorch/backends/xnnpack/test/tester/tester.py +134 -0
  2049. executorch/backends/xnnpack/utils/configs.py +41 -0
  2050. executorch/backends/xnnpack/utils/quant_utils.py +301 -0
  2051. executorch/backends/xnnpack/utils/utils.py +241 -0
  2052. executorch/backends/xnnpack/utils/xnnpack_constants.py +37 -0
  2053. executorch/backends/xnnpack/xnnpack_preprocess.py +194 -0
  2054. executorch/codegen/__init__.py +0 -0
  2055. executorch/codegen/api/__init__.py +0 -0
  2056. executorch/codegen/api/custom_ops.py +151 -0
  2057. executorch/codegen/api/et_cpp.py +367 -0
  2058. executorch/codegen/api/types/__init__.py +5 -0
  2059. executorch/codegen/api/types/signatures.py +77 -0
  2060. executorch/codegen/api/types/types.py +76 -0
  2061. executorch/codegen/api/unboxing.py +232 -0
  2062. executorch/codegen/gen.py +1055 -0
  2063. executorch/codegen/model.py +220 -0
  2064. executorch/codegen/parse.py +158 -0
  2065. executorch/codegen/tools/__init__.py +20 -0
  2066. executorch/codegen/tools/combine_prim_ops_headers.py +164 -0
  2067. executorch/codegen/tools/gen_all_oplist.py +252 -0
  2068. executorch/codegen/tools/gen_max_kernel_num.py +174 -0
  2069. executorch/codegen/tools/gen_oplist.py +370 -0
  2070. executorch/codegen/tools/gen_ops_def.py +96 -0
  2071. executorch/codegen/tools/gen_selected_op_variants.py +135 -0
  2072. executorch/codegen/tools/gen_selected_prim_ops.py +133 -0
  2073. executorch/codegen/tools/merge_yaml.py +125 -0
  2074. executorch/codegen/tools/selective_build.cp315-win_amd64.pyd +0 -0
  2075. executorch/codegen/tools/selective_build.pyi +23 -0
  2076. executorch/codegen/tools/yaml_util.py +15 -0
  2077. executorch/data/bin/__init__.py +44 -0
  2078. executorch/data/bin/flatc.exe +0 -0
  2079. executorch/devtools/__init__.py +19 -0
  2080. executorch/devtools/backend_debug/__init__.py +13 -0
  2081. executorch/devtools/backend_debug/delegation_info.py +183 -0
  2082. executorch/devtools/bundled_program/config.py +120 -0
  2083. executorch/devtools/bundled_program/core.py +395 -0
  2084. executorch/devtools/bundled_program/schema/__init__.py +9 -0
  2085. executorch/devtools/bundled_program/schema/bundled_program_schema.fbs +97 -0
  2086. executorch/devtools/bundled_program/schema/bundled_program_schema.py +99 -0
  2087. executorch/devtools/bundled_program/schema/scalar_type.fbs +43 -0
  2088. executorch/devtools/bundled_program/serialize/__init__.py +298 -0
  2089. executorch/devtools/bundled_program/serialize/bundled_program_schema.fbs +97 -0
  2090. executorch/devtools/bundled_program/serialize/generate_bundled_program.py +174 -0
  2091. executorch/devtools/bundled_program/serialize/generated/__init__.py +9 -0
  2092. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Bool.py +92 -0
  2093. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledMethodTestCase.py +194 -0
  2094. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledMethodTestSuite.py +158 -0
  2095. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/BundledProgram.py +212 -0
  2096. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Double.py +92 -0
  2097. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Int.py +92 -0
  2098. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Tensor.py +267 -0
  2099. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/Value.py +125 -0
  2100. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/ValueUnion.py +29 -0
  2101. executorch/devtools/bundled_program/serialize/generated/bundled_program_flatbuffer/__init__.py +23 -0
  2102. executorch/devtools/bundled_program/serialize/generated/executorch_flatbuffer/ScalarType.py +28 -0
  2103. executorch/devtools/bundled_program/serialize/generated/executorch_flatbuffer/__init__.py +7 -0
  2104. executorch/devtools/bundled_program/serialize/scalar_type.fbs +43 -0
  2105. executorch/devtools/bundled_program/util/test_util.py +289 -0
  2106. executorch/devtools/bundled_program/version.py +13 -0
  2107. executorch/devtools/debug_format/base_schema.py +61 -0
  2108. executorch/devtools/debug_format/et_schema.py +432 -0
  2109. executorch/devtools/etdump/etdump_schema_flatcc.fbs +181 -0
  2110. executorch/devtools/etdump/scalar_type.fbs +43 -0
  2111. executorch/devtools/etdump/schema_flatcc.py +154 -0
  2112. executorch/devtools/etdump/serialize.py +118 -0
  2113. executorch/devtools/etrecord/__init__.py +13 -0
  2114. executorch/devtools/etrecord/_etrecord.py +929 -0
  2115. executorch/devtools/etrecord/tests/etrecord_test.py +1936 -0
  2116. executorch/devtools/inspector/__init__.py +31 -0
  2117. executorch/devtools/inspector/_inspector.py +1702 -0
  2118. executorch/devtools/inspector/_inspector_utils.py +1264 -0
  2119. executorch/devtools/inspector/_intermediate_output_capturer.py +62 -0
  2120. executorch/devtools/inspector/inspector_cli.py +84 -0
  2121. executorch/devtools/inspector/numerical_comparator/__init__.py +55 -0
  2122. executorch/devtools/inspector/numerical_comparator/l1_numerical_comparator.py +35 -0
  2123. executorch/devtools/inspector/numerical_comparator/mse_numerical_comparator.py +37 -0
  2124. executorch/devtools/inspector/numerical_comparator/numerical_comparator_base.py +266 -0
  2125. executorch/devtools/inspector/numerical_comparator/snr_numerical_comparator.py +47 -0
  2126. executorch/devtools/inspector/tests/inspector_test_utils.py +189 -0
  2127. executorch/devtools/inspector/vgf_neural_statistics.py +183 -0
  2128. executorch/devtools/intermediate_output_tap/__init__.py +93 -0
  2129. executorch/devtools/intermediate_output_tap/_convenience.py +191 -0
  2130. executorch/devtools/intermediate_output_tap/_reducers.py +319 -0
  2131. executorch/devtools/intermediate_output_tap/_selectors.py +231 -0
  2132. executorch/devtools/intermediate_output_tap/_spec.py +55 -0
  2133. executorch/devtools/intermediate_output_tap/_strip_pass.py +92 -0
  2134. executorch/devtools/intermediate_output_tap/_tap_pass.py +278 -0
  2135. executorch/devtools/intermediate_output_tap/custom_ops_lib.py +24 -0
  2136. executorch/devtools/pte_tool/diff_pte.py +895 -0
  2137. executorch/devtools/scripts/generate_profiling_csv.py +62 -0
  2138. executorch/devtools/size_analysis_tool/size_analysis_tool.py +194 -0
  2139. executorch/devtools/size_analysis_tool/size_analysis_tool_test.py +107 -0
  2140. executorch/devtools/visualization/__init__.py +13 -0
  2141. executorch/devtools/visualization/visualization_utils.py +313 -0
  2142. executorch/devtools/visualization/visualization_utils_test.py +177 -0
  2143. executorch/examples/apple/coreml/llama/export.py +224 -0
  2144. executorch/examples/apple/coreml/llama/export_static_llm_coreml.py +717 -0
  2145. executorch/examples/apple/coreml/llama/llama_transformer.py +899 -0
  2146. executorch/examples/apple/coreml/llama/run.py +206 -0
  2147. executorch/examples/apple/coreml/llama/run_lookahead.py +284 -0
  2148. executorch/examples/apple/coreml/llama/run_static_llm.py +293 -0
  2149. executorch/examples/apple/coreml/llama/run_static_llm_multifunction.py +325 -0
  2150. executorch/examples/apple/coreml/llama/test.py +48 -0
  2151. executorch/examples/apple/coreml/llama/utils.py +334 -0
  2152. executorch/examples/apple/coreml/scripts/coreml_compute_plan.py +236 -0
  2153. executorch/examples/apple/coreml/scripts/debugger_cli.py +181 -0
  2154. executorch/examples/apple/coreml/scripts/export.py +280 -0
  2155. executorch/examples/apple/coreml/scripts/extract_coreml_models.py +143 -0
  2156. executorch/examples/apple/coreml/scripts/inspector_cli.py +64 -0
  2157. executorch/examples/apple/coreml/scripts/inspector_utils.py +425 -0
  2158. executorch/examples/apple/coreml/scripts/test_coreml_compute_plan.py +161 -0
  2159. executorch/examples/cuda/scripts/__init__.py +0 -0
  2160. executorch/examples/cuda/scripts/export.py +124 -0
  2161. executorch/examples/cuda/scripts/export_amd_pointwise.py +142 -0
  2162. executorch/examples/llm_pte_finetuning/__init__.py +19 -0
  2163. executorch/examples/llm_pte_finetuning/llama3_config.yaml +96 -0
  2164. executorch/examples/llm_pte_finetuning/model_exporter.py +87 -0
  2165. executorch/examples/llm_pte_finetuning/model_loading_lib.py +143 -0
  2166. executorch/examples/llm_pte_finetuning/phi3_alpaca_code_config.yaml +44 -0
  2167. executorch/examples/llm_pte_finetuning/phi3_config.yaml +42 -0
  2168. executorch/examples/llm_pte_finetuning/qwen_05b_config.yaml +43 -0
  2169. executorch/examples/llm_pte_finetuning/runner.py +135 -0
  2170. executorch/examples/llm_pte_finetuning/training_lib.py +157 -0
  2171. executorch/examples/llm_server/__init__.py +5 -0
  2172. executorch/examples/llm_server/conformance/test_openai_contract.py +207 -0
  2173. executorch/examples/llm_server/evals/__init__.py +5 -0
  2174. executorch/examples/llm_server/evals/terminal_bench/__init__.py +5 -0
  2175. executorch/examples/llm_server/evals/terminal_bench/runner.py +501 -0
  2176. executorch/examples/llm_server/evals/terminal_bench/sessions.py +80 -0
  2177. executorch/examples/llm_server/python/__init__.py +7 -0
  2178. executorch/examples/llm_server/python/chat_template.py +345 -0
  2179. executorch/examples/llm_server/python/errors.py +105 -0
  2180. executorch/examples/llm_server/python/multiplexed_worker_client.py +844 -0
  2181. executorch/examples/llm_server/python/openai_transcript.py +385 -0
  2182. executorch/examples/llm_server/python/protocol.py +165 -0
  2183. executorch/examples/llm_server/python/serve.py +185 -0
  2184. executorch/examples/llm_server/python/server.py +347 -0
  2185. executorch/examples/llm_server/python/serving_chat.py +966 -0
  2186. executorch/examples/llm_server/python/session_runtime.py +873 -0
  2187. executorch/examples/llm_server/python/tests/test_multiplexed_worker_client.py +1681 -0
  2188. executorch/examples/llm_server/python/tests/test_worker_client.py +712 -0
  2189. executorch/examples/llm_server/python/tool_parsers/__init__.py +29 -0
  2190. executorch/examples/llm_server/python/tool_parsers/gemma.py +258 -0
  2191. executorch/examples/llm_server/python/tool_parsers/hermes.py +119 -0
  2192. executorch/examples/llm_server/python/tool_parsers/qwen.py +193 -0
  2193. executorch/examples/llm_server/python/tool_parsers/types.py +33 -0
  2194. executorch/examples/llm_server/python/worker_client.py +660 -0
  2195. executorch/examples/models/__init__.py +125 -0
  2196. executorch/examples/models/checkpoint.py +142 -0
  2197. executorch/examples/models/codegen/__init__.py +16 -0
  2198. executorch/examples/models/codegen/convert_weight.py +93 -0
  2199. executorch/examples/models/deeplab_v3/__init__.py +9 -0
  2200. executorch/examples/models/deeplab_v3/model.py +50 -0
  2201. executorch/examples/models/deepseek-r1-distill-llama-8B/config/deepseek_xnnpack_q8da4w.yaml +16 -0
  2202. executorch/examples/models/deit_tiny/__init__.py +8 -0
  2203. executorch/examples/models/deit_tiny/model.py +36 -0
  2204. executorch/examples/models/dinov2/__init__.py +0 -0
  2205. executorch/examples/models/dinov2/export_dinov2.py +187 -0
  2206. executorch/examples/models/edsr/__init__.py +11 -0
  2207. executorch/examples/models/edsr/model.py +28 -0
  2208. executorch/examples/models/efficient_sam/__init__.py +11 -0
  2209. executorch/examples/models/efficient_sam/efficient_sam_core/build_efficient_sam.py +25 -0
  2210. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam.py +316 -0
  2211. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_decoder.py +373 -0
  2212. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_encoder.py +261 -0
  2213. executorch/examples/models/efficient_sam/efficient_sam_core/mlp.py +31 -0
  2214. executorch/examples/models/efficient_sam/efficient_sam_core/two_way_transformer.py +268 -0
  2215. executorch/examples/models/efficient_sam/model.py +34 -0
  2216. executorch/examples/models/emformer_rnnt/__init__.py +17 -0
  2217. executorch/examples/models/emformer_rnnt/model.py +132 -0
  2218. executorch/examples/models/gemma/__init__.py +16 -0
  2219. executorch/examples/models/gemma/convert_weights.py +104 -0
  2220. executorch/examples/models/gemma2/__init__.py +19 -0
  2221. executorch/examples/models/gemma2/convert_weights.py +113 -0
  2222. executorch/examples/models/gemma3/__init__.py +16 -0
  2223. executorch/examples/models/gemma3/convert_weights.py +110 -0
  2224. executorch/examples/models/gemma4/__init__.py +13 -0
  2225. executorch/examples/models/gemma4/export_gemma4.py +884 -0
  2226. executorch/examples/models/gemma4/image_utils.py +155 -0
  2227. executorch/examples/models/gemma4/quant_utils.py +93 -0
  2228. executorch/examples/models/gemma4/run_gemma4.py +365 -0
  2229. executorch/examples/models/gemma4/speech_transform.py +149 -0
  2230. executorch/examples/models/gemma4/text_decoder/__init__.py +17 -0
  2231. executorch/examples/models/gemma4/text_decoder/convert_weights.py +314 -0
  2232. executorch/examples/models/gemma4/text_decoder/gemma4_attention.py +629 -0
  2233. executorch/examples/models/gemma4/text_decoder/gemma4_config.py +299 -0
  2234. executorch/examples/models/gemma4/text_decoder/gemma4_cross_decoder.py +83 -0
  2235. executorch/examples/models/gemma4/text_decoder/gemma4_decoder_layer.py +185 -0
  2236. executorch/examples/models/gemma4/text_decoder/gemma4_model.py +207 -0
  2237. executorch/examples/models/gemma4/text_decoder/gemma4_self_decoder.py +229 -0
  2238. executorch/examples/models/gemma4/text_decoder/gemma4_transformer.py +171 -0
  2239. executorch/examples/models/gemma4_31b/__init__.py +5 -0
  2240. executorch/examples/models/gemma4_31b/cuda_packers.py +160 -0
  2241. executorch/examples/models/gemma4_31b/cuda_source_transformations.py +361 -0
  2242. executorch/examples/models/gemma4_31b/export.py +612 -0
  2243. executorch/examples/models/gemma4_31b/gguf_loader.py +60 -0
  2244. executorch/examples/models/gemma4_31b/inference.py +263 -0
  2245. executorch/examples/models/gemma4_31b/mlx_source_transformations.py +234 -0
  2246. executorch/examples/models/gemma4_31b/model.py +645 -0
  2247. executorch/examples/models/gemma4_31b/quant/quantize.py +340 -0
  2248. executorch/examples/models/gemma4_31b/quant/recipe.py +62 -0
  2249. executorch/examples/models/gemma4_31b/quantize_and_save.py +158 -0
  2250. executorch/examples/models/gemma4_31b/sampler.py +37 -0
  2251. executorch/examples/models/gemma4_31b/serve.py +214 -0
  2252. executorch/examples/models/gemma4_31b/test_ondevice_serving.py +62 -0
  2253. executorch/examples/models/gemma4_31b/test_serve.py +184 -0
  2254. executorch/examples/models/gemma4_31b/tests/test_pipeline.py +504 -0
  2255. executorch/examples/models/glm/__init__.py +16 -0
  2256. executorch/examples/models/glm/convert_weights.py +79 -0
  2257. executorch/examples/models/granite/__init__.py +16 -0
  2258. executorch/examples/models/granite/convert_weights.py +106 -0
  2259. executorch/examples/models/granite_speech/__init__.py +16 -0
  2260. executorch/examples/models/granite_speech/convert_weights.py +111 -0
  2261. executorch/examples/models/inception_v3/__init__.py +11 -0
  2262. executorch/examples/models/inception_v3/model.py +28 -0
  2263. executorch/examples/models/inception_v4/__init__.py +11 -0
  2264. executorch/examples/models/inception_v4/model.py +26 -0
  2265. executorch/examples/models/internvl3/__init__.py +16 -0
  2266. executorch/examples/models/internvl3/convert_weights.py +82 -0
  2267. executorch/examples/models/lfm2/__init__.py +10 -0
  2268. executorch/examples/models/lfm2/config/lfm2_coreml_fp32.yaml +15 -0
  2269. executorch/examples/models/lfm2/config/lfm2_mlx_4w.yaml +15 -0
  2270. executorch/examples/models/lfm2/config/lfm2_xnnpack_fp32.yaml +12 -0
  2271. executorch/examples/models/lfm2/config/lfm2_xnnpack_q8da4w.yaml +15 -0
  2272. executorch/examples/models/lfm2/convert_weights.py +92 -0
  2273. executorch/examples/models/lfm2/short_conv.py +124 -0
  2274. executorch/examples/models/lfm2/test_lfm2_5_mlx.py +102 -0
  2275. executorch/examples/models/llama/__init__.py +20 -0
  2276. executorch/examples/models/llama/attention.py +981 -0
  2277. executorch/examples/models/llama/config/llama_attention_sink.yaml +30 -0
  2278. executorch/examples/models/llama/config/llama_bf16.yaml +7 -0
  2279. executorch/examples/models/llama/config/llama_q8da4w.yaml +11 -0
  2280. executorch/examples/models/llama/config/llama_xnnpack.yaml +17 -0
  2281. executorch/examples/models/llama/config/llama_xnnpack_qat.yaml +23 -0
  2282. executorch/examples/models/llama/config/llama_xnnpack_spinquant.yaml +22 -0
  2283. executorch/examples/models/llama/config/test_llm_config.py +145 -0
  2284. executorch/examples/models/llama/convert_weights.py +135 -0
  2285. executorch/examples/models/llama/eval_llama.py +38 -0
  2286. executorch/examples/models/llama/eval_llama_lib.py +441 -0
  2287. executorch/examples/models/llama/evaluate/__init__.py +11 -0
  2288. executorch/examples/models/llama/evaluate/eager_eval.py +93 -0
  2289. executorch/examples/models/llama/experimental/__init__.py +0 -0
  2290. executorch/examples/models/llama/experimental/generate.py +190 -0
  2291. executorch/examples/models/llama/experimental/load_gguf_q4_0.py +184 -0
  2292. executorch/examples/models/llama/experimental/subclass.py +413 -0
  2293. executorch/examples/models/llama/experimental/test_subclass.py +28 -0
  2294. executorch/examples/models/llama/export_llama.py +56 -0
  2295. executorch/examples/models/llama/export_llama_lib.py +2378 -0
  2296. executorch/examples/models/llama/fairseq2.py +63 -0
  2297. executorch/examples/models/llama/feed_forward.py +73 -0
  2298. executorch/examples/models/llama/hf_download.py +169 -0
  2299. executorch/examples/models/llama/install_requirement_helper.py +70 -0
  2300. executorch/examples/models/llama/llama_transformer.py +604 -0
  2301. executorch/examples/models/llama/lora.py +80 -0
  2302. executorch/examples/models/llama/model.py +402 -0
  2303. executorch/examples/models/llama/model_args.py +243 -0
  2304. executorch/examples/models/llama/norm.py +250 -0
  2305. executorch/examples/models/llama/rope.py +402 -0
  2306. executorch/examples/models/llama/runner/eager.py +142 -0
  2307. executorch/examples/models/llama/runner/generation.py +234 -0
  2308. executorch/examples/models/llama/runner/native.py +145 -0
  2309. executorch/examples/models/llama/source_transformation/__init__.py +0 -0
  2310. executorch/examples/models/llama/source_transformation/apply_spin_quant_r1_r2.py +202 -0
  2311. executorch/examples/models/llama/source_transformation/attention.py +223 -0
  2312. executorch/examples/models/llama/source_transformation/attention_sink.py +375 -0
  2313. executorch/examples/models/llama/source_transformation/custom_kv_cache.py +1034 -0
  2314. executorch/examples/models/llama/source_transformation/lora.py +153 -0
  2315. executorch/examples/models/llama/source_transformation/moe.py +359 -0
  2316. executorch/examples/models/llama/source_transformation/pre_quantization.py +348 -0
  2317. executorch/examples/models/llama/source_transformation/prune_vocab.py +119 -0
  2318. executorch/examples/models/llama/source_transformation/quantize.py +913 -0
  2319. executorch/examples/models/llama/source_transformation/rms_norm.py +23 -0
  2320. executorch/examples/models/llama/source_transformation/rope.py +39 -0
  2321. executorch/examples/models/llama/source_transformation/sdpa.py +553 -0
  2322. executorch/examples/models/llama/source_transformation/spin_quant.py +88 -0
  2323. executorch/examples/models/llama/source_transformation/test_attention_sink.py +624 -0
  2324. executorch/examples/models/llama/source_transformation/test_quantized_kv_cache.py +126 -0
  2325. executorch/examples/models/llama/source_transformation/test_quantized_sdpa.py +167 -0
  2326. executorch/examples/models/llama/source_transformation/test_sdpa_with_quantized_kv_cache.py +170 -0
  2327. executorch/examples/models/llama/static_attention.py +1663 -0
  2328. executorch/examples/models/llama/tokenizer/tiktoken.py +224 -0
  2329. executorch/examples/models/llama3_2_vision/__init__.py +14 -0
  2330. executorch/examples/models/llama3_2_vision/preprocess/__init__.py +0 -0
  2331. executorch/examples/models/llama3_2_vision/preprocess/export_preprocess.py +45 -0
  2332. executorch/examples/models/llama3_2_vision/preprocess/model.py +72 -0
  2333. executorch/examples/models/llama3_2_vision/preprocess/test_preprocess.py +338 -0
  2334. executorch/examples/models/llama3_2_vision/runner/eager.py +59 -0
  2335. executorch/examples/models/llama3_2_vision/runner/exported.py +94 -0
  2336. executorch/examples/models/llama3_2_vision/runner/generation.py +102 -0
  2337. executorch/examples/models/llama3_2_vision/runner/native.py +143 -0
  2338. executorch/examples/models/llama3_2_vision/text_decoder/model.py +199 -0
  2339. executorch/examples/models/llama3_2_vision/vision_encoder/__init__.py +12 -0
  2340. executorch/examples/models/llama3_2_vision/vision_encoder/model.py +96 -0
  2341. executorch/examples/models/llama3_2_vision/vision_encoder/test/__init__.py +0 -0
  2342. executorch/examples/models/llava/__init__.py +11 -0
  2343. executorch/examples/models/llava/export_llava.py +365 -0
  2344. executorch/examples/models/llava/model.py +415 -0
  2345. executorch/examples/models/llava/test/test_llava.py +151 -0
  2346. executorch/examples/models/llava/test/test_pte.py +105 -0
  2347. executorch/examples/models/lstm/__init__.py +12 -0
  2348. executorch/examples/models/lstm/model.py +31 -0
  2349. executorch/examples/models/mlperf_tiny/__init__.py +23 -0
  2350. executorch/examples/models/mlperf_tiny/deep_autoencoder.py +40 -0
  2351. executorch/examples/models/mlperf_tiny/ds_cnn.py +90 -0
  2352. executorch/examples/models/mlperf_tiny/mobilenet_v1_025.py +102 -0
  2353. executorch/examples/models/mlperf_tiny/resnet8.py +98 -0
  2354. executorch/examples/models/mlperf_tiny/streaming_wakeword.py +87 -0
  2355. executorch/examples/models/mobilebert/__init__.py +11 -0
  2356. executorch/examples/models/mobilebert/model.py +31 -0
  2357. executorch/examples/models/mobilenet_v2/__init__.py +12 -0
  2358. executorch/examples/models/mobilenet_v2/model.py +41 -0
  2359. executorch/examples/models/mobilenet_v3/__init__.py +11 -0
  2360. executorch/examples/models/mobilenet_v3/model.py +30 -0
  2361. executorch/examples/models/model_base.py +47 -0
  2362. executorch/examples/models/model_factory.py +60 -0
  2363. executorch/examples/models/moshi/mimi/test_mimi.py +245 -0
  2364. executorch/examples/models/muse-glimmer/__init__.py +13 -0
  2365. executorch/examples/models/muse-glimmer/export/__init__.py +5 -0
  2366. executorch/examples/models/muse-glimmer/export/common.py +169 -0
  2367. executorch/examples/models/muse-glimmer/export/export_dflash.py +1171 -0
  2368. executorch/examples/models/muse-glimmer/export/export_solo.py +1214 -0
  2369. executorch/examples/models/muse-glimmer/inference.py +356 -0
  2370. executorch/examples/models/muse-glimmer/loaders/__init__.py +5 -0
  2371. executorch/examples/models/muse-glimmer/loaders/checkpoint_loader.py +880 -0
  2372. executorch/examples/models/muse-glimmer/loaders/dflash_loader.py +203 -0
  2373. executorch/examples/models/muse-glimmer/loaders/quantize_and_save.py +199 -0
  2374. executorch/examples/models/muse-glimmer/model/__init__.py +5 -0
  2375. executorch/examples/models/muse-glimmer/model/dflash_model.py +532 -0
  2376. executorch/examples/models/muse-glimmer/model/dflash_token_sampler.py +336 -0
  2377. executorch/examples/models/muse-glimmer/model/model.py +969 -0
  2378. executorch/examples/models/muse-glimmer/model/vision_tower.py +197 -0
  2379. executorch/examples/models/muse-glimmer/serving/__init__.py +5 -0
  2380. executorch/examples/models/muse-glimmer/serving/serve.py +512 -0
  2381. executorch/examples/models/muse-glimmer/serving/serve_batching.py +228 -0
  2382. executorch/examples/models/muse-glimmer/serving/stream_parser.py +164 -0
  2383. executorch/examples/models/muse-glimmer/serving/tool_parsers/__init__.py +11 -0
  2384. executorch/examples/models/muse-glimmer/serving/tool_parsers/atem.py +185 -0
  2385. executorch/examples/models/muse-glimmer/source_transformations/__init__.py +5 -0
  2386. executorch/examples/models/muse-glimmer/source_transformations/cuda.py +1130 -0
  2387. executorch/examples/models/muse-glimmer/source_transformations/mlx.py +707 -0
  2388. executorch/examples/models/muse-glimmer/source_transformations/sampler.py +39 -0
  2389. executorch/examples/models/muse-glimmer/tests/__init__.py +5 -0
  2390. executorch/examples/models/muse-glimmer/vision/__init__.py +5 -0
  2391. executorch/examples/models/muse-glimmer/vision/precompute.py +297 -0
  2392. executorch/examples/models/muse_glimmer/__init__.py +13 -0
  2393. executorch/examples/models/muse_glimmer/export/__init__.py +5 -0
  2394. executorch/examples/models/muse_glimmer/export/common.py +169 -0
  2395. executorch/examples/models/muse_glimmer/export/export_dflash.py +1171 -0
  2396. executorch/examples/models/muse_glimmer/export/export_solo.py +1214 -0
  2397. executorch/examples/models/muse_glimmer/inference.py +356 -0
  2398. executorch/examples/models/muse_glimmer/loaders/__init__.py +5 -0
  2399. executorch/examples/models/muse_glimmer/loaders/checkpoint_loader.py +880 -0
  2400. executorch/examples/models/muse_glimmer/loaders/dflash_loader.py +203 -0
  2401. executorch/examples/models/muse_glimmer/loaders/quantize_and_save.py +199 -0
  2402. executorch/examples/models/muse_glimmer/model/__init__.py +5 -0
  2403. executorch/examples/models/muse_glimmer/model/dflash_model.py +532 -0
  2404. executorch/examples/models/muse_glimmer/model/dflash_token_sampler.py +336 -0
  2405. executorch/examples/models/muse_glimmer/model/model.py +969 -0
  2406. executorch/examples/models/muse_glimmer/model/vision_tower.py +197 -0
  2407. executorch/examples/models/muse_glimmer/serving/__init__.py +5 -0
  2408. executorch/examples/models/muse_glimmer/serving/serve.py +512 -0
  2409. executorch/examples/models/muse_glimmer/serving/serve_batching.py +228 -0
  2410. executorch/examples/models/muse_glimmer/serving/stream_parser.py +164 -0
  2411. executorch/examples/models/muse_glimmer/serving/tool_parsers/__init__.py +11 -0
  2412. executorch/examples/models/muse_glimmer/serving/tool_parsers/atem.py +185 -0
  2413. executorch/examples/models/muse_glimmer/source_transformations/__init__.py +5 -0
  2414. executorch/examples/models/muse_glimmer/source_transformations/cuda.py +1130 -0
  2415. executorch/examples/models/muse_glimmer/source_transformations/mlx.py +707 -0
  2416. executorch/examples/models/muse_glimmer/source_transformations/sampler.py +39 -0
  2417. executorch/examples/models/muse_glimmer/tests/__init__.py +5 -0
  2418. executorch/examples/models/muse_glimmer/tests/gen_prompt_golden.py +59 -0
  2419. executorch/examples/models/muse_glimmer/tests/gen_resize_golden.py +46 -0
  2420. executorch/examples/models/muse_glimmer/tests/prompt_cases.py +193 -0
  2421. executorch/examples/models/muse_glimmer/tests/test_mlx_pipeline.py +289 -0
  2422. executorch/examples/models/muse_glimmer/tests/test_pipeline.py +1235 -0
  2423. executorch/examples/models/muse_glimmer/tests/test_prompt_tokens.py +365 -0
  2424. executorch/examples/models/muse_glimmer/tests/test_serve.py +1041 -0
  2425. executorch/examples/models/muse_glimmer/vision/__init__.py +5 -0
  2426. executorch/examples/models/muse_glimmer/vision/precompute.py +297 -0
  2427. executorch/examples/models/nemotron3_diarization/__init__.py +5 -0
  2428. executorch/examples/models/nemotron3_diarization/export_nemotron.py +295 -0
  2429. executorch/examples/models/parakeet/export_parakeet_tdt.py +826 -0
  2430. executorch/examples/models/parakeet/quantize.py +8 -0
  2431. executorch/examples/models/phi-3-mini/__init__.py +11 -0
  2432. executorch/examples/models/phi-3-mini-lora/export_model.py +144 -0
  2433. executorch/examples/models/phi_4_mini/__init__.py +16 -0
  2434. executorch/examples/models/phi_4_mini/config/phi_4_mini_xnnpack.yaml +12 -0
  2435. executorch/examples/models/phi_4_mini/convert_weights.py +153 -0
  2436. executorch/examples/models/qwen2_5/__init__.py +16 -0
  2437. executorch/examples/models/qwen2_5/config/qwen2_5_coder_xnnpack_q8da4w.yaml +20 -0
  2438. executorch/examples/models/qwen2_5/config/qwen2_5_xnnpack_q8da4w.yaml +14 -0
  2439. executorch/examples/models/qwen2_5/convert_weights.py +105 -0
  2440. executorch/examples/models/qwen3/__init__.py +16 -0
  2441. executorch/examples/models/qwen3/config/qwen3_multimethod.yaml +34 -0
  2442. executorch/examples/models/qwen3/config/qwen3_xnnpack_lora.yaml +21 -0
  2443. executorch/examples/models/qwen3/config/qwen3_xnnpack_q8da4w.yaml +20 -0
  2444. executorch/examples/models/qwen3/convert_weights.py +142 -0
  2445. executorch/examples/models/qwen3_5/__init__.py +19 -0
  2446. executorch/examples/models/qwen3_5/config/qwen3_5_xnnpack_fp32.yaml +21 -0
  2447. executorch/examples/models/qwen3_5/convert_weights.py +165 -0
  2448. executorch/examples/models/qwen3_5/tests/__init__.py +2 -0
  2449. executorch/examples/models/qwen3_5_moe/__init__.py +0 -0
  2450. executorch/examples/models/qwen3_5_moe/export.py +1379 -0
  2451. executorch/examples/models/qwen3_5_moe/inference.py +196 -0
  2452. executorch/examples/models/qwen3_5_moe/metal_source_transformations.py +336 -0
  2453. executorch/examples/models/qwen3_5_moe/mlx_source_transformations.py +371 -0
  2454. executorch/examples/models/qwen3_5_moe/model.py +955 -0
  2455. executorch/examples/models/qwen3_5_moe/quantize_and_save.py +570 -0
  2456. executorch/examples/models/qwen3_5_moe/run.py +329 -0
  2457. executorch/examples/models/qwen3_5_moe/sampler.py +60 -0
  2458. executorch/examples/models/qwen3_5_moe/serve.py +182 -0
  2459. executorch/examples/models/qwen3_5_moe/test_chunked_prefill.py +124 -0
  2460. executorch/examples/models/qwen3_5_moe/test_quantize_roundtrip.py +323 -0
  2461. executorch/examples/models/qwen3_5_moe/test_sampler.py +142 -0
  2462. executorch/examples/models/qwen3_5_moe/test_serve.py +158 -0
  2463. executorch/examples/models/qwen3_5_moe/test_turboquant.py +211 -0
  2464. executorch/examples/models/resnet/__init__.py +12 -0
  2465. executorch/examples/models/resnet/model.py +48 -0
  2466. executorch/examples/models/silero_vad/export_silero_vad.py +232 -0
  2467. executorch/examples/models/smollm2/__init__.py +16 -0
  2468. executorch/examples/models/smollm2/convert_weights.py +84 -0
  2469. executorch/examples/models/smollm3/__init__.py +16 -0
  2470. executorch/examples/models/smollm3/convert_weights.py +112 -0
  2471. executorch/examples/models/smolvlm/__init__.py +16 -0
  2472. executorch/examples/models/smolvlm/convert_weights.py +77 -0
  2473. executorch/examples/models/sortformer/export_sortformer.py +409 -0
  2474. executorch/examples/models/sortformer/validate_pte.py +136 -0
  2475. executorch/examples/models/spark_x2_5/__init__.py +5 -0
  2476. executorch/examples/models/spark_x2_5/config/spark_x2_5_xnnpack_fp32.yaml +12 -0
  2477. executorch/examples/models/spark_x2_5/config/spark_x2_5_xnnpack_q8da4w.yaml +15 -0
  2478. executorch/examples/models/spark_x2_5/convert_weights.py +136 -0
  2479. executorch/examples/models/spark_x2_5/test_spark_x2_5.py +125 -0
  2480. executorch/examples/models/stable_diffusion/__init__.py +21 -0
  2481. executorch/examples/models/stable_diffusion/model.py +202 -0
  2482. executorch/examples/models/stable_diffusion_3_5_large/__init__.py +28 -0
  2483. executorch/examples/models/stable_diffusion_3_5_large/export_sd3_5_large.py +445 -0
  2484. executorch/examples/models/stable_diffusion_3_5_large/model.py +415 -0
  2485. executorch/examples/models/supertonic/__init__.py +5 -0
  2486. executorch/examples/models/supertonic/export/__init__.py +5 -0
  2487. executorch/examples/models/supertonic/export/common.py +348 -0
  2488. executorch/examples/models/supertonic/export/export_supertonic.py +147 -0
  2489. executorch/examples/models/supertonic/loaders/__init__.py +5 -0
  2490. executorch/examples/models/supertonic/loaders/checkpoint_loader.py +549 -0
  2491. executorch/examples/models/supertonic/loaders/voice_style_loader.py +57 -0
  2492. executorch/examples/models/supertonic/model/__init__.py +5 -0
  2493. executorch/examples/models/supertonic/model/config.py +62 -0
  2494. executorch/examples/models/supertonic/model/duration_predictor.py +153 -0
  2495. executorch/examples/models/supertonic/model/layers.py +200 -0
  2496. executorch/examples/models/supertonic/model/text_encoder.py +346 -0
  2497. executorch/examples/models/supertonic/model/vector_estimator.py +576 -0
  2498. executorch/examples/models/supertonic/model/vocoder.py +204 -0
  2499. executorch/examples/models/supertonic/preprocessing.py +207 -0
  2500. executorch/examples/models/supertonic/source_transformations/__init__.py +5 -0
  2501. executorch/examples/models/supertonic/source_transformations/mlx.py +245 -0
  2502. executorch/examples/models/supertonic/tests/__init__.py +5 -0
  2503. executorch/examples/models/test/__init__.py +0 -0
  2504. executorch/examples/models/torchvision_vit/__init__.py +11 -0
  2505. executorch/examples/models/torchvision_vit/model.py +28 -0
  2506. executorch/examples/models/toy_model/__init__.py +25 -0
  2507. executorch/examples/models/toy_model/model.py +143 -0
  2508. executorch/examples/models/voxtral_realtime/__init__.py +5 -0
  2509. executorch/examples/models/voxtral_realtime/export_voxtral_rt.py +798 -0
  2510. executorch/examples/models/voxtral_realtime/model.py +1517 -0
  2511. executorch/examples/models/voxtral_tts/__init__.py +5 -0
  2512. executorch/examples/models/voxtral_tts/export_voxtral_tts.py +720 -0
  2513. executorch/examples/models/voxtral_tts/model.py +1609 -0
  2514. executorch/examples/models/voxtral_tts/voice.py +91 -0
  2515. executorch/examples/models/wav2letter/__init__.py +11 -0
  2516. executorch/examples/models/wav2letter/model.py +29 -0
  2517. executorch/examples/models/whisper/__init__.py +8 -0
  2518. executorch/examples/models/whisper/model.py +43 -0
  2519. executorch/examples/models/yolo26/__init__.py +8 -0
  2520. executorch/examples/models/yolo26/export_and_validate.py +400 -0
  2521. executorch/examples/models/yolo26/model.py +31 -0
  2522. executorch/examples/nxp/__init__.py +4 -0
  2523. executorch/examples/nxp/analyzing_with_inspector.py +90 -0
  2524. executorch/examples/nxp/aot_neutron_compile.py +511 -0
  2525. executorch/examples/nxp/experimental/__init__.py +4 -0
  2526. executorch/examples/nxp/experimental/cifar_net/__init__.py +4 -0
  2527. executorch/examples/nxp/experimental/cifar_net/cifar_net.py +301 -0
  2528. executorch/examples/nxp/models/__init__.py +4 -0
  2529. executorch/examples/nxp/models/mlperf_tiny/__init__.py +4 -0
  2530. executorch/examples/nxp/models/mlperf_tiny/anomaly_detection/__init__.py +4 -0
  2531. executorch/examples/nxp/models/mlperf_tiny/anomaly_detection/mlperf_tiny_anomaly_detection.py +182 -0
  2532. executorch/examples/nxp/models/mlperf_tiny/image_classification/__init__.py +4 -0
  2533. executorch/examples/nxp/models/mlperf_tiny/image_classification/mlperf_tiny_image_classification.py +52 -0
  2534. executorch/examples/nxp/models/mlperf_tiny/keyword_spotting/__init__.py +4 -0
  2535. executorch/examples/nxp/models/mlperf_tiny/keyword_spotting/mlperf_tiny_keyword_spotting.py +60 -0
  2536. executorch/examples/nxp/models/mlperf_tiny/visual_wake_words/__init__.py +4 -0
  2537. executorch/examples/nxp/models/mlperf_tiny/visual_wake_words/mlperf_tiny_visual_wake_words.py +64 -0
  2538. executorch/examples/nxp/models/mobilenet_v2.py +103 -0
  2539. executorch/examples/nxp/models/nxp_test_base_model.py +202 -0
  2540. executorch/examples/qualcomm/__init__.py +5 -0
  2541. executorch/examples/qualcomm/custom_op/custom_ops_1.py +307 -0
  2542. executorch/examples/qualcomm/custom_op/custom_ops_2.py +317 -0
  2543. executorch/examples/qualcomm/custom_op/custom_ops_lpai.py +511 -0
  2544. executorch/examples/qualcomm/oss_scripts/__init__.py +5 -0
  2545. executorch/examples/qualcomm/oss_scripts/albert.py +175 -0
  2546. executorch/examples/qualcomm/oss_scripts/bert.py +163 -0
  2547. executorch/examples/qualcomm/oss_scripts/conv_former.py +135 -0
  2548. executorch/examples/qualcomm/oss_scripts/convnext_small.py +139 -0
  2549. executorch/examples/qualcomm/oss_scripts/cvt.py +201 -0
  2550. executorch/examples/qualcomm/oss_scripts/deit.py +153 -0
  2551. executorch/examples/qualcomm/oss_scripts/depthanything_v2_small.py +214 -0
  2552. executorch/examples/qualcomm/oss_scripts/dino_v2.py +139 -0
  2553. executorch/examples/qualcomm/oss_scripts/distilbert.py +164 -0
  2554. executorch/examples/qualcomm/oss_scripts/dit.py +153 -0
  2555. executorch/examples/qualcomm/oss_scripts/efficientSAM/efficientSAM.py +329 -0
  2556. executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/__init__.py +17 -0
  2557. executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/mask_decoder.py +125 -0
  2558. executorch/examples/qualcomm/oss_scripts/efficientSAM/source_transformation/pos_emb.py +64 -0
  2559. executorch/examples/qualcomm/oss_scripts/efficientnet.py +144 -0
  2560. executorch/examples/qualcomm/oss_scripts/esrgan.py +172 -0
  2561. executorch/examples/qualcomm/oss_scripts/eurobert.py +173 -0
  2562. executorch/examples/qualcomm/oss_scripts/fastvit.py +218 -0
  2563. executorch/examples/qualcomm/oss_scripts/fbnet.py +137 -0
  2564. executorch/examples/qualcomm/oss_scripts/focalnet.py +138 -0
  2565. executorch/examples/qualcomm/oss_scripts/gMLP_image_classification.py +127 -0
  2566. executorch/examples/qualcomm/oss_scripts/gemma4/model_wrapper.py +232 -0
  2567. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/__init__.py +9 -0
  2568. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/attention.py +253 -0
  2569. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/convert_weights.py +26 -0
  2570. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/cross_decoder.py +80 -0
  2571. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/decoder_layer.py +114 -0
  2572. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/feed_forward.py +56 -0
  2573. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/self_decoder.py +80 -0
  2574. executorch/examples/qualcomm/oss_scripts/gemma4/text_decoder/text_model.py +128 -0
  2575. executorch/examples/qualcomm/oss_scripts/hf_causal_lm.py +288 -0
  2576. executorch/examples/qualcomm/oss_scripts/llama/__init__.py +632 -0
  2577. executorch/examples/qualcomm/oss_scripts/llama/dataset/__init__.py +69 -0
  2578. executorch/examples/qualcomm/oss_scripts/llama/dataset/builders.py +549 -0
  2579. executorch/examples/qualcomm/oss_scripts/llama/dataset/collators.py +127 -0
  2580. executorch/examples/qualcomm/oss_scripts/llama/dataset/config.py +61 -0
  2581. executorch/examples/qualcomm/oss_scripts/llama/dataset/constants.py +7 -0
  2582. executorch/examples/qualcomm/oss_scripts/llama/dataset/datasets.py +48 -0
  2583. executorch/examples/qualcomm/oss_scripts/llama/dataset/loaders.py +192 -0
  2584. executorch/examples/qualcomm/oss_scripts/llama/dataset/preprocessors.py +122 -0
  2585. executorch/examples/qualcomm/oss_scripts/llama/dataset/schema.py +34 -0
  2586. executorch/examples/qualcomm/oss_scripts/llama/dataset/targets.py +43 -0
  2587. executorch/examples/qualcomm/oss_scripts/llama/decoder_constants.py +67 -0
  2588. executorch/examples/qualcomm/oss_scripts/llama/encoder/__init__.py +31 -0
  2589. executorch/examples/qualcomm/oss_scripts/llama/encoder/encoder_config.py +120 -0
  2590. executorch/examples/qualcomm/oss_scripts/llama/encoder/encoder_quant_recipe.py +118 -0
  2591. executorch/examples/qualcomm/oss_scripts/llama/evaluator/__init__.py +25 -0
  2592. executorch/examples/qualcomm/oss_scripts/llama/evaluator/device_evaluator.py +795 -0
  2593. executorch/examples/qualcomm/oss_scripts/llama/evaluator/lm_eval_adapter.py +99 -0
  2594. executorch/examples/qualcomm/oss_scripts/llama/inference/__init__.py +25 -0
  2595. executorch/examples/qualcomm/oss_scripts/llama/inference/decoder.py +164 -0
  2596. executorch/examples/qualcomm/oss_scripts/llama/inference/encoder.py +22 -0
  2597. executorch/examples/qualcomm/oss_scripts/llama/inference/model.py +59 -0
  2598. executorch/examples/qualcomm/oss_scripts/llama/llama.py +990 -0
  2599. executorch/examples/qualcomm/oss_scripts/llama/masking_utils.py +312 -0
  2600. executorch/examples/qualcomm/oss_scripts/llama/mix_precision_analyzer.py +694 -0
  2601. executorch/examples/qualcomm/oss_scripts/llama/model/__init__.py +18 -0
  2602. executorch/examples/qualcomm/oss_scripts/llama/model/apply_rope.py +52 -0
  2603. executorch/examples/qualcomm/oss_scripts/llama/model/audio_encoder.py +163 -0
  2604. executorch/examples/qualcomm/oss_scripts/llama/model/embedding.py +39 -0
  2605. executorch/examples/qualcomm/oss_scripts/llama/model/feed_forward.py +141 -0
  2606. executorch/examples/qualcomm/oss_scripts/llama/model/layernorm.py +50 -0
  2607. executorch/examples/qualcomm/oss_scripts/llama/model/static_llama.py +1093 -0
  2608. executorch/examples/qualcomm/oss_scripts/llama/model/vision_encoder.py +374 -0
  2609. executorch/examples/qualcomm/oss_scripts/llama/quantize/__init__.py +13 -0
  2610. executorch/examples/qualcomm/oss_scripts/llama/quantize/ptq.py +77 -0
  2611. executorch/examples/qualcomm/oss_scripts/llama/quantize/qat.py +105 -0
  2612. executorch/examples/qualcomm/oss_scripts/llama/quantize/strategy.py +34 -0
  2613. executorch/examples/qualcomm/oss_scripts/llama/range_setting_pt2e.py +279 -0
  2614. executorch/examples/qualcomm/oss_scripts/llama/static_llm_quant_recipe.py +802 -0
  2615. executorch/examples/qualcomm/oss_scripts/llama/tokenizer.py +417 -0
  2616. executorch/examples/qualcomm/oss_scripts/llama/train/__init__.py +25 -0
  2617. executorch/examples/qualcomm/oss_scripts/llama/train/config/__init__.py +11 -0
  2618. executorch/examples/qualcomm/oss_scripts/llama/train/config/config.py +45 -0
  2619. executorch/examples/qualcomm/oss_scripts/llama/train/config/lr_config.yaml +49 -0
  2620. executorch/examples/qualcomm/oss_scripts/llama/train/config/qad.yaml +20 -0
  2621. executorch/examples/qualcomm/oss_scripts/llama/train/loss.py +66 -0
  2622. executorch/examples/qualcomm/oss_scripts/llama/train/trainer.py +303 -0
  2623. executorch/examples/qualcomm/oss_scripts/llama/train/utils.py +96 -0
  2624. executorch/examples/qualcomm/oss_scripts/llama/utils.py +70 -0
  2625. executorch/examples/qualcomm/oss_scripts/llama/wrappers/__init__.py +23 -0
  2626. executorch/examples/qualcomm/oss_scripts/llama/wrappers/attention_sink_wrappers.py +469 -0
  2627. executorch/examples/qualcomm/oss_scripts/llama/wrappers/base_component.py +201 -0
  2628. executorch/examples/qualcomm/oss_scripts/llama/wrappers/llm_wrappers.py +1534 -0
  2629. executorch/examples/qualcomm/oss_scripts/llm_utils/decoder_model_wrapper.py +283 -0
  2630. executorch/examples/qualcomm/oss_scripts/llm_utils/eval_decoder_model_qnn.py +299 -0
  2631. executorch/examples/qualcomm/oss_scripts/llm_utils/llm_quant_recipe.py +314 -0
  2632. executorch/examples/qualcomm/oss_scripts/llm_utils/qnn_decoder_model_manager.py +423 -0
  2633. executorch/examples/qualcomm/oss_scripts/maxvit_t.py +247 -0
  2634. executorch/examples/qualcomm/oss_scripts/mobilevit_v1.py +166 -0
  2635. executorch/examples/qualcomm/oss_scripts/mobilevit_v2.py +171 -0
  2636. executorch/examples/qualcomm/oss_scripts/moshi/mimi.py +525 -0
  2637. executorch/examples/qualcomm/oss_scripts/moshi/model/static_conv.py +145 -0
  2638. executorch/examples/qualcomm/oss_scripts/moshi/model/static_convtr.py +175 -0
  2639. executorch/examples/qualcomm/oss_scripts/moshi/model/static_mimi.py +679 -0
  2640. executorch/examples/qualcomm/oss_scripts/moshi/model/static_seanet_decoder.py +313 -0
  2641. executorch/examples/qualcomm/oss_scripts/pvt.py +137 -0
  2642. executorch/examples/qualcomm/oss_scripts/regnet.py +144 -0
  2643. executorch/examples/qualcomm/oss_scripts/retinanet.py +319 -0
  2644. executorch/examples/qualcomm/oss_scripts/roberta.py +191 -0
  2645. executorch/examples/qualcomm/oss_scripts/squeezenet.py +129 -0
  2646. executorch/examples/qualcomm/oss_scripts/ssd300_vgg16.py +275 -0
  2647. executorch/examples/qualcomm/oss_scripts/swin_transformer.py +191 -0
  2648. executorch/examples/qualcomm/oss_scripts/swin_v2_t.py +189 -0
  2649. executorch/examples/qualcomm/oss_scripts/t5/t5.py +380 -0
  2650. executorch/examples/qualcomm/oss_scripts/t5/t5_model.py +550 -0
  2651. executorch/examples/qualcomm/oss_scripts/vit_b_16.py +140 -0
  2652. executorch/examples/qualcomm/oss_scripts/whisper/whisper.py +543 -0
  2653. executorch/examples/qualcomm/oss_scripts/whisper/whisper_model.py +114 -0
  2654. executorch/examples/qualcomm/qaihub_scripts/llama/llama2/qaihub_llama2_7b.py +241 -0
  2655. executorch/examples/qualcomm/qaihub_scripts/llama/llama3/qaihub_llama3_8b.py +248 -0
  2656. executorch/examples/qualcomm/qaihub_scripts/stable_diffusion/qaihub_stable_diffusion.py +403 -0
  2657. executorch/examples/qualcomm/qaihub_scripts/stable_diffusion/stable_diffusion_lib.py +22 -0
  2658. executorch/examples/qualcomm/qaihub_scripts/utils/export.py +509 -0
  2659. executorch/examples/qualcomm/qaihub_scripts/utils/utils.py +82 -0
  2660. executorch/examples/qualcomm/scripts/deeplab_v3.py +199 -0
  2661. executorch/examples/qualcomm/scripts/edsr.py +231 -0
  2662. executorch/examples/qualcomm/scripts/export_example.py +127 -0
  2663. executorch/examples/qualcomm/scripts/inception_v3.py +133 -0
  2664. executorch/examples/qualcomm/scripts/inception_v4.py +132 -0
  2665. executorch/examples/qualcomm/scripts/mobilebert_fine_tune.py +378 -0
  2666. executorch/examples/qualcomm/scripts/mobilenet_v2.py +133 -0
  2667. executorch/examples/qualcomm/scripts/mobilenet_v3.py +140 -0
  2668. executorch/examples/qualcomm/scripts/torchvision_vit.py +180 -0
  2669. executorch/examples/qualcomm/scripts/wav2letter.py +218 -0
  2670. executorch/examples/qualcomm/util_scripts/cli.py +731 -0
  2671. executorch/examples/qualcomm/util_scripts/fcb.py +347 -0
  2672. executorch/examples/qualcomm/util_scripts/gen_etrecord.py +104 -0
  2673. executorch/examples/qualcomm/util_scripts/htp_profiling_on_device_op_trace_offline.py +132 -0
  2674. executorch/examples/qualcomm/util_scripts/htp_profiling_on_device_op_trace_online.py +130 -0
  2675. executorch/examples/qualcomm/util_scripts/htp_profiling_on_host_hextimate.py +112 -0
  2676. executorch/examples/qualcomm/util_scripts/qnn_intermediate_debugger_demo.py +217 -0
  2677. executorch/examples/qualcomm/utils.py +364 -0
  2678. executorch/examples/xnnpack/__init__.py +51 -0
  2679. executorch/examples/xnnpack/aot_compiler.py +151 -0
  2680. executorch/examples/xnnpack/quantization/example.py +205 -0
  2681. executorch/examples/xnnpack/quantization/utils.py +42 -0
  2682. executorch/exir/__init__.py +57 -0
  2683. executorch/exir/_program_utils.py +109 -0
  2684. executorch/exir/_serialize/__init__.py +20 -0
  2685. executorch/exir/_serialize/_cord.py +140 -0
  2686. executorch/exir/_serialize/_dataclass.py +145 -0
  2687. executorch/exir/_serialize/_flatbuffer.py +467 -0
  2688. executorch/exir/_serialize/_flatbuffer_program.py +359 -0
  2689. executorch/exir/_serialize/_named_data_store.py +358 -0
  2690. executorch/exir/_serialize/_program.py +809 -0
  2691. executorch/exir/_serialize/_ptn.py +370 -0
  2692. executorch/exir/_serialize/_serialize.py +123 -0
  2693. executorch/exir/_serialize/data_serializer.py +120 -0
  2694. executorch/exir/_serialize/generate_program.py +167 -0
  2695. executorch/exir/_serialize/generated/__init__.py +7 -0
  2696. executorch/exir/_serialize/generated/executorch_flatbuffer/AllocationDetails.py +130 -0
  2697. executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegate.py +189 -0
  2698. executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegateDataReference.py +113 -0
  2699. executorch/exir/_serialize/generated/executorch_flatbuffer/BackendDelegateInlineData.py +141 -0
  2700. executorch/exir/_serialize/generated/executorch_flatbuffer/Bool.py +96 -0
  2701. executorch/exir/_serialize/generated/executorch_flatbuffer/BoolList.py +141 -0
  2702. executorch/exir/_serialize/generated/executorch_flatbuffer/Buffer.py +141 -0
  2703. executorch/exir/_serialize/generated/executorch_flatbuffer/Chain.py +317 -0
  2704. executorch/exir/_serialize/generated/executorch_flatbuffer/CompileSpec.py +162 -0
  2705. executorch/exir/_serialize/generated/executorch_flatbuffer/ContainerMetadata.py +120 -0
  2706. executorch/exir/_serialize/generated/executorch_flatbuffer/DataLocation.py +7 -0
  2707. executorch/exir/_serialize/generated/executorch_flatbuffer/DataSegment.py +113 -0
  2708. executorch/exir/_serialize/generated/executorch_flatbuffer/DelegateCall.py +218 -0
  2709. executorch/exir/_serialize/generated/executorch_flatbuffer/DelegateScratch.py +128 -0
  2710. executorch/exir/_serialize/generated/executorch_flatbuffer/DeviceType.py +7 -0
  2711. executorch/exir/_serialize/generated/executorch_flatbuffer/Double.py +96 -0
  2712. executorch/exir/_serialize/generated/executorch_flatbuffer/DoubleList.py +141 -0
  2713. executorch/exir/_serialize/generated/executorch_flatbuffer/EValue.py +137 -0
  2714. executorch/exir/_serialize/generated/executorch_flatbuffer/ExecutionPlan.py +595 -0
  2715. executorch/exir/_serialize/generated/executorch_flatbuffer/ExtraTensorInfo.py +168 -0
  2716. executorch/exir/_serialize/generated/executorch_flatbuffer/Frame.py +157 -0
  2717. executorch/exir/_serialize/generated/executorch_flatbuffer/FrameList.py +143 -0
  2718. executorch/exir/_serialize/generated/executorch_flatbuffer/FreeCall.py +96 -0
  2719. executorch/exir/_serialize/generated/executorch_flatbuffer/Instruction.py +131 -0
  2720. executorch/exir/_serialize/generated/executorch_flatbuffer/InstructionArguments.py +33 -0
  2721. executorch/exir/_serialize/generated/executorch_flatbuffer/Int.py +96 -0
  2722. executorch/exir/_serialize/generated/executorch_flatbuffer/IntList.py +141 -0
  2723. executorch/exir/_serialize/generated/executorch_flatbuffer/JumpFalseCall.py +113 -0
  2724. executorch/exir/_serialize/generated/executorch_flatbuffer/KernelCall.py +158 -0
  2725. executorch/exir/_serialize/generated/executorch_flatbuffer/KernelTypes.py +57 -0
  2726. executorch/exir/_serialize/generated/executorch_flatbuffer/MoveCall.py +113 -0
  2727. executorch/exir/_serialize/generated/executorch_flatbuffer/NamedData.py +117 -0
  2728. executorch/exir/_serialize/generated/executorch_flatbuffer/NonConstBufferDevice.py +130 -0
  2729. executorch/exir/_serialize/generated/executorch_flatbuffer/Null.py +80 -0
  2730. executorch/exir/_serialize/generated/executorch_flatbuffer/Operator.py +120 -0
  2731. executorch/exir/_serialize/generated/executorch_flatbuffer/OptionalTensorList.py +141 -0
  2732. executorch/exir/_serialize/generated/executorch_flatbuffer/Program.py +474 -0
  2733. executorch/exir/_serialize/generated/executorch_flatbuffer/ScalarType.py +28 -0
  2734. executorch/exir/_serialize/generated/executorch_flatbuffer/String.py +100 -0
  2735. executorch/exir/_serialize/generated/executorch_flatbuffer/SubsegmentOffsets.py +158 -0
  2736. executorch/exir/_serialize/generated/executorch_flatbuffer/Tensor.py +355 -0
  2737. executorch/exir/_serialize/generated/executorch_flatbuffer/TensorDataLocation.py +7 -0
  2738. executorch/exir/_serialize/generated/executorch_flatbuffer/TensorList.py +141 -0
  2739. executorch/exir/_serialize/generated/executorch_flatbuffer/TensorShapeDynamism.py +8 -0
  2740. executorch/exir/_serialize/generated/executorch_flatbuffer/__init__.py +93 -0
  2741. executorch/exir/_serialize/padding.py +39 -0
  2742. executorch/exir/_serialize/program.fbs +551 -0
  2743. executorch/exir/_serialize/scalar_type.fbs +43 -0
  2744. executorch/exir/_serialize/test/__init__.py +0 -0
  2745. executorch/exir/_warnings.py +44 -0
  2746. executorch/exir/backend/backend_api.py +808 -0
  2747. executorch/exir/backend/backend_details.py +206 -0
  2748. executorch/exir/backend/canonical_partitioners/all_node_partitioner.py +55 -0
  2749. executorch/exir/backend/canonical_partitioners/config_partitioner.py +262 -0
  2750. executorch/exir/backend/canonical_partitioners/duplicate_constant_node_pass.py +154 -0
  2751. executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
  2752. executorch/exir/backend/canonical_partitioners/group_partitioner.py +495 -0
  2753. executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +188 -0
  2754. executorch/exir/backend/compile_spec_schema.py +17 -0
  2755. executorch/exir/backend/operator_support.py +127 -0
  2756. executorch/exir/backend/partitioner.py +139 -0
  2757. executorch/exir/backend/test/backend_with_compiler_demo.py +144 -0
  2758. executorch/exir/backend/test/backend_with_delegate_mapping_demo.py +210 -0
  2759. executorch/exir/backend/test/backend_with_named_data_map.py +115 -0
  2760. executorch/exir/backend/test/backend_with_preprocess_all_demo.py +297 -0
  2761. executorch/exir/backend/test/demo_backend.py +35 -0
  2762. executorch/exir/backend/test/demos/rpc/executor_backend_partitioner.py +77 -0
  2763. executorch/exir/backend/test/demos/rpc/executor_backend_preprocess.py +39 -0
  2764. executorch/exir/backend/test/device_util.py +112 -0
  2765. executorch/exir/backend/test/hta_partitioner_demo.py +247 -0
  2766. executorch/exir/backend/test/op_partitioner_demo.py +266 -0
  2767. executorch/exir/backend/utils.py +750 -0
  2768. executorch/exir/banked_memory_planning.py +490 -0
  2769. executorch/exir/capture/__init__.py +28 -0
  2770. executorch/exir/capture/_capture.py +381 -0
  2771. executorch/exir/capture/_config.py +140 -0
  2772. executorch/exir/capture/_unlift.py +159 -0
  2773. executorch/exir/common.py +140 -0
  2774. executorch/exir/control_flow.py +204 -0
  2775. executorch/exir/debug_handle_utils.py +29 -0
  2776. executorch/exir/delegate.py +171 -0
  2777. executorch/exir/delegate.pyi +21 -0
  2778. executorch/exir/dialects/__init__.py +0 -0
  2779. executorch/exir/dialects/_ops.py +166 -0
  2780. executorch/exir/dialects/backend/_ops.py +123 -0
  2781. executorch/exir/dialects/edge/_ops.py +405 -0
  2782. executorch/exir/dialects/edge/arg/model.py +238 -0
  2783. executorch/exir/dialects/edge/arg/type.py +46 -0
  2784. executorch/exir/dialects/edge/dtype/runner.py +122 -0
  2785. executorch/exir/dialects/edge/dtype/supported.py +49 -0
  2786. executorch/exir/dialects/edge/dtype/utils.py +36 -0
  2787. executorch/exir/dialects/edge/edge.yaml +8388 -0
  2788. executorch/exir/dialects/edge/op/api.py +86 -0
  2789. executorch/exir/dialects/edge/op/sample_input.py +1283 -0
  2790. executorch/exir/dialects/edge/spec/gen.py +523 -0
  2791. executorch/exir/dialects/edge/spec/utils.py +328 -0
  2792. executorch/exir/dim_order_utils.py +85 -0
  2793. executorch/exir/dynamic_shape.py +12 -0
  2794. executorch/exir/emit/__init__.py +11 -0
  2795. executorch/exir/emit/_emit_program.py +216 -0
  2796. executorch/exir/emit/_emitter.py +2220 -0
  2797. executorch/exir/error.py +55 -0
  2798. executorch/exir/graph.py +86 -0
  2799. executorch/exir/graph_module.py +181 -0
  2800. executorch/exir/inplace_aliasing.py +197 -0
  2801. executorch/exir/lowered_backend_module.py +1134 -0
  2802. executorch/exir/memory.py +91 -0
  2803. executorch/exir/memory_planning.py +1567 -0
  2804. executorch/exir/native/__init__.py +14 -0
  2805. executorch/exir/native/native.py +449 -0
  2806. executorch/exir/native/test/__init__.py +0 -0
  2807. executorch/exir/operator/convert.py +371 -0
  2808. executorch/exir/operator/manip.py +89 -0
  2809. executorch/exir/operator/util.py +68 -0
  2810. executorch/exir/pass_base.py +1141 -0
  2811. executorch/exir/pass_manager.py +280 -0
  2812. executorch/exir/passes/__init__.py +553 -0
  2813. executorch/exir/passes/_device_copy_ops_registry.py +58 -0
  2814. executorch/exir/passes/_quant_patterns_and_replacements.py +1564 -0
  2815. executorch/exir/passes/const_prop_pass.py +84 -0
  2816. executorch/exir/passes/constant_prop_pass.py +563 -0
  2817. executorch/exir/passes/convert_constant_dim_order_pass.py +159 -0
  2818. executorch/exir/passes/cse_pass.py +201 -0
  2819. executorch/exir/passes/debug_handle_generator_pass.py +81 -0
  2820. executorch/exir/passes/delegate_scratch_pass.py +100 -0
  2821. executorch/exir/passes/dim_order_ops_registry.py +90 -0
  2822. executorch/exir/passes/dynamic_shape_prop_pass.py +301 -0
  2823. executorch/exir/passes/executorch_prim_ops_registry.py +186 -0
  2824. executorch/exir/passes/external_constants_pass.py +113 -0
  2825. executorch/exir/passes/fold_redundant_qdq_pass.py +36 -0
  2826. executorch/exir/passes/init_mutable_pass.py +32 -0
  2827. executorch/exir/passes/insert_write_back_for_buffers_pass.py +481 -0
  2828. executorch/exir/passes/legalize_portable_dim_order_pass.py +173 -0
  2829. executorch/exir/passes/memory_format_ops_pass.py +187 -0
  2830. executorch/exir/passes/memory_planning_pass.py +372 -0
  2831. executorch/exir/passes/normalize_transpose_pass.py +24 -0
  2832. executorch/exir/passes/normalize_view_copy_base_pass.py +62 -0
  2833. executorch/exir/passes/pass_registry.py +89 -0
  2834. executorch/exir/passes/propagate_device_config.py +133 -0
  2835. executorch/exir/passes/propagate_device_pass.py +890 -0
  2836. executorch/exir/passes/prune_empty_tensors_pass.py +68 -0
  2837. executorch/exir/passes/quant_fusion_pass.py +174 -0
  2838. executorch/exir/passes/quantize_io_pass.py +414 -0
  2839. executorch/exir/passes/reinplace.py +532 -0
  2840. executorch/exir/passes/remove_graph_asserts_pass.py +62 -0
  2841. executorch/exir/passes/remove_mixed_type_operators.py +116 -0
  2842. executorch/exir/passes/remove_noop_pass.py +128 -0
  2843. executorch/exir/passes/remove_unused_parameters_pass.py +55 -0
  2844. executorch/exir/passes/replace_aten_with_edge_pass.py +59 -0
  2845. executorch/exir/passes/replace_broken_ops_with_function_ops_pass.py +42 -0
  2846. executorch/exir/passes/replace_edge_with_backend_pass.py +56 -0
  2847. executorch/exir/passes/replace_sym_size_op_pass.py +35 -0
  2848. executorch/exir/passes/replace_view_copy_with_view_pass.py +516 -0
  2849. executorch/exir/passes/scalar_to_tensor_pass.py +44 -0
  2850. executorch/exir/passes/spec_prop_pass.py +136 -0
  2851. executorch/exir/passes/sym_shape_eval_pass.py +289 -0
  2852. executorch/exir/passes/sym_to_tensor_pass.py +64 -0
  2853. executorch/exir/passes/to_device_pass.py +45 -0
  2854. executorch/exir/passes/weights_to_outputs_pass.py +88 -0
  2855. executorch/exir/print_program.py +435 -0
  2856. executorch/exir/program/__init__.py +32 -0
  2857. executorch/exir/program/_fake_program.py +67 -0
  2858. executorch/exir/program/_program.py +2056 -0
  2859. executorch/exir/program/test/__init__.py +0 -0
  2860. executorch/exir/scalar_type.py +38 -0
  2861. executorch/exir/schema.py +337 -0
  2862. executorch/exir/serde/__init__.py +0 -0
  2863. executorch/exir/serde/export_serialize.py +2897 -0
  2864. executorch/exir/serde/schema.py +418 -0
  2865. executorch/exir/serde/schema_check.py +293 -0
  2866. executorch/exir/serde/serialize.py +859 -0
  2867. executorch/exir/serde/union.py +77 -0
  2868. executorch/exir/sym_util.py +105 -0
  2869. executorch/exir/tensor.py +480 -0
  2870. executorch/exir/tensor_layout.py +39 -0
  2871. executorch/exir/tests/common.py +96 -0
  2872. executorch/exir/tests/control_flow_models.py +105 -0
  2873. executorch/exir/tests/dynamic_shape_models.py +51 -0
  2874. executorch/exir/tests/models.py +576 -0
  2875. executorch/exir/tests/test_memory_format_ops_pass_utils.py +266 -0
  2876. executorch/exir/tests/transformer.py +122 -0
  2877. executorch/exir/tracer.py +828 -0
  2878. executorch/exir/types.py +18 -0
  2879. executorch/exir/verification/arg_validator.py +148 -0
  2880. executorch/exir/verification/dev_html.py +68 -0
  2881. executorch/exir/verification/interpreter.py +425 -0
  2882. executorch/exir/verification/verifier.py +372 -0
  2883. executorch/exir/version.py +17 -0
  2884. executorch/exir/wrap.py +32 -0
  2885. executorch/export/__init__.py +40 -0
  2886. executorch/export/export.py +759 -0
  2887. executorch/export/huggingface/__init__.py +7 -0
  2888. executorch/export/huggingface/diffusers/__init__.py +11 -0
  2889. executorch/export/huggingface/diffusers/backends.py +68 -0
  2890. executorch/export/huggingface/diffusers/config.py +88 -0
  2891. executorch/export/huggingface/diffusers/export.py +296 -0
  2892. executorch/export/huggingface/diffusers/pipeline_discovery.py +109 -0
  2893. executorch/export/huggingface/diffusers/pipeline_specs/__init__.py +31 -0
  2894. executorch/export/huggingface/diffusers/pipeline_specs/_stable_diffusion.py +85 -0
  2895. executorch/export/huggingface/diffusers/pipeline_specs/base.py +118 -0
  2896. executorch/export/huggingface/diffusers/pipeline_specs/sd15.py +169 -0
  2897. executorch/export/huggingface/diffusers/pipeline_specs/sdxl.py +190 -0
  2898. executorch/export/huggingface/diffusers/wrappers.py +226 -0
  2899. executorch/export/recipe.py +721 -0
  2900. executorch/export/recipe_provider.py +60 -0
  2901. executorch/export/recipe_registry.py +86 -0
  2902. executorch/export/stages.py +932 -0
  2903. executorch/export/target_recipes.py +203 -0
  2904. executorch/export/types.py +22 -0
  2905. executorch/export/utils.py +63 -0
  2906. executorch/extension/apple/ExecuTorch/__tests__/resources/generate_coreml_test_models.py +81 -0
  2907. executorch/extension/audio/mel_spectrogram.py +332 -0
  2908. executorch/extension/diffusers/__init__.py +19 -0
  2909. executorch/extension/diffusers/metadata.py +147 -0
  2910. executorch/extension/diffusers/pipeline_behaviors/__init__.py +23 -0
  2911. executorch/extension/diffusers/pipeline_behaviors/_stable_diffusion.py +80 -0
  2912. executorch/extension/diffusers/pipeline_behaviors/base.py +147 -0
  2913. executorch/extension/diffusers/pipeline_behaviors/sd15.py +50 -0
  2914. executorch/extension/diffusers/pipeline_behaviors/sdxl.py +57 -0
  2915. executorch/extension/diffusers/runner.py +473 -0
  2916. executorch/extension/diffusers/test/__init__.py +7 -0
  2917. executorch/extension/export_util/__init__.py +13 -0
  2918. executorch/extension/export_util/utils.py +154 -0
  2919. executorch/extension/flat_tensor/__init__.py +0 -0
  2920. executorch/extension/flat_tensor/serialize/__init__.py +0 -0
  2921. executorch/extension/flat_tensor/serialize/flat_tensor.fbs +73 -0
  2922. executorch/extension/flat_tensor/serialize/flat_tensor_schema.py +34 -0
  2923. executorch/extension/flat_tensor/serialize/scalar_type.fbs +43 -0
  2924. executorch/extension/flat_tensor/serialize/serialize.py +429 -0
  2925. executorch/extension/gguf_util/convert_main.py +53 -0
  2926. executorch/extension/gguf_util/converter.py +27 -0
  2927. executorch/extension/gguf_util/converters/llama_converter.py +123 -0
  2928. executorch/extension/gguf_util/load_gguf.py +103 -0
  2929. executorch/extension/image/benchmark/compare_benchmarks.py +122 -0
  2930. executorch/extension/llm/batching/sampler.py +118 -0
  2931. executorch/extension/llm/cache/__init__.py +0 -0
  2932. executorch/extension/llm/cache/reference_cache.py +871 -0
  2933. executorch/extension/llm/cache/test_update_and_attend.py +1186 -0
  2934. executorch/extension/llm/cache/update_and_attend.py +120 -0
  2935. executorch/extension/llm/custom_ops/__init__.py +0 -0
  2936. executorch/extension/llm/custom_ops/bench_gated_delta_rule.py +104 -0
  2937. executorch/extension/llm/custom_ops/custom_ops.py +695 -0
  2938. executorch/extension/llm/custom_ops/custom_ops_aot_lib.dll +0 -0
  2939. executorch/extension/llm/custom_ops/model_sharding.py +130 -0
  2940. executorch/extension/llm/custom_ops/op_fallback.py +29 -0
  2941. executorch/extension/llm/custom_ops/op_tile_crop_aot.py +54 -0
  2942. executorch/extension/llm/custom_ops/preprocess_custom_ops.py +69 -0
  2943. executorch/extension/llm/custom_ops/spinquant/special_hadamard_code_gen.py +279 -0
  2944. executorch/extension/llm/custom_ops/test_gated_delta.py +574 -0
  2945. executorch/extension/llm/custom_ops/test_preprocess_custom_ops.py +34 -0
  2946. executorch/extension/llm/custom_ops/test_quantized_moe.py +705 -0
  2947. executorch/extension/llm/custom_ops/test_quantized_sdpa.py +550 -0
  2948. executorch/extension/llm/custom_ops/test_sdpa_with_kv_cache.py +685 -0
  2949. executorch/extension/llm/custom_ops/test_update_cache.py +433 -0
  2950. executorch/extension/llm/custom_ops/test_update_cross_attn_cache.py +286 -0
  2951. executorch/extension/llm/export/__init__.py +29 -0
  2952. executorch/extension/llm/export/builder.py +600 -0
  2953. executorch/extension/llm/export/config/llm_config.py +973 -0
  2954. executorch/extension/llm/export/export_llm.py +106 -0
  2955. executorch/extension/llm/export/export_passes.py +202 -0
  2956. executorch/extension/llm/export/gguf.py +577 -0
  2957. executorch/extension/llm/export/int4.py +193 -0
  2958. executorch/extension/llm/export/load.py +329 -0
  2959. executorch/extension/llm/export/model_metadata.py +118 -0
  2960. executorch/extension/llm/export/mx.py +244 -0
  2961. executorch/extension/llm/export/nvfp4.py +213 -0
  2962. executorch/extension/llm/export/partitioner_lib.py +289 -0
  2963. executorch/extension/llm/export/quant/__init__.py +20 -0
  2964. executorch/extension/llm/export/quant/convert.py +247 -0
  2965. executorch/extension/llm/export/quant/quantize.py +386 -0
  2966. executorch/extension/llm/export/quant/recipe.py +62 -0
  2967. executorch/extension/llm/export/quantize.py +286 -0
  2968. executorch/extension/llm/export/quantizer_lib.py +443 -0
  2969. executorch/extension/llm/export/test/__init__.py +0 -0
  2970. executorch/extension/llm/export/test/test_gguf.py +409 -0
  2971. executorch/extension/llm/export/test_export_passes.py +209 -0
  2972. executorch/extension/llm/modules/__init__.py +24 -0
  2973. executorch/extension/llm/modules/_position_embeddings.py +729 -0
  2974. executorch/extension/llm/modules/attention.py +413 -0
  2975. executorch/extension/llm/modules/kv_cache.py +151 -0
  2976. executorch/extension/llm/modules/test/__init__.py +0 -0
  2977. executorch/extension/llm/modules/turboquant/__init__.py +11 -0
  2978. executorch/extension/llm/modules/turboquant/codebook.py +124 -0
  2979. executorch/extension/llm/modules/turboquant/kv_cache.py +170 -0
  2980. executorch/extension/llm/runner/__init__.py +267 -0
  2981. executorch/extension/llm/runner/_llm_runner.pyi +606 -0
  2982. executorch/extension/pybindings/_C.cp315-win_amd64.pyd +0 -0
  2983. executorch/extension/pybindings/_C.pyi +486 -0
  2984. executorch/extension/pybindings/data_loader.cp315-win_amd64.pyd +0 -0
  2985. executorch/extension/pybindings/data_loader.pyi +12 -0
  2986. executorch/extension/pybindings/portable_lib.py +159 -0
  2987. executorch/extension/pybindings/py.typed +0 -0
  2988. executorch/extension/pybindings/pybindings.pyi +486 -0
  2989. executorch/extension/pybindings/test/make_test.py +237 -0
  2990. executorch/extension/pybindings/test/test_pybindings.py +4062 -0
  2991. executorch/extension/pytree/__init__.py +54 -0
  2992. executorch/extension/training/__init__.py +22 -0
  2993. executorch/extension/training/examples/CIFAR/data_utils.py +389 -0
  2994. executorch/extension/training/examples/CIFAR/export.py +220 -0
  2995. executorch/extension/training/examples/CIFAR/main.py +188 -0
  2996. executorch/extension/training/examples/CIFAR/model.py +73 -0
  2997. executorch/extension/training/examples/CIFAR/train_utils.py +622 -0
  2998. executorch/extension/training/examples/XOR/export_model.py +77 -0
  2999. executorch/extension/training/examples/XOR/model.py +34 -0
  3000. executorch/extension/training/pybindings/_training_lib.pyi +45 -0
  3001. executorch/extension/training/pybindings/_training_module.py +86 -0
  3002. executorch/include/executorch/devtools/etdump/data_sinks/buffer_data_sink.h +127 -0
  3003. executorch/include/executorch/devtools/etdump/data_sinks/data_sink_base.h +61 -0
  3004. executorch/include/executorch/devtools/etdump/data_sinks/file_data_sink.h +95 -0
  3005. executorch/include/executorch/devtools/etdump/emitter.h +28 -0
  3006. executorch/include/executorch/devtools/etdump/etdump_flatcc.h +213 -0
  3007. executorch/include/executorch/devtools/etdump/utils.h +39 -0
  3008. executorch/include/executorch/extension/data_loader/buffer_data_loader.h +89 -0
  3009. executorch/include/executorch/extension/data_loader/file_data_loader.h +114 -0
  3010. executorch/include/executorch/extension/data_loader/mman.h +140 -0
  3011. executorch/include/executorch/extension/data_loader/mman_windows.h +75 -0
  3012. executorch/include/executorch/extension/data_loader/mmap_data_loader.h +149 -0
  3013. executorch/include/executorch/extension/data_loader/shared_ptr_data_loader.h +89 -0
  3014. executorch/include/executorch/extension/flat_tensor/flat_tensor_data_map.h +142 -0
  3015. executorch/include/executorch/extension/flat_tensor/serialize/flat_tensor_header.h +90 -0
  3016. executorch/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +260 -0
  3017. executorch/include/executorch/extension/kernel_util/meta_programming.h +119 -0
  3018. executorch/include/executorch/extension/kernel_util/type_list.h +145 -0
  3019. executorch/include/executorch/extension/memory_allocator/malloc_memory_allocator.h +94 -0
  3020. executorch/include/executorch/extension/memory_allocator/memory_allocator_utils.h +39 -0
  3021. executorch/include/executorch/extension/module/module.h +810 -0
  3022. executorch/include/executorch/extension/module/ptn_module.h +109 -0
  3023. executorch/include/executorch/extension/named_data_map/merged_data_map.h +118 -0
  3024. executorch/include/executorch/extension/tensor/tensor.h +14 -0
  3025. executorch/include/executorch/extension/tensor/tensor_accessor.h +218 -0
  3026. executorch/include/executorch/extension/tensor/tensor_ptr.h +650 -0
  3027. executorch/include/executorch/extension/tensor/tensor_ptr_maker.h +811 -0
  3028. executorch/include/executorch/extension/threadpool/threadpool_guard.h +37 -0
  3029. executorch/include/executorch/runtime/backend/backend_execution_context.h +107 -0
  3030. executorch/include/executorch/runtime/backend/backend_init_context.h +149 -0
  3031. executorch/include/executorch/runtime/backend/backend_option_context.h +34 -0
  3032. executorch/include/executorch/runtime/backend/backend_options_map.h +229 -0
  3033. executorch/include/executorch/runtime/backend/interface.h +238 -0
  3034. executorch/include/executorch/runtime/backend/options.h +208 -0
  3035. executorch/include/executorch/runtime/core/array_ref.h +264 -0
  3036. executorch/include/executorch/runtime/core/data_loader.h +206 -0
  3037. executorch/include/executorch/runtime/core/defines.h +20 -0
  3038. executorch/include/executorch/runtime/core/device_allocator.h +215 -0
  3039. executorch/include/executorch/runtime/core/device_memory_buffer.h +129 -0
  3040. executorch/include/executorch/runtime/core/error.h +264 -0
  3041. executorch/include/executorch/runtime/core/evalue.h +877 -0
  3042. executorch/include/executorch/runtime/core/event_tracer.h +592 -0
  3043. executorch/include/executorch/runtime/core/event_tracer_hooks.h +340 -0
  3044. executorch/include/executorch/runtime/core/event_tracer_hooks_delegate.h +204 -0
  3045. executorch/include/executorch/runtime/core/exec_aten/exec_aten.h +208 -0
  3046. executorch/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +290 -0
  3047. executorch/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1430 -0
  3048. executorch/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +23 -0
  3049. executorch/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +68 -0
  3050. executorch/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1428 -0
  3051. executorch/include/executorch/runtime/core/freeable_buffer.h +281 -0
  3052. executorch/include/executorch/runtime/core/function_ref.h +108 -0
  3053. executorch/include/executorch/runtime/core/hierarchical_allocator.h +167 -0
  3054. executorch/include/executorch/runtime/core/memory_allocator.h +249 -0
  3055. executorch/include/executorch/runtime/core/named_data_map.h +76 -0
  3056. executorch/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  3057. executorch/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  3058. executorch/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
  3059. executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +1 -0
  3060. executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +1 -0
  3061. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -0
  3062. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +3 -0
  3063. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +1 -0
  3064. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +1 -0
  3065. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +8 -0
  3066. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +1 -0
  3067. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -0
  3068. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +73 -0
  3069. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +441 -0
  3070. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +1 -0
  3071. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +3 -0
  3072. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +906 -0
  3073. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +11 -0
  3074. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +112 -0
  3075. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +145 -0
  3076. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +830 -0
  3077. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16-math.h +337 -0
  3078. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +481 -0
  3079. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/Half.h +788 -0
  3080. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/TypeSafeSignMath.h +100 -0
  3081. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/bit_cast.h +50 -0
  3082. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex.h +676 -0
  3083. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex_utils.h +48 -0
  3084. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/floating_point_utils.h +38 -0
  3085. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/irange.h +137 -0
  3086. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/overflows.h +120 -0
  3087. executorch/include/executorch/runtime/core/portable_type/complex.h +21 -0
  3088. executorch/include/executorch/runtime/core/portable_type/device.h +85 -0
  3089. executorch/include/executorch/runtime/core/portable_type/half.h +27 -0
  3090. executorch/include/executorch/runtime/core/portable_type/optional.h +37 -0
  3091. executorch/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
  3092. executorch/include/executorch/runtime/core/portable_type/scalar.h +123 -0
  3093. executorch/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  3094. executorch/include/executorch/runtime/core/portable_type/string_view.h +31 -0
  3095. executorch/include/executorch/runtime/core/portable_type/tensor.h +190 -0
  3096. executorch/include/executorch/runtime/core/portable_type/tensor_impl.h +345 -0
  3097. executorch/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  3098. executorch/include/executorch/runtime/core/result.h +333 -0
  3099. executorch/include/executorch/runtime/core/span.h +110 -0
  3100. executorch/include/executorch/runtime/core/tag.h +90 -0
  3101. executorch/include/executorch/runtime/core/tensor_layout.h +93 -0
  3102. executorch/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  3103. executorch/include/executorch/runtime/executor/memory_manager.h +149 -0
  3104. executorch/include/executorch/runtime/executor/merged_data_map.h +150 -0
  3105. executorch/include/executorch/runtime/executor/method.h +466 -0
  3106. executorch/include/executorch/runtime/executor/method_meta.h +338 -0
  3107. executorch/include/executorch/runtime/executor/platform_memory_allocator.h +125 -0
  3108. executorch/include/executorch/runtime/executor/program.h +365 -0
  3109. executorch/include/executorch/runtime/executor/program_validation.h +51 -0
  3110. executorch/include/executorch/runtime/executor/pte_data_map.h +151 -0
  3111. executorch/include/executorch/runtime/kernel/kernel_includes.h +62 -0
  3112. executorch/include/executorch/runtime/kernel/kernel_runtime_context.h +131 -0
  3113. executorch/include/executorch/runtime/kernel/operator_registry.h +308 -0
  3114. executorch/include/executorch/runtime/kernel/thread_parallel_interface.h +121 -0
  3115. executorch/include/executorch/runtime/platform/abort.h +36 -0
  3116. executorch/include/executorch/runtime/platform/assert.h +124 -0
  3117. executorch/include/executorch/runtime/platform/clock.h +43 -0
  3118. executorch/include/executorch/runtime/platform/compat_unistd.h +75 -0
  3119. executorch/include/executorch/runtime/platform/compiler.h +254 -0
  3120. executorch/include/executorch/runtime/platform/log.h +216 -0
  3121. executorch/include/executorch/runtime/platform/platform.h +276 -0
  3122. executorch/include/executorch/runtime/platform/profiler.h +293 -0
  3123. executorch/include/executorch/runtime/platform/runtime.h +35 -0
  3124. executorch/include/executorch/runtime/platform/system.h +49 -0
  3125. executorch/include/executorch/runtime/platform/types.h +24 -0
  3126. executorch/kernels/portable/__init__.py +26 -0
  3127. executorch/kernels/portable/custom_ops.yaml +32 -0
  3128. executorch/kernels/portable/et_copy_ops.yaml +16 -0
  3129. executorch/kernels/portable/functions.yaml +1096 -0
  3130. executorch/kernels/portable/test/supported_features_def.yaml +1 -0
  3131. executorch/kernels/quantized/__init__.py +36 -0
  3132. executorch/kernels/quantized/quantized.yaml +113 -0
  3133. executorch/kernels/quantized/quantized_ops_aot_lib.dll +0 -0
  3134. executorch/kernels/quantized/test/supported_features_def.yaml +1 -0
  3135. executorch/lib/cmake/executorch/executorch-config-version.cmake +60 -0
  3136. executorch/lib/cmake/executorch/executorch-config.cmake +1056 -0
  3137. executorch/lib/executorch.dll +0 -0
  3138. executorch/lib/executorch.lib +0 -0
  3139. executorch/lib/executorch_backend_openvino.dll +0 -0
  3140. executorch/lib/executorch_backend_openvino.lib +0 -0
  3141. executorch/lib/executorch_backend_xnnpack.dll +0 -0
  3142. executorch/lib/executorch_backend_xnnpack.lib +0 -0
  3143. executorch/lib/executorch_etdump.dll +0 -0
  3144. executorch/lib/executorch_kernels_optimized.dll +0 -0
  3145. executorch/lib/executorch_kernels_optimized.lib +0 -0
  3146. executorch/lib/executorch_kernels_quantized.dll +0 -0
  3147. executorch/lib/executorch_kernels_quantized.lib +0 -0
  3148. executorch/lib/executorch_threadpool.dll +0 -0
  3149. executorch/lib/executorch_threadpool.lib +0 -0
  3150. executorch/runtime/__init__.py +390 -0
  3151. executorch/runtime/cuda.py +222 -0
  3152. executorch/runtime/kernel/test/functions.yaml +13 -0
  3153. executorch/schema/program.fbs +551 -0
  3154. executorch/schema/scalar_type.fbs +43 -0
  3155. executorch/share/cmake/executorch-config-version.cmake +60 -0
  3156. executorch/share/cmake/executorch-config.cmake +1056 -0
  3157. executorch/util/activation_memory_profiler.py +177 -0
  3158. executorch/util/collect_env.py +748 -0
  3159. executorch/util/python_profiler.py +96 -0
  3160. executorch/version.py +4 -0
  3161. executorch-1.6.0.dist-info/METADATA +123 -0
  3162. executorch-1.6.0.dist-info/RECORD +3166 -0
  3163. executorch-1.6.0.dist-info/WHEEL +5 -0
  3164. executorch-1.6.0.dist-info/entry_points.txt +2 -0
  3165. executorch-1.6.0.dist-info/licenses/LICENSE +37 -0
  3166. executorch-1.6.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3269 @@
1
+ # Copyright 2026 Arm Limited and/or its affiliates.
2
+ #
3
+ # This source code is licensed under the BSD-style license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+ """Generate Arm backend PyTorch operator-support documentation.
6
+
7
+ The implementation is shared by all configured backends. The selected backend
8
+ controls the test pipeline, TOSA profile, output path, infrastructure xfails and
9
+ backend-specific registry filtering. Run from the ExecuTorch repository root.
10
+
11
+ Examples:
12
+ python backends/arm/scripts/docgen/generate_op_support.py --backend all
13
+ python backends/arm/scripts/docgen/generate_op_support.py --backend vgf
14
+ python backends/arm/scripts/docgen/generate_op_support.py --backend u55
15
+ python backends/arm/scripts/docgen/generate_op_support.py --backend u85
16
+ python backends/arm/scripts/docgen/generate_op_support.py --backend u55 --debug --html
17
+ python backends/arm/scripts/docgen/generate_op_support.py --backend all --check
18
+ python backends/arm/scripts/docgen/generate_op_support.py --backend vgf --check --strict-ast
19
+
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import ast
26
+ import html
27
+ import logging
28
+ import operator
29
+ import re
30
+ import sys
31
+
32
+ from dataclasses import dataclass, field
33
+ from pathlib import Path
34
+ from typing import cast, Iterable, Mapping, Protocol, Sequence
35
+
36
+ import torch
37
+
38
+
39
+ # ---------------------------------------------------------------------------
40
+ # Backend-specific configuration.
41
+ #
42
+ # The AST scanner, registry checker, Markdown/HTML renderers and CLI behavior
43
+ # below are shared. Backend differences belong in BackendConfig.
44
+ # ---------------------------------------------------------------------------
45
+ BACKEND_NAME = "VGF"
46
+ BACKEND_PIPELINE_CLASS_NAMES = frozenset({"VgfPipeline"})
47
+ BACKEND_PIPELINE_LABEL = "VgfPipeline"
48
+ BACKEND_TOSA_SPEC = "TOSA-1.0+FP+INT+int4+int16"
49
+ BACKEND_PROFILE_TOSA_SPECS = {
50
+ "FP": "TOSA-1.0+FP",
51
+ "INT": "TOSA-1.0+INT",
52
+ }
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class BackendConfig:
57
+ key: str
58
+ name: str
59
+ pipeline_class_names: frozenset[str]
60
+ pipeline_label: str
61
+ tosa_spec: str
62
+ default_output: Path
63
+ quantize_keyword: str | None
64
+ quantize_default: bool
65
+ default_profile: str
66
+ aten_op_position: int = 2
67
+ aten_op_keywords: tuple[str, ...] = ("aten_op", "aten_ops")
68
+ exir_op_position: int = 3
69
+ exir_op_keywords: tuple[str, ...] = ("exir_op", "exir_ops")
70
+ support_profile_order: tuple[str, ...] = ("FP", "INT")
71
+ infrastructure_xfail_markers: frozenset[str] = frozenset()
72
+ filter_u55_unsupported_ops: bool = False
73
+ max_missing_profile_cells: int = 0
74
+
75
+
76
+ GENERATOR_PATH = Path("backends/arm/scripts/docgen/generate_op_support.py")
77
+ TEST_ROOT = Path("backends/arm/test")
78
+ DEFAULT_BACKEND_KEY = "vgf"
79
+ ALL_BACKENDS_KEY = "all"
80
+
81
+ BACKENDS: dict[str, BackendConfig] = {
82
+ "vgf": BackendConfig(
83
+ key="vgf",
84
+ name="VGF",
85
+ pipeline_class_names=frozenset({"VgfPipeline"}),
86
+ pipeline_label="VgfPipeline",
87
+ tosa_spec="TOSA-1.0+FP+INT+int4+int16",
88
+ default_output=Path("docs/source/backends/arm-vgf/VGF_op_support.md"),
89
+ quantize_keyword="quantize",
90
+ quantize_default=True,
91
+ default_profile="INT",
92
+ support_profile_order=("FP", "INT"),
93
+ ),
94
+ "u55": BackendConfig(
95
+ key="u55",
96
+ name="Ethos-U55",
97
+ pipeline_class_names=frozenset({"EthosU55PipelineINT"}),
98
+ pipeline_label="EthosU55PipelineINT",
99
+ tosa_spec="TOSA-1.0+INT+int16+int4+u55",
100
+ default_output=Path("docs/source/backends/arm-ethos-u/U55_op_support.md"),
101
+ quantize_keyword=None,
102
+ quantize_default=True,
103
+ default_profile="INT",
104
+ support_profile_order=("INT",),
105
+ # These xfails mean the FVP/executor is unavailable, not that the
106
+ # operator is unsupported. They should still count as static evidence.
107
+ infrastructure_xfail_markers=frozenset({"XfailIfNoCorstone300"}),
108
+ filter_u55_unsupported_ops=True,
109
+ max_missing_profile_cells=0,
110
+ ),
111
+ "u85": BackendConfig(
112
+ key="u85",
113
+ name="Ethos-U85",
114
+ pipeline_class_names=frozenset({"EthosU85PipelineINT"}),
115
+ pipeline_label="EthosU85PipelineINT",
116
+ tosa_spec="TOSA-1.0+INT+int16+int4+cf",
117
+ default_output=Path("docs/source/backends/arm-ethos-u/U85_op_support.md"),
118
+ quantize_keyword=None,
119
+ quantize_default=True,
120
+ default_profile="INT",
121
+ support_profile_order=("INT",),
122
+ # A missing Corstone-320 FVP is infrastructure, not evidence that the
123
+ # operator itself is unsupported.
124
+ infrastructure_xfail_markers=frozenset({"XfailIfNoCorstone320"}),
125
+ max_missing_profile_cells=0,
126
+ ),
127
+ }
128
+
129
+ # Compatibility globals used by the mature scanner implementation. They are
130
+ # populated from exactly one BackendConfig by _activate_backend().
131
+ ACTIVE_BACKEND_KEY: str
132
+ BACKEND_NAME: str # type: ignore[no-redef]
133
+ BACKEND_PIPELINE_CLASS_NAMES: frozenset[str] # type: ignore[no-redef]
134
+ BACKEND_PIPELINE_LABEL: str # type: ignore[no-redef]
135
+ BACKEND_TOSA_SPEC: str # type: ignore[no-redef]
136
+ DEFAULT_OUTPUT: Path
137
+ PIPELINE_QUANTIZE_KEYWORD: str | None
138
+ PIPELINE_QUANTIZE_DEFAULT: bool
139
+ PIPELINE_DEFAULT_PROFILE: str
140
+ PIPELINE_ATEN_OP_POSITION: int
141
+ PIPELINE_ATEN_OP_KEYWORDS: tuple[str, ...]
142
+ PIPELINE_EXIR_OP_POSITION: int
143
+ PIPELINE_EXIR_OP_KEYWORDS: tuple[str, ...]
144
+ BACKEND_INFRASTRUCTURE_XFAIL_MARKERS: frozenset[str]
145
+ BACKEND_FILTER_U55_UNSUPPORTED_OPS: bool
146
+ BACKEND_MAX_MISSING_PROFILE_CELLS: int
147
+ SUPPORT_PROFILE_ORDER: list[str]
148
+ GENERATOR_COMMAND: str
149
+ PAGE_TITLE: str
150
+ PAGE_DESCRIPTION: str
151
+ MARKDOWN_DEBUG_NOTE: str
152
+ HTML_DEBUG_NOTE: str
153
+ CLI_DESCRIPTION: str
154
+
155
+
156
+ def _activate_backend(backend: str | BackendConfig) -> BackendConfig:
157
+ """Activate one BackendConfig for the shared implementation."""
158
+
159
+ config = BACKENDS[backend] if isinstance(backend, str) else backend
160
+
161
+ global ACTIVE_BACKEND_KEY
162
+ global BACKEND_NAME
163
+ global BACKEND_PIPELINE_CLASS_NAMES
164
+ global BACKEND_PIPELINE_LABEL
165
+ global BACKEND_TOSA_SPEC
166
+ global DEFAULT_OUTPUT
167
+ global PIPELINE_QUANTIZE_KEYWORD
168
+ global PIPELINE_QUANTIZE_DEFAULT
169
+ global PIPELINE_DEFAULT_PROFILE
170
+ global PIPELINE_ATEN_OP_POSITION
171
+ global PIPELINE_ATEN_OP_KEYWORDS
172
+ global PIPELINE_EXIR_OP_POSITION
173
+ global PIPELINE_EXIR_OP_KEYWORDS
174
+ global BACKEND_INFRASTRUCTURE_XFAIL_MARKERS
175
+ global BACKEND_FILTER_U55_UNSUPPORTED_OPS
176
+ global BACKEND_MAX_MISSING_PROFILE_CELLS
177
+ global SUPPORT_PROFILE_ORDER
178
+ global GENERATOR_COMMAND
179
+ global PAGE_TITLE
180
+ global PAGE_DESCRIPTION
181
+ global MARKDOWN_DEBUG_NOTE
182
+ global HTML_DEBUG_NOTE
183
+ global CLI_DESCRIPTION
184
+
185
+ ACTIVE_BACKEND_KEY = config.key
186
+ BACKEND_NAME = config.name
187
+ BACKEND_PIPELINE_CLASS_NAMES = config.pipeline_class_names
188
+ BACKEND_PIPELINE_LABEL = config.pipeline_label
189
+ BACKEND_TOSA_SPEC = config.tosa_spec
190
+ DEFAULT_OUTPUT = config.default_output
191
+ PIPELINE_QUANTIZE_KEYWORD = config.quantize_keyword
192
+ PIPELINE_QUANTIZE_DEFAULT = config.quantize_default
193
+ PIPELINE_DEFAULT_PROFILE = config.default_profile
194
+ PIPELINE_ATEN_OP_POSITION = config.aten_op_position
195
+ PIPELINE_ATEN_OP_KEYWORDS = config.aten_op_keywords
196
+ PIPELINE_EXIR_OP_POSITION = config.exir_op_position
197
+ PIPELINE_EXIR_OP_KEYWORDS = config.exir_op_keywords
198
+ BACKEND_INFRASTRUCTURE_XFAIL_MARKERS = config.infrastructure_xfail_markers
199
+ BACKEND_FILTER_U55_UNSUPPORTED_OPS = config.filter_u55_unsupported_ops
200
+ BACKEND_MAX_MISSING_PROFILE_CELLS = config.max_missing_profile_cells
201
+ SUPPORT_PROFILE_ORDER = list(config.support_profile_order)
202
+
203
+ GENERATOR_COMMAND = f"python {GENERATOR_PATH} --backend {config.key}"
204
+ PAGE_TITLE = f"PyTorch operator support for the {BACKEND_NAME} backend"
205
+ PAGE_DESCRIPTION = (
206
+ f"This page lists {BACKEND_NAME}-supported PyTorch APIs and the dtype and "
207
+ f"quantization modes covered by the {BACKEND_NAME} backend test pipeline."
208
+ )
209
+ MARKDOWN_DEBUG_NOTE = (
210
+ f"Debug mode adds the exact exported ATen operator and the {BACKEND_NAME} "
211
+ "test functions that contributed each row. Do not publish this version as "
212
+ "the customer-facing page."
213
+ )
214
+ HTML_DEBUG_NOTE = (
215
+ "Debug mode. This page includes the exact exported ATen operator and the "
216
+ f"{BACKEND_NAME} test functions that contributed each row. Do not publish "
217
+ "it as the customer-facing page."
218
+ )
219
+ CLI_DESCRIPTION = (
220
+ f"Generate {BACKEND_NAME} PyTorch operator-support documentation from "
221
+ f"{BACKEND_PIPELINE_LABEL} tests."
222
+ )
223
+ return config
224
+
225
+
226
+ _activate_backend(DEFAULT_BACKEND_KEY)
227
+
228
+
229
+ DTYPE_ORDER = [
230
+ "FP32",
231
+ "FP16",
232
+ "BF16",
233
+ "FP8E4M3",
234
+ "FP8E5M2",
235
+ "INT8",
236
+ "INT16",
237
+ "INT4",
238
+ "INT32",
239
+ "BOOL",
240
+ ]
241
+ QUANTIZATION_MODE_ORDER = ["8x8", "8x4", "16x8"]
242
+
243
+ EDGE_OP_ALIASES = {
244
+ "__lshift__.Scalar": "bitwise_left_shift.Scalar",
245
+ "__rshift__.Scalar": "bitwise_right_shift.Scalar",
246
+ "_adaptive_avg_pool2d.default": "adaptive_avg_pool2d.default",
247
+ }
248
+
249
+ # Exact normalisation overrides. Overload-less ATen names are not assumed to
250
+ # use the default overload unless listed here.
251
+ OVERLOADLESS_OP_ALIASES: dict[str, str] = {
252
+ "torch.ops.aten.amax": "torch.ops.aten.amax.default",
253
+ "torch.ops.aten.amin": "torch.ops.aten.amin.default",
254
+ }
255
+
256
+ # Generated EdgeIR spellings are not always reversible by splitting on
257
+ # underscores. Check exact aliases before the generic conversion.
258
+ GENERATED_EDGE_OP_ALIASES: dict[str, str] = {
259
+ "slice_copy": "slice_copy.Tensor",
260
+ "masked_fill_scalar": "masked_fill.Scalar",
261
+ }
262
+
263
+ # File-specific overload aliases are used only where the test intentionally
264
+ # stores an overload-less operator constant.
265
+ CONTEXTUAL_OVERLOAD_ALIASES: dict[tuple[str, str], str] = {
266
+ (
267
+ "backends/arm/test/ops/test_amax.py",
268
+ "torch.ops.aten.max",
269
+ ): "torch.ops.aten.max.dim",
270
+ (
271
+ "backends/arm/test/ops/test_amin.py",
272
+ "torch.ops.aten.min",
273
+ ): "torch.ops.aten.min.dim",
274
+ }
275
+
276
+ SOURCE_ATEN = "ATen export"
277
+ EDGE_IR = "EdgeIR"
278
+ LOWERED = "lowered"
279
+ RUNTIME_ONLY = "runtime-only"
280
+
281
+ DIRECT = "direct"
282
+ STAGE_EQUIVALENT = "stage-equivalent"
283
+ DECOMPOSED = "decomposed"
284
+ TRANSFORM_ONLY = "transform-only"
285
+ EXPLICIT = "explicit"
286
+ INFERRED = "inferred"
287
+
288
+ # Registry targets and test assertions can describe different graph stages.
289
+ # The key is the backend registry target; values are equivalent ATen/Edge names
290
+ # that count as coverage for the same public operation.
291
+ STAGE_EQUIVALENT_OPS: dict[str, set[str]] = {
292
+ "torch.ops.aten.convolution.default": {"torch.ops.aten.conv2d.default"},
293
+ "torch.ops.aten._native_batch_norm_legit_no_training.default": {
294
+ "torch.ops.aten.batch_norm.default"
295
+ },
296
+ "torch.ops.aten.constant_pad_nd.default": {"torch.ops.aten.pad.default"},
297
+ "torch.ops.aten.native_group_norm.default": {"torch.ops.aten.group_norm.default"},
298
+ "torch.ops.aten.native_layer_norm.default": {"torch.ops.aten.layer_norm.default"},
299
+ "torch.ops.aten.max_pool2d_with_indices.default": {
300
+ "torch.ops.aten.max_pool2d.default"
301
+ },
302
+ "torch.ops.aten.squeeze_copy.dims": {
303
+ "torch.ops.aten.squeeze.default",
304
+ "torch.ops.aten.squeeze.dim",
305
+ "torch.ops.aten.squeeze.dims",
306
+ },
307
+ "torch.ops.aten.copy.default": {"torch.ops.aten.copy_.default"},
308
+ "torch.ops.aten._softmax.default": {
309
+ "torch.ops.aten.softmax.default",
310
+ "torch.ops.aten.softmax.int",
311
+ },
312
+ "torch.ops.aten._log_softmax.default": {
313
+ "torch.ops.aten.log_softmax.default",
314
+ "torch.ops.aten.log_softmax.int",
315
+ },
316
+ "torch.ops.aten.adaptive_avg_pool2d.default": {"torch.ops.aten.avg_pool2d.default"},
317
+ "torch.ops.aten.slice_copy.Tensor": {"torch.ops.aten.slice.Tensor"},
318
+ "torch.ops.aten.expand_copy.default": {"torch.ops.aten.expand.default"},
319
+ "torch.ops.aten.view_copy.default": {"torch.ops.aten.view.default"},
320
+ "torch.ops.aten.unsqueeze_copy.default": {"torch.ops.aten.unsqueeze.default"},
321
+ }
322
+
323
+ # Quantization can change overloads or decompose a public operator into a
324
+ # different ATen operator. These rules are deliberately profile-specific.
325
+ PROFILE_STAGE_EQUIVALENT_OPS: dict[tuple[str, str], set[str]] = {
326
+ ("torch.ops.aten.bitwise_and.Scalar", "INT"): {"torch.ops.aten.bitwise_and.Tensor"},
327
+ ("torch.ops.aten.bitwise_or.Scalar", "INT"): {"torch.ops.aten.bitwise_or.Tensor"},
328
+ ("torch.ops.aten.bitwise_xor.Scalar", "INT"): {"torch.ops.aten.bitwise_xor.Tensor"},
329
+ ("torch.ops.aten.bitwise_left_shift.Scalar", "INT"): {
330
+ "torch.ops.aten.bitwise_left_shift.Tensor"
331
+ },
332
+ ("torch.ops.aten.bitwise_right_shift.Scalar", "INT"): {
333
+ "torch.ops.aten.bitwise_right_shift.Tensor"
334
+ },
335
+ ("torch.ops.aten.eq.Scalar", "INT"): {"torch.ops.aten.eq.Tensor"},
336
+ ("torch.ops.aten.ge.Scalar", "INT"): {"torch.ops.aten.ge.Tensor"},
337
+ ("torch.ops.aten.gt.Scalar", "INT"): {"torch.ops.aten.gt.Tensor"},
338
+ ("torch.ops.aten.le.Scalar", "INT"): {"torch.ops.aten.le.Tensor"},
339
+ ("torch.ops.aten.lt.Scalar", "INT"): {"torch.ops.aten.lt.Tensor"},
340
+ ("torch.ops.aten.celu.default", "INT"): {"torch.ops.aten.elu.default"},
341
+ ("torch.ops.aten.selu.default", "INT"): {"torch.ops.aten.elu.default"},
342
+ }
343
+
344
+ # These operators are accepted by partitioning but removed or rewritten before
345
+ # backend lowering. They require transformation-path coverage, not a direct backend
346
+ # lowering test for every support profile.
347
+ TRANSFORM_ONLY_OPS = {
348
+ "torch.ops.aten.alias_copy.default",
349
+ "torch.ops.aten.copy.default",
350
+ "torch.ops.aten.detach_copy.default",
351
+ }
352
+
353
+ # These public operations are intentionally decomposed before backend lowering.
354
+ DECOMPOSED_OPS = {
355
+ "torch.ops.aten._softmax.default",
356
+ "torch.ops.aten._log_softmax.default",
357
+ "torch.ops.aten.split_with_sizes_copy.default",
358
+ "torch.ops.aten.native_group_norm.default",
359
+ "torch.ops.aten.native_layer_norm.default",
360
+ "torch.ops.aten.embedding.default",
361
+ "torch.ops.aten.pow.Tensor_Tensor",
362
+ "torch.ops.aten.scaled_dot_product_attention.default",
363
+ "torch.ops.aten.adaptive_avg_pool1d.default",
364
+ "torch.ops.aten.linalg_vector_norm.default",
365
+ }
366
+
367
+
368
+ # Tests that intentionally suppress ATen/Edge distribution assertions still
369
+ # provide runtime coverage. The key is (relative path, test function).
370
+ VGF_EXPLICIT_BACKEND_COVERAGE: dict[tuple[str, str], dict[str, set[str]]] = {
371
+ (
372
+ "backends/arm/test/ops/test_div_tensor_mode.py",
373
+ "test_div_tensor_mode_vgf_quant",
374
+ ): {
375
+ "INT": {"torch.ops.aten.div.Tensor_mode"},
376
+ },
377
+ (
378
+ "backends/arm/test/ops/test_masked_fill.py",
379
+ "test_masked_fill_scalar_vgf_no_quant",
380
+ ): {
381
+ "FP": {"torch.ops.aten.masked_fill.Scalar"},
382
+ },
383
+ (
384
+ "backends/arm/test/ops/test_masked_fill.py",
385
+ "test_masked_fill_scalar_vgf_quant",
386
+ ): {
387
+ "INT": {"torch.ops.aten.masked_fill.Scalar"},
388
+ },
389
+ ("backends/arm/test/ops/test_silu.py", "test_silu_vgf_quant"): {
390
+ "INT": {"torch.ops.aten.silu.default"},
391
+ },
392
+ ("backends/arm/test/ops/test_remainder.py", "test_remainder_tensor_vgf_quant"): {
393
+ "INT": {"torch.ops.aten.remainder.Tensor"},
394
+ },
395
+ ("backends/arm/test/ops/test_remainder.py", "test_remainder_scalar_vgf_quant"): {
396
+ "INT": {"torch.ops.aten.remainder.Scalar"},
397
+ },
398
+ ("backends/arm/test/ops/test_var.py", "test_var_dim_vgf_no_quant"): {
399
+ "FP": {"torch.ops.aten.var.dim"},
400
+ },
401
+ ("backends/arm/test/ops/test_var.py", "test_var_dim_vgf_no_quant_no_dim"): {
402
+ "FP": {"torch.ops.aten.var.correction"},
403
+ },
404
+ ("backends/arm/test/ops/test_var.py", "test_var_dim_vgf_no_quant_correction"): {
405
+ "FP": {"torch.ops.aten.var.correction"},
406
+ },
407
+ (
408
+ "backends/arm/test/ops/test_embedding.py",
409
+ "test_embedding_vgf_quant",
410
+ ): {
411
+ "INT": {"torch.ops.aten.embedding.default"},
412
+ },
413
+ (
414
+ "backends/arm/test/ops/test_sdpa.py",
415
+ "test_sdpa_vgf_no_quant",
416
+ ): {
417
+ "FP": {"torch.ops.aten.scaled_dot_product_attention.default"},
418
+ },
419
+ (
420
+ "backends/arm/test/ops/test_sdpa.py",
421
+ "test_sdpa_vgf_quant",
422
+ ): {
423
+ "INT": {"torch.ops.aten.scaled_dot_product_attention.default"},
424
+ },
425
+ (
426
+ "backends/arm/test/ops/test_linalg_vector_norm.py",
427
+ "test_vector_norm_vgf_no_quant",
428
+ ): {
429
+ "FP": {"torch.ops.aten.linalg_vector_norm.default"},
430
+ },
431
+ (
432
+ "backends/arm/test/ops/test_linalg_vector_norm.py",
433
+ "test_vector_norm_vgf_quant",
434
+ ): {
435
+ "INT": {"torch.ops.aten.linalg_vector_norm.default"},
436
+ },
437
+ }
438
+
439
+ # Existing U55 runtime tests below intentionally suppress direct ATen/Edge
440
+ # assertions because quantization/decomposition changes the graph. They still
441
+ # provide positive runtime coverage for the exported operator.
442
+ U55_EXPLICIT_BACKEND_COVERAGE: dict[tuple[str, str], dict[str, set[str]]] = {
443
+ (
444
+ "backends/arm/test/ops/test_div_tensor_mode.py",
445
+ "test_div_tensor_mode_u55_INT",
446
+ ): {
447
+ "INT": {"torch.ops.aten.div.Tensor_mode"},
448
+ },
449
+ (
450
+ "backends/arm/test/ops/test_index_select.py",
451
+ "test_index_select_u55_INT_constant_contiguous",
452
+ ): {
453
+ "INT": {"torch.ops.aten.index_select.default"},
454
+ },
455
+ (
456
+ "backends/arm/test/ops/test_index_tensor.py",
457
+ "test_index_tensor_u55_INT_constant",
458
+ ): {
459
+ "INT": {"torch.ops.aten.index.Tensor"},
460
+ },
461
+ (
462
+ "backends/arm/test/ops/test_silu.py",
463
+ "test_silu_u55_INT",
464
+ ): {
465
+ "INT": {"torch.ops.aten.silu.default"},
466
+ },
467
+ (
468
+ "backends/arm/test/ops/test_unfold_copy.py",
469
+ "test_unfold_copy_u55_INT",
470
+ ): {
471
+ "INT": {"torch.ops.aten.unfold_copy.default"},
472
+ },
473
+ (
474
+ "backends/arm/test/ops/test_pow.py",
475
+ "test_pow_tensor_tensor_u55_INT",
476
+ ): {
477
+ "INT": {"torch.ops.aten.pow.Tensor_Tensor"},
478
+ },
479
+ (
480
+ "backends/arm/test/ops/test_sdpa.py",
481
+ "test_sdpa_u55_INT",
482
+ ): {
483
+ "INT": {"torch.ops.aten.scaled_dot_product_attention.default"},
484
+ },
485
+ (
486
+ "backends/arm/test/ops/test_linalg_vector_norm.py",
487
+ "test_vector_norm_u55_INT_fvp",
488
+ ): {
489
+ "INT": {"torch.ops.aten.linalg_vector_norm.default"},
490
+ },
491
+ }
492
+
493
+ # Existing U85 runtime tests below intentionally suppress direct ATen/Edge
494
+ # assertions because quantization/decomposition changes the graph. They still
495
+ # provide positive runtime coverage for the exported operator.
496
+ # The test for embedding op has pipeline.pop_stage("check.aten"),
497
+ # that is why we need to set it explicitly.
498
+ U85_EXPLICIT_BACKEND_COVERAGE: dict[tuple[str, str], dict[str, set[str]]] = {
499
+ (
500
+ "backends/arm/test/ops/test_div_tensor_mode.py",
501
+ "test_div_tensor_mode_u85_INT",
502
+ ): {
503
+ "INT": {"torch.ops.aten.div.Tensor_mode"},
504
+ },
505
+ (
506
+ "backends/arm/test/ops/test_silu.py",
507
+ "test_silu_u85_INT",
508
+ ): {
509
+ "INT": {"torch.ops.aten.silu.default"},
510
+ },
511
+ (
512
+ "backends/arm/test/ops/test_embedding.py",
513
+ "test_embedding_u85_INT",
514
+ ): {
515
+ "INT": {"torch.ops.aten.embedding.default"},
516
+ },
517
+ (
518
+ "backends/arm/test/ops/test_pow.py",
519
+ "test_pow_tensor_tensor_u85_INT",
520
+ ): {
521
+ "INT": {"torch.ops.aten.pow.Tensor_Tensor"},
522
+ },
523
+ (
524
+ "backends/arm/test/ops/test_sdpa.py",
525
+ "test_sdpa_u85_INT",
526
+ ): {
527
+ "INT": {"torch.ops.aten.scaled_dot_product_attention.default"},
528
+ },
529
+ (
530
+ "backends/arm/test/ops/test_linalg_vector_norm.py",
531
+ "test_vector_norm_u85_INT_fvp",
532
+ ): {
533
+ "INT": {"torch.ops.aten.linalg_vector_norm.default"},
534
+ },
535
+ }
536
+
537
+
538
+ # These exported operators pass a generic TOSA positive-support declaration,
539
+ # but their actual U55 lowering path reaches an unsupported operation or a
540
+ # restriction that cannot support the general exported operator. Keep these
541
+ # backend-specific rather than weakening VGF/TOSA support.
542
+ BACKEND_EXPORTED_OP_EXCLUSIONS: dict[str, frozenset[str]] = {
543
+ "u55": frozenset(
544
+ {
545
+ "torch.ops.aten.masked_fill.Scalar",
546
+ "torch.ops.aten.embedding.default",
547
+ "torch.ops.aten.sign.default",
548
+ }
549
+ ),
550
+ }
551
+
552
+
553
+ def _active_explicit_backend_coverage() -> dict[tuple[str, str], dict[str, set[str]]]:
554
+ if ACTIVE_BACKEND_KEY == "vgf":
555
+ return VGF_EXPLICIT_BACKEND_COVERAGE
556
+ if ACTIVE_BACKEND_KEY == "u55":
557
+ return U55_EXPLICIT_BACKEND_COVERAGE
558
+ if ACTIVE_BACKEND_KEY == "u85":
559
+ return U85_EXPLICIT_BACKEND_COVERAGE
560
+ return {}
561
+
562
+
563
+ # ---------------------------------------------------------------------------
564
+ # Backend-agnostic implementation and shared normalization data.
565
+ # ---------------------------------------------------------------------------
566
+
567
+ # Friendly aliases for exported ATen operators that are commonly produced from
568
+ # higher-level PyTorch APIs. These are what should appear in the published page.
569
+ # Unknown operators fall back to a conservative ``torch.<aten-name>`` spelling.
570
+ PYTORCH_API_ALIASES: dict[str, tuple[str, ...]] = {
571
+ # Internal / higher-order operators with explicit public API spellings.
572
+ "torch.ops.aten._assert_scalar.default": ("torch._assert_scalar",),
573
+ "torch.ops.aten.t_copy.default": (
574
+ "torch.t",
575
+ "torch.Tensor.t",
576
+ ),
577
+ "torch.ops.aten.transpose_copy.int": (
578
+ "torch.transpose",
579
+ "torch.Tensor.transpose",
580
+ ),
581
+ "torch.ops.higher_order.cond": ("torch.cond",),
582
+ "torch.ops.higher_order.while_loop": ("torch.while_loop",),
583
+ # Arithmetic and comparisons.
584
+ "torch.ops.aten.add.Tensor": ("torch.add", "+"),
585
+ "torch.ops.aten.add.Scalar": ("torch.add", "+"),
586
+ "torch.ops.aten.sub.Tensor": ("torch.sub", "-"),
587
+ "torch.ops.aten.sub.Scalar": ("torch.sub", "-"),
588
+ "torch.ops.aten.mul.Tensor": ("torch.mul", "*"),
589
+ "torch.ops.aten.mul.Scalar": ("torch.mul", "*"),
590
+ "torch.ops.aten.div.Tensor": ("torch.div", "/"),
591
+ "torch.ops.aten.div.Scalar": ("torch.div", "/"),
592
+ "torch.ops.aten.floor_divide.default": ("torch.floor_divide", "//"),
593
+ "torch.ops.aten.pow.Tensor_Scalar": ("torch.pow", "**"),
594
+ "torch.ops.aten.pow.Tensor_Tensor": ("torch.pow", "**"),
595
+ "torch.ops.aten.neg.default": ("torch.neg", "unary -"),
596
+ "torch.ops.aten.eq.Tensor": ("torch.eq", "=="),
597
+ "torch.ops.aten.eq.Scalar": ("torch.eq", "=="),
598
+ "torch.ops.aten.ne.Tensor": ("torch.ne", "!="),
599
+ "torch.ops.aten.ne.Scalar": ("torch.ne", "!="),
600
+ "torch.ops.aten.gt.Tensor": ("torch.gt", ">"),
601
+ "torch.ops.aten.gt.Scalar": ("torch.gt", ">"),
602
+ "torch.ops.aten.ge.Tensor": ("torch.ge", ">="),
603
+ "torch.ops.aten.ge.Scalar": ("torch.ge", ">="),
604
+ "torch.ops.aten.lt.Tensor": ("torch.lt", "<"),
605
+ "torch.ops.aten.lt.Scalar": ("torch.lt", "<"),
606
+ "torch.ops.aten.le.Tensor": ("torch.le", "<="),
607
+ "torch.ops.aten.le.Scalar": ("torch.le", "<="),
608
+ "torch.ops.aten.maximum.default": ("torch.maximum",),
609
+ "torch.ops.aten.minimum.default": ("torch.minimum",),
610
+ "torch.ops.aten.clamp.default": ("torch.clamp",),
611
+ "torch.ops.aten.clamp.Tensor": ("torch.clamp",),
612
+ "torch.ops.aten.where.self": ("torch.where",),
613
+ # Bitwise and logical operators.
614
+ "torch.ops.aten.bitwise_and.Tensor": ("torch.bitwise_and", "&"),
615
+ "torch.ops.aten.bitwise_and.Scalar": ("torch.bitwise_and", "&"),
616
+ "torch.ops.aten.bitwise_or.Tensor": ("torch.bitwise_or", "|"),
617
+ "torch.ops.aten.bitwise_or.Scalar": ("torch.bitwise_or", "|"),
618
+ "torch.ops.aten.bitwise_xor.Tensor": ("torch.bitwise_xor", "^"),
619
+ "torch.ops.aten.bitwise_xor.Scalar": ("torch.bitwise_xor", "^"),
620
+ "torch.ops.aten.bitwise_not.default": ("torch.bitwise_not", "~"),
621
+ "torch.ops.aten.bitwise_left_shift.Tensor": ("torch.bitwise_left_shift", "<<"),
622
+ "torch.ops.aten.bitwise_left_shift.Scalar": ("torch.bitwise_left_shift", "<<"),
623
+ "torch.ops.aten.bitwise_right_shift.Tensor": ("torch.bitwise_right_shift", ">>"),
624
+ "torch.ops.aten.bitwise_right_shift.Scalar": ("torch.bitwise_right_shift", ">>"),
625
+ "torch.ops.aten.logical_and.default": ("torch.logical_and",),
626
+ "torch.ops.aten.logical_or.default": ("torch.logical_or",),
627
+ "torch.ops.aten.logical_xor.default": ("torch.logical_xor",),
628
+ "torch.ops.aten.logical_not.default": ("torch.logical_not",),
629
+ # Linear algebra and neural-network layers.
630
+ "torch.ops.aten.softplus.default": ("torch.nn.functional.softplus",),
631
+ "torch.ops.aten.linear.default": ("torch.nn.Linear", "torch.nn.functional.linear"),
632
+ "torch.ops.aten.mm.default": ("torch.mm",),
633
+ "torch.ops.aten.bmm.default": ("torch.bmm",),
634
+ "torch.ops.aten.matmul.default": ("torch.matmul", "@"),
635
+ "torch.ops.aten.addmm.default": ("torch.addmm",),
636
+ "torch.ops.aten.linalg_vector_norm.default": ("torch.linalg.vector_norm",),
637
+ "torch.ops.aten.convolution.default": (
638
+ "torch.nn.Conv2d",
639
+ "torch.nn.functional.conv2d",
640
+ ),
641
+ "torch.ops.aten.max_pool2d_with_indices.default": (
642
+ "torch.nn.MaxPool2d",
643
+ "torch.nn.functional.max_pool2d",
644
+ ),
645
+ "torch.ops.aten.avg_pool2d.default": (
646
+ "torch.nn.AvgPool2d",
647
+ "torch.nn.functional.avg_pool2d",
648
+ ),
649
+ "torch.ops.aten.adaptive_avg_pool1d.default": (
650
+ "torch.nn.AdaptiveAvgPool1d",
651
+ "torch.nn.functional.adaptive_avg_pool1d",
652
+ ),
653
+ "torch.ops.aten.adaptive_avg_pool2d.default": (
654
+ "torch.nn.AdaptiveAvgPool2d",
655
+ "torch.nn.functional.adaptive_avg_pool2d",
656
+ ),
657
+ "torch.ops.aten._native_batch_norm_legit_no_training.default": (
658
+ "torch.nn.BatchNorm2d",
659
+ "torch.nn.functional.batch_norm",
660
+ ),
661
+ "torch.ops.aten.native_layer_norm.default": (
662
+ "torch.nn.LayerNorm",
663
+ "torch.nn.functional.layer_norm",
664
+ ),
665
+ "torch.ops.aten.native_group_norm.default": (
666
+ "torch.nn.GroupNorm",
667
+ "torch.nn.functional.group_norm",
668
+ ),
669
+ "torch.ops.aten.embedding.default": (
670
+ "torch.nn.Embedding",
671
+ "torch.nn.functional.embedding",
672
+ ),
673
+ "torch.ops.aten.scaled_dot_product_attention.default": (
674
+ "torch.nn.functional.scaled_dot_product_attention",
675
+ ),
676
+ # Activations.
677
+ "torch.ops.aten.relu.default": ("torch.relu", "torch.nn.ReLU"),
678
+ "torch.ops.aten.relu_.default": ("torch.Tensor.relu_",),
679
+ "torch.ops.aten.leaky_relu.default": (
680
+ "torch.nn.LeakyReLU",
681
+ "torch.nn.functional.leaky_relu",
682
+ ),
683
+ "torch.ops.aten.hardtanh.default": (
684
+ "torch.nn.Hardtanh",
685
+ "torch.nn.functional.hardtanh",
686
+ ),
687
+ "torch.ops.aten.gelu.default": ("torch.nn.GELU", "torch.nn.functional.gelu"),
688
+ "torch.ops.aten.hardsigmoid.default": (
689
+ "torch.nn.Hardsigmoid",
690
+ "torch.nn.functional.hardsigmoid",
691
+ ),
692
+ "torch.ops.aten.hardswish.default": (
693
+ "torch.nn.Hardswish",
694
+ "torch.nn.functional.hardswish",
695
+ ),
696
+ "torch.ops.aten.sigmoid.default": ("torch.sigmoid", "torch.nn.Sigmoid"),
697
+ "torch.ops.aten.tanh.default": ("torch.tanh", "torch.nn.Tanh"),
698
+ "torch.ops.aten.silu.default": ("torch.nn.SiLU", "torch.nn.functional.silu"),
699
+ "torch.ops.aten.elu.default": ("torch.nn.ELU", "torch.nn.functional.elu"),
700
+ "torch.ops.aten.selu.default": ("torch.nn.SELU", "torch.nn.functional.selu"),
701
+ "torch.ops.aten.celu.default": ("torch.nn.CELU", "torch.nn.functional.celu"),
702
+ "torch.ops.aten._softmax.default": (
703
+ "torch.nn.Softmax",
704
+ "torch.nn.functional.softmax",
705
+ ),
706
+ "torch.ops.aten._log_softmax.default": (
707
+ "torch.nn.LogSoftmax",
708
+ "torch.nn.functional.log_softmax",
709
+ ),
710
+ "torch.ops.aten.softmax.int": ("torch.nn.Softmax", "torch.nn.functional.softmax"),
711
+ "torch.ops.aten.log_softmax.int": (
712
+ "torch.nn.LogSoftmax",
713
+ "torch.nn.functional.log_softmax",
714
+ ),
715
+ # Reductions.
716
+ "torch.ops.aten.sum.default": ("torch.sum",),
717
+ "torch.ops.aten.sum.dim_IntList": ("torch.sum",),
718
+ "torch.ops.aten.mean.default": ("torch.mean",),
719
+ "torch.ops.aten.mean.dim": ("torch.mean",),
720
+ "torch.ops.aten.amax.default": ("torch.amax",),
721
+ "torch.ops.aten.amin.default": ("torch.amin",),
722
+ "torch.ops.aten.max.dim": ("torch.max",),
723
+ "torch.ops.aten.min.dim": ("torch.min",),
724
+ "torch.ops.aten.argmax.default": ("torch.argmax",),
725
+ "torch.ops.aten.argmax.dim": ("torch.argmax",),
726
+ "torch.ops.aten.var.correction": ("torch.var",),
727
+ "torch.ops.aten.var.dim": ("torch.var",),
728
+ "torch.ops.aten.any.default": ("torch.any",),
729
+ "torch.ops.aten.any.dim": ("torch.any",),
730
+ "torch.ops.aten.any.dims": ("torch.any",),
731
+ # Elementwise math.
732
+ "torch.ops.aten.abs.default": ("torch.abs",),
733
+ "torch.ops.aten.exp.default": ("torch.exp",),
734
+ "torch.ops.aten.expm1.default": ("torch.expm1",),
735
+ "torch.ops.aten.log.default": ("torch.log",),
736
+ "torch.ops.aten.log1p.default": ("torch.log1p",),
737
+ "torch.ops.aten.log10.default": ("torch.log10",),
738
+ "torch.ops.aten.logit.default": ("torch.logit",),
739
+ "torch.ops.aten.sqrt.default": ("torch.sqrt",),
740
+ "torch.ops.aten.rsqrt.default": ("torch.rsqrt",),
741
+ "torch.ops.aten.reciprocal.default": ("torch.reciprocal",),
742
+ "torch.ops.aten.floor.default": ("torch.floor",),
743
+ "torch.ops.aten.ceil.default": ("torch.ceil",),
744
+ "torch.ops.aten.round.default": ("torch.round",),
745
+ "torch.ops.aten.sin.default": ("torch.sin",),
746
+ "torch.ops.aten.sinh.default": ("torch.sinh",),
747
+ "torch.ops.aten.cos.default": ("torch.cos",),
748
+ "torch.ops.aten.cosh.default": ("torch.cosh",),
749
+ "torch.ops.aten.tan.default": ("torch.tan",),
750
+ "torch.ops.aten.atan.default": ("torch.atan",),
751
+ "torch.ops.aten.atanh.default": ("torch.atanh",),
752
+ "torch.ops.aten.asin.default": ("torch.asin",),
753
+ "torch.ops.aten.asinh.default": ("torch.asinh",),
754
+ "torch.ops.aten.acos.default": ("torch.acos",),
755
+ "torch.ops.aten.acosh.default": ("torch.acosh",),
756
+ "torch.ops.aten.erf.default": ("torch.erf",),
757
+ "torch.ops.aten.erfinv.default": ("torch.erfinv",),
758
+ "torch.ops.aten.remainder.Scalar": ("torch.remainder",),
759
+ "torch.ops.aten.remainder.Tensor": ("torch.remainder",),
760
+ # Tensor creation / movement / shape operators.
761
+ "torch.ops.aten.cat.default": ("torch.cat",),
762
+ "torch.ops.aten.stack.default": ("torch.stack",),
763
+ "torch.ops.aten.view.default": ("torch.Tensor.view",),
764
+ "torch.ops.aten.view_copy.default": ("torch.Tensor.view",),
765
+ "torch.ops.aten.reshape.default": ("torch.reshape", "torch.Tensor.reshape"),
766
+ "torch.ops.aten.permute.default": ("torch.permute", "torch.Tensor.permute"),
767
+ "torch.ops.aten.permute_copy.default": ("torch.permute", "torch.Tensor.permute"),
768
+ "torch.ops.aten.transpose.int": ("torch.transpose", "torch.Tensor.transpose"),
769
+ "torch.ops.aten.squeeze.default": ("torch.squeeze", "torch.Tensor.squeeze"),
770
+ "torch.ops.aten.squeeze.dim": ("torch.squeeze", "torch.Tensor.squeeze"),
771
+ "torch.ops.aten.squeeze_copy.dims": ("torch.squeeze", "torch.Tensor.squeeze"),
772
+ "torch.ops.aten.unsqueeze.default": ("torch.unsqueeze", "torch.Tensor.unsqueeze"),
773
+ "torch.ops.aten.unsqueeze_copy.default": (
774
+ "torch.unsqueeze",
775
+ "torch.Tensor.unsqueeze",
776
+ ),
777
+ "torch.ops.aten.expand.default": ("torch.Tensor.expand",),
778
+ "torch.ops.aten.expand_copy.default": ("torch.Tensor.expand",),
779
+ "torch.ops.aten.repeat.default": ("torch.Tensor.repeat",),
780
+ "torch.ops.aten.clone.default": ("torch.clone", "torch.Tensor.clone"),
781
+ "torch.ops.aten.alias_copy.default": ("torch.alias_copy",),
782
+ "torch.ops.aten.detach_copy.default": ("torch.detach", "torch.Tensor.detach"),
783
+ "torch.ops.aten.copy.default": ("torch.Tensor.copy_",),
784
+ "torch.ops.aten.contiguous.default": ("torch.Tensor.contiguous",),
785
+ "torch.ops.aten.to.dtype": ("torch.Tensor.to",),
786
+ "torch.ops.aten._to_copy.default": ("torch.Tensor.to",),
787
+ "torch.ops.aten.full.default": ("torch.full",),
788
+ "torch.ops.aten.full_like.default": ("torch.full_like",),
789
+ "torch.ops.aten.zeros.default": ("torch.zeros",),
790
+ "torch.ops.aten.zeros_like.default": ("torch.zeros_like",),
791
+ "torch.ops.aten.ones.default": ("torch.ones",),
792
+ "torch.ops.aten.ones_like.default": ("torch.ones_like",),
793
+ "torch.ops.aten.eye.default": ("torch.eye",),
794
+ "torch.ops.aten.arange.start_step": ("torch.arange",),
795
+ "torch.ops.aten.linspace.default": ("torch.linspace",),
796
+ "torch.ops.aten.scalar_tensor.default": ("torch.scalar_tensor",),
797
+ "torch.ops.aten.split_copy.Tensor": ("torch.split", "torch.Tensor.split"),
798
+ "torch.ops.aten.split_with_sizes_copy.default": (
799
+ "torch.split",
800
+ "torch.Tensor.split",
801
+ ),
802
+ "torch.ops.aten.unfold_copy.default": ("torch.Tensor.unfold",),
803
+ "torch.ops.aten.slice_scatter.default": ("torch.slice_scatter",),
804
+ # Indexing and data movement.
805
+ "torch.ops.aten.select.int": ("torch.select", "torch.Tensor.select"),
806
+ "torch.ops.aten.select_copy.int": ("torch.select", "torch.Tensor.select"),
807
+ "torch.ops.aten.slice.Tensor": ("torch.Tensor.__getitem__", "tensor slicing"),
808
+ "torch.ops.aten.slice_copy.Tensor": ("torch.Tensor.__getitem__", "tensor slicing"),
809
+ "torch.ops.aten.index.Tensor": ("torch.Tensor.__getitem__", "tensor indexing"),
810
+ "torch.ops.aten.gather.default": ("torch.gather",),
811
+ "torch.ops.aten.index_select.default": ("torch.index_select",),
812
+ "torch.ops.aten.index_put.default": (
813
+ "torch.Tensor.__setitem__",
814
+ "tensor indexing assignment",
815
+ ),
816
+ "torch.ops.aten.masked_fill.Scalar": (
817
+ "torch.masked_fill",
818
+ "torch.Tensor.masked_fill",
819
+ ),
820
+ "torch.ops.aten.constant_pad_nd.default": ("torch.nn.functional.pad",),
821
+ "torch.ops.aten.pad.default": ("torch.nn.functional.pad",),
822
+ "torch.ops.aten.flip.default": ("torch.flip",),
823
+ }
824
+
825
+ GENERATED_EDGE_OVERLOAD_SUFFIXES = [
826
+ "_dim_IntList",
827
+ "_Tensor_Scalar",
828
+ "_Tensor_Tensor",
829
+ "_Scalar_Tensor",
830
+ "_Tensor",
831
+ "_Scalar",
832
+ "_dtype",
833
+ "_int",
834
+ "_self",
835
+ "_dim",
836
+ "_dims",
837
+ "_default",
838
+ ]
839
+
840
+ MAX_STATIC_EXPANSION = 256
841
+
842
+ logger = logging.getLogger(__name__)
843
+
844
+
845
+ class TosaSpecificationLike(Protocol):
846
+ """Structural type for the TOSA profile queries used by this script."""
847
+
848
+ def support_float(self) -> bool: ...
849
+
850
+ def support_integer(self) -> bool: ...
851
+
852
+
853
+ @dataclass(frozen=True)
854
+ class CoverageEvidence:
855
+ exported_op: str
856
+ profile: str
857
+ stage: str
858
+ classification: str
859
+ test: str
860
+ asserted_op: str | None = None
861
+
862
+
863
+ @dataclass
864
+ class UnresolvedPipelineEvidence:
865
+ path: Path
866
+ function: str
867
+ profile: str
868
+ aten_expression: str
869
+ exir_expression: str
870
+ reason: str
871
+
872
+
873
+ @dataclass(frozen=True)
874
+ class StaticBinding:
875
+ expression: ast.AST
876
+ scope_locals: dict[str, list[ast.AST]]
877
+
878
+
879
+ @dataclass
880
+ class PipelineCoverage:
881
+ """Coverage inferred from one or more configured backend pipeline tests."""
882
+
883
+ exported_op: str
884
+ pytorch_apis: tuple[str, ...]
885
+ support_profiles: set[str] = field(default_factory=set)
886
+ dtypes: set[str] = field(default_factory=set)
887
+ quantization_modes: set[str] = field(default_factory=set)
888
+ tests: set[str] = field(default_factory=set)
889
+ stages: set[str] = field(default_factory=set)
890
+ classifications: set[str] = field(default_factory=set)
891
+ evidence_records: list[CoverageEvidence] = field(default_factory=list)
892
+
893
+
894
+ @dataclass
895
+ class PublicCoverage:
896
+ """Customer-facing coverage aggregated by PyTorch API spelling."""
897
+
898
+ pytorch_apis: tuple[str, ...]
899
+ support_profiles: set[str] = field(default_factory=set)
900
+ dtypes: set[str] = field(default_factory=set)
901
+ quantization_modes: set[str] = field(default_factory=set)
902
+
903
+
904
+ @dataclass
905
+ class SupportedOperatorEvidence:
906
+ """Backend evidence that an exported ATen operator should have tests."""
907
+
908
+ exported_op: str
909
+ pytorch_apis: tuple[str, ...]
910
+ support_profiles: set[str] = field(default_factory=set)
911
+ evidence: set[str] = field(default_factory=set)
912
+
913
+
914
+ @dataclass
915
+ class ClassContext:
916
+ """Static information extracted from one Python class."""
917
+
918
+ assignments: dict[str, ast.AST] = field(default_factory=dict)
919
+ methods: dict[str, ast.FunctionDef] = field(default_factory=dict)
920
+ fields: list[str] = field(default_factory=list)
921
+
922
+
923
+ @dataclass
924
+ class ModuleContext:
925
+ """Static information extracted from a Python test module."""
926
+
927
+ path: Path
928
+ source: str
929
+ tree: ast.Module
930
+ assignments: dict[str, ast.AST]
931
+ functions: dict[str, ast.FunctionDef]
932
+ classes: dict[str, ClassContext]
933
+ parents: dict[ast.AST, ast.AST]
934
+
935
+
936
+ @dataclass
937
+ class ResolutionScope:
938
+ """Local static bindings available at a particular call site."""
939
+
940
+ locals: dict[str, list[ast.AST]] = field(default_factory=dict)
941
+ param_candidates: dict[str, list[ast.AST]] = field(default_factory=dict)
942
+ class_name: str | None = None
943
+
944
+
945
+ def _scope_with_class(scope: ResolutionScope, class_name: str) -> ResolutionScope:
946
+ return ResolutionScope(
947
+ locals=scope.locals,
948
+ param_candidates=scope.param_candidates,
949
+ class_name=class_name,
950
+ )
951
+
952
+
953
+ def _repo_root(repo_root: Path | None) -> Path:
954
+ if repo_root is not None:
955
+ return repo_root.resolve()
956
+
957
+ candidates = [Path.cwd().resolve(), *Path(__file__).resolve().parents]
958
+ for candidate in candidates:
959
+ if (candidate / "backends/arm").is_dir() and (
960
+ candidate / "docs/source"
961
+ ).is_dir():
962
+ return candidate
963
+
964
+ raise RuntimeError("Could not locate the ExecuTorch repository root.")
965
+
966
+
967
+ def _ensure_repo_importable(repo_root: Path) -> None:
968
+ root = str(repo_root)
969
+ if root not in sys.path:
970
+ sys.path.insert(0, root)
971
+
972
+
973
+ def _format_backtick_items(
974
+ items: Iterable[str], order: Sequence[str] | None = None
975
+ ) -> str:
976
+ values = _sort_items(items, order)
977
+ return ", ".join(f"`{value}`" for value in values) if values else "-"
978
+
979
+
980
+ def _format_items(items: Iterable[str], order: Sequence[str] | None = None) -> str:
981
+ values = _sort_items(items, order)
982
+ return ", ".join(values) if values else "-"
983
+
984
+
985
+ def _format_api_items(items: Sequence[str]) -> str:
986
+ return " / ".join(f"`{item}`" for item in items) if items else "-"
987
+
988
+
989
+ def _format_test_items(items: Iterable[str]) -> str:
990
+ values = sorted(set(items))
991
+ return "<br />".join(f"`{value}`" for value in values) if values else "-"
992
+
993
+
994
+ def _html_code(value: str) -> str:
995
+ return f"<code>{html.escape(value)}</code>"
996
+
997
+
998
+ def _format_html_code_items(
999
+ items: Iterable[str], order: Sequence[str] | None = None
1000
+ ) -> str:
1001
+ values = _sort_items(items, order)
1002
+ return ", ".join(_html_code(value) for value in values) if values else "-"
1003
+
1004
+
1005
+ def _format_html_items(items: Iterable[str], order: Sequence[str] | None = None) -> str:
1006
+ values = _sort_items(items, order)
1007
+ return ", ".join(html.escape(value) for value in values) if values else "-"
1008
+
1009
+
1010
+ def _format_html_api_items(items: Sequence[str]) -> str:
1011
+ return " / ".join(_html_code(item) for item in items) if items else "-"
1012
+
1013
+
1014
+ def _format_html_test_items(items: Iterable[str]) -> str:
1015
+ values = sorted(set(items))
1016
+ return "<br />".join(_html_code(value) for value in values) if values else "-"
1017
+
1018
+
1019
+ def _sort_items(items: Iterable[str], order: Sequence[str] | None = None) -> list[str]:
1020
+ values = {item for item in items if item}
1021
+ if order is None:
1022
+ return sorted(values)
1023
+ position = {item: idx for idx, item in enumerate(order)}
1024
+ return sorted(values, key=lambda item: (position.get(item, 10_000), item))
1025
+
1026
+
1027
+ def _expr_text(node: ast.AST | None) -> str:
1028
+ if node is None:
1029
+ return ""
1030
+ try:
1031
+ return ast.unparse(node)
1032
+ except Exception:
1033
+ return ""
1034
+
1035
+
1036
+ def _attribute_name(node: ast.AST) -> str:
1037
+ parts: list[str] = []
1038
+ current = node
1039
+ while isinstance(current, ast.Attribute):
1040
+ parts.append(current.attr)
1041
+ current = current.value
1042
+ if isinstance(current, ast.Name):
1043
+ parts.append(current.id)
1044
+ return ".".join(reversed(parts))
1045
+
1046
+
1047
+ def _call_name(node: ast.AST) -> str:
1048
+ if isinstance(node, ast.Name):
1049
+ return node.id
1050
+ if isinstance(node, ast.Attribute):
1051
+ return node.attr
1052
+ if isinstance(node, ast.Subscript):
1053
+ return _call_name(node.value)
1054
+ return ""
1055
+
1056
+
1057
+ def _is_backend_pipeline_call(node: ast.Call) -> bool:
1058
+ return _call_name(node.func) in BACKEND_PIPELINE_CLASS_NAMES
1059
+
1060
+
1061
+ def _literal_bool(node: ast.AST | None, default: bool) -> bool:
1062
+ if isinstance(node, ast.Constant) and isinstance(node.value, bool):
1063
+ return node.value
1064
+ return default
1065
+
1066
+
1067
+ def _keyword(call: ast.Call, name: str) -> ast.AST | None:
1068
+ for keyword in call.keywords:
1069
+ if keyword.arg == name:
1070
+ return keyword.value
1071
+ return None
1072
+
1073
+
1074
+ def _positional_or_keyword(call: ast.Call, index: int, name: str) -> ast.AST | None:
1075
+ if len(call.args) > index:
1076
+ return call.args[index]
1077
+ return _keyword(call, name)
1078
+
1079
+
1080
+ def _pipeline_profile(call: ast.Call) -> str:
1081
+ if PIPELINE_QUANTIZE_KEYWORD is None:
1082
+ return PIPELINE_DEFAULT_PROFILE
1083
+ quantize = _literal_bool(
1084
+ _keyword(call, PIPELINE_QUANTIZE_KEYWORD),
1085
+ default=PIPELINE_QUANTIZE_DEFAULT,
1086
+ )
1087
+ return "INT" if quantize else "FP"
1088
+
1089
+
1090
+ def _pipeline_operator_expr(
1091
+ call: ast.Call, position: int, keyword_names: tuple[str, ...]
1092
+ ) -> ast.AST | None:
1093
+ if not keyword_names:
1094
+ return call.args[position] if len(call.args) > position else None
1095
+
1096
+ value = _positional_or_keyword(call, position, keyword_names[0])
1097
+ if value is not None:
1098
+ return value
1099
+ for keyword_name in keyword_names[1:]:
1100
+ value = _keyword(call, keyword_name)
1101
+ if value is not None:
1102
+ return value
1103
+ return None
1104
+
1105
+
1106
+ def _edge_generated_name_to_aten(text: str) -> str:
1107
+ exact = GENERATED_EDGE_OP_ALIASES.get(text)
1108
+ if exact is not None:
1109
+ return exact
1110
+ for suffix in GENERATED_EDGE_OVERLOAD_SUFFIXES:
1111
+ if text.endswith(suffix):
1112
+ return f"{text[: -len(suffix)]}.{suffix[1:]}"
1113
+ return text.replace("_", ".", 1)
1114
+
1115
+
1116
+ def _normalize_pytorch_op_name( # noqa: C901
1117
+ op: str,
1118
+ *,
1119
+ path: Path | None = None,
1120
+ diagnostics: list[str] | None = None,
1121
+ ) -> str | None:
1122
+ """Normalize test and registry spellings to canonical exported ATen
1123
+ names.
1124
+ """
1125
+
1126
+ text = op.strip().strip("'\"")
1127
+ if not text or text in {"[]", "None"}:
1128
+ return None
1129
+ if "quantized_decomposed" in text:
1130
+ return None
1131
+ if text in {"operator.getitem", "<built-in function getitem>"}:
1132
+ return None
1133
+ if text.startswith("tosa.") or ".tosa." in text:
1134
+ return None
1135
+
1136
+ generated_prefix = "executorch_exir_dialects_edge__ops_aten_"
1137
+ recognized = (
1138
+ text.startswith(generated_prefix)
1139
+ or text.startswith("torch.ops.")
1140
+ or text.startswith("exir_ops.edge.")
1141
+ or text.startswith("executorch.exir.dialects._ops.ops.edge.")
1142
+ or text.startswith("edge.")
1143
+ or text.startswith("aten::")
1144
+ or text.startswith("aten.")
1145
+ or ".aten." in text
1146
+ )
1147
+ if not recognized:
1148
+ return None
1149
+
1150
+ original = text
1151
+
1152
+ # Higher-order operators are not ATen operators. Preserve their namespace
1153
+ # instead of rewriting torch.ops.higher_order.* as torch.ops.aten.*.
1154
+ if text.startswith("torch.ops.higher_order."):
1155
+ return text
1156
+
1157
+ if text.startswith(generated_prefix):
1158
+ text = _edge_generated_name_to_aten(text.removeprefix(generated_prefix))
1159
+
1160
+ for prefix in (
1161
+ "torch.ops.",
1162
+ "exir_ops.edge.",
1163
+ "executorch.exir.dialects._ops.ops.edge.",
1164
+ "edge.",
1165
+ ):
1166
+ if text.startswith(prefix):
1167
+ text = text.removeprefix(prefix)
1168
+
1169
+ if text.startswith("aten::"):
1170
+ text = text.removeprefix("aten::")
1171
+ if "." not in text:
1172
+ text = f"{text}.default"
1173
+ elif text.startswith("aten."):
1174
+ text = text.removeprefix("aten.")
1175
+ elif ".aten." in text:
1176
+ text = text.split(".aten.", maxsplit=1)[1]
1177
+
1178
+ text = EDGE_OP_ALIASES.get(text, text)
1179
+ canonical_without_overload = f"torch.ops.aten.{text}"
1180
+ if "." not in text:
1181
+ contextual = None
1182
+ if path is not None:
1183
+ contextual = CONTEXTUAL_OVERLOAD_ALIASES.get(
1184
+ (str(path), canonical_without_overload)
1185
+ )
1186
+ if contextual is not None:
1187
+ return contextual
1188
+ explicit = OVERLOADLESS_OP_ALIASES.get(canonical_without_overload)
1189
+ if explicit is not None:
1190
+ return explicit
1191
+ if diagnostics is not None:
1192
+ diagnostics.append(f"ambiguous overload-less operator: {original}")
1193
+ return None
1194
+
1195
+ if not re.match(r"^[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z0-9_]+$", text):
1196
+ return None
1197
+ return f"torch.ops.aten.{text}"
1198
+
1199
+
1200
+ def _canonical_pytorch_op_from_target(target: object) -> str | None:
1201
+ if target is operator.getitem:
1202
+ return None
1203
+
1204
+ schema = getattr(target, "_schema", None)
1205
+ if schema is not None:
1206
+ schema_name = str(getattr(schema, "name", ""))
1207
+ overload = str(getattr(schema, "overload_name", "")) or "default"
1208
+ namespace, _, op_name = schema_name.partition("::")
1209
+ if namespace != "aten" or not op_name:
1210
+ return None
1211
+ return _normalize_pytorch_op_name(f"aten.{op_name}.{overload}")
1212
+
1213
+ return _normalize_pytorch_op_name(str(target))
1214
+
1215
+
1216
+ def _split_exported_op(exported_op: str) -> tuple[str, str] | None:
1217
+ prefix = "torch.ops.aten."
1218
+ if not exported_op.startswith(prefix):
1219
+ return None
1220
+ body = exported_op.removeprefix(prefix)
1221
+ if "." not in body:
1222
+ return None
1223
+ name, overload = body.rsplit(".", maxsplit=1)
1224
+ return name, overload
1225
+
1226
+
1227
+ def _torch_api_exists(api: str) -> bool:
1228
+ """Return whether a dotted torch API exists and is callable."""
1229
+
1230
+ if not api.startswith("torch."):
1231
+ return False
1232
+
1233
+ obj: object = torch
1234
+ for part in api.split(".")[1:]:
1235
+ if not hasattr(obj, part):
1236
+ return False
1237
+ obj = getattr(obj, part)
1238
+
1239
+ return callable(obj)
1240
+
1241
+
1242
+ def _fallback_pytorch_api_aliases(exported_op: str) -> tuple[str, ...]:
1243
+ split = _split_exported_op(exported_op)
1244
+ if split is None:
1245
+ return ()
1246
+
1247
+ name, _overload = split
1248
+ candidate = f"torch.{name}"
1249
+ return (candidate,) if _torch_api_exists(candidate) else ()
1250
+
1251
+
1252
+ def _pytorch_api_aliases(exported_op: str) -> tuple[str, ...]:
1253
+ return PYTORCH_API_ALIASES.get(
1254
+ exported_op, _fallback_pytorch_api_aliases(exported_op)
1255
+ )
1256
+
1257
+
1258
+ def _api_sort_key(apis: Sequence[str]) -> tuple[str, ...]:
1259
+ return tuple(api.lower() for api in apis)
1260
+
1261
+
1262
+ def _api_key(apis: Sequence[str]) -> str:
1263
+ return "\0".join(apis)
1264
+
1265
+
1266
+ def _call_class_name(node: ast.Call) -> str | None:
1267
+ if isinstance(node.func, ast.Name):
1268
+ return node.func.id
1269
+ return None
1270
+
1271
+
1272
+ def _call_keyword_bool(call: ast.Call, name: str, default: bool = False) -> bool:
1273
+ value = _keyword(call, name)
1274
+ return _literal_bool(value, default)
1275
+
1276
+
1277
+ def _class_attr_value(
1278
+ class_name: str,
1279
+ attr: str,
1280
+ context: ModuleContext,
1281
+ seen: set[tuple[str, str]] | None = None,
1282
+ ) -> ast.AST | None:
1283
+ class_ctx = context.classes.get(class_name)
1284
+ if class_ctx is None:
1285
+ return None
1286
+
1287
+ key = (class_name, attr)
1288
+ if seen is None:
1289
+ seen = set()
1290
+ if key in seen:
1291
+ return None
1292
+ seen.add(key)
1293
+
1294
+ value = class_ctx.assignments.get(attr)
1295
+ if isinstance(value, ast.Name):
1296
+ if value.id == attr:
1297
+ # In a class body, ``aten_op = aten_op`` resolves the right-hand
1298
+ # name from the surrounding module because the class attribute is
1299
+ # not bound until the assignment completes.
1300
+ return context.assignments.get(value.id, value)
1301
+ if value.id in class_ctx.assignments:
1302
+ # Resolve class-local aliases such as
1303
+ # ``quantized_aten_op = aten_op`` before falling back to module
1304
+ # assignments.
1305
+ return _class_attr_value(class_name, value.id, context, seen)
1306
+ return value
1307
+
1308
+
1309
+ def _resolve_name_expr(
1310
+ name: str,
1311
+ context: ModuleContext,
1312
+ scope: ResolutionScope,
1313
+ seen: set[tuple[str, str]],
1314
+ ) -> list[ast.AST]:
1315
+ """Resolve a name to one or more candidate AST expressions."""
1316
+
1317
+ if scope.class_name is not None:
1318
+ class_value = _class_attr_value(scope.class_name, name, context)
1319
+ if class_value is not None:
1320
+ class_key = ("class_attr", f"{scope.class_name}.{name}")
1321
+ if class_key in seen:
1322
+ return []
1323
+ seen.add(class_key)
1324
+ return _candidate_exprs(class_value, context, scope, seen)
1325
+
1326
+ key = ("name", name)
1327
+ if key in seen:
1328
+ return []
1329
+ seen.add(key)
1330
+
1331
+ if name in scope.locals:
1332
+ values: list[ast.AST] = []
1333
+ for candidate in scope.locals[name]:
1334
+ values.extend(_candidate_exprs(candidate, context, scope, seen.copy()))
1335
+ return values[:MAX_STATIC_EXPANSION]
1336
+ if name in scope.param_candidates:
1337
+ return scope.param_candidates[name]
1338
+ if name in context.assignments:
1339
+ return _candidate_exprs(context.assignments[name], context, scope, seen)
1340
+ return []
1341
+
1342
+
1343
+ def _dict_value_candidates(node: ast.Dict) -> list[ast.AST]:
1344
+ # common.parametrize(name, dict) in the Arm tests parametrizes over values.
1345
+ # Keys are test IDs; values are lambdas or pytest.param objects.
1346
+ return [value for value in node.values if value is not None]
1347
+
1348
+
1349
+ def _parametrize_names(node: ast.AST) -> list[str]:
1350
+ if not isinstance(node, ast.Constant) or not isinstance(node.value, str):
1351
+ return []
1352
+ return [part.strip() for part in node.value.split(",") if part.strip()]
1353
+
1354
+
1355
+ def _candidate_exprs( # noqa: C901
1356
+ node: ast.AST | None,
1357
+ context: ModuleContext,
1358
+ scope: ResolutionScope,
1359
+ seen: set[tuple[str, str]] | None = None,
1360
+ ) -> list[ast.AST]:
1361
+ """Expand an AST expression into possible runtime values when feasible."""
1362
+
1363
+ if node is None:
1364
+ return []
1365
+ if seen is None:
1366
+ seen = set()
1367
+
1368
+ if isinstance(node, ast.Name):
1369
+ name_values = _resolve_name_expr(node.id, context, scope, seen)
1370
+ return name_values or [node]
1371
+
1372
+ if isinstance(node, ast.Lambda):
1373
+ return _candidate_exprs(node.body, context, scope, seen)
1374
+
1375
+ if isinstance(node, ast.Call):
1376
+ call_name = _call_name(node.func)
1377
+ if call_name == "param" and node.args:
1378
+ return _candidate_exprs(node.args[0], context, scope, seen)
1379
+ if isinstance(node.func, ast.Name) and node.func.id in scope.param_candidates:
1380
+ parameter_values: list[ast.AST] = []
1381
+ for candidate in scope.param_candidates[node.func.id]:
1382
+ parameter_values.extend(
1383
+ _candidate_exprs(candidate, context, scope, seen)
1384
+ )
1385
+ return parameter_values[:MAX_STATIC_EXPANSION]
1386
+ return [node]
1387
+
1388
+ if isinstance(node, ast.Dict):
1389
+ dictionary_values: list[ast.AST] = []
1390
+ for value in _dict_value_candidates(node):
1391
+ dictionary_values.extend(_candidate_exprs(value, context, scope, seen))
1392
+ return dictionary_values[:MAX_STATIC_EXPANSION]
1393
+
1394
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
1395
+ union_values = _candidate_exprs(
1396
+ node.left, context, scope, seen
1397
+ ) + _candidate_exprs(node.right, context, scope, seen)
1398
+ return union_values[:MAX_STATIC_EXPANSION]
1399
+
1400
+ if isinstance(node, (ast.List, ast.Tuple, ast.Set)):
1401
+ collection_values: list[ast.AST] = []
1402
+ for element in node.elts:
1403
+ collection_values.extend(_candidate_exprs(element, context, scope, seen))
1404
+ return collection_values[:MAX_STATIC_EXPANSION]
1405
+
1406
+ return [node]
1407
+
1408
+
1409
+ def _parametrize_case_exprs( # noqa: C901
1410
+ node: ast.AST | None,
1411
+ context: ModuleContext,
1412
+ scope: ResolutionScope,
1413
+ seen: set[tuple[str, str]] | None = None,
1414
+ ) -> list[ast.AST]:
1415
+ """Expand a parametrization source while preserving each case tuple."""
1416
+
1417
+ if node is None:
1418
+ return []
1419
+ if seen is None:
1420
+ seen = set()
1421
+ if isinstance(node, ast.Name):
1422
+ key = ("param-source", node.id)
1423
+ if key in seen:
1424
+ return []
1425
+ seen.add(key)
1426
+ if node.id in context.assignments:
1427
+ return _parametrize_case_exprs(
1428
+ context.assignments[node.id], context, scope, seen
1429
+ )
1430
+ return [node]
1431
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
1432
+ return (
1433
+ _parametrize_case_exprs(node.left, context, scope, seen.copy())
1434
+ + _parametrize_case_exprs(node.right, context, scope, seen.copy())
1435
+ )[:MAX_STATIC_EXPANSION]
1436
+ if isinstance(node, ast.Dict):
1437
+ dictionary_cases: list[ast.AST] = []
1438
+ for value in _dict_value_candidates(node):
1439
+ dictionary_cases.extend(
1440
+ _parametrize_case_exprs(value, context, scope, seen.copy())
1441
+ )
1442
+ return dictionary_cases[:MAX_STATIC_EXPANSION]
1443
+ if isinstance(node, ast.Lambda):
1444
+ return [node.body]
1445
+ if isinstance(node, ast.Call) and _call_name(node.func) == "param" and node.args:
1446
+ return [node.args[0]]
1447
+ if isinstance(node, (ast.List, ast.Set)):
1448
+ collection_cases: list[ast.AST] = []
1449
+ for element in node.elts:
1450
+ collection_cases.extend(
1451
+ _parametrize_case_exprs(element, context, scope, seen.copy())
1452
+ )
1453
+ return collection_cases[:MAX_STATIC_EXPANSION]
1454
+ # A tuple is one case for single-argument parametrization. Multi-argument
1455
+ # parametrization splits it later in _parameter_candidates.
1456
+ return [node]
1457
+
1458
+
1459
+ def _parameter_candidates(
1460
+ function: ast.FunctionDef, context: ModuleContext
1461
+ ) -> dict[str, list[ast.AST]]:
1462
+ result: dict[str, list[ast.AST]] = {}
1463
+ scope = ResolutionScope()
1464
+
1465
+ for decorator in function.decorator_list:
1466
+ if not isinstance(decorator, ast.Call):
1467
+ continue
1468
+ if "parametrize" not in _expr_text(decorator.func):
1469
+ continue
1470
+ if len(decorator.args) < 2:
1471
+ continue
1472
+ names = _parametrize_names(decorator.args[0])
1473
+ if not names:
1474
+ continue
1475
+
1476
+ candidates = _parametrize_case_exprs(decorator.args[1], context, scope)
1477
+ if len(names) == 1:
1478
+ result.setdefault(names[0], []).extend(candidates[:MAX_STATIC_EXPANSION])
1479
+ continue
1480
+
1481
+ for candidate in candidates:
1482
+ if not isinstance(candidate, (ast.Tuple, ast.List)):
1483
+ continue
1484
+ for name, value in zip(names, candidate.elts):
1485
+ result.setdefault(name, []).append(value)
1486
+
1487
+ for name, candidates in result.items():
1488
+ result[name] = candidates[:MAX_STATIC_EXPANSION]
1489
+ return result
1490
+
1491
+
1492
+ def _bind_assignment_target(
1493
+ target: ast.AST,
1494
+ values: list[ast.AST],
1495
+ bindings: dict[str, list[ast.AST]],
1496
+ ) -> None:
1497
+ if isinstance(target, ast.Name):
1498
+ bindings[target.id] = values[:MAX_STATIC_EXPANSION]
1499
+ return
1500
+
1501
+ if isinstance(target, ast.Starred):
1502
+ _bind_assignment_target(target.value, values, bindings)
1503
+ return
1504
+ if not isinstance(target, (ast.Tuple, ast.List)):
1505
+ return
1506
+
1507
+ element_values: list[list[ast.AST]] = [[] for _ in target.elts]
1508
+ for value in values:
1509
+ if not isinstance(value, (ast.Tuple, ast.List)):
1510
+ continue
1511
+ for index, element in enumerate(value.elts[: len(target.elts)]):
1512
+ element_values[index].append(element)
1513
+
1514
+ for target_element, candidates in zip(target.elts, element_values):
1515
+ if candidates:
1516
+ _bind_assignment_target(target_element, candidates, bindings)
1517
+
1518
+
1519
+ def _iter_statements_before(
1520
+ statements: list[ast.stmt], marker_line: int
1521
+ ) -> Iterable[ast.stmt]:
1522
+ """Yield statements lexically preceding a marker, including nested blocks.
1523
+
1524
+ Compound statement nodes do not expose a uniform set of fields. In
1525
+ particular, ``with``/``async with`` have ``body`` but no ``orelse``. Keep
1526
+ the cases explicit rather than probing attributes that do not exist.
1527
+
1528
+ Nested function and class bodies are intentionally not traversed: their
1529
+ assignments are not local bindings executed in the enclosing test function.
1530
+
1531
+ """
1532
+
1533
+ for statement in statements:
1534
+ if getattr(statement, "lineno", 10**9) >= marker_line:
1535
+ continue
1536
+
1537
+ yield statement
1538
+ nested: list[list[ast.stmt]] = []
1539
+
1540
+ if isinstance(statement, ast.If):
1541
+ nested.extend((statement.body, statement.orelse))
1542
+ elif isinstance(statement, (ast.For, ast.AsyncFor, ast.While)):
1543
+ nested.extend((statement.body, statement.orelse))
1544
+ elif isinstance(statement, (ast.With, ast.AsyncWith)):
1545
+ nested.append(statement.body)
1546
+ elif isinstance(statement, ast.Try):
1547
+ nested.extend((statement.body, statement.orelse, statement.finalbody))
1548
+ nested.extend(handler.body for handler in statement.handlers)
1549
+ elif type(statement).__name__ == "TryStar":
1550
+ # ``ast.TryStar`` is available only on newer Python versions. The
1551
+ # class-name check does not narrow ``statement`` for MyPy, so use
1552
+ # targeted ignores on its try-specific fields.
1553
+ nested.extend(
1554
+ (
1555
+ cast(
1556
+ list[ast.stmt],
1557
+ statement.body, # type: ignore[attr-defined]
1558
+ ),
1559
+ cast(
1560
+ list[ast.stmt],
1561
+ statement.orelse, # type: ignore[attr-defined]
1562
+ ),
1563
+ cast(
1564
+ list[ast.stmt],
1565
+ statement.finalbody, # type: ignore[attr-defined]
1566
+ ),
1567
+ )
1568
+ )
1569
+ handlers = cast(
1570
+ list[ast.ExceptHandler],
1571
+ statement.handlers, # type: ignore[attr-defined]
1572
+ )
1573
+ nested.extend(handler.body for handler in handlers)
1574
+ elif isinstance(statement, ast.Match):
1575
+ nested.extend(case.body for case in statement.cases)
1576
+
1577
+ for block in nested:
1578
+ yield from _iter_statements_before(block, marker_line)
1579
+
1580
+
1581
+ def _local_assignments_before(
1582
+ function: ast.FunctionDef,
1583
+ marker: ast.AST,
1584
+ context: ModuleContext,
1585
+ param_candidates: dict[str, list[ast.AST]],
1586
+ ) -> dict[str, list[ast.AST]]:
1587
+ """Collect local bindings in source order using pre-assignment RHS scope."""
1588
+
1589
+ marker_line = getattr(marker, "lineno", 10**9)
1590
+ bindings: dict[str, list[ast.AST]] = {}
1591
+ for node in _iter_statements_before(function.body, marker_line):
1592
+ if isinstance(node, ast.Assign):
1593
+ snapshot = {name: list(values) for name, values in bindings.items()}
1594
+ scope = ResolutionScope(locals=snapshot, param_candidates=param_candidates)
1595
+ if (
1596
+ isinstance(node.value, ast.Call)
1597
+ and isinstance(node.value.func, ast.Name)
1598
+ and node.value.func.id in param_candidates
1599
+ ):
1600
+ values = list(param_candidates[node.value.func.id])
1601
+ else:
1602
+ values = _candidate_exprs(node.value, context, scope) or [node.value]
1603
+ for target in node.targets:
1604
+ _bind_assignment_target(target, values, bindings)
1605
+ elif isinstance(node, ast.AnnAssign) and node.value is not None:
1606
+ snapshot = {name: list(values) for name, values in bindings.items()}
1607
+ scope = ResolutionScope(locals=snapshot, param_candidates=param_candidates)
1608
+ values = _candidate_exprs(node.value, context, scope) or [node.value]
1609
+ _bind_assignment_target(node.target, values, bindings)
1610
+ return bindings
1611
+
1612
+
1613
+ def _scope_for_call(
1614
+ function: ast.FunctionDef, call: ast.Call, context: ModuleContext
1615
+ ) -> ResolutionScope:
1616
+ params = _parameter_candidates(function, context)
1617
+ return ResolutionScope(
1618
+ locals=_local_assignments_before(function, call, context, params),
1619
+ param_candidates=params,
1620
+ )
1621
+
1622
+
1623
+ def _constructor_arg(
1624
+ call: ast.Call,
1625
+ class_ctx: ClassContext,
1626
+ field_name: str,
1627
+ ) -> ast.AST | None:
1628
+ if field_name in class_ctx.fields:
1629
+ index = class_ctx.fields.index(field_name)
1630
+ if len(call.args) > index:
1631
+ return call.args[index]
1632
+
1633
+ for keyword in call.keywords:
1634
+ if keyword.arg == field_name:
1635
+ return keyword.value
1636
+ return None
1637
+
1638
+
1639
+ def _model_attr_from_test_case_call(
1640
+ test_case_call: ast.Call,
1641
+ attr: str,
1642
+ context: ModuleContext,
1643
+ scope: ResolutionScope,
1644
+ ) -> list[str]:
1645
+ """Resolve patterns such as EluTestCase(Elu(), ...).aten_op()."""
1646
+
1647
+ class_name = _call_class_name(test_case_call)
1648
+ if class_name is None:
1649
+ return []
1650
+
1651
+ class_ctx = context.classes.get(class_name)
1652
+ if class_ctx is None:
1653
+ return []
1654
+
1655
+ model_expr = _constructor_arg(test_case_call, class_ctx, "model")
1656
+ if model_expr is None and test_case_call.args:
1657
+ # Dataclass test case helpers nearly always place the module/model as
1658
+ # the first field. Use that as a conservative fallback.
1659
+ model_expr = test_case_call.args[0]
1660
+ if model_expr is None:
1661
+ return []
1662
+
1663
+ values: list[str] = []
1664
+ for model_candidate in _candidate_exprs(model_expr, context, scope):
1665
+ if isinstance(model_candidate, ast.Call):
1666
+ model_class = _call_class_name(model_candidate)
1667
+ elif isinstance(model_candidate, ast.Name):
1668
+ model_class = model_candidate.id
1669
+ else:
1670
+ model_class = None
1671
+ if model_class is None:
1672
+ continue
1673
+
1674
+ attr_value = _class_attr_value(model_class, attr, context)
1675
+ values.extend(
1676
+ _op_texts(attr_value, context, _scope_with_class(scope, model_class))
1677
+ )
1678
+ return values
1679
+
1680
+
1681
+ def _resolve_getattr_call(
1682
+ node: ast.Call,
1683
+ context: ModuleContext,
1684
+ scope: ResolutionScope,
1685
+ ) -> list[str]:
1686
+ """Resolve simple getattr(obj, "aten_op") static patterns."""
1687
+
1688
+ if _call_name(node.func) != "getattr" or len(node.args) < 2:
1689
+ return []
1690
+
1691
+ attr_names: list[str] = []
1692
+ attr_arg = node.args[1]
1693
+ if isinstance(attr_arg, ast.Constant) and isinstance(attr_arg.value, str):
1694
+ attr_names = [attr_arg.value]
1695
+ elif isinstance(attr_arg, ast.Name):
1696
+ for candidate in _candidate_exprs(attr_arg, context, scope):
1697
+ if isinstance(candidate, ast.Constant) and isinstance(candidate.value, str):
1698
+ attr_names.append(candidate.value)
1699
+ if not attr_names:
1700
+ return []
1701
+
1702
+ values: list[str] = []
1703
+ for obj_candidate in _candidate_exprs(node.args[0], context, scope):
1704
+ if isinstance(obj_candidate, ast.Call):
1705
+ class_name = _call_class_name(obj_candidate)
1706
+ elif isinstance(obj_candidate, ast.Name):
1707
+ class_name = obj_candidate.id
1708
+ else:
1709
+ class_name = None
1710
+ if class_name is None:
1711
+ continue
1712
+ for attr_name in attr_names:
1713
+ values.extend(
1714
+ _op_texts(
1715
+ _class_attr_value(class_name, attr_name, context),
1716
+ context,
1717
+ _scope_with_class(scope, class_name),
1718
+ )
1719
+ )
1720
+ return values
1721
+
1722
+
1723
+ def _method_attr_for_call(method_name: str, call: ast.Call) -> str | None:
1724
+ """Map helper method calls such as aten_op(quantized=True) to class
1725
+ attrs.
1726
+ """
1727
+
1728
+ if method_name not in {"aten_op", "exir_op"}:
1729
+ return None
1730
+
1731
+ quantized = _call_keyword_bool(call, "quantized", default=False)
1732
+ if quantized:
1733
+ return f"quantized_{method_name}"
1734
+ return method_name
1735
+
1736
+
1737
+ def _resolve_helper_method_call(
1738
+ node: ast.Call,
1739
+ context: ModuleContext,
1740
+ scope: ResolutionScope,
1741
+ ) -> list[str]:
1742
+ """Resolve simple test helper method calls returning operator names.
1743
+
1744
+ The important pattern is a parametrized callable that returns a dataclass-like
1745
+ object with a ``model`` field. Example::
1746
+
1747
+ @common.parametrize("test_case", test_suite)
1748
+ def test_foo(test_case):
1749
+ test_case = test_case()
1750
+ BackendPipeline(..., aten_op=test_case.aten_op())
1751
+
1752
+ where each suite entry is ``lambda: FooTestCase(Model(), inputs)`` and
1753
+ ``FooTestCase.aten_op()`` returns ``getattr(self.model, "aten_op")``.
1754
+
1755
+ """
1756
+
1757
+ if not isinstance(node.func, ast.Attribute):
1758
+ return []
1759
+
1760
+ attr = _method_attr_for_call(node.func.attr, node)
1761
+ if attr is None:
1762
+ return []
1763
+
1764
+ receiver = node.func.value
1765
+ values: list[str] = []
1766
+ for receiver_candidate in _candidate_exprs(receiver, context, scope):
1767
+ if isinstance(receiver_candidate, ast.Call):
1768
+ # Direct class helper object: FooTestCase(Foo(), ...).aten_op()
1769
+ values.extend(
1770
+ _model_attr_from_test_case_call(
1771
+ receiver_candidate, attr, context, scope
1772
+ )
1773
+ )
1774
+
1775
+ # Direct model instance: Foo().aten_op() is unusual but cheap to
1776
+ # support when the class attribute exists.
1777
+ class_name = _call_class_name(receiver_candidate)
1778
+ if class_name is not None:
1779
+ values.extend(
1780
+ _op_texts(
1781
+ _class_attr_value(class_name, attr, context),
1782
+ context,
1783
+ _scope_with_class(scope, class_name),
1784
+ )
1785
+ )
1786
+ elif isinstance(receiver_candidate, ast.Name):
1787
+ values.extend(
1788
+ _op_texts(
1789
+ _class_attr_value(receiver_candidate.id, attr, context),
1790
+ context,
1791
+ _scope_with_class(scope, receiver_candidate.id),
1792
+ )
1793
+ )
1794
+ return values
1795
+
1796
+
1797
+ def _op_texts( # noqa: C901
1798
+ node: ast.AST | None,
1799
+ context: ModuleContext,
1800
+ scope: ResolutionScope | None = None,
1801
+ seen: set[tuple[str, str]] | None = None,
1802
+ ) -> list[str]:
1803
+ """Return raw operator-name strings represented by a static AST
1804
+ expression.
1805
+ """
1806
+
1807
+ if node is None:
1808
+ return []
1809
+ if scope is None:
1810
+ scope = ResolutionScope()
1811
+ if seen is None:
1812
+ seen = set()
1813
+
1814
+ if isinstance(node, ast.Constant):
1815
+ if isinstance(node.value, str):
1816
+ return [node.value]
1817
+ return []
1818
+
1819
+ if isinstance(node, ast.Name):
1820
+ name_values: list[str] = []
1821
+ for candidate in _resolve_name_expr(node.id, context, scope, seen):
1822
+ name_values.extend(_op_texts(candidate, context, scope, seen))
1823
+ return name_values
1824
+
1825
+ if isinstance(node, ast.Subscript):
1826
+ subscript_values = _op_texts(node.value, context, scope, seen.copy())
1827
+ index = node.slice.value if isinstance(node.slice, ast.Constant) else None
1828
+ if isinstance(index, int):
1829
+ return (
1830
+ subscript_values[index : index + 1]
1831
+ if index >= 0
1832
+ else subscript_values[index:]
1833
+ )
1834
+ return subscript_values
1835
+
1836
+ if isinstance(node, ast.Attribute):
1837
+ # ClassName.aten_op or a local instance such as model.aten_op.
1838
+ if isinstance(node.value, ast.Name):
1839
+ class_value = _class_attr_value(node.value.id, node.attr, context)
1840
+ if class_value is not None:
1841
+ return _op_texts(
1842
+ class_value,
1843
+ context,
1844
+ _scope_with_class(scope, node.value.id),
1845
+ seen,
1846
+ )
1847
+
1848
+ instance_attribute_values: list[str] = []
1849
+ for candidate in _candidate_exprs(node.value, context, scope, seen.copy()):
1850
+ if isinstance(candidate, ast.Call):
1851
+ class_name = _call_class_name(candidate)
1852
+ if class_name is not None:
1853
+ instance_attribute_values.extend(
1854
+ _op_texts(
1855
+ _class_attr_value(class_name, node.attr, context),
1856
+ context,
1857
+ _scope_with_class(scope, class_name),
1858
+ seen.copy(),
1859
+ )
1860
+ )
1861
+ if instance_attribute_values:
1862
+ return instance_attribute_values
1863
+
1864
+ # ClassName().aten_op or local_factory().aten_op
1865
+ if isinstance(node.value, ast.Call):
1866
+ call_attribute_values: list[str] = []
1867
+ for candidate in _candidate_exprs(node.value, context, scope, seen):
1868
+ if isinstance(candidate, ast.Call):
1869
+ class_name = _call_class_name(candidate)
1870
+ if class_name is not None:
1871
+ call_attribute_values.extend(
1872
+ _op_texts(
1873
+ _class_attr_value(class_name, node.attr, context),
1874
+ context,
1875
+ _scope_with_class(scope, class_name),
1876
+ seen,
1877
+ )
1878
+ )
1879
+ if call_attribute_values:
1880
+ return call_attribute_values
1881
+
1882
+ # Preserve direct operator-handle expressions such as
1883
+ # torch.ops.aten.neg.default, but still reject unresolved helper
1884
+ # expressions such as Neg.aten_op. The normalizer only accepts
1885
+ # ATen/Edge namespaces, so it is safe to use as a guard here.
1886
+ text = _attribute_name(node)
1887
+ return [text] if _normalize_pytorch_op_name(text) is not None else []
1888
+
1889
+ if isinstance(node, ast.Call):
1890
+ getattr_values = _resolve_getattr_call(node, context, scope)
1891
+ if getattr_values:
1892
+ return getattr_values
1893
+
1894
+ helper_values = _resolve_helper_method_call(node, context, scope)
1895
+ if helper_values:
1896
+ return helper_values
1897
+
1898
+ if _call_name(node.func) == "param" and node.args:
1899
+ return _op_texts(node.args[0], context, scope, seen)
1900
+
1901
+ # Calling a parametrized callable, e.g. test_module(), can reveal a
1902
+ # lambda body. This is mainly useful when an operator expression itself
1903
+ # is wrapped in a helper value.
1904
+ candidates = _candidate_exprs(node, context, scope, seen)
1905
+ if candidates != [node]:
1906
+ candidate_values: list[str] = []
1907
+ for candidate in candidates:
1908
+ candidate_values.extend(_op_texts(candidate, context, scope, seen))
1909
+ return candidate_values
1910
+
1911
+ return []
1912
+
1913
+ if isinstance(node, (ast.List, ast.Tuple, ast.Set)):
1914
+ collection_values: list[str] = []
1915
+ for element in node.elts:
1916
+ collection_values.extend(_op_texts(element, context, scope, seen))
1917
+ return collection_values
1918
+
1919
+ if isinstance(node, ast.Dict):
1920
+ dictionary_values: list[str] = []
1921
+ for value in _dict_value_candidates(node):
1922
+ dictionary_values.extend(_op_texts(value, context, scope, seen))
1923
+ return dictionary_values
1924
+
1925
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
1926
+ return _op_texts(node.left, context, scope, seen) + _op_texts(
1927
+ node.right, context, scope, seen
1928
+ )
1929
+
1930
+ return []
1931
+
1932
+
1933
+ def _resolve_exported_ops(
1934
+ node: ast.AST | None,
1935
+ context: ModuleContext,
1936
+ scope: ResolutionScope | None = None,
1937
+ diagnostics: list[str] | None = None,
1938
+ ) -> list[str]:
1939
+ ops = []
1940
+ for value in _op_texts(node, context, scope):
1941
+ normalized = _normalize_pytorch_op_name(
1942
+ value, path=context.path, diagnostics=diagnostics
1943
+ )
1944
+ if normalized is not None:
1945
+ ops.append(normalized)
1946
+ return sorted(set(ops))
1947
+
1948
+
1949
+ def _is_empty_op_expr(node: ast.AST | None) -> bool:
1950
+ return isinstance(node, (ast.List, ast.Tuple, ast.Set)) and not node.elts
1951
+
1952
+
1953
+ def _fallback_exported_ops_for_unattributed_pipeline_call(
1954
+ context: ModuleContext,
1955
+ scope: ResolutionScope,
1956
+ ) -> list[str]:
1957
+ """Infer coverage for op-level tests that pass an empty ATen op list.
1958
+
1959
+ Several op tests intentionally disable operator-distribution assertions in
1960
+ the configured backend pipeline by passing empty operator lists even though
1961
+ the module still defines a single module-level ``aten_op``/``aten_ops``
1962
+ constant. Treat those as backend coverage for --check/debug. Multi-op and
1963
+ model tests stay unattributed.
1964
+
1965
+ """
1966
+
1967
+ if "ops" not in context.path.parts:
1968
+ return []
1969
+
1970
+ candidates: list[str] = []
1971
+ for name in ("aten_op", "aten_ops"):
1972
+ assigned = context.assignments.get(name)
1973
+ if assigned is not None:
1974
+ candidates.extend(_resolve_exported_ops(assigned, context, scope))
1975
+
1976
+ unique = sorted(set(candidates))
1977
+ return unique if len(unique) == 1 else []
1978
+
1979
+
1980
+ def _has_xfail_marker(node: ast.AST) -> bool:
1981
+ return "xfail" in _expr_text(node).lower()
1982
+
1983
+
1984
+ def _dtype_from_expr(node: ast.AST) -> str | None:
1985
+ text = _expr_text(node).lower()
1986
+ attr = _attribute_name(node).lower() if isinstance(node, ast.Attribute) else ""
1987
+ combined = f"{text} {attr}"
1988
+ if "bfloat16" in combined or "bf16" in combined:
1989
+ return "BF16"
1990
+ if "float16" in combined or "fp16" in combined:
1991
+ return "FP16"
1992
+ if "float32" in combined or "fp32" in combined:
1993
+ return "FP32"
1994
+ if "torch.bool" in combined or "dtype=torch.bool" in combined:
1995
+ return "BOOL"
1996
+ return None
1997
+
1998
+
1999
+ def _dtype_hints_from_data_expr(node: ast.AST, context: ModuleContext) -> set[str]:
2000
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
2001
+ return _dtype_hints_from_data_expr(
2002
+ node.left, context
2003
+ ) | _dtype_hints_from_data_expr(node.right, context)
2004
+
2005
+ if isinstance(node, (ast.List, ast.Tuple, ast.Set)):
2006
+ collection_dtypes: set[str] = set()
2007
+ for element in node.elts:
2008
+ collection_dtypes.update(_dtype_hints_from_data_expr(element, context))
2009
+ return collection_dtypes
2010
+
2011
+ if isinstance(node, ast.Dict):
2012
+ dictionary_dtypes: set[str] = set()
2013
+ for value in _dict_value_candidates(node):
2014
+ dictionary_dtypes.update(_dtype_hints_from_data_expr(value, context))
2015
+ return dictionary_dtypes
2016
+
2017
+ if isinstance(node, ast.Call):
2018
+ name = _call_name(node.func)
2019
+ if name in context.functions:
2020
+ return _dtype_hints_from_helper(context.functions[name])
2021
+ return _dtype_hints_from_text(_expr_text(node))
2022
+
2023
+ if isinstance(node, ast.Name):
2024
+ assigned = context.assignments.get(node.id)
2025
+ if assigned is not None:
2026
+ return _dtype_hints_from_data_expr(assigned, context)
2027
+ return _dtype_hints_from_text(node.id)
2028
+
2029
+ if isinstance(node, ast.Attribute):
2030
+ return _dtype_hints_from_text(_attribute_name(node))
2031
+
2032
+ return _dtype_hints_from_text(_expr_text(node))
2033
+
2034
+
2035
+ def _dtype_hints_from_helper(function: ast.FunctionDef) -> set[str]:
2036
+ dtypes: set[str] = set()
2037
+
2038
+ def collect(node: ast.AST) -> None:
2039
+ if isinstance(node, (ast.List, ast.Tuple, ast.Set)):
2040
+ for element in node.elts:
2041
+ collect(element)
2042
+ return
2043
+
2044
+ if isinstance(node, ast.Call) and _call_name(node.func) == "param":
2045
+ # Do not claim support from parameter cases that are explicitly
2046
+ # marked xfail, for example BF16 cases that exist to document
2047
+ # missing runtime support.
2048
+ if _has_xfail_marker(node):
2049
+ return
2050
+ if node.args:
2051
+ collect(node.args[0])
2052
+ return
2053
+
2054
+ dtype = _dtype_from_expr(node)
2055
+ if dtype is not None:
2056
+ dtypes.add(dtype)
2057
+
2058
+ for return_node in [
2059
+ node for node in ast.walk(function) if isinstance(node, ast.Return)
2060
+ ]:
2061
+ if return_node.value is not None:
2062
+ collect(return_node.value)
2063
+ return dtypes
2064
+
2065
+
2066
+ def _dtype_hints_from_text(text: str) -> set[str]:
2067
+ value = text.lower()
2068
+ dtypes: set[str] = set()
2069
+ if "test_data_bf16" in value or "bfloat16" in value or "bf16" in value:
2070
+ dtypes.add("BF16")
2071
+ if "test_data_fp16" in value or "float16" in value or "fp16" in value:
2072
+ dtypes.add("FP16")
2073
+ if "float32" in value or "fp32" in value:
2074
+ dtypes.add("FP32")
2075
+ if "torch.bool" in value or "dtype=torch.bool" in value:
2076
+ dtypes.add("BOOL")
2077
+ if re.search(r"(^|\.)test_data($|[^a-z0-9_])", value):
2078
+ dtypes.add("FP32")
2079
+ return dtypes
2080
+
2081
+
2082
+ def _infer_fp_dtypes(
2083
+ function: ast.FunctionDef, call: ast.Call, context: ModuleContext
2084
+ ) -> set[str]:
2085
+ dtypes: set[str] = set()
2086
+
2087
+ test_data_expr = _positional_or_keyword(call, 1, "test_data")
2088
+ if test_data_expr is not None:
2089
+ dtypes.update(_dtype_hints_from_data_expr(test_data_expr, context))
2090
+
2091
+ for decorator in function.decorator_list:
2092
+ decorator_text = _expr_text(decorator).lower()
2093
+ if "parametrize" not in decorator_text:
2094
+ continue
2095
+ if isinstance(decorator, ast.Call) and len(decorator.args) >= 2:
2096
+ param_name = decorator.args[0]
2097
+ if isinstance(param_name, ast.Constant) and isinstance(
2098
+ param_name.value, str
2099
+ ):
2100
+ if "test_data" in param_name.value or "dtype" in param_name.value:
2101
+ dtypes.update(
2102
+ _dtype_hints_from_data_expr(decorator.args[1], context)
2103
+ )
2104
+ else:
2105
+ dtypes.update(_dtype_hints_from_text(decorator_text))
2106
+
2107
+ # The common test_data dictionaries use torch.randn/torch.ones without an
2108
+ # explicit dtype, which means FP32. Keep that as the default FP path.
2109
+ if not dtypes:
2110
+ dtypes.add("FP32")
2111
+ return dtypes
2112
+
2113
+
2114
+ def _function_has_a16w8_quantization(function: ast.FunctionDef, call: ast.Call) -> bool:
2115
+ function_text = _expr_text(function)
2116
+ call_text = _expr_text(call)
2117
+ return (
2118
+ "get_symmetric_a16w8_quantization_config" in function_text
2119
+ or "a16w8_quantization=True" in call_text
2120
+ or "tosa_extensions=['int16']" in call_text
2121
+ or 'tosa_extensions=["int16"]' in call_text
2122
+ )
2123
+
2124
+
2125
+ def _function_has_a8w4_quantization(function: ast.FunctionDef, call: ast.Call) -> bool:
2126
+ function_text = _expr_text(function)
2127
+ call_text = _expr_text(call)
2128
+ return (
2129
+ "get_symmetric_a8w4_quantization_config" in function_text
2130
+ or "a8w4_quantization=True" in call_text
2131
+ )
2132
+
2133
+
2134
+ def _function_is_skipped_or_xfailed(function: ast.FunctionDef) -> bool:
2135
+ infrastructure_markers = {
2136
+ marker.lower() for marker in BACKEND_INFRASTRUCTURE_XFAIL_MARKERS
2137
+ }
2138
+ for decorator in function.decorator_list:
2139
+ text = _expr_text(decorator).lower()
2140
+ # Skip semantic function-level xfails. Backend infrastructure xfails
2141
+ # (for example a missing Corstone FVP) still prove static coverage and
2142
+ # are explicitly retained by the selected BackendConfig.
2143
+ if "xfail" in text and "parametrize" not in text:
2144
+ if any(marker in text for marker in infrastructure_markers):
2145
+ continue
2146
+ return True
2147
+ return False
2148
+
2149
+
2150
+ def _class_context(node: ast.ClassDef) -> ClassContext:
2151
+ ctx = ClassContext()
2152
+
2153
+ for stmt in node.body:
2154
+ if isinstance(stmt, ast.Assign):
2155
+ for target in stmt.targets:
2156
+ if isinstance(target, ast.Name):
2157
+ ctx.assignments[target.id] = stmt.value
2158
+ if target.id not in ctx.fields:
2159
+ ctx.fields.append(target.id)
2160
+ elif isinstance(stmt, ast.AnnAssign) and isinstance(stmt.target, ast.Name):
2161
+ if stmt.target.id not in ctx.fields:
2162
+ ctx.fields.append(stmt.target.id)
2163
+ if stmt.value is not None:
2164
+ ctx.assignments[stmt.target.id] = stmt.value
2165
+ elif isinstance(stmt, ast.FunctionDef):
2166
+ ctx.methods[stmt.name] = stmt
2167
+
2168
+ return ctx
2169
+
2170
+
2171
+ def _build_module_context( # noqa: C901
2172
+ path: Path, repo_root: Path
2173
+ ) -> ModuleContext | None:
2174
+ try:
2175
+ source = path.read_text()
2176
+ tree = ast.parse(source, filename=str(path))
2177
+ except (OSError, SyntaxError):
2178
+ return None
2179
+
2180
+ assignments: dict[str, ast.AST] = {}
2181
+ functions: dict[str, ast.FunctionDef] = {}
2182
+ classes: dict[str, ClassContext] = {}
2183
+ parents: dict[ast.AST, ast.AST] = {}
2184
+
2185
+ for parent in ast.walk(tree):
2186
+ for child in ast.iter_child_nodes(parent):
2187
+ parents[child] = parent
2188
+
2189
+ for node in tree.body:
2190
+ if isinstance(node, ast.Assign):
2191
+ for target in node.targets:
2192
+ if isinstance(target, ast.Name):
2193
+ assignments[target.id] = node.value
2194
+ elif isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name):
2195
+ if node.value is not None:
2196
+ assignments[node.target.id] = node.value
2197
+ elif isinstance(node, ast.FunctionDef):
2198
+ functions[node.name] = node
2199
+ elif isinstance(node, ast.ClassDef):
2200
+ classes[node.name] = _class_context(node)
2201
+
2202
+ return ModuleContext(
2203
+ path=path.relative_to(repo_root),
2204
+ source=source,
2205
+ tree=tree,
2206
+ assignments=assignments,
2207
+ functions=functions,
2208
+ classes=classes,
2209
+ parents=parents,
2210
+ )
2211
+
2212
+
2213
+ def _find_enclosing_function(
2214
+ node: ast.AST, context: ModuleContext
2215
+ ) -> ast.FunctionDef | None:
2216
+ current = node
2217
+ while current in context.parents:
2218
+ current = context.parents[current]
2219
+ if isinstance(current, ast.FunctionDef):
2220
+ return current
2221
+ return None
2222
+
2223
+
2224
+ def _add_coverage(
2225
+ rows: dict[str, PipelineCoverage],
2226
+ op: str,
2227
+ profile: str,
2228
+ stage: str,
2229
+ test_label: str,
2230
+ function: ast.FunctionDef,
2231
+ call: ast.Call,
2232
+ context: ModuleContext,
2233
+ *,
2234
+ classification: str = DIRECT,
2235
+ asserted_op: str | None = None,
2236
+ ) -> None:
2237
+ row = rows.setdefault(
2238
+ op,
2239
+ PipelineCoverage(
2240
+ exported_op=op,
2241
+ pytorch_apis=_pytorch_api_aliases(op),
2242
+ ),
2243
+ )
2244
+ row.tests.add(test_label)
2245
+ row.support_profiles.add(profile)
2246
+ row.stages.add(stage)
2247
+ row.classifications.add(classification)
2248
+ row.evidence_records.append(
2249
+ CoverageEvidence(
2250
+ exported_op=op,
2251
+ profile=profile,
2252
+ stage=stage,
2253
+ classification=classification,
2254
+ test=test_label,
2255
+ asserted_op=asserted_op or op,
2256
+ )
2257
+ )
2258
+
2259
+ if profile == "INT":
2260
+ if _function_has_a16w8_quantization(function, call):
2261
+ row.dtypes.add("INT16")
2262
+ row.quantization_modes.add("16x8")
2263
+ elif _function_has_a8w4_quantization(function, call):
2264
+ row.dtypes.add("INT4")
2265
+ row.quantization_modes.add("8x4")
2266
+ else:
2267
+ row.dtypes.add("INT8")
2268
+ row.quantization_modes.add("8x8")
2269
+ else:
2270
+ row.dtypes.update(_infer_fp_dtypes(function, call, context))
2271
+
2272
+
2273
+ def _removed_pipeline_stages(
2274
+ function: ast.FunctionDef, pipeline_var: str | None
2275
+ ) -> set[str]:
2276
+ if pipeline_var is None:
2277
+ return set()
2278
+ removed: set[str] = set()
2279
+ for node in ast.walk(function):
2280
+ if not isinstance(node, ast.Call) or not isinstance(node.func, ast.Attribute):
2281
+ continue
2282
+ if node.func.attr != "pop_stage" or not isinstance(node.func.value, ast.Name):
2283
+ continue
2284
+ if node.func.value.id != pipeline_var or not node.args:
2285
+ continue
2286
+ if isinstance(node.args[0], ast.Constant) and isinstance(
2287
+ node.args[0].value, str
2288
+ ):
2289
+ removed.add(node.args[0].value)
2290
+ return removed
2291
+
2292
+
2293
+ def _assigned_pipeline_name(call: ast.Call, context: ModuleContext) -> str | None:
2294
+ parent = context.parents.get(call)
2295
+ if (
2296
+ isinstance(parent, ast.Assign)
2297
+ and len(parent.targets) == 1
2298
+ and isinstance(parent.targets[0], ast.Name)
2299
+ ):
2300
+ return parent.targets[0].id
2301
+ if isinstance(parent, ast.AnnAssign) and isinstance(parent.target, ast.Name):
2302
+ return parent.target.id
2303
+ return None
2304
+
2305
+
2306
+ def _scan_backend_pipeline_tests( # noqa: C901
2307
+ repo_root: Path,
2308
+ ) -> tuple[dict[str, PipelineCoverage], list[UnresolvedPipelineEvidence], list[str]]:
2309
+ rows: dict[str, PipelineCoverage] = {}
2310
+ unresolved: list[UnresolvedPipelineEvidence] = []
2311
+ normalisation_diagnostics: list[str] = []
2312
+ test_dir = repo_root / TEST_ROOT
2313
+ if not test_dir.is_dir():
2314
+ raise RuntimeError(
2315
+ f"Could not locate {BACKEND_NAME} test directory: {test_dir}"
2316
+ )
2317
+
2318
+ for path in sorted(test_dir.rglob("*.py")):
2319
+ context = _build_module_context(path, repo_root)
2320
+ if context is None:
2321
+ continue
2322
+
2323
+ for node in ast.walk(context.tree):
2324
+ if not isinstance(node, ast.Call) or not _is_backend_pipeline_call(node):
2325
+ continue
2326
+ function = _find_enclosing_function(node, context)
2327
+ if function is None or _function_is_skipped_or_xfailed(function):
2328
+ continue
2329
+
2330
+ profile = _pipeline_profile(node)
2331
+ test_label = f"{context.path}::{function.name}"
2332
+ scope = _scope_for_call(function, node, context)
2333
+ aten_expr = _pipeline_operator_expr(
2334
+ node, PIPELINE_ATEN_OP_POSITION, PIPELINE_ATEN_OP_KEYWORDS
2335
+ )
2336
+ exir_expr = _pipeline_operator_expr(
2337
+ node, PIPELINE_EXIR_OP_POSITION, PIPELINE_EXIR_OP_KEYWORDS
2338
+ )
2339
+
2340
+ diagnostics: list[str] = []
2341
+ aten_ops = _resolve_exported_ops(aten_expr, context, scope, diagnostics)
2342
+ exir_ops = _resolve_exported_ops(exir_expr, context, scope, diagnostics)
2343
+ normalisation_diagnostics.extend(
2344
+ f"{test_label}: {message}" for message in diagnostics
2345
+ )
2346
+
2347
+ removed = _removed_pipeline_stages(
2348
+ function, _assigned_pipeline_name(node, context)
2349
+ )
2350
+ aten_assertion_removed = bool({"check.aten", "check_count.aten"} & removed)
2351
+ exir_assertion_removed = bool({"check.exir", "check_count.exir"} & removed)
2352
+
2353
+ if not aten_assertion_removed:
2354
+ for op in aten_ops:
2355
+ _add_coverage(
2356
+ rows,
2357
+ op,
2358
+ profile,
2359
+ SOURCE_ATEN,
2360
+ test_label,
2361
+ function,
2362
+ node,
2363
+ context,
2364
+ asserted_op=op,
2365
+ )
2366
+ if not exir_assertion_removed:
2367
+ for op in exir_ops:
2368
+ _add_coverage(
2369
+ rows,
2370
+ op,
2371
+ profile,
2372
+ EDGE_IR,
2373
+ test_label,
2374
+ function,
2375
+ node,
2376
+ context,
2377
+ asserted_op=op,
2378
+ )
2379
+
2380
+ explicit = _active_explicit_backend_coverage().get(
2381
+ (str(context.path), function.name), {}
2382
+ )
2383
+ for explicit_op in explicit.get(profile, set()):
2384
+ _add_coverage(
2385
+ rows,
2386
+ explicit_op,
2387
+ profile,
2388
+ RUNTIME_ONLY,
2389
+ test_label,
2390
+ function,
2391
+ node,
2392
+ context,
2393
+ classification=EXPLICIT,
2394
+ )
2395
+
2396
+ if not aten_ops and not exir_ops and not explicit.get(profile):
2397
+ fallback: list[str] = []
2398
+ if _is_empty_op_expr(aten_expr):
2399
+ fallback = _fallback_exported_ops_for_unattributed_pipeline_call(
2400
+ context, scope
2401
+ )
2402
+ for op in fallback:
2403
+ _add_coverage(
2404
+ rows,
2405
+ op,
2406
+ profile,
2407
+ RUNTIME_ONLY,
2408
+ test_label,
2409
+ function,
2410
+ node,
2411
+ context,
2412
+ classification=INFERRED,
2413
+ )
2414
+ if not fallback:
2415
+ unresolved.append(
2416
+ UnresolvedPipelineEvidence(
2417
+ path=context.path,
2418
+ function=function.name,
2419
+ profile=profile,
2420
+ aten_expression=_expr_text(aten_expr),
2421
+ exir_expression=_expr_text(exir_expr),
2422
+ reason="no statically attributable ATen or Edge operator",
2423
+ )
2424
+ )
2425
+
2426
+ return rows, unresolved, sorted(set(normalisation_diagnostics))
2427
+
2428
+
2429
+ def _public_rows_from_exact_rows(
2430
+ exact_rows: Mapping[str, PipelineCoverage],
2431
+ ) -> list[PublicCoverage]:
2432
+ public_rows: dict[str, PublicCoverage] = {}
2433
+ for exact in exact_rows.values():
2434
+ if not exact.pytorch_apis:
2435
+ continue
2436
+
2437
+ key = _api_key(exact.pytorch_apis)
2438
+ row = public_rows.setdefault(
2439
+ key,
2440
+ PublicCoverage(pytorch_apis=exact.pytorch_apis),
2441
+ )
2442
+ row.support_profiles.update(exact.support_profiles)
2443
+ row.dtypes.update(exact.dtypes)
2444
+ row.quantization_modes.update(exact.quantization_modes)
2445
+
2446
+ return sorted(public_rows.values(), key=lambda row: _api_sort_key(row.pytorch_apis))
2447
+
2448
+
2449
+ def _profiles_for_checker(
2450
+ checker: type, backend_tosa_spec: TosaSpecificationLike
2451
+ ) -> set[str]:
2452
+ """Best-effort profile extraction for registered support checks.
2453
+
2454
+ Some checkers are unconditional over all profiles; others declare a narrower
2455
+ ``tosa_specs`` class attribute. This cannot model dtype predicates inside
2456
+ ``is_node_tosa_supported`` but avoids assigning a checker to a profile that
2457
+ its own declared spec list excludes.
2458
+
2459
+ """
2460
+
2461
+ profiles: set[str] = set()
2462
+ tosa_specs = getattr(checker, "tosa_specs", None)
2463
+
2464
+ if tosa_specs is None:
2465
+ if backend_tosa_spec.support_float():
2466
+ profiles.add("FP")
2467
+ if backend_tosa_spec.support_integer():
2468
+ profiles.add("INT")
2469
+ return profiles
2470
+
2471
+ try:
2472
+ specs = list(tosa_specs)
2473
+ except TypeError:
2474
+ specs = [tosa_specs]
2475
+
2476
+ for raw_spec in specs:
2477
+ spec = cast(TosaSpecificationLike, raw_spec)
2478
+ try:
2479
+ if spec.support_float() and backend_tosa_spec.support_float():
2480
+ profiles.add("FP")
2481
+ if spec.support_integer() and backend_tosa_spec.support_integer():
2482
+ profiles.add("INT")
2483
+ except Exception as error:
2484
+ logger.debug("Skipping unsupported TOSA spec %r: %s", spec, error)
2485
+ continue
2486
+
2487
+ return profiles
2488
+
2489
+
2490
+ def _collect_backend_custom_partition_ops(
2491
+ backend_tosa_spec: TosaSpecificationLike,
2492
+ ) -> dict[str, set[object]]:
2493
+ """Collect VGF custom partition ops for each enabled support profile.
2494
+
2495
+ Instantiate the partitioner with a single-profile compile spec so custom
2496
+ registrations that are conditional on the compile spec are attributed only
2497
+ to the profiles for which they are actually registered.
2498
+
2499
+ """
2500
+ if ACTIVE_BACKEND_KEY != "vgf":
2501
+ return {}
2502
+
2503
+ from executorch.backends.arm.vgf import VgfCompileSpec, VgfPartitioner
2504
+
2505
+ enabled_profiles = {
2506
+ "FP": backend_tosa_spec.support_float(),
2507
+ "INT": backend_tosa_spec.support_integer(),
2508
+ }
2509
+ custom_ops_by_profile: dict[str, set[object]] = {}
2510
+
2511
+ for profile, enabled in enabled_profiles.items():
2512
+ if not enabled:
2513
+ continue
2514
+ partitioner = VgfPartitioner(
2515
+ VgfCompileSpec(BACKEND_PROFILE_TOSA_SPECS[profile])
2516
+ )
2517
+ custom_ops_by_profile[profile] = set(
2518
+ getattr(partitioner, "_custom_partition_ops", ())
2519
+ )
2520
+
2521
+ return custom_ops_by_profile
2522
+
2523
+
2524
+ def _unconditionally_unsupported_backend_ops(
2525
+ tosa_spec: TosaSpecificationLike,
2526
+ ) -> set[str]:
2527
+ """Return whole operators rejected by backend-specific negative checks."""
2528
+
2529
+ if not BACKEND_FILTER_U55_UNSUPPORTED_OPS:
2530
+ return set()
2531
+ if not getattr(tosa_spec, "is_U55_subset", False):
2532
+ return set()
2533
+
2534
+ try:
2535
+ from executorch.backends.arm.operator_support.ethos_u55_support import (
2536
+ EthosU55NotSupported,
2537
+ )
2538
+ except Exception as error:
2539
+ logger.debug("Could not collect U55 unsupported operators: %s", error)
2540
+ return set()
2541
+
2542
+ unsupported: set[str] = set()
2543
+ for target in EthosU55NotSupported.unsupported_ops:
2544
+ exported_op = _canonical_pytorch_op_from_target(target)
2545
+ if exported_op is None:
2546
+ exported_op = _normalize_pytorch_op_name(str(target))
2547
+ if exported_op is not None:
2548
+ unsupported.add(exported_op)
2549
+ return unsupported
2550
+
2551
+
2552
+ def _filter_backend_supported_ops(
2553
+ expected: dict[str, SupportedOperatorEvidence],
2554
+ tosa_spec: TosaSpecificationLike,
2555
+ ) -> dict[str, SupportedOperatorEvidence]:
2556
+ # Hardware subsets can apply negative checks on top of the generic TOSA
2557
+ # positive registry. Remove only operators rejected for every U55 case;
2558
+ # shape/dtype-constrained operators remain supported and still require tests.
2559
+ for exported_op in _unconditionally_unsupported_backend_ops(tosa_spec):
2560
+ expected.pop(exported_op, None)
2561
+
2562
+ # Some exported operators are only known to be unsupported after their
2563
+ # transformation/decomposition path is considered. The direct U55 negative
2564
+ # check sees the resulting Edge op, not necessarily the original exported
2565
+ # ATen operator, so apply those source-level exclusions here.
2566
+ for exported_op in BACKEND_EXPORTED_OP_EXCLUSIONS.get(
2567
+ ACTIVE_BACKEND_KEY, frozenset()
2568
+ ):
2569
+ expected.pop(exported_op, None)
2570
+
2571
+ return expected
2572
+
2573
+
2574
+ def _registered_checker_has_supported_dtype(
2575
+ checker: type,
2576
+ tosa_spec: TosaSpecificationLike,
2577
+ ) -> bool:
2578
+ """Return False when a checker explicitly has no legal dtype for this spec.
2579
+
2580
+ Most registered checks have node-dependent predicates and do not expose a
2581
+ static dtype capability helper. Those remain eligible. A checker that does
2582
+ expose _supported_dtypes(tosa_spec) and returns an empty sequence cannot
2583
+ support any node in this profile, so it must not contribute positive docgen
2584
+ evidence.
2585
+
2586
+ """
2587
+
2588
+ supported_dtypes = getattr(checker, "_supported_dtypes", None)
2589
+ if not callable(supported_dtypes):
2590
+ return True
2591
+ try:
2592
+ return bool(supported_dtypes(tosa_spec))
2593
+ except (AttributeError, TypeError, ValueError):
2594
+ # Do not make documentation generation more restrictive if a future
2595
+ # checker exposes a node-dependent helper with an incompatible shape.
2596
+ return True
2597
+
2598
+
2599
+ def _collect_backend_supported_ops( # noqa: C901
2600
+ repo_root: Path,
2601
+ ) -> dict[str, SupportedOperatorEvidence]:
2602
+ """Collect exported ATen ops that backend registries say should be
2603
+ supported.
2604
+ """
2605
+
2606
+ _ensure_repo_importable(repo_root)
2607
+
2608
+ # Importing the package registers all @register_tosa_support_check classes.
2609
+ import executorch.backends.arm.operator_support # noqa: F401
2610
+
2611
+ from executorch.backends.arm.operator_support import (
2612
+ tosa_profile_supported_op_lists as profile_op_lists,
2613
+ tosa_supported_operators,
2614
+ )
2615
+ from executorch.backends.arm.tosa import TosaSpecification
2616
+
2617
+ tosa_spec = TosaSpecification.create_from_string(BACKEND_TOSA_SPEC)
2618
+ expected: dict[str, SupportedOperatorEvidence] = {}
2619
+
2620
+ def add(target: object, profile: str, evidence: str) -> None:
2621
+ exported_op = _canonical_pytorch_op_from_target(target)
2622
+ if exported_op is None:
2623
+ return
2624
+ row = expected.setdefault(
2625
+ exported_op,
2626
+ SupportedOperatorEvidence(
2627
+ exported_op=exported_op,
2628
+ pytorch_apis=_pytorch_api_aliases(exported_op),
2629
+ ),
2630
+ )
2631
+ row.support_profiles.add(profile)
2632
+ row.evidence.add(evidence)
2633
+
2634
+ if tosa_spec.support_float():
2635
+ for target in profile_op_lists.TOSA_PRO_FP_SupportList:
2636
+ add(target, "FP", "TOSA_PRO_FP_SupportList")
2637
+
2638
+ if tosa_spec.support_integer():
2639
+ for target in profile_op_lists.TOSA_PRO_INT_SupportList:
2640
+ add(target, "INT", "TOSA_PRO_INT_SupportList")
2641
+
2642
+ for checker in tosa_supported_operators.get_registered_tosa_support_checks(
2643
+ tosa_spec
2644
+ ):
2645
+ if not _registered_checker_has_supported_dtype(checker, tosa_spec):
2646
+ continue
2647
+ checker_evidence = f"registered support check `{checker.__name__}`"
2648
+ for target in getattr(checker, "targets", ()): # type: ignore[attr-defined]
2649
+ for profile in _profiles_for_checker(checker, tosa_spec):
2650
+ add(target, profile, checker_evidence)
2651
+
2652
+ for profile, targets in _collect_backend_custom_partition_ops(tosa_spec).items():
2653
+ for target in targets:
2654
+ add(target, profile, "VgfPartitioner.register_custom_partition_op")
2655
+
2656
+ # Lowering visitors are not the source of partitioner support, but they are
2657
+ # useful evidence when the exported op name matches a registered visitor
2658
+ # target directly.
2659
+ try:
2660
+ from executorch.backends.arm.operators.node_visitor import get_node_visitors
2661
+
2662
+ for target, visitor in get_node_visitors(tosa_spec).items():
2663
+ exported_op = _normalize_pytorch_op_name(target)
2664
+ if exported_op is None or exported_op not in expected:
2665
+ continue
2666
+ expected[exported_op].evidence.add(
2667
+ f"lowering visitor `{visitor.__class__.__name__}`"
2668
+ )
2669
+ except Exception as error:
2670
+ # Keep --check focused on missing test diagnostics even if optional
2671
+ # lowering visitor imports fail in a reduced environment.
2672
+ logger.debug("Could not collect optional lowering visitors: %s", error)
2673
+
2674
+ return _filter_backend_supported_ops(expected, tosa_spec)
2675
+
2676
+
2677
+ def _format_markdown_table_row(cells: Sequence[str]) -> str:
2678
+ # Serializes a list of cell values into a Markdown table row.
2679
+ # It escapes literal | characters inside cells so they aren’t
2680
+ # interpreted as column separators,
2681
+ # then joins the cells using Markdown’s | delimiter.
2682
+ escaped_cells = (cell.replace("|", r"\|") for cell in cells)
2683
+ return "| " + " | ".join(escaped_cells) + " |"
2684
+
2685
+
2686
+ def generate_markdown(repo_root: Path, *, debug: bool = False) -> str:
2687
+ exact_rows, _unresolved, _diagnostics = _scan_backend_pipeline_tests(repo_root)
2688
+ command = GENERATOR_COMMAND
2689
+ if debug:
2690
+ command += " --debug"
2691
+
2692
+ lines = [
2693
+ f"# {PAGE_TITLE}",
2694
+ "",
2695
+ f"<!-- DO NOT EDIT: generated by `{command}`. -->",
2696
+ "",
2697
+ PAGE_DESCRIPTION,
2698
+ "",
2699
+ "`8x8` means 8-bit activations and 8-bit weights. `16x8` means "
2700
+ "16-bit activations and 8-bit weights. `8x4` means "
2701
+ "8-bit activations and 4-bit weights.",
2702
+ "",
2703
+ ]
2704
+
2705
+ if debug:
2706
+ sorted_rows = sorted(
2707
+ exact_rows.values(),
2708
+ key=lambda row: (_api_sort_key(row.pytorch_apis), row.exported_op),
2709
+ )
2710
+ lines.extend(
2711
+ [
2712
+ f"Total tested exported operators: **{len(sorted_rows)}**.",
2713
+ "",
2714
+ "```{note}",
2715
+ MARKDOWN_DEBUG_NOTE,
2716
+ "```",
2717
+ "",
2718
+ "| PyTorch API | Exported operator | Support profile | DType | Quantization mode | Test |",
2719
+ "| --- | --- | --- | --- | --- | --- |",
2720
+ ]
2721
+ )
2722
+ for exact_row in sorted_rows:
2723
+ cells = [
2724
+ _format_api_items(exact_row.pytorch_apis),
2725
+ f"`{exact_row.exported_op}`",
2726
+ _format_items(exact_row.support_profiles, SUPPORT_PROFILE_ORDER),
2727
+ _format_backtick_items(exact_row.dtypes, DTYPE_ORDER),
2728
+ _format_items(exact_row.quantization_modes, QUANTIZATION_MODE_ORDER),
2729
+ _format_test_items(exact_row.tests),
2730
+ ]
2731
+ lines.append(_format_markdown_table_row(cells))
2732
+ else:
2733
+ public_rows = _public_rows_from_exact_rows(exact_rows)
2734
+ lines.extend(
2735
+ [
2736
+ f"Total supported PyTorch APIs: **{len(public_rows)}**.",
2737
+ "",
2738
+ "| PyTorch API | Support profile | DType | Quantization mode |",
2739
+ "| --- | --- | --- | --- |",
2740
+ ]
2741
+ )
2742
+ for public_row in public_rows:
2743
+ cells = [
2744
+ _format_api_items(public_row.pytorch_apis),
2745
+ _format_items(public_row.support_profiles, SUPPORT_PROFILE_ORDER),
2746
+ _format_backtick_items(public_row.dtypes, DTYPE_ORDER),
2747
+ _format_items(public_row.quantization_modes, QUANTIZATION_MODE_ORDER),
2748
+ ]
2749
+ lines.append(_format_markdown_table_row(cells))
2750
+ return "\n".join(lines).rstrip() + "\n"
2751
+
2752
+
2753
+ def generate_html(repo_root: Path, *, debug: bool = False) -> str:
2754
+ """Generate a standalone HTML version of the operator-support page."""
2755
+
2756
+ exact_rows, _unresolved, _diagnostics = _scan_backend_pipeline_tests(repo_root)
2757
+ command = GENERATOR_COMMAND
2758
+ if debug:
2759
+ command += " --debug"
2760
+ command += " --html"
2761
+
2762
+ lines = [
2763
+ "<!DOCTYPE html>",
2764
+ '<html lang="en">',
2765
+ "<head>",
2766
+ ' <meta charset="utf-8" />',
2767
+ ' <meta name="viewport" content="width=device-width, initial-scale=1" />',
2768
+ f" <title>{html.escape(PAGE_TITLE)}</title>",
2769
+ " <style>",
2770
+ " :root { color-scheme: light dark; }",
2771
+ " body {",
2772
+ " font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;",
2773
+ " line-height: 1.5;",
2774
+ " margin: 0 auto;",
2775
+ " max-width: 1600px;",
2776
+ " padding: 2rem;",
2777
+ " }",
2778
+ " h1 { line-height: 1.2; }",
2779
+ " .generated { opacity: 0.75; }",
2780
+ " .note {",
2781
+ " border-left: 0.3rem solid currentColor;",
2782
+ " margin: 1.5rem 0;",
2783
+ " padding: 0.75rem 1rem;",
2784
+ " }",
2785
+ " .table-container { overflow-x: auto; }",
2786
+ " table { border-collapse: collapse; width: 100%; }",
2787
+ " th, td { border: 1px solid #8888; padding: 0.55rem; text-align: left; vertical-align: top; }",
2788
+ " th { background: #8882; position: sticky; top: 0; }",
2789
+ " tbody tr:nth-child(even) { background: #8881; }",
2790
+ " code { white-space: nowrap; }",
2791
+ " </style>",
2792
+ "</head>",
2793
+ "<body>",
2794
+ " <main>",
2795
+ f" <h1>{html.escape(PAGE_TITLE)}</h1>",
2796
+ f' <p class="generated">Generated by {_html_code(command)}.</p>',
2797
+ f" <p>{html.escape(PAGE_DESCRIPTION)}</p>",
2798
+ " <p><code>8x8</code> means 8-bit activations and 8-bit weights. <code>16x8</code> means 16-bit activations and 8-bit weights.</p>",
2799
+ ]
2800
+
2801
+ if debug:
2802
+ sorted_rows = sorted(
2803
+ exact_rows.values(),
2804
+ key=lambda row: (_api_sort_key(row.pytorch_apis), row.exported_op),
2805
+ )
2806
+ lines.extend(
2807
+ [
2808
+ f" <p>Total tested exported operators: <strong>{len(sorted_rows)}</strong>.</p>",
2809
+ f' <div class="note">{html.escape(HTML_DEBUG_NOTE)}</div>',
2810
+ ' <div class="table-container">',
2811
+ " <table>",
2812
+ " <thead>",
2813
+ " <tr>",
2814
+ ' <th scope="col">PyTorch API</th>',
2815
+ ' <th scope="col">Exported operator</th>',
2816
+ ' <th scope="col">Support profile</th>',
2817
+ ' <th scope="col">DType</th>',
2818
+ ' <th scope="col">Quantization mode</th>',
2819
+ ' <th scope="col">Test</th>',
2820
+ " </tr>",
2821
+ " </thead>",
2822
+ " <tbody>",
2823
+ ]
2824
+ )
2825
+ for exact_row in sorted_rows:
2826
+ cells = [
2827
+ _format_html_api_items(exact_row.pytorch_apis),
2828
+ _html_code(exact_row.exported_op),
2829
+ _format_html_items(exact_row.support_profiles, SUPPORT_PROFILE_ORDER),
2830
+ _format_html_code_items(exact_row.dtypes, DTYPE_ORDER),
2831
+ _format_html_items(
2832
+ exact_row.quantization_modes, QUANTIZATION_MODE_ORDER
2833
+ ),
2834
+ _format_html_test_items(exact_row.tests),
2835
+ ]
2836
+ lines.append(
2837
+ " <tr>"
2838
+ + "".join(f"<td>{cell}</td>" for cell in cells)
2839
+ + "</tr>"
2840
+ )
2841
+ else:
2842
+ public_rows = _public_rows_from_exact_rows(exact_rows)
2843
+ lines.extend(
2844
+ [
2845
+ f" <p>Total supported PyTorch APIs: <strong>{len(public_rows)}</strong>.</p>",
2846
+ ' <div class="table-container">',
2847
+ " <table>",
2848
+ " <thead>",
2849
+ " <tr>",
2850
+ ' <th scope="col">PyTorch API</th>',
2851
+ ' <th scope="col">Support profile</th>',
2852
+ ' <th scope="col">DType</th>',
2853
+ ' <th scope="col">Quantization mode</th>',
2854
+ " </tr>",
2855
+ " </thead>",
2856
+ " <tbody>",
2857
+ ]
2858
+ )
2859
+ for public_row in public_rows:
2860
+ cells = [
2861
+ _format_html_api_items(public_row.pytorch_apis),
2862
+ _format_html_items(public_row.support_profiles, SUPPORT_PROFILE_ORDER),
2863
+ _format_html_code_items(public_row.dtypes, DTYPE_ORDER),
2864
+ _format_html_items(
2865
+ public_row.quantization_modes, QUANTIZATION_MODE_ORDER
2866
+ ),
2867
+ ]
2868
+ lines.append(
2869
+ " <tr>"
2870
+ + "".join(f"<td>{cell}</td>" for cell in cells)
2871
+ + "</tr>"
2872
+ )
2873
+
2874
+ lines.extend(
2875
+ [
2876
+ " </tbody>",
2877
+ " </table>",
2878
+ " </div>",
2879
+ " </main>",
2880
+ "</body>",
2881
+ "</html>",
2882
+ ]
2883
+ )
2884
+ return "\n".join(lines) + "\n"
2885
+
2886
+
2887
+ def _coverage_aliases(expected_op: str, profile: str) -> set[str]:
2888
+ return {
2889
+ expected_op,
2890
+ *STAGE_EQUIVALENT_OPS.get(expected_op, set()),
2891
+ *PROFILE_STAGE_EQUIVALENT_OPS.get((expected_op, profile), set()),
2892
+ }
2893
+
2894
+
2895
+ def _matching_evidence(
2896
+ tested: Mapping[str, PipelineCoverage],
2897
+ expected_op: str,
2898
+ profile: str,
2899
+ ) -> list[CoverageEvidence]:
2900
+ records: list[CoverageEvidence] = []
2901
+ for alias in _coverage_aliases(expected_op, profile):
2902
+ coverage = tested.get(alias)
2903
+ if coverage is None:
2904
+ continue
2905
+ for record in coverage.evidence_records:
2906
+ if record.profile != profile:
2907
+ continue
2908
+ classification = record.classification
2909
+ if alias != expected_op and classification == DIRECT:
2910
+ classification = STAGE_EQUIVALENT
2911
+ records.append(
2912
+ CoverageEvidence(
2913
+ exported_op=expected_op,
2914
+ profile=profile,
2915
+ stage=record.stage,
2916
+ classification=classification,
2917
+ test=record.test,
2918
+ asserted_op=alias,
2919
+ )
2920
+ )
2921
+ return records
2922
+
2923
+
2924
+ def _validate_configuration(repo_root: Path) -> list[str]:
2925
+ errors: list[str] = []
2926
+ valid_profiles = set(SUPPORT_PROFILE_ORDER)
2927
+ for (op, profile), aliases in PROFILE_STAGE_EQUIVALENT_OPS.items():
2928
+ if profile not in valid_profiles:
2929
+ errors.append(f"invalid profile {profile!r} for {op}")
2930
+ for candidate in {op, *aliases}:
2931
+ if _normalize_pytorch_op_name(candidate) != candidate:
2932
+ errors.append(f"non-canonical equivalence operator: {candidate}")
2933
+ overlap = TRANSFORM_ONLY_OPS & DECOMPOSED_OPS
2934
+ if overlap:
2935
+ errors.append(
2936
+ f"operators configured as both transform-only and decomposed: {sorted(overlap)}"
2937
+ )
2938
+ for (path, function), profiles in _active_explicit_backend_coverage().items():
2939
+ full_path = repo_root / path
2940
+ if not full_path.is_file():
2941
+ errors.append(f"explicit coverage path does not exist: {path}")
2942
+ continue
2943
+ context = _build_module_context(full_path, repo_root)
2944
+ if context is not None and function not in context.functions:
2945
+ errors.append(
2946
+ f"explicit coverage function does not exist: {path}::{function}"
2947
+ )
2948
+ for profile in profiles:
2949
+ if profile not in valid_profiles:
2950
+ errors.append(
2951
+ f"invalid explicit coverage profile {profile!r}: {path}::{function}"
2952
+ )
2953
+ return errors
2954
+
2955
+
2956
+ def _print_unresolved(unresolved: Sequence[UnresolvedPipelineEvidence]) -> None:
2957
+ if not unresolved:
2958
+ return
2959
+ print(f"Unresolved {BACKEND_PIPELINE_LABEL} attribution:")
2960
+ print()
2961
+ print("| Test | Profile | ATen expression | Edge expression | Reason |")
2962
+ print("| --- | --- | --- | --- | --- |")
2963
+ for item in unresolved:
2964
+ print(
2965
+ f"| `{item.path}::{item.function}` | {item.profile} | "
2966
+ f"`{item.aten_expression or '-'}` | `{item.exir_expression or '-'}` | "
2967
+ f"{item.reason} |"
2968
+ )
2969
+ print()
2970
+
2971
+
2972
+ def explain_operator(repo_root: Path, requested_op: str) -> int:
2973
+ tested, unresolved, diagnostics = _scan_backend_pipeline_tests(repo_root)
2974
+ expected = _collect_backend_supported_ops(repo_root)
2975
+ op = _normalize_pytorch_op_name(requested_op) or requested_op
2976
+ row = expected.get(op)
2977
+ if row is None:
2978
+ print(f"Operator is not present in the {BACKEND_NAME} support registry: {op}")
2979
+ return 1
2980
+ print(f"Operator: {op}")
2981
+ print(
2982
+ f"Expected profiles: {_format_items(row.support_profiles, SUPPORT_PROFILE_ORDER)}"
2983
+ )
2984
+ print()
2985
+ for profile in _sort_items(row.support_profiles, SUPPORT_PROFILE_ORDER):
2986
+ print(f"{profile}:")
2987
+ if op in TRANSFORM_ONLY_OPS:
2988
+ print(" transform-only exemption")
2989
+ continue
2990
+ records = _matching_evidence(tested, op, profile)
2991
+ if not records:
2992
+ print(" missing")
2993
+ continue
2994
+ for record in sorted(
2995
+ records, key=lambda r: (r.classification, r.test, r.asserted_op or "")
2996
+ ):
2997
+ print(
2998
+ f" {record.classification}; {record.stage}; "
2999
+ f"satisfied by {record.asserted_op}; {record.test}"
3000
+ )
3001
+ if diagnostics:
3002
+ print()
3003
+ print("Normalisation diagnostics:")
3004
+ for diagnostic in diagnostics:
3005
+ if op.rsplit(".", 1)[0].split(".")[-1] in diagnostic:
3006
+ print(f" {diagnostic}")
3007
+ relevant_unresolved = [
3008
+ item
3009
+ for item in unresolved
3010
+ if op.split(".")[-2] in (item.aten_expression + item.exir_expression)
3011
+ ]
3012
+ if relevant_unresolved:
3013
+ print()
3014
+ _print_unresolved(relevant_unresolved)
3015
+ return 0
3016
+
3017
+
3018
+ def run_check(repo_root: Path, *, strict_ast: bool = False) -> int: # noqa: C901
3019
+ config_errors = _validate_configuration(repo_root)
3020
+ if config_errors:
3021
+ print(f"Invalid {BACKEND_NAME} support-check configuration:")
3022
+ for error in config_errors:
3023
+ print(f"- {error}")
3024
+ return 2
3025
+
3026
+ tested, unresolved, diagnostics = _scan_backend_pipeline_tests(repo_root)
3027
+ expected = _collect_backend_supported_ops(repo_root)
3028
+
3029
+ missing_cells: list[tuple[SupportedOperatorEvidence, str]] = []
3030
+ classified: list[tuple[str, str, str, str, str]] = []
3031
+
3032
+ for op, registry_evidence in expected.items():
3033
+ for profile in _sort_items(
3034
+ registry_evidence.support_profiles, SUPPORT_PROFILE_ORDER
3035
+ ):
3036
+ if op in TRANSFORM_ONLY_OPS:
3037
+ classified.append((op, profile, TRANSFORM_ONLY, "exempt", "-"))
3038
+ continue
3039
+ records = _matching_evidence(tested, op, profile)
3040
+ if not records:
3041
+ missing_cells.append((registry_evidence, profile))
3042
+ continue
3043
+ best = sorted(
3044
+ records,
3045
+ key=lambda record: (
3046
+ 0 if record.classification == DIRECT else 1,
3047
+ record.test,
3048
+ ),
3049
+ )[0]
3050
+ if best.classification != DIRECT or op in DECOMPOSED_OPS:
3051
+ classification = (
3052
+ DECOMPOSED if op in DECOMPOSED_OPS else best.classification
3053
+ )
3054
+ classified.append(
3055
+ (
3056
+ op,
3057
+ profile,
3058
+ classification,
3059
+ best.asserted_op or op,
3060
+ best.test,
3061
+ )
3062
+ )
3063
+
3064
+ if classified:
3065
+ print("Classified non-direct coverage:")
3066
+ print()
3067
+ print(
3068
+ "| Exported operator | Expected profile | Classification | Satisfied by | Evidence test |"
3069
+ )
3070
+ print("| --- | --- | --- | --- | --- |")
3071
+ for op, profile, classification, satisfied_by, test in sorted(classified):
3072
+ sat = f"`{satisfied_by}`" if satisfied_by != "exempt" else "exempt"
3073
+ test_cell = f"`{test}`" if test != "-" else "-"
3074
+ print(f"| `{op}` | {profile} | {classification} | {sat} | {test_cell} |")
3075
+ print()
3076
+
3077
+ if strict_ast and unresolved:
3078
+ _print_unresolved(unresolved)
3079
+ if diagnostics:
3080
+ print("AST normalisation diagnostics:")
3081
+ for diagnostic in diagnostics:
3082
+ print(f"- {diagnostic}")
3083
+ print()
3084
+
3085
+ if not missing_cells:
3086
+ print(
3087
+ f"All backend-supported exported ATen operator/profile pairs have {BACKEND_PIPELINE_LABEL} coverage."
3088
+ )
3089
+ return 1 if strict_ast and unresolved else 0
3090
+
3091
+ print(
3092
+ f"The following backend-supported exported ATen operator/profile pairs are missing {BACKEND_PIPELINE_LABEL} coverage:"
3093
+ )
3094
+ print()
3095
+ print(
3096
+ "| PyTorch API | Exported operator | Missing profile | Expected profile | Evidence |"
3097
+ )
3098
+ print("| --- | --- | --- | --- | --- |")
3099
+ for row, profile in sorted(
3100
+ missing_cells,
3101
+ key=lambda item: (
3102
+ _api_sort_key(item[0].pytorch_apis),
3103
+ item[0].exported_op,
3104
+ item[1],
3105
+ ),
3106
+ ):
3107
+ print(
3108
+ "| "
3109
+ f"{_format_api_items(row.pytorch_apis)} | "
3110
+ f"`{row.exported_op}` | {profile} | "
3111
+ f"{_format_items(row.support_profiles, SUPPORT_PROFILE_ORDER)} | "
3112
+ f"{_format_items(row.evidence)} |"
3113
+ )
3114
+
3115
+ missing_ops = {row.exported_op for row, _profile in missing_cells}
3116
+ print()
3117
+ print(
3118
+ f"Missing {len(missing_cells)} profile cells across {len(missing_ops)} "
3119
+ f"of {len(expected)} backend-supported exported ATen operators."
3120
+ )
3121
+
3122
+ if len(missing_cells) <= BACKEND_MAX_MISSING_PROFILE_CELLS:
3123
+ print(
3124
+ f"Allowing {len(missing_cells)} missing profile cells for "
3125
+ f"{BACKEND_NAME}; configured maximum is "
3126
+ f"{BACKEND_MAX_MISSING_PROFILE_CELLS}."
3127
+ )
3128
+ return 1 if strict_ast and unresolved else 0
3129
+
3130
+ return 1
3131
+
3132
+
3133
+ def _write_documentation(
3134
+ root: Path,
3135
+ *,
3136
+ output: Path | None,
3137
+ debug: bool,
3138
+ write_html: bool,
3139
+ ) -> None:
3140
+ resolved_output = output or root / DEFAULT_OUTPUT
3141
+ if not resolved_output.is_absolute():
3142
+ resolved_output = root / resolved_output
3143
+
3144
+ markdown = generate_markdown(root, debug=debug)
3145
+ resolved_output.parent.mkdir(parents=True, exist_ok=True)
3146
+ resolved_output.write_text(markdown, encoding="utf-8")
3147
+ print(f"Wrote {resolved_output}")
3148
+
3149
+ if write_html:
3150
+ html_output = resolved_output.with_suffix(".html")
3151
+ html_page = generate_html(root, debug=debug)
3152
+ html_output.write_text(html_page, encoding="utf-8")
3153
+ print(f"Wrote {html_output}")
3154
+
3155
+
3156
+ def main(argv: Sequence[str] | None = None) -> int:
3157
+ parser = argparse.ArgumentParser(
3158
+ description="Generate Arm backend PyTorch operator-support documentation.",
3159
+ formatter_class=argparse.RawDescriptionHelpFormatter,
3160
+ )
3161
+ parser.add_argument(
3162
+ "--backend",
3163
+ choices=sorted([*BACKENDS, ALL_BACKENDS_KEY]),
3164
+ default=DEFAULT_BACKEND_KEY,
3165
+ help=(
3166
+ "Backend to document, or 'all' to process every configured backend. "
3167
+ "Defaults to vgf."
3168
+ ),
3169
+ )
3170
+ parser.add_argument(
3171
+ "--repo-root",
3172
+ type=Path,
3173
+ default=None,
3174
+ help="Path to the ExecuTorch repository root. Defaults to auto-detect.",
3175
+ )
3176
+ parser.add_argument(
3177
+ "--output",
3178
+ type=Path,
3179
+ default=None,
3180
+ help=(
3181
+ "Markdown output path. Defaults to the selected backend output path. "
3182
+ "Cannot be used with --backend all."
3183
+ ),
3184
+ )
3185
+ parser.add_argument(
3186
+ "--html",
3187
+ action="store_true",
3188
+ help=(
3189
+ "Also write a standalone HTML page next to the Markdown output, "
3190
+ "using the same file name with a .html suffix."
3191
+ ),
3192
+ )
3193
+ parser.add_argument(
3194
+ "--debug",
3195
+ action="store_true",
3196
+ help="Include maintainer-facing Exported operator and Test columns.",
3197
+ )
3198
+ parser.add_argument(
3199
+ "--check",
3200
+ action="store_true",
3201
+ help=(
3202
+ "Do not write the page. Compare exact selected-backend pipeline "
3203
+ "coverage against backend support registries. With --backend all, "
3204
+ "check every configured backend."
3205
+ ),
3206
+ )
3207
+ parser.add_argument(
3208
+ "--strict-ast",
3209
+ action="store_true",
3210
+ help=(
3211
+ "Fail --check when any selected-backend pipeline call cannot be "
3212
+ "statically attributed."
3213
+ ),
3214
+ )
3215
+ parser.add_argument(
3216
+ "--explain",
3217
+ metavar="EXPORTED_OP",
3218
+ help=(
3219
+ "Explain how one exported ATen operator is covered per profile. "
3220
+ "Cannot be used with --backend all."
3221
+ ),
3222
+ )
3223
+ args = parser.parse_args(argv)
3224
+
3225
+ if args.backend == ALL_BACKENDS_KEY:
3226
+ if args.output is not None:
3227
+ parser.error("--output cannot be used with --backend all")
3228
+ if args.explain:
3229
+ parser.error("--explain cannot be used with --backend all")
3230
+
3231
+ root = _repo_root(args.repo_root)
3232
+
3233
+ if args.backend == ALL_BACKENDS_KEY:
3234
+ previous_backend = ACTIVE_BACKEND_KEY
3235
+ try:
3236
+ result = 0
3237
+ for backend in BACKENDS:
3238
+ _activate_backend(backend)
3239
+ if args.check:
3240
+ result = max(result, run_check(root, strict_ast=args.strict_ast))
3241
+ else:
3242
+ _write_documentation(
3243
+ root,
3244
+ output=None,
3245
+ debug=args.debug,
3246
+ write_html=args.html,
3247
+ )
3248
+ return result
3249
+ finally:
3250
+ _activate_backend(previous_backend)
3251
+
3252
+ _activate_backend(args.backend)
3253
+
3254
+ if args.explain:
3255
+ return explain_operator(root, args.explain)
3256
+ if args.check:
3257
+ return run_check(root, strict_ast=args.strict_ast)
3258
+
3259
+ _write_documentation(
3260
+ root,
3261
+ output=args.output,
3262
+ debug=args.debug,
3263
+ write_html=args.html,
3264
+ )
3265
+ return 0
3266
+
3267
+
3268
+ if __name__ == "__main__":
3269
+ raise SystemExit(main())