executorch 1.1.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2784) hide show
  1. executorch/backends/__init__.py +0 -0
  2. executorch/backends/aoti/aoti_backend.py +271 -0
  3. executorch/backends/aoti/aoti_partitioner.py +109 -0
  4. executorch/backends/aoti/passes/replace_view_copy_with_view.py +118 -0
  5. executorch/backends/apple/coreml/compiler/__init__.py +9 -0
  6. executorch/backends/apple/coreml/compiler/coreml_preprocess.py +588 -0
  7. executorch/backends/apple/coreml/compiler/enumerated_shape_utils.py +244 -0
  8. executorch/backends/apple/coreml/compiler/torch_ops.py +219 -0
  9. executorch/backends/apple/coreml/executorchcoreml.pyi +10 -0
  10. executorch/backends/apple/coreml/logging.py +24 -0
  11. executorch/backends/apple/coreml/partition/__init__.py +9 -0
  12. executorch/backends/apple/coreml/partition/coreml_partitioner.py +307 -0
  13. executorch/backends/apple/coreml/quantizer/__init__.py +9 -0
  14. executorch/backends/apple/coreml/quantizer/_annotation_config.py +130 -0
  15. executorch/backends/apple/coreml/quantizer/_coreml_quantizer.py +628 -0
  16. executorch/backends/apple/coreml/quantizer/_coreml_quantizer_utils.py +800 -0
  17. executorch/backends/apple/coreml/quantizer/coreml_quantizer.py +7 -0
  18. executorch/backends/apple/coreml/recipes/__init__.py +17 -0
  19. executorch/backends/apple/coreml/recipes/coreml_recipe_provider.py +413 -0
  20. executorch/backends/apple/coreml/recipes/coreml_recipe_types.py +53 -0
  21. executorch/backends/apple/coreml/runtime/test/export_stateful_model.py +77 -0
  22. executorch/backends/apple/coreml/test/test_coreml_partitioner.py +348 -0
  23. executorch/backends/apple/coreml/test/test_coreml_quantizer.py +172 -0
  24. executorch/backends/apple/coreml/test/test_coreml_recipes.py +552 -0
  25. executorch/backends/apple/coreml/test/test_coreml_utils.py +19 -0
  26. executorch/backends/apple/coreml/test/test_enumerated_shapes.py +112 -0
  27. executorch/backends/apple/coreml/test/test_torch_ops.py +333 -0
  28. executorch/backends/apple/coreml/test/tester.py +121 -0
  29. executorch/backends/apple/metal/metal_backend.py +67 -0
  30. executorch/backends/apple/metal/metal_partitioner.py +25 -0
  31. executorch/backends/apple/metal/tests/__init__.py +5 -0
  32. executorch/backends/apple/metal/tests/test_metal_backend.py +79 -0
  33. executorch/backends/apple/metal/tests/test_metal_partitioner.py +172 -0
  34. executorch/backends/apple/mps/__init__.py +10 -0
  35. executorch/backends/apple/mps/mps_preprocess.py +301 -0
  36. executorch/backends/apple/mps/operators/__init__.py +77 -0
  37. executorch/backends/apple/mps/operators/activation_ops.py +99 -0
  38. executorch/backends/apple/mps/operators/binary_ops.py +156 -0
  39. executorch/backends/apple/mps/operators/clamp_ops.py +60 -0
  40. executorch/backends/apple/mps/operators/constant_ops.py +128 -0
  41. executorch/backends/apple/mps/operators/convolution_ops.py +70 -0
  42. executorch/backends/apple/mps/operators/indexing_ops.py +225 -0
  43. executorch/backends/apple/mps/operators/linear_algebra_ops.py +52 -0
  44. executorch/backends/apple/mps/operators/node_visitor.py +473 -0
  45. executorch/backends/apple/mps/operators/normalization_ops.py +97 -0
  46. executorch/backends/apple/mps/operators/op_clone.py +54 -0
  47. executorch/backends/apple/mps/operators/op_getitem.py +29 -0
  48. executorch/backends/apple/mps/operators/op_quant_dequant.py +142 -0
  49. executorch/backends/apple/mps/operators/op_skip_ops.py +24 -0
  50. executorch/backends/apple/mps/operators/pad_ops.py +37 -0
  51. executorch/backends/apple/mps/operators/pooling_ops.py +142 -0
  52. executorch/backends/apple/mps/operators/range_ops.py +53 -0
  53. executorch/backends/apple/mps/operators/reduce_ops.py +39 -0
  54. executorch/backends/apple/mps/operators/shape_ops.py +263 -0
  55. executorch/backends/apple/mps/operators/unary_ops.py +130 -0
  56. executorch/backends/apple/mps/partition/__init__.py +10 -0
  57. executorch/backends/apple/mps/partition/mps_partitioner.py +133 -0
  58. executorch/backends/apple/mps/serialization/mps_graph_schema.py +817 -0
  59. executorch/backends/apple/mps/serialization/mps_graph_serialize.py +34 -0
  60. executorch/backends/apple/mps/serialization/schema.fbs +523 -0
  61. executorch/backends/apple/mps/test/test_mps.py +2507 -0
  62. executorch/backends/apple/mps/test/test_mps_binary_ops.py +296 -0
  63. executorch/backends/apple/mps/test/test_mps_indexing_ops.py +264 -0
  64. executorch/backends/apple/mps/test/test_mps_linear.py +523 -0
  65. executorch/backends/apple/mps/test/test_mps_models.py +416 -0
  66. executorch/backends/apple/mps/test/test_mps_unary_ops.py +26 -0
  67. executorch/backends/apple/mps/test/test_mps_utils.py +326 -0
  68. executorch/backends/apple/mps/utils/mps_utils.py +82 -0
  69. executorch/backends/apple/mps/utils/quant_utils.py +41 -0
  70. executorch/backends/arm/_passes/__init__.py +134 -0
  71. executorch/backends/arm/_passes/_debug_passes.py +58 -0
  72. executorch/backends/arm/_passes/annotate_decomposed_matmul.py +127 -0
  73. executorch/backends/arm/_passes/annotate_output_dim_order_pass.py +26 -0
  74. executorch/backends/arm/_passes/arm_pass.py +95 -0
  75. executorch/backends/arm/_passes/arm_pass_manager.py +462 -0
  76. executorch/backends/arm/_passes/arm_pass_utils.py +281 -0
  77. executorch/backends/arm/_passes/broadcast_args_pass.py +72 -0
  78. executorch/backends/arm/_passes/cast_int64_pass.py +70 -0
  79. executorch/backends/arm/_passes/cast_to_int32_pass.py +67 -0
  80. executorch/backends/arm/_passes/conv1d_unsqueeze_pass.py +98 -0
  81. executorch/backends/arm/_passes/convert_elu_params.py +67 -0
  82. executorch/backends/arm/_passes/convert_expand_copy_to_repeat.py +77 -0
  83. executorch/backends/arm/_passes/convert_full_like_to_full_pass.py +42 -0
  84. executorch/backends/arm/_passes/convert_int64_const_ops_to_int32.py +81 -0
  85. executorch/backends/arm/_passes/convert_int64_output_ops_to_int32.py +155 -0
  86. executorch/backends/arm/_passes/convert_minmax_pass.py +166 -0
  87. executorch/backends/arm/_passes/convert_permute_singleton_to_view_pass.py +64 -0
  88. executorch/backends/arm/_passes/convert_split_to_slice.py +132 -0
  89. executorch/backends/arm/_passes/convert_squeezes_to_view.py +36 -0
  90. executorch/backends/arm/_passes/convert_to_clamp_pass.py +45 -0
  91. executorch/backends/arm/_passes/decompose_acosh_pass.py +77 -0
  92. executorch/backends/arm/_passes/decompose_adaptive_avg_pool2d_pass.py +112 -0
  93. executorch/backends/arm/_passes/decompose_add_sub_alpha_pass.py +98 -0
  94. executorch/backends/arm/_passes/decompose_addmm_pass.py +72 -0
  95. executorch/backends/arm/_passes/decompose_any_pass.py +114 -0
  96. executorch/backends/arm/_passes/decompose_asin_and_acos_pass.py +236 -0
  97. executorch/backends/arm/_passes/decompose_asinh_pass.py +74 -0
  98. executorch/backends/arm/_passes/decompose_atan_pass.py +142 -0
  99. executorch/backends/arm/_passes/decompose_atanh_pass.py +86 -0
  100. executorch/backends/arm/_passes/decompose_avg_pool2d_pass.py +154 -0
  101. executorch/backends/arm/_passes/decompose_batch_norm_no_stats.py +233 -0
  102. executorch/backends/arm/_passes/decompose_cosh_pass.py +72 -0
  103. executorch/backends/arm/_passes/decompose_cosine_similarity_pass.py +92 -0
  104. executorch/backends/arm/_passes/decompose_cumsum_pass.py +167 -0
  105. executorch/backends/arm/_passes/decompose_div_pass.py +61 -0
  106. executorch/backends/arm/_passes/decompose_div_tensor_mode.py +94 -0
  107. executorch/backends/arm/_passes/decompose_elu_pass.py +107 -0
  108. executorch/backends/arm/_passes/decompose_embedding_pass.py +126 -0
  109. executorch/backends/arm/_passes/decompose_expm1_pass.py +163 -0
  110. executorch/backends/arm/_passes/decompose_floor_divide_pass.py +75 -0
  111. executorch/backends/arm/_passes/decompose_gelu_pass.py +172 -0
  112. executorch/backends/arm/_passes/decompose_glu_pass.py +81 -0
  113. executorch/backends/arm/_passes/decompose_grouped_conv_pass.py +185 -0
  114. executorch/backends/arm/_passes/decompose_groupnorm_pass.py +227 -0
  115. executorch/backends/arm/_passes/decompose_int16_activation_conv_pass.py +137 -0
  116. executorch/backends/arm/_passes/decompose_int_pow_pass.py +64 -0
  117. executorch/backends/arm/_passes/decompose_layernorm_pass.py +203 -0
  118. executorch/backends/arm/_passes/decompose_leaky_relu_pass.py +76 -0
  119. executorch/backends/arm/_passes/decompose_linalg_vector_norm_pass.py +92 -0
  120. executorch/backends/arm/_passes/decompose_linear_pass.py +109 -0
  121. executorch/backends/arm/_passes/decompose_log1p_pass.py +97 -0
  122. executorch/backends/arm/_passes/decompose_logit_pass.py +119 -0
  123. executorch/backends/arm/_passes/decompose_masked_fill_pass.py +58 -0
  124. executorch/backends/arm/_passes/decompose_maxpool2d_with_dilation_pass.py +218 -0
  125. executorch/backends/arm/_passes/decompose_meandim_pass.py +283 -0
  126. executorch/backends/arm/_passes/decompose_ne_pass.py +74 -0
  127. executorch/backends/arm/_passes/decompose_quant_nodes.py +156 -0
  128. executorch/backends/arm/_passes/decompose_remainder_pass.py +70 -0
  129. executorch/backends/arm/_passes/decompose_round_pass.py +96 -0
  130. executorch/backends/arm/_passes/decompose_sdpa_pass.py +36 -0
  131. executorch/backends/arm/_passes/decompose_select.py +75 -0
  132. executorch/backends/arm/_passes/decompose_select_scatter_pass.py +143 -0
  133. executorch/backends/arm/_passes/decompose_sign_pass.py +78 -0
  134. executorch/backends/arm/_passes/decompose_silu_pass.py +41 -0
  135. executorch/backends/arm/_passes/decompose_sinh_pass.py +77 -0
  136. executorch/backends/arm/_passes/decompose_softmax_pass.py +93 -0
  137. executorch/backends/arm/_passes/decompose_softmax_unstable_pass.py +86 -0
  138. executorch/backends/arm/_passes/decompose_sqrt_pass.py +53 -0
  139. executorch/backends/arm/_passes/decompose_sum_pass.py +93 -0
  140. executorch/backends/arm/_passes/decompose_tan_pass.py +51 -0
  141. executorch/backends/arm/_passes/decompose_tosa_unsupported_clamp_pass.py +97 -0
  142. executorch/backends/arm/_passes/decompose_var_pass.py +109 -0
  143. executorch/backends/arm/_passes/decorate_fp32_to_int32_casting_pass.py +88 -0
  144. executorch/backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py +394 -0
  145. executorch/backends/arm/_passes/fuse_batch_norm2d_pass.py +241 -0
  146. executorch/backends/arm/_passes/fuse_constant_ops_pass.py +272 -0
  147. executorch/backends/arm/_passes/fuse_duplicate_users_pass.py +165 -0
  148. executorch/backends/arm/_passes/fuse_equal_placeholders_pass.py +104 -0
  149. executorch/backends/arm/_passes/fuse_quantized_activation_pass.py +80 -0
  150. executorch/backends/arm/_passes/fuse_view_copy_transform_pass.py +14 -0
  151. executorch/backends/arm/_passes/insert_int32_casts_after_int64_placeholders.py +130 -0
  152. executorch/backends/arm/_passes/insert_rescales_pass.py +584 -0
  153. executorch/backends/arm/_passes/insert_table_ops.py +305 -0
  154. executorch/backends/arm/_passes/match_arg_dtype_pass.py +104 -0
  155. executorch/backends/arm/_passes/match_arg_ranks_pass.py +114 -0
  156. executorch/backends/arm/_passes/mm_to_bmm_pass.py +104 -0
  157. executorch/backends/arm/_passes/normalize_while_initial_args_pass.py +113 -0
  158. executorch/backends/arm/_passes/promote_bool_operands_pass.py +88 -0
  159. executorch/backends/arm/_passes/quant_args.py +125 -0
  160. executorch/backends/arm/_passes/remove_getitem_pass.py +14 -0
  161. executorch/backends/arm/_passes/remove_graph_asserts_pass.py +18 -0
  162. executorch/backends/arm/_passes/remove_noop_pass.py +40 -0
  163. executorch/backends/arm/_passes/replace_inf_and_limit_values_pass.py +73 -0
  164. executorch/backends/arm/_passes/replace_scalar_with_tensor_pass.py +121 -0
  165. executorch/backends/arm/_passes/rewrite_bool_bitwise_not_to_logical_not_pass.py +43 -0
  166. executorch/backends/arm/_passes/rewrite_bool_to_fp32_cast_via_int8_pass.py +77 -0
  167. executorch/backends/arm/_passes/rewrite_conv_pass.py +336 -0
  168. executorch/backends/arm/_passes/rewrite_matmul.py +98 -0
  169. executorch/backends/arm/_passes/rewrite_upsample.py +93 -0
  170. executorch/backends/arm/_passes/scalars_to_attribute_pass.py +97 -0
  171. executorch/backends/arm/_passes/size_adjust_input_pass.py +227 -0
  172. executorch/backends/arm/_passes/to_tosa_memory_format_pass.py +454 -0
  173. executorch/backends/arm/_passes/unsqueeze_before_repeat_pass.py +66 -0
  174. executorch/backends/arm/_passes/unsqueeze_scalar_placeholders_pass.py +85 -0
  175. executorch/backends/arm/arm_vela.py +137 -0
  176. executorch/backends/arm/common/__init__.py +4 -0
  177. executorch/backends/arm/common/annotation_meta.py +39 -0
  178. executorch/backends/arm/common/arm_compile_spec.py +271 -0
  179. executorch/backends/arm/common/debug.py +79 -0
  180. executorch/backends/arm/common/pipeline_config.py +59 -0
  181. executorch/backends/arm/common/type.py +28 -0
  182. executorch/backends/arm/constants.py +48 -0
  183. executorch/backends/arm/debug/__init__.py +4 -0
  184. executorch/backends/arm/debug/schema.py +145 -0
  185. executorch/backends/arm/ethosu/__init__.py +11 -0
  186. executorch/backends/arm/ethosu/backend.py +115 -0
  187. executorch/backends/arm/ethosu/compile_spec.py +117 -0
  188. executorch/backends/arm/ethosu/partitioner.py +35 -0
  189. executorch/backends/arm/operator_support/__init__.py +23 -0
  190. executorch/backends/arm/operator_support/clone_dim_order_support.py +82 -0
  191. executorch/backends/arm/operator_support/control_flow_support.py +162 -0
  192. executorch/backends/arm/operator_support/convolution_support.py +160 -0
  193. executorch/backends/arm/operator_support/embedding_support.py +61 -0
  194. executorch/backends/arm/operator_support/ethos_u55_support.py +598 -0
  195. executorch/backends/arm/operator_support/index_select_support.py +60 -0
  196. executorch/backends/arm/operator_support/index_tensor_support.py +160 -0
  197. executorch/backends/arm/operator_support/minmax_support.py +61 -0
  198. executorch/backends/arm/operator_support/pool_2d_support.py +214 -0
  199. executorch/backends/arm/operator_support/reduce_sum_support.py +76 -0
  200. executorch/backends/arm/operator_support/right_shift_support.py +52 -0
  201. executorch/backends/arm/operator_support/slice_copy_support.py +48 -0
  202. executorch/backends/arm/operator_support/to_dim_order_copy_support.py +200 -0
  203. executorch/backends/arm/operator_support/tosa_profile_supported_op_lists.py +251 -0
  204. executorch/backends/arm/operator_support/tosa_supported_operators.py +748 -0
  205. executorch/backends/arm/operator_support/where_support.py +77 -0
  206. executorch/backends/arm/operators/__init__.py +71 -0
  207. executorch/backends/arm/operators/node_visitor.py +177 -0
  208. executorch/backends/arm/operators/op_abs.py +59 -0
  209. executorch/backends/arm/operators/op_add.py +60 -0
  210. executorch/backends/arm/operators/op_amax.py +72 -0
  211. executorch/backends/arm/operators/op_amin.py +73 -0
  212. executorch/backends/arm/operators/op_any.py +61 -0
  213. executorch/backends/arm/operators/op_avg_pool2d.py +142 -0
  214. executorch/backends/arm/operators/op_bitwise_not.py +62 -0
  215. executorch/backends/arm/operators/op_cat.py +68 -0
  216. executorch/backends/arm/operators/op_ceil.py +56 -0
  217. executorch/backends/arm/operators/op_clamp.py +118 -0
  218. executorch/backends/arm/operators/op_cond_if.py +56 -0
  219. executorch/backends/arm/operators/op_constant_pad_nd.py +117 -0
  220. executorch/backends/arm/operators/op_cos.py +49 -0
  221. executorch/backends/arm/operators/op_eq.py +64 -0
  222. executorch/backends/arm/operators/op_erf.py +54 -0
  223. executorch/backends/arm/operators/op_exp.py +54 -0
  224. executorch/backends/arm/operators/op_floor.py +56 -0
  225. executorch/backends/arm/operators/op_ge.py +64 -0
  226. executorch/backends/arm/operators/op_gt.py +64 -0
  227. executorch/backends/arm/operators/op_index_select.py +109 -0
  228. executorch/backends/arm/operators/op_index_tensor.py +247 -0
  229. executorch/backends/arm/operators/op_le.py +64 -0
  230. executorch/backends/arm/operators/op_log.py +50 -0
  231. executorch/backends/arm/operators/op_logical_not.py +62 -0
  232. executorch/backends/arm/operators/op_lt.py +64 -0
  233. executorch/backends/arm/operators/op_max_pool2d.py +108 -0
  234. executorch/backends/arm/operators/op_maximum.py +66 -0
  235. executorch/backends/arm/operators/op_minimum.py +67 -0
  236. executorch/backends/arm/operators/op_mul.py +61 -0
  237. executorch/backends/arm/operators/op_neg.py +92 -0
  238. executorch/backends/arm/operators/op_permute.py +150 -0
  239. executorch/backends/arm/operators/op_pow.py +63 -0
  240. executorch/backends/arm/operators/op_reciprocal.py +51 -0
  241. executorch/backends/arm/operators/op_repeat.py +77 -0
  242. executorch/backends/arm/operators/op_rshift_tensor.py +62 -0
  243. executorch/backends/arm/operators/op_rsqrt.py +51 -0
  244. executorch/backends/arm/operators/op_sigmoid.py +50 -0
  245. executorch/backends/arm/operators/op_sin.py +49 -0
  246. executorch/backends/arm/operators/op_slice.py +151 -0
  247. executorch/backends/arm/operators/op_sub.py +63 -0
  248. executorch/backends/arm/operators/op_sum.py +64 -0
  249. executorch/backends/arm/operators/op_tanh.py +51 -0
  250. executorch/backends/arm/operators/op_to_dim_order_copy.py +49 -0
  251. executorch/backends/arm/operators/op_tosa_conv2d.py +139 -0
  252. executorch/backends/arm/operators/op_tosa_conv3d.py +24 -0
  253. executorch/backends/arm/operators/op_tosa_depthwise_conv2d.py +32 -0
  254. executorch/backends/arm/operators/op_tosa_matmul.py +102 -0
  255. executorch/backends/arm/operators/op_tosa_rescale.py +261 -0
  256. executorch/backends/arm/operators/op_tosa_resize.py +124 -0
  257. executorch/backends/arm/operators/op_tosa_table.py +72 -0
  258. executorch/backends/arm/operators/op_tosa_transpose.py +71 -0
  259. executorch/backends/arm/operators/op_view.py +81 -0
  260. executorch/backends/arm/operators/op_where.py +75 -0
  261. executorch/backends/arm/operators/op_while.py +103 -0
  262. executorch/backends/arm/operators/operator_validation_utils.py +201 -0
  263. executorch/backends/arm/operators/ops_binary.py +112 -0
  264. executorch/backends/arm/operators/ops_identity.py +80 -0
  265. executorch/backends/arm/process_node.py +230 -0
  266. executorch/backends/arm/quantizer/__init__.py +35 -0
  267. executorch/backends/arm/quantizer/arm_quantizer.py +710 -0
  268. executorch/backends/arm/quantizer/arm_quantizer_utils.py +76 -0
  269. executorch/backends/arm/quantizer/quantization_annotator.py +815 -0
  270. executorch/backends/arm/quantizer/quantization_config.py +228 -0
  271. executorch/backends/arm/scripts/collect_testname_resources.py +194 -0
  272. executorch/backends/arm/scripts/parse_test_names.py +271 -0
  273. executorch/backends/arm/test/common.py +302 -0
  274. executorch/backends/arm/test/conftest.py +134 -0
  275. executorch/backends/arm/test/misc/test_bn_relu_folding_qat.py +124 -0
  276. executorch/backends/arm/test/misc/test_call_operator_submodule.py +72 -0
  277. executorch/backends/arm/test/misc/test_compile_spec.py +55 -0
  278. executorch/backends/arm/test/misc/test_conv_relu_residual_add.py +108 -0
  279. executorch/backends/arm/test/misc/test_custom_partition.py +183 -0
  280. executorch/backends/arm/test/misc/test_debug_feats.py +316 -0
  281. executorch/backends/arm/test/misc/test_debug_hook.py +186 -0
  282. executorch/backends/arm/test/misc/test_dim_order.py +127 -0
  283. executorch/backends/arm/test/misc/test_dw_convs_with_shared_weights.py +46 -0
  284. executorch/backends/arm/test/misc/test_extract_io_params_tosa.py +92 -0
  285. executorch/backends/arm/test/misc/test_int64.py +112 -0
  286. executorch/backends/arm/test/misc/test_lifted_tensor.py +146 -0
  287. executorch/backends/arm/test/misc/test_mixed_type_lowering.py +83 -0
  288. executorch/backends/arm/test/misc/test_model_evaluator.py +58 -0
  289. executorch/backends/arm/test/misc/test_multiple_delegates.py +53 -0
  290. executorch/backends/arm/test/misc/test_multiple_outputs.py +70 -0
  291. executorch/backends/arm/test/misc/test_non_persistent_buffers.py +49 -0
  292. executorch/backends/arm/test/misc/test_outputs_order.py +122 -0
  293. executorch/backends/arm/test/misc/test_partition_decomposed_quantized_ops.py +181 -0
  294. executorch/backends/arm/test/misc/test_pass_pipeline_config.py +35 -0
  295. executorch/backends/arm/test/misc/test_pass_required_order.py +97 -0
  296. executorch/backends/arm/test/misc/test_qat_training_loop.py +100 -0
  297. executorch/backends/arm/test/misc/test_quant_custom_meta.py +105 -0
  298. executorch/backends/arm/test/misc/test_rescale_range.py +130 -0
  299. executorch/backends/arm/test/misc/test_save_exported_model.py +64 -0
  300. executorch/backends/arm/test/misc/test_tosa_dialect_conv2d.py +220 -0
  301. executorch/backends/arm/test/misc/test_tosa_dialect_dw_conv2d.py +227 -0
  302. executorch/backends/arm/test/misc/test_tosa_spec.py +169 -0
  303. executorch/backends/arm/test/models/stable_diffusion/stable_diffusion_module_test_configs.py +114 -0
  304. executorch/backends/arm/test/models/stable_diffusion/test_CLIPTextModelWithProjection.py +168 -0
  305. executorch/backends/arm/test/models/stable_diffusion/test_SD3Transformer2DModel.py +193 -0
  306. executorch/backends/arm/test/models/stable_diffusion/test_T5EncoderModel.py +161 -0
  307. executorch/backends/arm/test/models/stable_diffusion/test_vae_AutoencoderKL.py +118 -0
  308. executorch/backends/arm/test/models/test_conformer.py +138 -0
  309. executorch/backends/arm/test/models/test_deit_tiny_arm.py +120 -0
  310. executorch/backends/arm/test/models/test_dl3_arm.py +118 -0
  311. executorch/backends/arm/test/models/test_inception_v3_arm.py +120 -0
  312. executorch/backends/arm/test/models/test_llama.py +227 -0
  313. executorch/backends/arm/test/models/test_lstm_arm.py +194 -0
  314. executorch/backends/arm/test/models/test_mobilenet_v2_arm.py +179 -0
  315. executorch/backends/arm/test/models/test_mobilenet_v3_arm.py +113 -0
  316. executorch/backends/arm/test/models/test_nn_functional.py +124 -0
  317. executorch/backends/arm/test/models/test_nn_modules.py +161 -0
  318. executorch/backends/arm/test/models/test_nss.py +146 -0
  319. executorch/backends/arm/test/models/test_resnet18.py +98 -0
  320. executorch/backends/arm/test/models/test_torch_functions.py +151 -0
  321. executorch/backends/arm/test/models/test_w2l_arm.py +136 -0
  322. executorch/backends/arm/test/ops/test_abs.py +101 -0
  323. executorch/backends/arm/test/ops/test_acos.py +121 -0
  324. executorch/backends/arm/test/ops/test_acosh.py +137 -0
  325. executorch/backends/arm/test/ops/test_adaptive_avg_pool2d.py +242 -0
  326. executorch/backends/arm/test/ops/test_add.py +291 -0
  327. executorch/backends/arm/test/ops/test_addmm.py +285 -0
  328. executorch/backends/arm/test/ops/test_alias_copy.py +114 -0
  329. executorch/backends/arm/test/ops/test_amax.py +191 -0
  330. executorch/backends/arm/test/ops/test_amin.py +205 -0
  331. executorch/backends/arm/test/ops/test_any.py +210 -0
  332. executorch/backends/arm/test/ops/test_arange.py +258 -0
  333. executorch/backends/arm/test/ops/test_asin.py +105 -0
  334. executorch/backends/arm/test/ops/test_asinh.py +104 -0
  335. executorch/backends/arm/test/ops/test_at.py +256 -0
  336. executorch/backends/arm/test/ops/test_atan.py +111 -0
  337. executorch/backends/arm/test/ops/test_atanh.py +112 -0
  338. executorch/backends/arm/test/ops/test_avg_pool2d.py +295 -0
  339. executorch/backends/arm/test/ops/test_batch_norm.py +385 -0
  340. executorch/backends/arm/test/ops/test_bitwise.py +672 -0
  341. executorch/backends/arm/test/ops/test_bitwise_not.py +115 -0
  342. executorch/backends/arm/test/ops/test_bmm.py +193 -0
  343. executorch/backends/arm/test/ops/test_cat.py +219 -0
  344. executorch/backends/arm/test/ops/test_ceil.py +125 -0
  345. executorch/backends/arm/test/ops/test_clamp.py +474 -0
  346. executorch/backends/arm/test/ops/test_clone.py +150 -0
  347. executorch/backends/arm/test/ops/test_cond.py +338 -0
  348. executorch/backends/arm/test/ops/test_constant_pad_nd.py +119 -0
  349. executorch/backends/arm/test/ops/test_conv1d.py +356 -0
  350. executorch/backends/arm/test/ops/test_conv2d.py +592 -0
  351. executorch/backends/arm/test/ops/test_conv3d.py +711 -0
  352. executorch/backends/arm/test/ops/test_conv_combos.py +668 -0
  353. executorch/backends/arm/test/ops/test_conv_constant_pad_nd.py +145 -0
  354. executorch/backends/arm/test/ops/test_copy.py +171 -0
  355. executorch/backends/arm/test/ops/test_cos.py +115 -0
  356. executorch/backends/arm/test/ops/test_cosh.py +111 -0
  357. executorch/backends/arm/test/ops/test_cumsum.py +122 -0
  358. executorch/backends/arm/test/ops/test_depthwise_conv.py +404 -0
  359. executorch/backends/arm/test/ops/test_div.py +151 -0
  360. executorch/backends/arm/test/ops/test_div_tensor_mode.py +151 -0
  361. executorch/backends/arm/test/ops/test_elu.py +133 -0
  362. executorch/backends/arm/test/ops/test_embedding.py +146 -0
  363. executorch/backends/arm/test/ops/test_eq.py +286 -0
  364. executorch/backends/arm/test/ops/test_erf.py +96 -0
  365. executorch/backends/arm/test/ops/test_exp.py +110 -0
  366. executorch/backends/arm/test/ops/test_expand.py +153 -0
  367. executorch/backends/arm/test/ops/test_expm1.py +113 -0
  368. executorch/backends/arm/test/ops/test_eye.py +156 -0
  369. executorch/backends/arm/test/ops/test_fill_scalar.py +108 -0
  370. executorch/backends/arm/test/ops/test_floor.py +125 -0
  371. executorch/backends/arm/test/ops/test_floor_div.py +156 -0
  372. executorch/backends/arm/test/ops/test_full.py +255 -0
  373. executorch/backends/arm/test/ops/test_ge.py +292 -0
  374. executorch/backends/arm/test/ops/test_gelu.py +156 -0
  375. executorch/backends/arm/test/ops/test_glu.py +130 -0
  376. executorch/backends/arm/test/ops/test_group_norm.py +200 -0
  377. executorch/backends/arm/test/ops/test_gt.py +293 -0
  378. executorch/backends/arm/test/ops/test_hardsigmoid.py +114 -0
  379. executorch/backends/arm/test/ops/test_hardswish.py +104 -0
  380. executorch/backends/arm/test/ops/test_hardtanh.py +113 -0
  381. executorch/backends/arm/test/ops/test_index_select.py +177 -0
  382. executorch/backends/arm/test/ops/test_index_tensor.py +467 -0
  383. executorch/backends/arm/test/ops/test_layer_norm.py +186 -0
  384. executorch/backends/arm/test/ops/test_le.py +296 -0
  385. executorch/backends/arm/test/ops/test_leaky_relu.py +125 -0
  386. executorch/backends/arm/test/ops/test_linalg_vector_norm.py +160 -0
  387. executorch/backends/arm/test/ops/test_linear.py +389 -0
  388. executorch/backends/arm/test/ops/test_log.py +100 -0
  389. executorch/backends/arm/test/ops/test_log1p.py +78 -0
  390. executorch/backends/arm/test/ops/test_logical.py +429 -0
  391. executorch/backends/arm/test/ops/test_logit.py +119 -0
  392. executorch/backends/arm/test/ops/test_logsoftmax.py +124 -0
  393. executorch/backends/arm/test/ops/test_lshift.py +220 -0
  394. executorch/backends/arm/test/ops/test_lt.py +293 -0
  395. executorch/backends/arm/test/ops/test_masked_fill.py +171 -0
  396. executorch/backends/arm/test/ops/test_matmul.py +289 -0
  397. executorch/backends/arm/test/ops/test_max_pool.py +329 -0
  398. executorch/backends/arm/test/ops/test_maximum.py +98 -0
  399. executorch/backends/arm/test/ops/test_mean_dim.py +388 -0
  400. executorch/backends/arm/test/ops/test_minimum.py +98 -0
  401. executorch/backends/arm/test/ops/test_mm.py +93 -0
  402. executorch/backends/arm/test/ops/test_mul.py +376 -0
  403. executorch/backends/arm/test/ops/test_multihead_attention.py +138 -0
  404. executorch/backends/arm/test/ops/test_ne.py +243 -0
  405. executorch/backends/arm/test/ops/test_neg.py +99 -0
  406. executorch/backends/arm/test/ops/test_ones.py +152 -0
  407. executorch/backends/arm/test/ops/test_permute.py +256 -0
  408. executorch/backends/arm/test/ops/test_pixel_shuffling.py +237 -0
  409. executorch/backends/arm/test/ops/test_pow.py +204 -0
  410. executorch/backends/arm/test/ops/test_reciprocal.py +112 -0
  411. executorch/backends/arm/test/ops/test_relu.py +166 -0
  412. executorch/backends/arm/test/ops/test_remainder.py +199 -0
  413. executorch/backends/arm/test/ops/test_repeat.py +162 -0
  414. executorch/backends/arm/test/ops/test_round.py +111 -0
  415. executorch/backends/arm/test/ops/test_rshift.py +226 -0
  416. executorch/backends/arm/test/ops/test_rsqrt.py +153 -0
  417. executorch/backends/arm/test/ops/test_rsub.py +126 -0
  418. executorch/backends/arm/test/ops/test_scalar_tensor.py +135 -0
  419. executorch/backends/arm/test/ops/test_scalars.py +438 -0
  420. executorch/backends/arm/test/ops/test_sdpa.py +73 -0
  421. executorch/backends/arm/test/ops/test_select.py +219 -0
  422. executorch/backends/arm/test/ops/test_select_scatter.py +173 -0
  423. executorch/backends/arm/test/ops/test_sigmoid.py +357 -0
  424. executorch/backends/arm/test/ops/test_sigmoid_32bit.py +177 -0
  425. executorch/backends/arm/test/ops/test_sign.py +113 -0
  426. executorch/backends/arm/test/ops/test_silu.py +174 -0
  427. executorch/backends/arm/test/ops/test_sin.py +108 -0
  428. executorch/backends/arm/test/ops/test_sinh.py +103 -0
  429. executorch/backends/arm/test/ops/test_slice.py +217 -0
  430. executorch/backends/arm/test/ops/test_softmax.py +121 -0
  431. executorch/backends/arm/test/ops/test_split.py +312 -0
  432. executorch/backends/arm/test/ops/test_sqrt.py +112 -0
  433. executorch/backends/arm/test/ops/test_squeeze.py +291 -0
  434. executorch/backends/arm/test/ops/test_stack.py +150 -0
  435. executorch/backends/arm/test/ops/test_sub.py +366 -0
  436. executorch/backends/arm/test/ops/test_sum.py +161 -0
  437. executorch/backends/arm/test/ops/test_t_copy.py +115 -0
  438. executorch/backends/arm/test/ops/test_tan.py +146 -0
  439. executorch/backends/arm/test/ops/test_tanh.py +169 -0
  440. executorch/backends/arm/test/ops/test_to_copy.py +296 -0
  441. executorch/backends/arm/test/ops/test_transpose_copy.py +114 -0
  442. executorch/backends/arm/test/ops/test_unary_combos.py +144 -0
  443. executorch/backends/arm/test/ops/test_unbind.py +82 -0
  444. executorch/backends/arm/test/ops/test_unflatten.py +107 -0
  445. executorch/backends/arm/test/ops/test_unsqueeze.py +107 -0
  446. executorch/backends/arm/test/ops/test_upsample_bilinear2d.py +443 -0
  447. executorch/backends/arm/test/ops/test_upsample_nearest2d.py +520 -0
  448. executorch/backends/arm/test/ops/test_var.py +394 -0
  449. executorch/backends/arm/test/ops/test_view.py +253 -0
  450. executorch/backends/arm/test/ops/test_where.py +285 -0
  451. executorch/backends/arm/test/ops/test_while.py +264 -0
  452. executorch/backends/arm/test/ops/test_zeros.py +158 -0
  453. executorch/backends/arm/test/passes/test_broadcast_args_pass.py +57 -0
  454. executorch/backends/arm/test/passes/test_cast_int64_pass.py +49 -0
  455. executorch/backends/arm/test/passes/test_convert_expand_copy_to_repeat.py +51 -0
  456. executorch/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py +529 -0
  457. executorch/backends/arm/test/passes/test_convert_int64_output_ops_to_int32.py +129 -0
  458. executorch/backends/arm/test/passes/test_convert_permute_singleton_to_view_pass.py +100 -0
  459. executorch/backends/arm/test/passes/test_convert_split_to_slice.py +75 -0
  460. executorch/backends/arm/test/passes/test_convert_to_clamp.py +92 -0
  461. executorch/backends/arm/test/passes/test_decompose_avg_pool2d_pass.py +82 -0
  462. executorch/backends/arm/test/passes/test_decompose_cosine_similarity_pass.py +58 -0
  463. executorch/backends/arm/test/passes/test_decompose_div_pass.py +70 -0
  464. executorch/backends/arm/test/passes/test_decompose_int_pow_pass.py +80 -0
  465. executorch/backends/arm/test/passes/test_decompose_layernorm_pass.py +69 -0
  466. executorch/backends/arm/test/passes/test_decompose_linalg_vector_norm_pass.py +107 -0
  467. executorch/backends/arm/test/passes/test_decompose_meandim_pass.py +137 -0
  468. executorch/backends/arm/test/passes/test_decompose_quant_nodes.py +44 -0
  469. executorch/backends/arm/test/passes/test_decompose_softmax_pass.py +103 -0
  470. executorch/backends/arm/test/passes/test_decompose_tosa_unsupported_clamp_pass.py +73 -0
  471. executorch/backends/arm/test/passes/test_decompose_var_pass.py +89 -0
  472. executorch/backends/arm/test/passes/test_decorate_fp32_to_int32_casting_pass.py +85 -0
  473. executorch/backends/arm/test/passes/test_fold_qdq_pass.py +51 -0
  474. executorch/backends/arm/test/passes/test_fuse_batchnorm_pass.py +164 -0
  475. executorch/backends/arm/test/passes/test_fuse_constant_ops_pass.py +177 -0
  476. executorch/backends/arm/test/passes/test_fuse_duplicate_users_pass.py +70 -0
  477. executorch/backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py +170 -0
  478. executorch/backends/arm/test/passes/test_fuse_view_copy.py +82 -0
  479. executorch/backends/arm/test/passes/test_insert_int32_casts_after_int64_placeholders_pass.py +114 -0
  480. executorch/backends/arm/test/passes/test_insert_rescale_i32_pass.py +107 -0
  481. executorch/backends/arm/test/passes/test_insert_table_ops_pass.py +47 -0
  482. executorch/backends/arm/test/passes/test_int32_cast_embedding_pass.py +46 -0
  483. executorch/backends/arm/test/passes/test_ioquantization_pass.py +48 -0
  484. executorch/backends/arm/test/passes/test_promote_bool_operands_pass.py +103 -0
  485. executorch/backends/arm/test/passes/test_remove_clone_pass.py +45 -0
  486. executorch/backends/arm/test/passes/test_replace_inf_values_pass.py +96 -0
  487. executorch/backends/arm/test/passes/test_rescale_pass.py +81 -0
  488. executorch/backends/arm/test/passes/test_rewrite_conv_pass.py +20 -0
  489. executorch/backends/arm/test/passes/test_to_tosa_memory_format.py +213 -0
  490. executorch/backends/arm/test/passes/test_unsqueeze_before_repeat_pass.py +62 -0
  491. executorch/backends/arm/test/quantizer/test_conv_relu_fusing.py +118 -0
  492. executorch/backends/arm/test/quantizer/test_generic_annotater.py +109 -0
  493. executorch/backends/arm/test/quantizer/test_partial_quantization.py +104 -0
  494. executorch/backends/arm/test/quantizer/test_selective_quantization.py +212 -0
  495. executorch/backends/arm/test/quantizer/test_set_module_name.py +158 -0
  496. executorch/backends/arm/test/quantizer/test_tosa_quantizer_validate.py +55 -0
  497. executorch/backends/arm/test/runner_utils.py +840 -0
  498. executorch/backends/arm/test/test_memory_allocator_log.py +170 -0
  499. executorch/backends/arm/test/test_model.py +345 -0
  500. executorch/backends/arm/test/tester/__init__.py +6 -0
  501. executorch/backends/arm/test/tester/analyze_output_utils.py +346 -0
  502. executorch/backends/arm/test/tester/arm_tester.py +1149 -0
  503. executorch/backends/arm/test/tester/quantize.py +43 -0
  504. executorch/backends/arm/test/tester/serialize.py +78 -0
  505. executorch/backends/arm/test/tester/test_pipeline.py +1190 -0
  506. executorch/backends/arm/tosa/__init__.py +9 -0
  507. executorch/backends/arm/tosa/backend.py +443 -0
  508. executorch/backends/arm/tosa/compile_spec.py +48 -0
  509. executorch/backends/arm/tosa/dialect/__init__.py +15 -0
  510. executorch/backends/arm/tosa/dialect/lib.py +85 -0
  511. executorch/backends/arm/tosa/dialect/ops/conv2d.py +111 -0
  512. executorch/backends/arm/tosa/dialect/ops/conv3d.py +74 -0
  513. executorch/backends/arm/tosa/dialect/ops/depthwise_conv2d.py +56 -0
  514. executorch/backends/arm/tosa/dialect/ops/matmul.py +56 -0
  515. executorch/backends/arm/tosa/dialect/ops/rescale.py +53 -0
  516. executorch/backends/arm/tosa/dialect/ops/resize.py +66 -0
  517. executorch/backends/arm/tosa/dialect/ops/table.py +53 -0
  518. executorch/backends/arm/tosa/dialect/ops/transpose.py +35 -0
  519. executorch/backends/arm/tosa/dialect/ops_registration.py +68 -0
  520. executorch/backends/arm/tosa/mapping.py +309 -0
  521. executorch/backends/arm/tosa/partitioner.py +486 -0
  522. executorch/backends/arm/tosa/schemas/__init__.py +4 -0
  523. executorch/backends/arm/tosa/schemas/tosa_1.0.fbs +559 -0
  524. executorch/backends/arm/tosa/specification.py +406 -0
  525. executorch/backends/arm/tosa/utils.py +304 -0
  526. executorch/backends/arm/util/_factory.py +59 -0
  527. executorch/backends/arm/util/arm_model_evaluator.py +388 -0
  528. executorch/backends/arm/vgf/__init__.py +11 -0
  529. executorch/backends/arm/vgf/backend.py +172 -0
  530. executorch/backends/arm/vgf/compile_spec.py +73 -0
  531. executorch/backends/arm/vgf/model_converter.py +34 -0
  532. executorch/backends/arm/vgf/partitioner.py +35 -0
  533. executorch/backends/cadence/aot/__init__.py +5 -0
  534. executorch/backends/cadence/aot/compiler.py +484 -0
  535. executorch/backends/cadence/aot/compiler_funcs.py +203 -0
  536. executorch/backends/cadence/aot/compiler_utils.py +293 -0
  537. executorch/backends/cadence/aot/decompose_ops.py +120 -0
  538. executorch/backends/cadence/aot/export_example.py +117 -0
  539. executorch/backends/cadence/aot/functions.yaml +470 -0
  540. executorch/backends/cadence/aot/functions_fusion_g3.yaml +191 -0
  541. executorch/backends/cadence/aot/functions_hifi.yaml +565 -0
  542. executorch/backends/cadence/aot/functions_vision.yaml +275 -0
  543. executorch/backends/cadence/aot/fuse_ops.py +1138 -0
  544. executorch/backends/cadence/aot/graph_builder.py +142 -0
  545. executorch/backends/cadence/aot/memory_constraints.py +731 -0
  546. executorch/backends/cadence/aot/memory_planning.py +469 -0
  547. executorch/backends/cadence/aot/memory_planning_algo.py +341 -0
  548. executorch/backends/cadence/aot/ops_registrations.py +2841 -0
  549. executorch/backends/cadence/aot/pass_utils.py +274 -0
  550. executorch/backends/cadence/aot/passes.py +132 -0
  551. executorch/backends/cadence/aot/program_builder.py +138 -0
  552. executorch/backends/cadence/aot/quantizer/fusion_pass.py +743 -0
  553. executorch/backends/cadence/aot/quantizer/patterns.py +738 -0
  554. executorch/backends/cadence/aot/quantizer/quantizer.py +409 -0
  555. executorch/backends/cadence/aot/quantizer/utils.py +288 -0
  556. executorch/backends/cadence/aot/ref_implementations.py +2210 -0
  557. executorch/backends/cadence/aot/remove_ops.py +936 -0
  558. executorch/backends/cadence/aot/reorder_ops.py +843 -0
  559. executorch/backends/cadence/aot/replace_ops.py +2526 -0
  560. executorch/backends/cadence/aot/simplify_ops.py +221 -0
  561. executorch/backends/cadence/aot/tests/test_decompose_ops_passes.py +80 -0
  562. executorch/backends/cadence/aot/tests/test_fusion_ops_passes.py +1023 -0
  563. executorch/backends/cadence/aot/tests/test_graph_builder.py +104 -0
  564. executorch/backends/cadence/aot/tests/test_idma_ops.py +31 -0
  565. executorch/backends/cadence/aot/tests/test_memory_passes.py +1367 -0
  566. executorch/backends/cadence/aot/tests/test_pass_filter.py +167 -0
  567. executorch/backends/cadence/aot/tests/test_program_builder.py +222 -0
  568. executorch/backends/cadence/aot/tests/test_quantizer_ops.py +649 -0
  569. executorch/backends/cadence/aot/tests/test_ref_implementations.py +3151 -0
  570. executorch/backends/cadence/aot/tests/test_remove_ops_passes.py +977 -0
  571. executorch/backends/cadence/aot/tests/test_reorder_ops_passes.py +635 -0
  572. executorch/backends/cadence/aot/tests/test_replace_ops_passes.py +2777 -0
  573. executorch/backends/cadence/aot/tests/test_simplify_ops_passes.py +160 -0
  574. executorch/backends/cadence/aot/tests/test_type_dispatch_passes.py +481 -0
  575. executorch/backends/cadence/aot/type_dispatch.py +190 -0
  576. executorch/backends/cadence/aot/typing_stubs.py +22 -0
  577. executorch/backends/cadence/aot/utils.py +363 -0
  578. executorch/backends/cadence/runtime/__init__.py +13 -0
  579. executorch/backends/cadence/runtime/etdump.py +173 -0
  580. executorch/backends/cadence/runtime/executor.py +202 -0
  581. executorch/backends/cadence/runtime/runtime.py +156 -0
  582. executorch/backends/cadence/runtime/utils.py +100 -0
  583. executorch/backends/cadence/utils/FACTO/calibrator/__init__.py +0 -0
  584. executorch/backends/cadence/utils/FACTO/calibrator/runner.py +190 -0
  585. executorch/backends/cadence/utils/FACTO/examples/example.py +59 -0
  586. executorch/backends/cadence/utils/FACTO/examples/minimal_example.py +21 -0
  587. executorch/backends/cadence/utils/FACTO/examples/random_seed.py +35 -0
  588. executorch/backends/cadence/utils/FACTO/facto/__init__.py +0 -0
  589. executorch/backends/cadence/utils/FACTO/facto/inputgen/__init__.py +0 -0
  590. executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/__init__.py +0 -0
  591. executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/engine.py +129 -0
  592. executorch/backends/cadence/utils/FACTO/facto/inputgen/argtuple/gen.py +47 -0
  593. executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/__init__.py +0 -0
  594. executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/engine.py +291 -0
  595. executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/gen.py +139 -0
  596. executorch/backends/cadence/utils/FACTO/facto/inputgen/argument/type.py +134 -0
  597. executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/__init__.py +0 -0
  598. executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/engine.py +54 -0
  599. executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/model.py +133 -0
  600. executorch/backends/cadence/utils/FACTO/facto/inputgen/attribute/solve.py +125 -0
  601. executorch/backends/cadence/utils/FACTO/facto/inputgen/specs/__init__.py +0 -0
  602. executorch/backends/cadence/utils/FACTO/facto/inputgen/specs/model.py +149 -0
  603. executorch/backends/cadence/utils/FACTO/facto/inputgen/utils/__init__.py +0 -0
  604. executorch/backends/cadence/utils/FACTO/facto/inputgen/utils/random_manager.py +33 -0
  605. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/__init__.py +0 -0
  606. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/constants.py +9 -0
  607. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/gen.py +283 -0
  608. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/solve.py +142 -0
  609. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/space.py +450 -0
  610. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/type.py +105 -0
  611. executorch/backends/cadence/utils/FACTO/facto/inputgen/variable/utils.py +30 -0
  612. executorch/backends/cadence/utils/FACTO/facto/specdb/db.py +4361 -0
  613. executorch/backends/cadence/utils/FACTO/facto/specdb/default.py +36 -0
  614. executorch/backends/cadence/utils/FACTO/facto/specdb/dtypes.py +25 -0
  615. executorch/backends/cadence/utils/FACTO/facto/specdb/function.py +537 -0
  616. executorch/backends/cadence/utils/FACTO/setup.py +19 -0
  617. executorch/backends/cadence/utils/FACTO/test/inputgen/test_argtuple_engine.py +53 -0
  618. executorch/backends/cadence/utils/FACTO/test/inputgen/test_argtuple_generator.py +58 -0
  619. executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_attributes.py +78 -0
  620. executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_generator.py +98 -0
  621. executorch/backends/cadence/utils/FACTO/test/inputgen/test_argument_types.py +28 -0
  622. executorch/backends/cadence/utils/FACTO/test/inputgen/test_attribute_engine.py +62 -0
  623. executorch/backends/cadence/utils/FACTO/test/inputgen/test_attribute_solver.py +83 -0
  624. executorch/backends/cadence/utils/FACTO/test/inputgen/test_constraints.py +27 -0
  625. executorch/backends/cadence/utils/FACTO/test/inputgen/test_meta_arg_engine.py +70 -0
  626. executorch/backends/cadence/utils/FACTO/test/inputgen/test_specs.py +48 -0
  627. executorch/backends/cadence/utils/FACTO/test/inputgen/test_structural_engine.py +32 -0
  628. executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_generation.py +80 -0
  629. executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_solving.py +193 -0
  630. executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_space.py +231 -0
  631. executorch/backends/cadence/utils/FACTO/test/inputgen/test_variable_types.py +71 -0
  632. executorch/backends/cadence/utils/facto_util.py +611 -0
  633. executorch/backends/cadence/utils/gen_header.py +49 -0
  634. executorch/backends/cadence/utils/post_compilation.py +173 -0
  635. executorch/backends/cortex_m/ops/operators.py +890 -0
  636. executorch/backends/cortex_m/ops/operators.yaml +78 -0
  637. executorch/backends/cortex_m/passes/__init__.py +12 -0
  638. executorch/backends/cortex_m/passes/activation_fusion_pass.py +181 -0
  639. executorch/backends/cortex_m/passes/clamp_hardswish_pass.py +37 -0
  640. executorch/backends/cortex_m/passes/convert_to_cortex_m_pass.py +318 -0
  641. executorch/backends/cortex_m/passes/cortex_m_pass_manager.py +73 -0
  642. executorch/backends/cortex_m/passes/decompose_hardswish_pass.py +127 -0
  643. executorch/backends/cortex_m/passes/passes_utils.py +226 -0
  644. executorch/backends/cortex_m/passes/quantized_op_fusion_pass.py +255 -0
  645. executorch/backends/cortex_m/passes/replace_quant_nodes_pass.py +67 -0
  646. executorch/backends/cortex_m/quantizer/__init__.py +18 -0
  647. executorch/backends/cortex_m/quantizer/operator_configs.py +74 -0
  648. executorch/backends/cortex_m/quantizer/quantization_configs.py +121 -0
  649. executorch/backends/cortex_m/quantizer/quantizer.py +500 -0
  650. executorch/backends/cortex_m/test/misc/test_quantization.py +359 -0
  651. executorch/backends/cortex_m/test/models/__init__.py +4 -0
  652. executorch/backends/cortex_m/test/models/test_mobilenet_v3.py +74 -0
  653. executorch/backends/cortex_m/test/ops/__init__.py +4 -0
  654. executorch/backends/cortex_m/test/ops/test_activation.py +528 -0
  655. executorch/backends/cortex_m/test/ops/test_add.py +182 -0
  656. executorch/backends/cortex_m/test/ops/test_avg_pool2d.py +99 -0
  657. executorch/backends/cortex_m/test/ops/test_conv.py +342 -0
  658. executorch/backends/cortex_m/test/ops/test_linear.py +130 -0
  659. executorch/backends/cortex_m/test/ops/test_lstm.py +98 -0
  660. executorch/backends/cortex_m/test/ops/test_maximum.py +83 -0
  661. executorch/backends/cortex_m/test/ops/test_minimum.py +104 -0
  662. executorch/backends/cortex_m/test/ops/test_mul.py +156 -0
  663. executorch/backends/cortex_m/test/ops/test_softmax.py +84 -0
  664. executorch/backends/cortex_m/test/ops/test_transpose.py +102 -0
  665. executorch/backends/cortex_m/test/test_helpers_passes_utils.py +103 -0
  666. executorch/backends/cortex_m/test/test_replace_quant_nodes.py +134 -0
  667. executorch/backends/cortex_m/test/tester.py +113 -0
  668. executorch/backends/cuda/__init__.py +5 -0
  669. executorch/backends/cuda/cuda_backend.py +250 -0
  670. executorch/backends/cuda/cuda_partitioner.py +25 -0
  671. executorch/backends/cuda/passes/__init__.py +0 -0
  672. executorch/backends/cuda/passes/move_cond_predicate_to_cpu.py +90 -0
  673. executorch/backends/cuda/passes/tests/__init__.py +0 -0
  674. executorch/backends/cuda/passes/tests/test_move_cond_predicate_to_cpu.py +553 -0
  675. executorch/backends/cuda/tests/__init__.py +5 -0
  676. executorch/backends/cuda/tests/test_cuda_export.py +327 -0
  677. executorch/backends/cuda/tests/test_cuda_partitioner.py +224 -0
  678. executorch/backends/cuda/triton/__init__.py +17 -0
  679. executorch/backends/cuda/triton/kernels/__init__.py +11 -0
  680. executorch/backends/cuda/triton/kernels/sdpa.py +827 -0
  681. executorch/backends/cuda/triton/replacement_pass.py +130 -0
  682. executorch/backends/example/example_backend.py +41 -0
  683. executorch/backends/example/example_backend_delegate_passes/merge_to_dim_pass.py +83 -0
  684. executorch/backends/example/example_backend_delegate_passes/permute_memory_formats_pass.py +143 -0
  685. executorch/backends/example/example_operators/adaptive_avg_pool2d.py +47 -0
  686. executorch/backends/example/example_operators/add.py +44 -0
  687. executorch/backends/example/example_operators/conv2d.py +52 -0
  688. executorch/backends/example/example_operators/conv_relu.py +49 -0
  689. executorch/backends/example/example_operators/dropout.py +44 -0
  690. executorch/backends/example/example_operators/flatten.py +40 -0
  691. executorch/backends/example/example_operators/linear.py +62 -0
  692. executorch/backends/example/example_operators/op_base.py +15 -0
  693. executorch/backends/example/example_operators/ops.py +32 -0
  694. executorch/backends/example/example_operators/utils.py +34 -0
  695. executorch/backends/example/example_partitioner.py +88 -0
  696. executorch/backends/example/example_quantizer.py +108 -0
  697. executorch/backends/example/test_example_delegate.py +112 -0
  698. executorch/backends/mediatek/__init__.py +5 -0
  699. executorch/backends/mediatek/_passes/__init__.py +0 -0
  700. executorch/backends/mediatek/_passes/decompose_scaled_dot_product_attention.py +79 -0
  701. executorch/backends/mediatek/partitioner.py +107 -0
  702. executorch/backends/mediatek/preprocess.py +214 -0
  703. executorch/backends/mediatek/quantizer/__init__.py +4 -0
  704. executorch/backends/mediatek/quantizer/annotator.py +263 -0
  705. executorch/backends/mediatek/quantizer/qconfig.py +174 -0
  706. executorch/backends/mediatek/quantizer/quantizer.py +45 -0
  707. executorch/backends/nxp/_passes/remove_getitem_pass.py +105 -0
  708. executorch/backends/nxp/aten_passes/convert_unsqueeze_to_view.py +79 -0
  709. executorch/backends/nxp/aten_passes/decompose_split_to_slices_pass.py +193 -0
  710. executorch/backends/nxp/aten_passes/fuse_batch_norm_with_conv_pass.py +146 -0
  711. executorch/backends/nxp/aten_passes/fuse_batch_norm_with_linear_pass.py +150 -0
  712. executorch/backends/nxp/aten_passes/fuse_linear_and_add_pass.py +204 -0
  713. executorch/backends/nxp/aten_passes/move_activation_before_concat.py +102 -0
  714. executorch/backends/nxp/aten_passes/neutron_aten_pass_manager.py +80 -0
  715. executorch/backends/nxp/aten_passes/remove_nodes_with_known_outputs.py +196 -0
  716. executorch/backends/nxp/aten_passes/split_group_convolution.py +281 -0
  717. executorch/backends/nxp/aten_passes/split_gru_based_on_num_layers.py +307 -0
  718. executorch/backends/nxp/backend/custom_delegation_options.py +19 -0
  719. executorch/backends/nxp/backend/edge_helper.py +222 -0
  720. executorch/backends/nxp/backend/edge_program_converter.py +247 -0
  721. executorch/backends/nxp/backend/ir/conversion_config.py +54 -0
  722. executorch/backends/nxp/backend/ir/conversion_context.py +38 -0
  723. executorch/backends/nxp/backend/ir/converter/__init__.py +0 -0
  724. executorch/backends/nxp/backend/ir/converter/builder/__init__.py +0 -0
  725. executorch/backends/nxp/backend/ir/converter/builder/aten_model_builder_director.py +142 -0
  726. executorch/backends/nxp/backend/ir/converter/builder/model_builder.py +1720 -0
  727. executorch/backends/nxp/backend/ir/converter/builder/quantization_verification.py +377 -0
  728. executorch/backends/nxp/backend/ir/converter/conversion/__init__.py +0 -0
  729. executorch/backends/nxp/backend/ir/converter/conversion/aten_translator.py +71 -0
  730. executorch/backends/nxp/backend/ir/converter/conversion/common.py +207 -0
  731. executorch/backends/nxp/backend/ir/converter/conversion/translator.py +689 -0
  732. executorch/backends/nxp/backend/ir/converter/node_converter.py +234 -0
  733. executorch/backends/nxp/backend/ir/converter/node_converters/__init__.py +4 -0
  734. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/__init__.py +101 -0
  735. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/abs_converter.py +35 -0
  736. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/adaptive_avg_pool_2d_converter.py +68 -0
  737. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/add_tensor_converter.py +57 -0
  738. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/addmm_converter.py +62 -0
  739. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/avg_pool_2d_converter.py +101 -0
  740. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/cat_converter.py +209 -0
  741. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/clone_converter.py +118 -0
  742. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/constant_pad_nd_converter.py +160 -0
  743. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/convolution_converter.py +535 -0
  744. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/hardtanh_converter.py +47 -0
  745. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/max_pool_2d_converter.py +104 -0
  746. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mean_dim_converter.py +112 -0
  747. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mm_converter.py +59 -0
  748. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/mul_tensor_converter.py +61 -0
  749. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/permute_copy_converter.py +468 -0
  750. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_dequantize_converter.py +116 -0
  751. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/qdq_quantize_converter.py +46 -0
  752. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/relu_converter.py +33 -0
  753. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sigmoid_converter.py +35 -0
  754. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/slice_tensor_converter.py +158 -0
  755. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/softmax_converter.py +62 -0
  756. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/sub_tensor_converter.py +59 -0
  757. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/tanh_converter.py +33 -0
  758. executorch/backends/nxp/backend/ir/converter/node_converters/ops_converters/view_copy_converter.py +220 -0
  759. executorch/backends/nxp/backend/ir/converter/node_converters/shared/__init__.py +0 -0
  760. executorch/backends/nxp/backend/ir/converter/node_converters/shared/conv_utils.py +105 -0
  761. executorch/backends/nxp/backend/ir/converter/node_converters/shared/recurrent_utils.py +64 -0
  762. executorch/backends/nxp/backend/ir/converter/node_converters/shared/reduce_utils.py +97 -0
  763. executorch/backends/nxp/backend/ir/converter/node_converters/shared/reshape_transposition.py +233 -0
  764. executorch/backends/nxp/backend/ir/converter/quantization_utils.py +149 -0
  765. executorch/backends/nxp/backend/ir/converter/tensor_utils.py +50 -0
  766. executorch/backends/nxp/backend/ir/lib/__init__.py +0 -0
  767. executorch/backends/nxp/backend/ir/lib/tflite/ATan2Options.py +50 -0
  768. executorch/backends/nxp/backend/ir/lib/tflite/AbsOptions.py +50 -0
  769. executorch/backends/nxp/backend/ir/lib/tflite/ActivationFunctionType.py +12 -0
  770. executorch/backends/nxp/backend/ir/lib/tflite/AddNOptions.py +50 -0
  771. executorch/backends/nxp/backend/ir/lib/tflite/AddOptions.py +82 -0
  772. executorch/backends/nxp/backend/ir/lib/tflite/ArgMaxOptions.py +65 -0
  773. executorch/backends/nxp/backend/ir/lib/tflite/ArgMinOptions.py +65 -0
  774. executorch/backends/nxp/backend/ir/lib/tflite/AssignVariableOptions.py +50 -0
  775. executorch/backends/nxp/backend/ir/lib/tflite/BatchMatMulOptions.py +101 -0
  776. executorch/backends/nxp/backend/ir/lib/tflite/BatchToSpaceNDOptions.py +50 -0
  777. executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceLSTMOptions.py +160 -0
  778. executorch/backends/nxp/backend/ir/lib/tflite/BidirectionalSequenceRNNOptions.py +126 -0
  779. executorch/backends/nxp/backend/ir/lib/tflite/BitcastOptions.py +50 -0
  780. executorch/backends/nxp/backend/ir/lib/tflite/BitwiseXorOptions.py +50 -0
  781. executorch/backends/nxp/backend/ir/lib/tflite/BroadcastToOptions.py +50 -0
  782. executorch/backends/nxp/backend/ir/lib/tflite/BucketizeOptions.py +98 -0
  783. executorch/backends/nxp/backend/ir/lib/tflite/Buffer.py +132 -0
  784. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOperator.py +212 -0
  785. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions.py +133 -0
  786. executorch/backends/nxp/backend/ir/lib/tflite/BuiltinOptions2.py +27 -0
  787. executorch/backends/nxp/backend/ir/lib/tflite/CallOnceOptions.py +65 -0
  788. executorch/backends/nxp/backend/ir/lib/tflite/CallOptions.py +67 -0
  789. executorch/backends/nxp/backend/ir/lib/tflite/CastOptions.py +80 -0
  790. executorch/backends/nxp/backend/ir/lib/tflite/CombinerType.py +9 -0
  791. executorch/backends/nxp/backend/ir/lib/tflite/ConcatEmbeddingsOptions.py +163 -0
  792. executorch/backends/nxp/backend/ir/lib/tflite/ConcatenationOptions.py +80 -0
  793. executorch/backends/nxp/backend/ir/lib/tflite/Conv2DOptions.py +155 -0
  794. executorch/backends/nxp/backend/ir/lib/tflite/Conv3DOptions.py +170 -0
  795. executorch/backends/nxp/backend/ir/lib/tflite/CosOptions.py +50 -0
  796. executorch/backends/nxp/backend/ir/lib/tflite/CumsumOptions.py +84 -0
  797. executorch/backends/nxp/backend/ir/lib/tflite/CustomOptionsFormat.py +7 -0
  798. executorch/backends/nxp/backend/ir/lib/tflite/CustomQuantization.py +98 -0
  799. executorch/backends/nxp/backend/ir/lib/tflite/DensifyOptions.py +50 -0
  800. executorch/backends/nxp/backend/ir/lib/tflite/DepthToSpaceOptions.py +65 -0
  801. executorch/backends/nxp/backend/ir/lib/tflite/DepthwiseConv2DOptions.py +157 -0
  802. executorch/backends/nxp/backend/ir/lib/tflite/DequantizeOptions.py +50 -0
  803. executorch/backends/nxp/backend/ir/lib/tflite/DilateOptions.py +50 -0
  804. executorch/backends/nxp/backend/ir/lib/tflite/DimensionMetadata.py +152 -0
  805. executorch/backends/nxp/backend/ir/lib/tflite/DimensionType.py +8 -0
  806. executorch/backends/nxp/backend/ir/lib/tflite/DivOptions.py +65 -0
  807. executorch/backends/nxp/backend/ir/lib/tflite/DynamicUpdateSliceOptions.py +52 -0
  808. executorch/backends/nxp/backend/ir/lib/tflite/EmbeddingLookupSparseOptions.py +67 -0
  809. executorch/backends/nxp/backend/ir/lib/tflite/EqualOptions.py +50 -0
  810. executorch/backends/nxp/backend/ir/lib/tflite/ExpOptions.py +50 -0
  811. executorch/backends/nxp/backend/ir/lib/tflite/ExpandDimsOptions.py +50 -0
  812. executorch/backends/nxp/backend/ir/lib/tflite/FakeQuantOptions.py +116 -0
  813. executorch/backends/nxp/backend/ir/lib/tflite/FillOptions.py +50 -0
  814. executorch/backends/nxp/backend/ir/lib/tflite/FloorDivOptions.py +50 -0
  815. executorch/backends/nxp/backend/ir/lib/tflite/FloorModOptions.py +50 -0
  816. executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptions.py +129 -0
  817. executorch/backends/nxp/backend/ir/lib/tflite/FullyConnectedOptionsWeightsFormat.py +8 -0
  818. executorch/backends/nxp/backend/ir/lib/tflite/GatherNdOptions.py +50 -0
  819. executorch/backends/nxp/backend/ir/lib/tflite/GatherOptions.py +80 -0
  820. executorch/backends/nxp/backend/ir/lib/tflite/GeluOptions.py +67 -0
  821. executorch/backends/nxp/backend/ir/lib/tflite/GreaterEqualOptions.py +50 -0
  822. executorch/backends/nxp/backend/ir/lib/tflite/GreaterOptions.py +50 -0
  823. executorch/backends/nxp/backend/ir/lib/tflite/HardSwishOptions.py +50 -0
  824. executorch/backends/nxp/backend/ir/lib/tflite/HashtableFindOptions.py +50 -0
  825. executorch/backends/nxp/backend/ir/lib/tflite/HashtableImportOptions.py +52 -0
  826. executorch/backends/nxp/backend/ir/lib/tflite/HashtableOptions.py +95 -0
  827. executorch/backends/nxp/backend/ir/lib/tflite/HashtableSizeOptions.py +50 -0
  828. executorch/backends/nxp/backend/ir/lib/tflite/IfOptions.py +80 -0
  829. executorch/backends/nxp/backend/ir/lib/tflite/Int32Vector.py +98 -0
  830. executorch/backends/nxp/backend/ir/lib/tflite/L2NormOptions.py +65 -0
  831. executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionOptions.py +65 -0
  832. executorch/backends/nxp/backend/ir/lib/tflite/LSHProjectionType.py +9 -0
  833. executorch/backends/nxp/backend/ir/lib/tflite/LSTMKernelType.py +8 -0
  834. executorch/backends/nxp/backend/ir/lib/tflite/LSTMOptions.py +131 -0
  835. executorch/backends/nxp/backend/ir/lib/tflite/LeakyReluOptions.py +67 -0
  836. executorch/backends/nxp/backend/ir/lib/tflite/LessEqualOptions.py +50 -0
  837. executorch/backends/nxp/backend/ir/lib/tflite/LessOptions.py +50 -0
  838. executorch/backends/nxp/backend/ir/lib/tflite/LocalResponseNormalizationOptions.py +118 -0
  839. executorch/backends/nxp/backend/ir/lib/tflite/LogSoftmaxOptions.py +50 -0
  840. executorch/backends/nxp/backend/ir/lib/tflite/LogicalAndOptions.py +50 -0
  841. executorch/backends/nxp/backend/ir/lib/tflite/LogicalNotOptions.py +50 -0
  842. executorch/backends/nxp/backend/ir/lib/tflite/LogicalOrOptions.py +50 -0
  843. executorch/backends/nxp/backend/ir/lib/tflite/MatrixDiagOptions.py +50 -0
  844. executorch/backends/nxp/backend/ir/lib/tflite/MatrixSetDiagOptions.py +50 -0
  845. executorch/backends/nxp/backend/ir/lib/tflite/MaximumMinimumOptions.py +50 -0
  846. executorch/backends/nxp/backend/ir/lib/tflite/Metadata.py +84 -0
  847. executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadMode.py +8 -0
  848. executorch/backends/nxp/backend/ir/lib/tflite/MirrorPadOptions.py +65 -0
  849. executorch/backends/nxp/backend/ir/lib/tflite/Model.py +352 -0
  850. executorch/backends/nxp/backend/ir/lib/tflite/MulOptions.py +65 -0
  851. executorch/backends/nxp/backend/ir/lib/tflite/NegOptions.py +50 -0
  852. executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV4Options.py +52 -0
  853. executorch/backends/nxp/backend/ir/lib/tflite/NonMaxSuppressionV5Options.py +52 -0
  854. executorch/backends/nxp/backend/ir/lib/tflite/NotEqualOptions.py +50 -0
  855. executorch/backends/nxp/backend/ir/lib/tflite/OneHotOptions.py +65 -0
  856. executorch/backends/nxp/backend/ir/lib/tflite/Operator.py +428 -0
  857. executorch/backends/nxp/backend/ir/lib/tflite/OperatorCode.py +112 -0
  858. executorch/backends/nxp/backend/ir/lib/tflite/PackOptions.py +80 -0
  859. executorch/backends/nxp/backend/ir/lib/tflite/PadOptions.py +50 -0
  860. executorch/backends/nxp/backend/ir/lib/tflite/PadV2Options.py +50 -0
  861. executorch/backends/nxp/backend/ir/lib/tflite/Padding.py +8 -0
  862. executorch/backends/nxp/backend/ir/lib/tflite/Pool2DOptions.py +140 -0
  863. executorch/backends/nxp/backend/ir/lib/tflite/PowOptions.py +50 -0
  864. executorch/backends/nxp/backend/ir/lib/tflite/QuantizationDetails.py +8 -0
  865. executorch/backends/nxp/backend/ir/lib/tflite/QuantizationParameters.py +295 -0
  866. executorch/backends/nxp/backend/ir/lib/tflite/QuantizeOptions.py +50 -0
  867. executorch/backends/nxp/backend/ir/lib/tflite/RNNOptions.py +82 -0
  868. executorch/backends/nxp/backend/ir/lib/tflite/RandomOptions.py +80 -0
  869. executorch/backends/nxp/backend/ir/lib/tflite/RangeOptions.py +50 -0
  870. executorch/backends/nxp/backend/ir/lib/tflite/RankOptions.py +50 -0
  871. executorch/backends/nxp/backend/ir/lib/tflite/ReadVariableOptions.py +50 -0
  872. executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowFunction.py +13 -0
  873. executorch/backends/nxp/backend/ir/lib/tflite/ReduceWindowOptions.py +65 -0
  874. executorch/backends/nxp/backend/ir/lib/tflite/ReducerOptions.py +67 -0
  875. executorch/backends/nxp/backend/ir/lib/tflite/ReshapeOptions.py +98 -0
  876. executorch/backends/nxp/backend/ir/lib/tflite/ResizeBilinearOptions.py +84 -0
  877. executorch/backends/nxp/backend/ir/lib/tflite/ResizeNearestNeighborOptions.py +86 -0
  878. executorch/backends/nxp/backend/ir/lib/tflite/ReverseSequenceOptions.py +82 -0
  879. executorch/backends/nxp/backend/ir/lib/tflite/ReverseV2Options.py +50 -0
  880. executorch/backends/nxp/backend/ir/lib/tflite/Rfft2dOptions.py +50 -0
  881. executorch/backends/nxp/backend/ir/lib/tflite/RightShiftOptions.py +50 -0
  882. executorch/backends/nxp/backend/ir/lib/tflite/RngAlgorithm.py +9 -0
  883. executorch/backends/nxp/backend/ir/lib/tflite/SVDFOptions.py +97 -0
  884. executorch/backends/nxp/backend/ir/lib/tflite/ScatterNdOptions.py +50 -0
  885. executorch/backends/nxp/backend/ir/lib/tflite/SegmentSumOptions.py +50 -0
  886. executorch/backends/nxp/backend/ir/lib/tflite/SelectOptions.py +50 -0
  887. executorch/backends/nxp/backend/ir/lib/tflite/SelectV2Options.py +50 -0
  888. executorch/backends/nxp/backend/ir/lib/tflite/SequenceRNNOptions.py +99 -0
  889. executorch/backends/nxp/backend/ir/lib/tflite/ShapeOptions.py +65 -0
  890. executorch/backends/nxp/backend/ir/lib/tflite/SignOptions.py +50 -0
  891. executorch/backends/nxp/backend/ir/lib/tflite/SignatureDef.py +172 -0
  892. executorch/backends/nxp/backend/ir/lib/tflite/SkipGramOptions.py +97 -0
  893. executorch/backends/nxp/backend/ir/lib/tflite/SliceOptions.py +50 -0
  894. executorch/backends/nxp/backend/ir/lib/tflite/SoftmaxOptions.py +67 -0
  895. executorch/backends/nxp/backend/ir/lib/tflite/SpaceToBatchNDOptions.py +50 -0
  896. executorch/backends/nxp/backend/ir/lib/tflite/SpaceToDepthOptions.py +65 -0
  897. executorch/backends/nxp/backend/ir/lib/tflite/SparseIndexVector.py +10 -0
  898. executorch/backends/nxp/backend/ir/lib/tflite/SparseToDenseOptions.py +67 -0
  899. executorch/backends/nxp/backend/ir/lib/tflite/SparsityParameters.py +190 -0
  900. executorch/backends/nxp/backend/ir/lib/tflite/SplitOptions.py +65 -0
  901. executorch/backends/nxp/backend/ir/lib/tflite/SplitVOptions.py +65 -0
  902. executorch/backends/nxp/backend/ir/lib/tflite/SquareOptions.py +50 -0
  903. executorch/backends/nxp/backend/ir/lib/tflite/SquaredDifferenceOptions.py +52 -0
  904. executorch/backends/nxp/backend/ir/lib/tflite/SqueezeOptions.py +98 -0
  905. executorch/backends/nxp/backend/ir/lib/tflite/StablehloBroadcastInDimOptions.py +102 -0
  906. executorch/backends/nxp/backend/ir/lib/tflite/StablehloCompareOptions.py +86 -0
  907. executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonDirection.py +12 -0
  908. executorch/backends/nxp/backend/ir/lib/tflite/StablehloComparisonType.py +11 -0
  909. executorch/backends/nxp/backend/ir/lib/tflite/StablehloConcatenateOptions.py +67 -0
  910. executorch/backends/nxp/backend/ir/lib/tflite/StablehloConvolutionOptions.py +634 -0
  911. executorch/backends/nxp/backend/ir/lib/tflite/StablehloCustomCallOptions.py +214 -0
  912. executorch/backends/nxp/backend/ir/lib/tflite/StablehloDotGeneralOptions.py +304 -0
  913. executorch/backends/nxp/backend/ir/lib/tflite/StablehloDynamicSliceOptions.py +100 -0
  914. executorch/backends/nxp/backend/ir/lib/tflite/StablehloGatherOptions.py +276 -0
  915. executorch/backends/nxp/backend/ir/lib/tflite/StablehloIotaOptions.py +65 -0
  916. executorch/backends/nxp/backend/ir/lib/tflite/StablehloPadOptions.py +194 -0
  917. executorch/backends/nxp/backend/ir/lib/tflite/StablehloPrecisionConfig.py +9 -0
  918. executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceOptions.py +115 -0
  919. executorch/backends/nxp/backend/ir/lib/tflite/StablehloReduceWindowOptions.py +307 -0
  920. executorch/backends/nxp/backend/ir/lib/tflite/StablehloRngBitGeneratorOptions.py +67 -0
  921. executorch/backends/nxp/backend/ir/lib/tflite/StablehloScatterOptions.py +268 -0
  922. executorch/backends/nxp/backend/ir/lib/tflite/StablehloSliceOptions.py +194 -0
  923. executorch/backends/nxp/backend/ir/lib/tflite/StablehloSortOptions.py +97 -0
  924. executorch/backends/nxp/backend/ir/lib/tflite/StablehloTransposeOptions.py +100 -0
  925. executorch/backends/nxp/backend/ir/lib/tflite/StablehloWhileOptions.py +80 -0
  926. executorch/backends/nxp/backend/ir/lib/tflite/StridedSliceOptions.py +142 -0
  927. executorch/backends/nxp/backend/ir/lib/tflite/SubGraph.py +251 -0
  928. executorch/backends/nxp/backend/ir/lib/tflite/SubOptions.py +82 -0
  929. executorch/backends/nxp/backend/ir/lib/tflite/Tensor.py +317 -0
  930. executorch/backends/nxp/backend/ir/lib/tflite/TensorMap.py +84 -0
  931. executorch/backends/nxp/backend/ir/lib/tflite/TensorType.py +24 -0
  932. executorch/backends/nxp/backend/ir/lib/tflite/TileOptions.py +50 -0
  933. executorch/backends/nxp/backend/ir/lib/tflite/TopKV2Options.py +50 -0
  934. executorch/backends/nxp/backend/ir/lib/tflite/TransposeConvOptions.py +125 -0
  935. executorch/backends/nxp/backend/ir/lib/tflite/TransposeOptions.py +50 -0
  936. executorch/backends/nxp/backend/ir/lib/tflite/Uint16Vector.py +98 -0
  937. executorch/backends/nxp/backend/ir/lib/tflite/Uint8Vector.py +98 -0
  938. executorch/backends/nxp/backend/ir/lib/tflite/UnidirectionalSequenceLSTMOptions.py +164 -0
  939. executorch/backends/nxp/backend/ir/lib/tflite/UniqueOptions.py +65 -0
  940. executorch/backends/nxp/backend/ir/lib/tflite/UnpackOptions.py +80 -0
  941. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMaxOptions.py +52 -0
  942. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentMinOptions.py +52 -0
  943. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentProdOptions.py +52 -0
  944. executorch/backends/nxp/backend/ir/lib/tflite/UnsortedSegmentSumOptions.py +52 -0
  945. executorch/backends/nxp/backend/ir/lib/tflite/VarHandleOptions.py +84 -0
  946. executorch/backends/nxp/backend/ir/lib/tflite/VariantSubType.py +130 -0
  947. executorch/backends/nxp/backend/ir/lib/tflite/WhereOptions.py +50 -0
  948. executorch/backends/nxp/backend/ir/lib/tflite/WhileOptions.py +80 -0
  949. executorch/backends/nxp/backend/ir/lib/tflite/ZerosLikeOptions.py +50 -0
  950. executorch/backends/nxp/backend/ir/lib/tflite/__init__.py +0 -0
  951. executorch/backends/nxp/backend/ir/logger.py +341 -0
  952. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/__init__.py +0 -0
  953. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/graph_utils.py +115 -0
  954. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/operator_rules.py +102 -0
  955. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/__init__.py +0 -0
  956. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/base_optimization.py +41 -0
  957. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/permute_fully_connected_weights_after_reshape.py +121 -0
  958. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizations/prune_transpose_operators.py +174 -0
  959. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/optimizer.py +127 -0
  960. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/pattern_matcher.py +925 -0
  961. executorch/backends/nxp/backend/ir/neutron_ir_post_processing/tensor_rules.py +710 -0
  962. executorch/backends/nxp/backend/ir/tensor_formatting.py +69 -0
  963. executorch/backends/nxp/backend/ir/tflite_generator/__init__.py +0 -0
  964. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/__init__.py +0 -0
  965. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/abs_options.py +25 -0
  966. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_n_options.py +32 -0
  967. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/add_options.py +46 -0
  968. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_max_options.py +28 -0
  969. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/arg_min_options.py +28 -0
  970. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/average_pool_2d_options.py +63 -0
  971. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/batch_mat_mul_options.py +45 -0
  972. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_lstm_options.py +65 -0
  973. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bidirectional_sequence_rnn_options.py +53 -0
  974. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/bitwise_xor_options.py +23 -0
  975. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/broadcast_to_options.py +25 -0
  976. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cast_options.py +32 -0
  977. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/concatenation_options.py +38 -0
  978. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_2d_options.py +59 -0
  979. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/conv_3d_options.py +67 -0
  980. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/cum_sum_options.py +30 -0
  981. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depth_to_space_options.py +29 -0
  982. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/depthwise_conv_2d_options.py +69 -0
  983. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/dequantize_options.py +24 -0
  984. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/div_options.py +43 -0
  985. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/equal_options.py +23 -0
  986. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/exp_options.py +23 -0
  987. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/floor_mod_options.py +23 -0
  988. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/fully_connected_options.py +57 -0
  989. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_nd_options.py +23 -0
  990. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gather_options.py +30 -0
  991. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/gelu_options.py +27 -0
  992. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_equal_options.py +25 -0
  993. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/greater_options.py +23 -0
  994. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/hard_swish_options.py +23 -0
  995. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/leaky_relu_options.py +32 -0
  996. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_equal_options.py +23 -0
  997. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/less_options.py +23 -0
  998. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/log_softmax_options.py +30 -0
  999. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_and_options.py +23 -0
  1000. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_not_options.py +23 -0
  1001. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/logical_or_options.py +23 -0
  1002. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lrn_options.py +45 -0
  1003. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/lstm_options.py +60 -0
  1004. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/max_pool_2d_options.py +63 -0
  1005. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/maximum_options.py +21 -0
  1006. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mean_options.py +28 -0
  1007. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/minimum_options.py +21 -0
  1008. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mirror_pad_options.py +60 -0
  1009. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/mul_options.py +36 -0
  1010. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/multinomial_options.py +30 -0
  1011. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/neg_options.py +23 -0
  1012. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/not_equal_options.py +23 -0
  1013. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/one_hot_options.py +27 -0
  1014. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_options.py +27 -0
  1015. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pad_v2_options.py +27 -0
  1016. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/pow_options.py +24 -0
  1017. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/quantize_options.py +30 -0
  1018. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/range_options.py +23 -0
  1019. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_max_options.py +28 -0
  1020. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_min_options.py +28 -0
  1021. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reduce_prod_options.py +28 -0
  1022. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reshape_options.py +53 -0
  1023. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_bilinear_options.py +34 -0
  1024. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/resize_nearest_neighbor_options.py +37 -0
  1025. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/reverse_sequence_options.py +32 -0
  1026. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/scatter_nd_options.py +23 -0
  1027. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/select_v2_options.py +24 -0
  1028. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/shape_options.py +34 -0
  1029. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sign_options.py +22 -0
  1030. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/slice_options.py +29 -0
  1031. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/softmax_options.py +36 -0
  1032. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/space_to_depth_options.py +29 -0
  1033. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_options.py +27 -0
  1034. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/split_v_options.py +27 -0
  1035. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/square_options.py +23 -0
  1036. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squared_difference_options.py +25 -0
  1037. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/squeeze_options.py +42 -0
  1038. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/strided_slice_options.py +35 -0
  1039. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sub_options.py +46 -0
  1040. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/sum_options.py +28 -0
  1041. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/tile_options.py +23 -0
  1042. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_conv_options.py +50 -0
  1043. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/transpose_options.py +30 -0
  1044. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_lstm_options.py +67 -0
  1045. executorch/backends/nxp/backend/ir/tflite_generator/builtin_options/unidirectional_sequence_rnn_options.py +49 -0
  1046. executorch/backends/nxp/backend/ir/tflite_generator/custom_options/flex_transpose_options.py +78 -0
  1047. executorch/backends/nxp/backend/ir/tflite_generator/meta/__init__.py +0 -0
  1048. executorch/backends/nxp/backend/ir/tflite_generator/meta/meta.py +255 -0
  1049. executorch/backends/nxp/backend/ir/tflite_generator/meta/types.py +198 -0
  1050. executorch/backends/nxp/backend/ir/tflite_generator/tflite_model.py +814 -0
  1051. executorch/backends/nxp/backend/neutron_converter_manager.py +117 -0
  1052. executorch/backends/nxp/backend/neutron_operator_support.py +79 -0
  1053. executorch/backends/nxp/backend/neutron_target_spec.py +143 -0
  1054. executorch/backends/nxp/backend/node_format.py +26 -0
  1055. executorch/backends/nxp/backend/node_format_inference.py +294 -0
  1056. executorch/backends/nxp/edge_passes/move_auxiliary_operator_into_separate_qdq_cluster_pass.py +254 -0
  1057. executorch/backends/nxp/edge_passes/neutron_edge_pass.py +55 -0
  1058. executorch/backends/nxp/edge_passes/neutron_edge_pass_manager.py +29 -0
  1059. executorch/backends/nxp/edge_passes/remove_additional_quantize_dequantize_nodes_pass.py +111 -0
  1060. executorch/backends/nxp/edge_passes/remove_as_strided_copy_nodes.py +66 -0
  1061. executorch/backends/nxp/edge_passes/remove_io_quant_ops_pass.py +79 -0
  1062. executorch/backends/nxp/neutron_node_extraction.py +152 -0
  1063. executorch/backends/nxp/neutron_partitioner.py +421 -0
  1064. executorch/backends/nxp/neutron_pass_manager.py +50 -0
  1065. executorch/backends/nxp/nxp_backend.py +391 -0
  1066. executorch/backends/nxp/quantizer/neutron_quantizer.py +353 -0
  1067. executorch/backends/nxp/quantizer/patterns.py +1089 -0
  1068. executorch/backends/nxp/quantizer/utils.py +195 -0
  1069. executorch/backends/nxp/tests/executorch_pipeline.py +184 -0
  1070. executorch/backends/nxp/tests/executors.py +401 -0
  1071. executorch/backends/nxp/tests/ir/__init__.py +0 -0
  1072. executorch/backends/nxp/tests/ir/converter/__init__.py +0 -0
  1073. executorch/backends/nxp/tests/ir/converter/node_converter/__init__.py +0 -0
  1074. executorch/backends/nxp/tests/ir/converter/node_converter/test_abs_converter.py +91 -0
  1075. executorch/backends/nxp/tests/ir/converter/node_converter/test_adaptive_avg_pool2d_converter.py +148 -0
  1076. executorch/backends/nxp/tests/ir/converter/node_converter/test_add_tensor_converter.py +161 -0
  1077. executorch/backends/nxp/tests/ir/converter/node_converter/test_addmm_converter.py +96 -0
  1078. executorch/backends/nxp/tests/ir/converter/node_converter/test_avg_pool2d_converter.py +221 -0
  1079. executorch/backends/nxp/tests/ir/converter/node_converter/test_cat_converter.py +495 -0
  1080. executorch/backends/nxp/tests/ir/converter/node_converter/test_clone_converter.py +344 -0
  1081. executorch/backends/nxp/tests/ir/converter/node_converter/test_constant_pad_nd_converter.py +188 -0
  1082. executorch/backends/nxp/tests/ir/converter/node_converter/test_conv_converter.py +680 -0
  1083. executorch/backends/nxp/tests/ir/converter/node_converter/test_hardtanh_converter.py +107 -0
  1084. executorch/backends/nxp/tests/ir/converter/node_converter/test_max_pool_2d_converter.py +132 -0
  1085. executorch/backends/nxp/tests/ir/converter/node_converter/test_mean_dim_converter.py +280 -0
  1086. executorch/backends/nxp/tests/ir/converter/node_converter/test_mm_converter.py +96 -0
  1087. executorch/backends/nxp/tests/ir/converter/node_converter/test_mul_tensor_converter.py +212 -0
  1088. executorch/backends/nxp/tests/ir/converter/node_converter/test_permute_copy_converter.py +426 -0
  1089. executorch/backends/nxp/tests/ir/converter/node_converter/test_relu_converter.py +114 -0
  1090. executorch/backends/nxp/tests/ir/converter/node_converter/test_sigmoid_converter.py +78 -0
  1091. executorch/backends/nxp/tests/ir/converter/node_converter/test_slice_tensor_converter.py +244 -0
  1092. executorch/backends/nxp/tests/ir/converter/node_converter/test_softmax_converter.py +115 -0
  1093. executorch/backends/nxp/tests/ir/converter/node_converter/test_sub_tensor_converter.py +181 -0
  1094. executorch/backends/nxp/tests/ir/converter/node_converter/test_tanh_converter.py +90 -0
  1095. executorch/backends/nxp/tests/ir/converter/node_converter/test_view_copy_converter.py +509 -0
  1096. executorch/backends/nxp/tests/ir/edge_passes/__init__.py +0 -0
  1097. executorch/backends/nxp/tests/ir/edge_passes/test_remove_io_quant_ops_pass.py +127 -0
  1098. executorch/backends/nxp/tests/models.py +737 -0
  1099. executorch/backends/nxp/tests/test_batch_norm_fusion.py +233 -0
  1100. executorch/backends/nxp/tests/test_context_sensitive_delegation.py +71 -0
  1101. executorch/backends/nxp/tests/test_convert_unsqueeze_to_view.py +143 -0
  1102. executorch/backends/nxp/tests/test_decompose_split_to_slices.py +315 -0
  1103. executorch/backends/nxp/tests/test_edge_passes.py +382 -0
  1104. executorch/backends/nxp/tests/test_gru_splitting.py +267 -0
  1105. executorch/backends/nxp/tests/test_integration.py +53 -0
  1106. executorch/backends/nxp/tests/test_linear_and_add_fusion.py +653 -0
  1107. executorch/backends/nxp/tests/test_move_activation_before_concatenation.py +905 -0
  1108. executorch/backends/nxp/tests/test_neutron_backend.py +63 -0
  1109. executorch/backends/nxp/tests/test_neutron_backend_executor.py +327 -0
  1110. executorch/backends/nxp/tests/test_neutron_converter_manager.py +59 -0
  1111. executorch/backends/nxp/tests/test_node_format_inference.py +91 -0
  1112. executorch/backends/nxp/tests/test_operator_selector.py +24 -0
  1113. executorch/backends/nxp/tests/test_per_channel_conversion.py +182 -0
  1114. executorch/backends/nxp/tests/test_qdq_clustering_conv.py +31 -0
  1115. executorch/backends/nxp/tests/test_quantizer.py +703 -0
  1116. executorch/backends/nxp/tests/test_removing_dead_code.py +65 -0
  1117. executorch/backends/nxp/tests/test_removing_nodes_with_known_outputs.py +116 -0
  1118. executorch/backends/nxp/tests/test_split_group_convolution.py +291 -0
  1119. executorch/backends/nxp/tests/use_qat.py +11 -0
  1120. executorch/backends/openvino/__init__.py +5 -0
  1121. executorch/backends/openvino/partitioner.py +238 -0
  1122. executorch/backends/openvino/preprocess.py +62 -0
  1123. executorch/backends/openvino/quantizer/__init__.py +3 -0
  1124. executorch/backends/openvino/quantizer/observers.py +186 -0
  1125. executorch/backends/openvino/quantizer/quantizer.py +595 -0
  1126. executorch/backends/openvino/tests/models/test_classification.py +38 -0
  1127. executorch/backends/openvino/tests/ops/base_openvino_op_test.py +86 -0
  1128. executorch/backends/openvino/tests/ops/test_add.py +22 -0
  1129. executorch/backends/openvino/tests/ops/test_addmm.py +28 -0
  1130. executorch/backends/openvino/tests/ops/test_arange.py +23 -0
  1131. executorch/backends/openvino/tests/ops/test_batch_norm.py +61 -0
  1132. executorch/backends/openvino/tests/ops/test_convolution.py +296 -0
  1133. executorch/backends/openvino/tests/ops/test_mean.py +90 -0
  1134. executorch/backends/openvino/tests/ops/test_permute.py +33 -0
  1135. executorch/backends/openvino/tests/ops/test_pooling.py +91 -0
  1136. executorch/backends/openvino/tests/ops/test_unary_ops.py +37 -0
  1137. executorch/backends/openvino/tests/ops/test_view.py +35 -0
  1138. executorch/backends/openvino/tests/test_runner.py +76 -0
  1139. executorch/backends/qualcomm/__init__.py +13 -0
  1140. executorch/backends/qualcomm/_passes/__init__.py +101 -0
  1141. executorch/backends/qualcomm/_passes/annotate_adaptive_avg_pool1d.py +43 -0
  1142. executorch/backends/qualcomm/_passes/annotate_quant_attrs.py +145 -0
  1143. executorch/backends/qualcomm/_passes/annotate_stack.py +44 -0
  1144. executorch/backends/qualcomm/_passes/annotate_unbind.py +42 -0
  1145. executorch/backends/qualcomm/_passes/build_quant_io.py +49 -0
  1146. executorch/backends/qualcomm/_passes/canonicalize_conv.py +204 -0
  1147. executorch/backends/qualcomm/_passes/convert_bmm_to_matmul.py +83 -0
  1148. executorch/backends/qualcomm/_passes/convert_linear_to_conv2d.py +232 -0
  1149. executorch/backends/qualcomm/_passes/convert_mha_to_sha.py +626 -0
  1150. executorch/backends/qualcomm/_passes/convert_square_to_pow.py +38 -0
  1151. executorch/backends/qualcomm/_passes/decompose_any.py +64 -0
  1152. executorch/backends/qualcomm/_passes/decompose_binary_alpha.py +61 -0
  1153. executorch/backends/qualcomm/_passes/decompose_cdist.py +69 -0
  1154. executorch/backends/qualcomm/_passes/decompose_col_im.py +121 -0
  1155. executorch/backends/qualcomm/_passes/decompose_einsum.py +51 -0
  1156. executorch/backends/qualcomm/_passes/decompose_expm1.py +46 -0
  1157. executorch/backends/qualcomm/_passes/decompose_floor_divide.py +62 -0
  1158. executorch/backends/qualcomm/_passes/decompose_glu.py +55 -0
  1159. executorch/backends/qualcomm/_passes/decompose_linalg_vector_norm.py +75 -0
  1160. executorch/backends/qualcomm/_passes/decompose_maxpool3d.py +133 -0
  1161. executorch/backends/qualcomm/_passes/decompose_minmaxdim.py +109 -0
  1162. executorch/backends/qualcomm/_passes/decompose_roll.py +78 -0
  1163. executorch/backends/qualcomm/_passes/decompose_silu.py +45 -0
  1164. executorch/backends/qualcomm/_passes/decompose_threshold.py +61 -0
  1165. executorch/backends/qualcomm/_passes/decompose_triu.py +71 -0
  1166. executorch/backends/qualcomm/_passes/decompose_wrap_with_autocast.py +79 -0
  1167. executorch/backends/qualcomm/_passes/expand_broadcast_tensor_shape.py +67 -0
  1168. executorch/backends/qualcomm/_passes/fixed_linear_keep_dim.py +95 -0
  1169. executorch/backends/qualcomm/_passes/fold_qdq.py +80 -0
  1170. executorch/backends/qualcomm/_passes/fuse_consecutive_cast.py +116 -0
  1171. executorch/backends/qualcomm/_passes/fuse_consecutive_transpose.py +109 -0
  1172. executorch/backends/qualcomm/_passes/i64_to_i32.py +184 -0
  1173. executorch/backends/qualcomm/_passes/insert_io_qdq.py +154 -0
  1174. executorch/backends/qualcomm/_passes/insert_requantize.py +111 -0
  1175. executorch/backends/qualcomm/_passes/insert_reshape_for_reduce_ops.py +59 -0
  1176. executorch/backends/qualcomm/_passes/layout_transform.py +355 -0
  1177. executorch/backends/qualcomm/_passes/lift_constant_scalar_operands.py +186 -0
  1178. executorch/backends/qualcomm/_passes/qnn_pass_manager.py +271 -0
  1179. executorch/backends/qualcomm/_passes/recompose_pad_maxpool2d.py +147 -0
  1180. executorch/backends/qualcomm/_passes/recompose_pixel_unshuffle.py +81 -0
  1181. executorch/backends/qualcomm/_passes/recompose_rms_norm.py +155 -0
  1182. executorch/backends/qualcomm/_passes/reduce_dynamic_range.py +60 -0
  1183. executorch/backends/qualcomm/_passes/remove_0d_tensor.py +36 -0
  1184. executorch/backends/qualcomm/_passes/remove_redundancy.py +73 -0
  1185. executorch/backends/qualcomm/_passes/replace_arange_args.py +48 -0
  1186. executorch/backends/qualcomm/_passes/replace_inf_values.py +60 -0
  1187. executorch/backends/qualcomm/_passes/seq_mse.py +224 -0
  1188. executorch/backends/qualcomm/_passes/tag_quant_io.py +45 -0
  1189. executorch/backends/qualcomm/_passes/utils.py +283 -0
  1190. executorch/backends/qualcomm/builders/__init__.py +221 -0
  1191. executorch/backends/qualcomm/builders/node_visitor.py +518 -0
  1192. executorch/backends/qualcomm/builders/node_visitor_manager.py +79 -0
  1193. executorch/backends/qualcomm/builders/op_abs.py +57 -0
  1194. executorch/backends/qualcomm/builders/op_adaptive_avg_pool2d.py +126 -0
  1195. executorch/backends/qualcomm/builders/op_adaptive_max_pool2d.py +151 -0
  1196. executorch/backends/qualcomm/builders/op_add.py +62 -0
  1197. executorch/backends/qualcomm/builders/op_amax.py +90 -0
  1198. executorch/backends/qualcomm/builders/op_amin.py +90 -0
  1199. executorch/backends/qualcomm/builders/op_and.py +60 -0
  1200. executorch/backends/qualcomm/builders/op_arange.py +41 -0
  1201. executorch/backends/qualcomm/builders/op_argmax.py +78 -0
  1202. executorch/backends/qualcomm/builders/op_argmin.py +78 -0
  1203. executorch/backends/qualcomm/builders/op_asin.py +56 -0
  1204. executorch/backends/qualcomm/builders/op_atan.py +55 -0
  1205. executorch/backends/qualcomm/builders/op_avg_pool2d.py +168 -0
  1206. executorch/backends/qualcomm/builders/op_avg_pool3d.py +299 -0
  1207. executorch/backends/qualcomm/builders/op_batch_norm.py +151 -0
  1208. executorch/backends/qualcomm/builders/op_binary.py +84 -0
  1209. executorch/backends/qualcomm/builders/op_bmm.py +59 -0
  1210. executorch/backends/qualcomm/builders/op_cat.py +89 -0
  1211. executorch/backends/qualcomm/builders/op_ceil.py +56 -0
  1212. executorch/backends/qualcomm/builders/op_clamp.py +80 -0
  1213. executorch/backends/qualcomm/builders/op_conv.py +263 -0
  1214. executorch/backends/qualcomm/builders/op_copy.py +112 -0
  1215. executorch/backends/qualcomm/builders/op_cos.py +56 -0
  1216. executorch/backends/qualcomm/builders/op_cum_sum.py +87 -0
  1217. executorch/backends/qualcomm/builders/op_custom_op.py +93 -0
  1218. executorch/backends/qualcomm/builders/op_depth_to_space.py +78 -0
  1219. executorch/backends/qualcomm/builders/op_dequantize.py +72 -0
  1220. executorch/backends/qualcomm/builders/op_div.py +62 -0
  1221. executorch/backends/qualcomm/builders/op_elu.py +68 -0
  1222. executorch/backends/qualcomm/builders/op_embedding.py +79 -0
  1223. executorch/backends/qualcomm/builders/op_eq.py +62 -0
  1224. executorch/backends/qualcomm/builders/op_exp.py +60 -0
  1225. executorch/backends/qualcomm/builders/op_expand.py +84 -0
  1226. executorch/backends/qualcomm/builders/op_flip.py +81 -0
  1227. executorch/backends/qualcomm/builders/op_floor.py +56 -0
  1228. executorch/backends/qualcomm/builders/op_full.py +41 -0
  1229. executorch/backends/qualcomm/builders/op_full_like.py +41 -0
  1230. executorch/backends/qualcomm/builders/op_gather.py +76 -0
  1231. executorch/backends/qualcomm/builders/op_ge.py +62 -0
  1232. executorch/backends/qualcomm/builders/op_gelu.py +57 -0
  1233. executorch/backends/qualcomm/builders/op_grid_sampler_2d.py +162 -0
  1234. executorch/backends/qualcomm/builders/op_group_norm.py +94 -0
  1235. executorch/backends/qualcomm/builders/op_gt.py +62 -0
  1236. executorch/backends/qualcomm/builders/op_hardsigmoid.py +78 -0
  1237. executorch/backends/qualcomm/builders/op_hardswish.py +57 -0
  1238. executorch/backends/qualcomm/builders/op_hardtanh.py +79 -0
  1239. executorch/backends/qualcomm/builders/op_index.py +85 -0
  1240. executorch/backends/qualcomm/builders/op_index_put.py +481 -0
  1241. executorch/backends/qualcomm/builders/op_index_select.py +81 -0
  1242. executorch/backends/qualcomm/builders/op_instance_norm.py +112 -0
  1243. executorch/backends/qualcomm/builders/op_layer_norm.py +113 -0
  1244. executorch/backends/qualcomm/builders/op_le.py +62 -0
  1245. executorch/backends/qualcomm/builders/op_linear.py +98 -0
  1246. executorch/backends/qualcomm/builders/op_log.py +58 -0
  1247. executorch/backends/qualcomm/builders/op_log_softmax.py +81 -0
  1248. executorch/backends/qualcomm/builders/op_logical_not.py +56 -0
  1249. executorch/backends/qualcomm/builders/op_lt.py +62 -0
  1250. executorch/backends/qualcomm/builders/op_matmul.py +59 -0
  1251. executorch/backends/qualcomm/builders/op_max.py +62 -0
  1252. executorch/backends/qualcomm/builders/op_max_dim.py +89 -0
  1253. executorch/backends/qualcomm/builders/op_max_pool2d.py +145 -0
  1254. executorch/backends/qualcomm/builders/op_mean_dim.py +100 -0
  1255. executorch/backends/qualcomm/builders/op_min.py +62 -0
  1256. executorch/backends/qualcomm/builders/op_min_dim.py +89 -0
  1257. executorch/backends/qualcomm/builders/op_mul.py +62 -0
  1258. executorch/backends/qualcomm/builders/op_ne.py +62 -0
  1259. executorch/backends/qualcomm/builders/op_neg.py +54 -0
  1260. executorch/backends/qualcomm/builders/op_or.py +60 -0
  1261. executorch/backends/qualcomm/builders/op_pad.py +97 -0
  1262. executorch/backends/qualcomm/builders/op_pow.py +75 -0
  1263. executorch/backends/qualcomm/builders/op_prelu.py +81 -0
  1264. executorch/backends/qualcomm/builders/op_quantize.py +73 -0
  1265. executorch/backends/qualcomm/builders/op_relu.py +58 -0
  1266. executorch/backends/qualcomm/builders/op_repeat.py +68 -0
  1267. executorch/backends/qualcomm/builders/op_reshape.py +55 -0
  1268. executorch/backends/qualcomm/builders/op_resize.py +85 -0
  1269. executorch/backends/qualcomm/builders/op_rms_norm.py +132 -0
  1270. executorch/backends/qualcomm/builders/op_round.py +58 -0
  1271. executorch/backends/qualcomm/builders/op_rsqrt.py +58 -0
  1272. executorch/backends/qualcomm/builders/op_scalar_tensor.py +51 -0
  1273. executorch/backends/qualcomm/builders/op_select_copy.py +89 -0
  1274. executorch/backends/qualcomm/builders/op_sigmoid.py +58 -0
  1275. executorch/backends/qualcomm/builders/op_sign.py +56 -0
  1276. executorch/backends/qualcomm/builders/op_sin.py +56 -0
  1277. executorch/backends/qualcomm/builders/op_skip_ops.py +55 -0
  1278. executorch/backends/qualcomm/builders/op_slice_copy.py +95 -0
  1279. executorch/backends/qualcomm/builders/op_slice_scatter.py +122 -0
  1280. executorch/backends/qualcomm/builders/op_softmax.py +79 -0
  1281. executorch/backends/qualcomm/builders/op_space_to_depth.py +78 -0
  1282. executorch/backends/qualcomm/builders/op_split_with_sizes.py +99 -0
  1283. executorch/backends/qualcomm/builders/op_sqrt.py +60 -0
  1284. executorch/backends/qualcomm/builders/op_squeeze.py +57 -0
  1285. executorch/backends/qualcomm/builders/op_stack.py +71 -0
  1286. executorch/backends/qualcomm/builders/op_sub.py +62 -0
  1287. executorch/backends/qualcomm/builders/op_sum_int_list.py +84 -0
  1288. executorch/backends/qualcomm/builders/op_tanh.py +57 -0
  1289. executorch/backends/qualcomm/builders/op_to.py +149 -0
  1290. executorch/backends/qualcomm/builders/op_topk.py +112 -0
  1291. executorch/backends/qualcomm/builders/op_transpose.py +76 -0
  1292. executorch/backends/qualcomm/builders/op_unbind.py +73 -0
  1293. executorch/backends/qualcomm/builders/op_unsqueeze.py +57 -0
  1294. executorch/backends/qualcomm/builders/op_upsample_bilinear2d.py +68 -0
  1295. executorch/backends/qualcomm/builders/op_upsample_nearest2d.py +68 -0
  1296. executorch/backends/qualcomm/builders/op_where.py +82 -0
  1297. executorch/backends/qualcomm/builders/op_xor.py +60 -0
  1298. executorch/backends/qualcomm/builders/qnn_constants.py +630 -0
  1299. executorch/backends/qualcomm/builders/utils.py +160 -0
  1300. executorch/backends/qualcomm/debugger/format_outputs.py +221 -0
  1301. executorch/backends/qualcomm/debugger/metrics_evaluator.py +90 -0
  1302. executorch/backends/qualcomm/debugger/qnn_intermediate_debugger.py +328 -0
  1303. executorch/backends/qualcomm/debugger/utils.py +435 -0
  1304. executorch/backends/qualcomm/partition/common_defs.py +44 -0
  1305. executorch/backends/qualcomm/partition/qnn_partitioner.py +225 -0
  1306. executorch/backends/qualcomm/partition/utils.py +75 -0
  1307. executorch/backends/qualcomm/qnn_preprocess.py +218 -0
  1308. executorch/backends/qualcomm/quantizer/annotators.py +1501 -0
  1309. executorch/backends/qualcomm/quantizer/custom_annotation.py +499 -0
  1310. executorch/backends/qualcomm/quantizer/observers/concat_observer.py +74 -0
  1311. executorch/backends/qualcomm/quantizer/observers/per_block_param_observer.py +145 -0
  1312. executorch/backends/qualcomm/quantizer/observers/per_channel_param_observer.py +113 -0
  1313. executorch/backends/qualcomm/quantizer/qconfig.py +802 -0
  1314. executorch/backends/qualcomm/quantizer/quant_recipe.py +402 -0
  1315. executorch/backends/qualcomm/quantizer/quantizer.py +507 -0
  1316. executorch/backends/qualcomm/recipes/__init__.py +16 -0
  1317. executorch/backends/qualcomm/recipes/qnn_recipe_provider.py +179 -0
  1318. executorch/backends/qualcomm/recipes/qnn_recipe_types.py +28 -0
  1319. executorch/backends/qualcomm/scripts/download_qnn_sdk.py +642 -0
  1320. executorch/backends/qualcomm/serialization/qc_compiler_spec.fbs +299 -0
  1321. executorch/backends/qualcomm/serialization/qc_schema.py +240 -0
  1322. executorch/backends/qualcomm/serialization/qc_schema_serialize.py +59 -0
  1323. executorch/backends/qualcomm/tests/models.py +2393 -0
  1324. executorch/backends/qualcomm/tests/test_passes.py +154 -0
  1325. executorch/backends/qualcomm/tests/test_qnn_delegate.py +8454 -0
  1326. executorch/backends/qualcomm/tests/tester.py +113 -0
  1327. executorch/backends/qualcomm/tests/utils.py +770 -0
  1328. executorch/backends/qualcomm/utils/constants.py +49 -0
  1329. executorch/backends/qualcomm/utils/qnn_manager_lifecycle.py +88 -0
  1330. executorch/backends/qualcomm/utils/utils.py +1302 -0
  1331. executorch/backends/samsung/_passes/annotate_qparams.py +201 -0
  1332. executorch/backends/samsung/_passes/annotate_scalar_parameters.py +65 -0
  1333. executorch/backends/samsung/_passes/conv1d_to_conv2d.py +97 -0
  1334. executorch/backends/samsung/_passes/customized_constant_prop.py +40 -0
  1335. executorch/backends/samsung/_passes/fold_qdq.py +36 -0
  1336. executorch/backends/samsung/_passes/fuse_conv_act.py +77 -0
  1337. executorch/backends/samsung/_passes/insert_qdq.py +164 -0
  1338. executorch/backends/samsung/_passes/remove_useless_ops.py +87 -0
  1339. executorch/backends/samsung/_passes/replace_scalar_ops.py +46 -0
  1340. executorch/backends/samsung/_passes/utils.py +15 -0
  1341. executorch/backends/samsung/builders/__init__.py +97 -0
  1342. executorch/backends/samsung/builders/node_visitor.py +116 -0
  1343. executorch/backends/samsung/builders/op_add.py +41 -0
  1344. executorch/backends/samsung/builders/op_avg_pool2d.py +70 -0
  1345. executorch/backends/samsung/builders/op_batch_norm.py +56 -0
  1346. executorch/backends/samsung/builders/op_bmm.py +43 -0
  1347. executorch/backends/samsung/builders/op_cat.py +50 -0
  1348. executorch/backends/samsung/builders/op_clamp.py +47 -0
  1349. executorch/backends/samsung/builders/op_constant_pad_nd.py +56 -0
  1350. executorch/backends/samsung/builders/op_conv2d.py +89 -0
  1351. executorch/backends/samsung/builders/op_dequantize.py +19 -0
  1352. executorch/backends/samsung/builders/op_div.py +42 -0
  1353. executorch/backends/samsung/builders/op_embedding.py +41 -0
  1354. executorch/backends/samsung/builders/op_expand_copy.py +77 -0
  1355. executorch/backends/samsung/builders/op_gelu.py +40 -0
  1356. executorch/backends/samsung/builders/op_getitem.py +32 -0
  1357. executorch/backends/samsung/builders/op_hardsigmoid.py +35 -0
  1358. executorch/backends/samsung/builders/op_hardswish.py +35 -0
  1359. executorch/backends/samsung/builders/op_hardtanh.py +42 -0
  1360. executorch/backends/samsung/builders/op_layer_norm.py +53 -0
  1361. executorch/backends/samsung/builders/op_leaky_relu.py +58 -0
  1362. executorch/backends/samsung/builders/op_linear.py +51 -0
  1363. executorch/backends/samsung/builders/op_log_softmax.py +39 -0
  1364. executorch/backends/samsung/builders/op_max_pool2d.py +96 -0
  1365. executorch/backends/samsung/builders/op_maximum.py +37 -0
  1366. executorch/backends/samsung/builders/op_mean_dim.py +49 -0
  1367. executorch/backends/samsung/builders/op_minimum.py +39 -0
  1368. executorch/backends/samsung/builders/op_mul.py +43 -0
  1369. executorch/backends/samsung/builders/op_permute.py +37 -0
  1370. executorch/backends/samsung/builders/op_pixel_shuffle.py +38 -0
  1371. executorch/backends/samsung/builders/op_quantize.py +60 -0
  1372. executorch/backends/samsung/builders/op_relu.py +37 -0
  1373. executorch/backends/samsung/builders/op_reshape.py +34 -0
  1374. executorch/backends/samsung/builders/op_rsqrt.py +35 -0
  1375. executorch/backends/samsung/builders/op_select.py +52 -0
  1376. executorch/backends/samsung/builders/op_slice_copy.py +59 -0
  1377. executorch/backends/samsung/builders/op_softmax.py +39 -0
  1378. executorch/backends/samsung/builders/op_sqrt.py +35 -0
  1379. executorch/backends/samsung/builders/op_squeeze.py +37 -0
  1380. executorch/backends/samsung/builders/op_sub.py +39 -0
  1381. executorch/backends/samsung/builders/op_to_copy.py +44 -0
  1382. executorch/backends/samsung/builders/op_unsqueeze.py +35 -0
  1383. executorch/backends/samsung/builders/op_upsample_bilinear2d.py +53 -0
  1384. executorch/backends/samsung/builders/op_upsample_nearest2d.py +52 -0
  1385. executorch/backends/samsung/builders/utils.py +64 -0
  1386. executorch/backends/samsung/enn_preprocess.py +110 -0
  1387. executorch/backends/samsung/partition/enn_partitioner.py +134 -0
  1388. executorch/backends/samsung/quantizer/__init__.py +10 -0
  1389. executorch/backends/samsung/quantizer/annotator.py +871 -0
  1390. executorch/backends/samsung/quantizer/qconfig.py +174 -0
  1391. executorch/backends/samsung/quantizer/quantizer.py +65 -0
  1392. executorch/backends/samsung/serialization/compile_options.py +77 -0
  1393. executorch/backends/samsung/serialization/compile_options_def.fbs +23 -0
  1394. executorch/backends/samsung/serialization/enn_graph_schema.py +141 -0
  1395. executorch/backends/samsung/test/models/test_deeplab_v3.py +28 -0
  1396. executorch/backends/samsung/test/models/test_edsr.py +30 -0
  1397. executorch/backends/samsung/test/models/test_inception_v3.py +30 -0
  1398. executorch/backends/samsung/test/models/test_inception_v4.py +30 -0
  1399. executorch/backends/samsung/test/models/test_mobilenet_v2.py +28 -0
  1400. executorch/backends/samsung/test/models/test_mobilenet_v3.py +33 -0
  1401. executorch/backends/samsung/test/models/test_resnet18.py +30 -0
  1402. executorch/backends/samsung/test/models/test_resnet50.py +30 -0
  1403. executorch/backends/samsung/test/models/test_torchvision_vit.py +32 -0
  1404. executorch/backends/samsung/test/models/test_wav2letter.py +28 -0
  1405. executorch/backends/samsung/test/ops/test_add.py +63 -0
  1406. executorch/backends/samsung/test/ops/test_avg_pool2d.py +66 -0
  1407. executorch/backends/samsung/test/ops/test_batch_norm.py +52 -0
  1408. executorch/backends/samsung/test/ops/test_bmm.py +50 -0
  1409. executorch/backends/samsung/test/ops/test_cat.py +49 -0
  1410. executorch/backends/samsung/test/ops/test_clamp.py +50 -0
  1411. executorch/backends/samsung/test/ops/test_constant_pad_nd.py +46 -0
  1412. executorch/backends/samsung/test/ops/test_conv2d.py +95 -0
  1413. executorch/backends/samsung/test/ops/test_div.py +50 -0
  1414. executorch/backends/samsung/test/ops/test_embedding.py +46 -0
  1415. executorch/backends/samsung/test/ops/test_expand_copy.py +46 -0
  1416. executorch/backends/samsung/test/ops/test_gelu.py +65 -0
  1417. executorch/backends/samsung/test/ops/test_leaky_relu.py +47 -0
  1418. executorch/backends/samsung/test/ops/test_linear.py +48 -0
  1419. executorch/backends/samsung/test/ops/test_log_softmax.py +46 -0
  1420. executorch/backends/samsung/test/ops/test_max_pool2d.py +72 -0
  1421. executorch/backends/samsung/test/ops/test_mean_dim.py +51 -0
  1422. executorch/backends/samsung/test/ops/test_minimum.py +45 -0
  1423. executorch/backends/samsung/test/ops/test_mul.py +63 -0
  1424. executorch/backends/samsung/test/ops/test_permute.py +55 -0
  1425. executorch/backends/samsung/test/ops/test_pixel_shuffle.py +49 -0
  1426. executorch/backends/samsung/test/ops/test_relu.py +65 -0
  1427. executorch/backends/samsung/test/ops/test_reshape.py +46 -0
  1428. executorch/backends/samsung/test/ops/test_rsqrt.py +46 -0
  1429. executorch/backends/samsung/test/ops/test_select.py +52 -0
  1430. executorch/backends/samsung/test/ops/test_slice_copy.py +46 -0
  1431. executorch/backends/samsung/test/ops/test_softmax.py +46 -0
  1432. executorch/backends/samsung/test/ops/test_sqrt.py +46 -0
  1433. executorch/backends/samsung/test/ops/test_squeeze.py +47 -0
  1434. executorch/backends/samsung/test/ops/test_sub.py +63 -0
  1435. executorch/backends/samsung/test/ops/test_to_copy.py +49 -0
  1436. executorch/backends/samsung/test/ops/test_unsqueeze.py +47 -0
  1437. executorch/backends/samsung/test/ops/test_upsample_bilinear2d.py +54 -0
  1438. executorch/backends/samsung/test/ops/test_upsample_nearest2d.py +53 -0
  1439. executorch/backends/samsung/test/tester/__init__.py +11 -0
  1440. executorch/backends/samsung/test/tester/samsung_tester.py +125 -0
  1441. executorch/backends/samsung/test/utils/__init__.py +11 -0
  1442. executorch/backends/samsung/test/utils/runtime_executor.py +186 -0
  1443. executorch/backends/samsung/utils/constants.py +45 -0
  1444. executorch/backends/samsung/utils/export_utils.py +93 -0
  1445. executorch/backends/samsung/utils/utils.py +125 -0
  1446. executorch/backends/test/facto/__init__.py +0 -0
  1447. executorch/backends/test/facto/facto_specs.py +59 -0
  1448. executorch/backends/test/facto/test_facto.py +301 -0
  1449. executorch/backends/test/harness/__init__.py +3 -0
  1450. executorch/backends/test/harness/error_statistics.py +99 -0
  1451. executorch/backends/test/harness/stages/__init__.py +23 -0
  1452. executorch/backends/test/harness/stages/export.py +32 -0
  1453. executorch/backends/test/harness/stages/partition.py +26 -0
  1454. executorch/backends/test/harness/stages/quantize.py +128 -0
  1455. executorch/backends/test/harness/stages/run_passes.py +66 -0
  1456. executorch/backends/test/harness/stages/serialize.py +59 -0
  1457. executorch/backends/test/harness/stages/stage.py +91 -0
  1458. executorch/backends/test/harness/stages/to_edge.py +27 -0
  1459. executorch/backends/test/harness/stages/to_edge_transform_and_lower.py +50 -0
  1460. executorch/backends/test/harness/stages/to_executorch.py +54 -0
  1461. executorch/backends/test/harness/tester.py +478 -0
  1462. executorch/backends/test/harness/tests/test_error_statistics.py +67 -0
  1463. executorch/backends/test/suite/__init__.py +74 -0
  1464. executorch/backends/test/suite/conftest.py +182 -0
  1465. executorch/backends/test/suite/context.py +34 -0
  1466. executorch/backends/test/suite/discovery.py +100 -0
  1467. executorch/backends/test/suite/flow.py +150 -0
  1468. executorch/backends/test/suite/flows/__init__.py +7 -0
  1469. executorch/backends/test/suite/flows/arm.py +92 -0
  1470. executorch/backends/test/suite/flows/coreml.py +31 -0
  1471. executorch/backends/test/suite/flows/portable.py +19 -0
  1472. executorch/backends/test/suite/flows/qualcomm.py +61 -0
  1473. executorch/backends/test/suite/flows/vulkan.py +44 -0
  1474. executorch/backends/test/suite/flows/xnnpack.py +79 -0
  1475. executorch/backends/test/suite/generate_markdown_summary.py +249 -0
  1476. executorch/backends/test/suite/generate_markdown_summary_json.py +229 -0
  1477. executorch/backends/test/suite/models/__init__.py +7 -0
  1478. executorch/backends/test/suite/models/test_torchaudio.py +110 -0
  1479. executorch/backends/test/suite/models/test_torchvision.py +194 -0
  1480. executorch/backends/test/suite/operators/__init__.py +108 -0
  1481. executorch/backends/test/suite/operators/test_abs.py +60 -0
  1482. executorch/backends/test/suite/operators/test_adaptive_avgpool1d.py +102 -0
  1483. executorch/backends/test/suite/operators/test_adaptive_avgpool2d.py +112 -0
  1484. executorch/backends/test/suite/operators/test_adaptive_avgpool3d.py +112 -0
  1485. executorch/backends/test/suite/operators/test_adaptive_maxpool1d.py +125 -0
  1486. executorch/backends/test/suite/operators/test_adaptive_maxpool2d.py +135 -0
  1487. executorch/backends/test/suite/operators/test_adaptive_maxpool3d.py +135 -0
  1488. executorch/backends/test/suite/operators/test_add.py +76 -0
  1489. executorch/backends/test/suite/operators/test_amax.py +257 -0
  1490. executorch/backends/test/suite/operators/test_amin.py +259 -0
  1491. executorch/backends/test/suite/operators/test_argmax.py +201 -0
  1492. executorch/backends/test/suite/operators/test_argmin.py +201 -0
  1493. executorch/backends/test/suite/operators/test_avgpool1d.py +155 -0
  1494. executorch/backends/test/suite/operators/test_avgpool2d.py +168 -0
  1495. executorch/backends/test/suite/operators/test_avgpool3d.py +163 -0
  1496. executorch/backends/test/suite/operators/test_cat.py +176 -0
  1497. executorch/backends/test/suite/operators/test_ceil.py +60 -0
  1498. executorch/backends/test/suite/operators/test_clamp.py +86 -0
  1499. executorch/backends/test/suite/operators/test_conv1d.py +144 -0
  1500. executorch/backends/test/suite/operators/test_conv2d.py +167 -0
  1501. executorch/backends/test/suite/operators/test_conv3d.py +162 -0
  1502. executorch/backends/test/suite/operators/test_convtranspose1d.py +144 -0
  1503. executorch/backends/test/suite/operators/test_convtranspose2d.py +171 -0
  1504. executorch/backends/test/suite/operators/test_convtranspose3d.py +166 -0
  1505. executorch/backends/test/suite/operators/test_div.py +110 -0
  1506. executorch/backends/test/suite/operators/test_elu.py +49 -0
  1507. executorch/backends/test/suite/operators/test_embedding.py +89 -0
  1508. executorch/backends/test/suite/operators/test_embedding_bag.py +118 -0
  1509. executorch/backends/test/suite/operators/test_exp.py +65 -0
  1510. executorch/backends/test/suite/operators/test_expand.py +122 -0
  1511. executorch/backends/test/suite/operators/test_floor.py +57 -0
  1512. executorch/backends/test/suite/operators/test_floor_divide.py +216 -0
  1513. executorch/backends/test/suite/operators/test_gelu.py +52 -0
  1514. executorch/backends/test/suite/operators/test_glu.py +52 -0
  1515. executorch/backends/test/suite/operators/test_hardsigmoid.py +50 -0
  1516. executorch/backends/test/suite/operators/test_hardswish.py +50 -0
  1517. executorch/backends/test/suite/operators/test_hardtanh.py +57 -0
  1518. executorch/backends/test/suite/operators/test_index_put.py +455 -0
  1519. executorch/backends/test/suite/operators/test_index_select.py +128 -0
  1520. executorch/backends/test/suite/operators/test_leaky_relu.py +56 -0
  1521. executorch/backends/test/suite/operators/test_linear.py +124 -0
  1522. executorch/backends/test/suite/operators/test_log.py +80 -0
  1523. executorch/backends/test/suite/operators/test_log10.py +60 -0
  1524. executorch/backends/test/suite/operators/test_log1p.py +60 -0
  1525. executorch/backends/test/suite/operators/test_log2.py +60 -0
  1526. executorch/backends/test/suite/operators/test_logsigmoid.py +40 -0
  1527. executorch/backends/test/suite/operators/test_lstm.py +247 -0
  1528. executorch/backends/test/suite/operators/test_masked_fill.py +101 -0
  1529. executorch/backends/test/suite/operators/test_maxpool1d.py +185 -0
  1530. executorch/backends/test/suite/operators/test_maxpool2d.py +191 -0
  1531. executorch/backends/test/suite/operators/test_maxpool3d.py +189 -0
  1532. executorch/backends/test/suite/operators/test_mean.py +305 -0
  1533. executorch/backends/test/suite/operators/test_median.py +188 -0
  1534. executorch/backends/test/suite/operators/test_mul.py +66 -0
  1535. executorch/backends/test/suite/operators/test_neg.py +70 -0
  1536. executorch/backends/test/suite/operators/test_permute.py +109 -0
  1537. executorch/backends/test/suite/operators/test_pow.py +149 -0
  1538. executorch/backends/test/suite/operators/test_prelu.py +55 -0
  1539. executorch/backends/test/suite/operators/test_relu.py +45 -0
  1540. executorch/backends/test/suite/operators/test_reshape.py +82 -0
  1541. executorch/backends/test/suite/operators/test_round.py +129 -0
  1542. executorch/backends/test/suite/operators/test_rsqrt.py +76 -0
  1543. executorch/backends/test/suite/operators/test_select.py +89 -0
  1544. executorch/backends/test/suite/operators/test_sigmoid.py +40 -0
  1545. executorch/backends/test/suite/operators/test_silu.py +50 -0
  1546. executorch/backends/test/suite/operators/test_slice.py +146 -0
  1547. executorch/backends/test/suite/operators/test_split.py +119 -0
  1548. executorch/backends/test/suite/operators/test_sqrt.py +71 -0
  1549. executorch/backends/test/suite/operators/test_square.py +67 -0
  1550. executorch/backends/test/suite/operators/test_squeeze.py +86 -0
  1551. executorch/backends/test/suite/operators/test_stack.py +114 -0
  1552. executorch/backends/test/suite/operators/test_sub.py +84 -0
  1553. executorch/backends/test/suite/operators/test_tanh.py +40 -0
  1554. executorch/backends/test/suite/operators/test_threshold.py +71 -0
  1555. executorch/backends/test/suite/operators/test_transpose.py +143 -0
  1556. executorch/backends/test/suite/operators/test_trunc.py +73 -0
  1557. executorch/backends/test/suite/operators/test_unsqueeze.py +110 -0
  1558. executorch/backends/test/suite/operators/test_upsample_bilinear2d.py +273 -0
  1559. executorch/backends/test/suite/operators/test_upsample_nearest2d.py +137 -0
  1560. executorch/backends/test/suite/operators/test_view.py +82 -0
  1561. executorch/backends/test/suite/reporting.py +421 -0
  1562. executorch/backends/test/suite/runner.py +328 -0
  1563. executorch/backends/test/suite/tests/__init__.py +0 -0
  1564. executorch/backends/test/suite/tests/test_reporting.py +144 -0
  1565. executorch/backends/transforms/__init__.py +12 -0
  1566. executorch/backends/transforms/addmm_mm_to_linear.py +170 -0
  1567. executorch/backends/transforms/convert_dtype_pass.py +103 -0
  1568. executorch/backends/transforms/decompose_sdpa.py +120 -0
  1569. executorch/backends/transforms/duplicate_dynamic_quant_chain.py +195 -0
  1570. executorch/backends/transforms/fuse_batch_norm_with_conv.py +161 -0
  1571. executorch/backends/transforms/fuse_conv_with_clamp.py +77 -0
  1572. executorch/backends/transforms/fuse_view_copy.py +116 -0
  1573. executorch/backends/transforms/mean_to_sum_div.py +41 -0
  1574. executorch/backends/transforms/rank_0_to_rank_1.py +18 -0
  1575. executorch/backends/transforms/remove_clone_ops.py +109 -0
  1576. executorch/backends/transforms/remove_getitem_op.py +109 -0
  1577. executorch/backends/transforms/replace_scalar_with_tensor.py +93 -0
  1578. executorch/backends/transforms/test/test_create_delete_constant_placeholder.py +122 -0
  1579. executorch/backends/transforms/test/test_create_mutable_buffer.py +503 -0
  1580. executorch/backends/transforms/test/test_duplicate_dynamic_quant_chain.py +184 -0
  1581. executorch/backends/transforms/test/test_rank_0_to_rank_1.py +32 -0
  1582. executorch/backends/transforms/test/test_remove_clone_ops.py +197 -0
  1583. executorch/backends/transforms/utils.py +377 -0
  1584. executorch/backends/transforms/view_copy_to_squeeze_unsqueeze.py +135 -0
  1585. executorch/backends/vulkan/__init__.py +14 -0
  1586. executorch/backends/vulkan/_passes/__init__.py +37 -0
  1587. executorch/backends/vulkan/_passes/fold_qdq.py +40 -0
  1588. executorch/backends/vulkan/_passes/fuse_patterns.py +34 -0
  1589. executorch/backends/vulkan/_passes/fuse_quantized_ops.py +236 -0
  1590. executorch/backends/vulkan/_passes/insert_prepack_nodes.py +83 -0
  1591. executorch/backends/vulkan/_passes/remove_asserts.py +52 -0
  1592. executorch/backends/vulkan/_passes/remove_redundant_ops.py +72 -0
  1593. executorch/backends/vulkan/_passes/squeeze_unsqueeze_inputs.py +93 -0
  1594. executorch/backends/vulkan/_passes/tag_memory_meta_pass.py +485 -0
  1595. executorch/backends/vulkan/custom_ops_lib.py +597 -0
  1596. executorch/backends/vulkan/op_registry.py +885 -0
  1597. executorch/backends/vulkan/partitioner/vulkan_partitioner.py +401 -0
  1598. executorch/backends/vulkan/patterns/__init__.py +139 -0
  1599. executorch/backends/vulkan/patterns/pattern_registry.py +116 -0
  1600. executorch/backends/vulkan/patterns/quantized_binary.py +161 -0
  1601. executorch/backends/vulkan/patterns/quantized_convolution.py +260 -0
  1602. executorch/backends/vulkan/patterns/quantized_linear.py +500 -0
  1603. executorch/backends/vulkan/patterns/rope.py +173 -0
  1604. executorch/backends/vulkan/patterns/sdpa.py +155 -0
  1605. executorch/backends/vulkan/patterns/select_as_symint.py +104 -0
  1606. executorch/backends/vulkan/quantizer/vulkan_quantizer.py +183 -0
  1607. executorch/backends/vulkan/quantizer/vulkan_quantizer_utils.py +223 -0
  1608. executorch/backends/vulkan/runtime/gen_vulkan_spv.py +1517 -0
  1609. executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_naive_buffer.yaml +19 -0
  1610. executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_naive_texture3d.yaml +24 -0
  1611. executorch/backends/vulkan/runtime/graph/ops/glsl/addmm_optimized.yaml +43 -0
  1612. executorch/backends/vulkan/runtime/graph/ops/glsl/arange.yaml +19 -0
  1613. executorch/backends/vulkan/runtime/graph/ops/glsl/avg_pool2d.yaml +18 -0
  1614. executorch/backends/vulkan/runtime/graph/ops/glsl/batchnorm.yaml +11 -0
  1615. executorch/backends/vulkan/runtime/graph/ops/glsl/binary_op.yaml +118 -0
  1616. executorch/backends/vulkan/runtime/graph/ops/glsl/binary_q8ta_q8ta_q8to.yaml +19 -0
  1617. executorch/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_buffer.yaml +20 -0
  1618. executorch/backends/vulkan/runtime/graph/ops/glsl/binary_scalar_texture.yaml +20 -0
  1619. executorch/backends/vulkan/runtime/graph/ops/glsl/bitw8_image_to_nchw_nobitw8buffer.yaml +22 -0
  1620. executorch/backends/vulkan/runtime/graph/ops/glsl/buffer_to_buffer.yaml +20 -0
  1621. executorch/backends/vulkan/runtime/graph/ops/glsl/buffer_to_nchw.yaml +25 -0
  1622. executorch/backends/vulkan/runtime/graph/ops/glsl/choose_qparams_per_row.yaml +19 -0
  1623. executorch/backends/vulkan/runtime/graph/ops/glsl/clone.yaml +13 -0
  1624. executorch/backends/vulkan/runtime/graph/ops/glsl/col2im.yaml +19 -0
  1625. executorch/backends/vulkan/runtime/graph/ops/glsl/concat_buffer.yaml +15 -0
  1626. executorch/backends/vulkan/runtime/graph/ops/glsl/concat_texture.yaml +15 -0
  1627. executorch/backends/vulkan/runtime/graph/ops/glsl/conv1d.yaml +19 -0
  1628. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d.yaml +19 -0
  1629. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw.yaml +19 -0
  1630. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_output_tile.yaml +27 -0
  1631. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_prepack_weights.yaml +15 -0
  1632. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_q8ta_q8csw_q8to.yaml +20 -0
  1633. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_sned_output_tile.yaml +25 -0
  1634. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_prepack_weights.yaml +15 -0
  1635. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw.yaml +21 -0
  1636. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_q8ta_q8csw_q8to_tiled.yaml +20 -0
  1637. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_s1p0.yaml +19 -0
  1638. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8csw_linear_tiled.yaml +22 -0
  1639. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_linear_tiled.yaml +22 -0
  1640. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_q8to.yaml +21 -0
  1641. executorch/backends/vulkan/runtime/graph/ops/glsl/conv2d_q8ta_q8csw_q8to_linear_tiled.yaml +21 -0
  1642. executorch/backends/vulkan/runtime/graph/ops/glsl/conv_transpose2d.yaml +19 -0
  1643. executorch/backends/vulkan/runtime/graph/ops/glsl/conv_transpose2d_prepack_weights.yaml +16 -0
  1644. executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_buffer.yaml +16 -0
  1645. executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_legacy.yaml +12 -0
  1646. executorch/backends/vulkan/runtime/graph/ops/glsl/embedding_texture.yaml +15 -0
  1647. executorch/backends/vulkan/runtime/graph/ops/glsl/expand_buffer.yaml +11 -0
  1648. executorch/backends/vulkan/runtime/graph/ops/glsl/flip.yaml +14 -0
  1649. executorch/backends/vulkan/runtime/graph/ops/glsl/full.yaml +20 -0
  1650. executorch/backends/vulkan/runtime/graph/ops/glsl/gather_buffer.yaml +18 -0
  1651. executorch/backends/vulkan/runtime/graph/ops/glsl/gather_texture.yaml +17 -0
  1652. executorch/backends/vulkan/runtime/graph/ops/glsl/grid_priors.yaml +12 -0
  1653. executorch/backends/vulkan/runtime/graph/ops/glsl/group_norm_reduce_texture.yaml +15 -0
  1654. executorch/backends/vulkan/runtime/graph/ops/glsl/group_norm_texture.yaml +15 -0
  1655. executorch/backends/vulkan/runtime/graph/ops/glsl/im2col.yaml +18 -0
  1656. executorch/backends/vulkan/runtime/graph/ops/glsl/im2col_packed_int8.yaml +15 -0
  1657. executorch/backends/vulkan/runtime/graph/ops/glsl/image_to_nchw.yaml +38 -0
  1658. executorch/backends/vulkan/runtime/graph/ops/glsl/index_select.yaml +13 -0
  1659. executorch/backends/vulkan/runtime/graph/ops/glsl/index_select_channel.yaml +13 -0
  1660. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_dq8ca_q4gsw_tiled.yaml +29 -0
  1661. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q4gsw_coop.yaml +43 -0
  1662. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q4gsw_tiled.yaml +28 -0
  1663. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q8csw_tiled.yaml +28 -0
  1664. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_q8ta_q8csw_tiled.yaml +24 -0
  1665. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw.yaml +23 -0
  1666. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw_coop.yaml +38 -0
  1667. executorch/backends/vulkan/runtime/graph/ops/glsl/linear_qcsnw_tiled.yaml +54 -0
  1668. executorch/backends/vulkan/runtime/graph/ops/glsl/max_pool2d.yaml +17 -0
  1669. executorch/backends/vulkan/runtime/graph/ops/glsl/native_layer_norm.yaml +16 -0
  1670. executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_bitw8_image_nobitw8buffer.yaml +22 -0
  1671. executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_buffer.yaml +25 -0
  1672. executorch/backends/vulkan/runtime/graph/ops/glsl/nchw_to_image.yaml +37 -0
  1673. executorch/backends/vulkan/runtime/graph/ops/glsl/no_op.yaml +24 -0
  1674. executorch/backends/vulkan/runtime/graph/ops/glsl/pack_int4_linear_weight_transposed_interleaved.yaml +19 -0
  1675. executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q4_linear_weight.yaml +14 -0
  1676. executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_conv2d_dw_weights.yaml +15 -0
  1677. executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_conv2d_weights.yaml +15 -0
  1678. executorch/backends/vulkan/runtime/graph/ops/glsl/pack_q8_linear_weight.yaml +14 -0
  1679. executorch/backends/vulkan/runtime/graph/ops/glsl/pad_channel.yaml +14 -0
  1680. executorch/backends/vulkan/runtime/graph/ops/glsl/pad_height_width.yaml +14 -0
  1681. executorch/backends/vulkan/runtime/graph/ops/glsl/permute_buffer.yaml +11 -0
  1682. executorch/backends/vulkan/runtime/graph/ops/glsl/permute_texture.yaml +11 -0
  1683. executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4h4w.yaml +25 -0
  1684. executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4h4w_with_group_sums.yaml +30 -0
  1685. executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_4w4c.yaml +23 -0
  1686. executorch/backends/vulkan/runtime/graph/ops/glsl/quantize_and_pack_im2col.yaml +18 -0
  1687. executorch/backends/vulkan/runtime/graph/ops/glsl/reduce.yaml +29 -0
  1688. executorch/backends/vulkan/runtime/graph/ops/glsl/reduce2d.yaml +29 -0
  1689. executorch/backends/vulkan/runtime/graph/ops/glsl/reduce_per_row_buffer.yaml +42 -0
  1690. executorch/backends/vulkan/runtime/graph/ops/glsl/repeat.yaml +14 -0
  1691. executorch/backends/vulkan/runtime/graph/ops/glsl/repeat_channel.yaml +12 -0
  1692. executorch/backends/vulkan/runtime/graph/ops/glsl/repeat_interleave.yaml +12 -0
  1693. executorch/backends/vulkan/runtime/graph/ops/glsl/rotary_embedding.yaml +13 -0
  1694. executorch/backends/vulkan/runtime/graph/ops/glsl/scalar_tensor.yaml +27 -0
  1695. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_attn_weights_softmax.yaml +19 -0
  1696. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_attn_weights_coop.yaml +25 -0
  1697. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_attn_weights_tiled.yaml +26 -0
  1698. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_out_coop.yaml +25 -0
  1699. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_compute_out_tiled.yaml +26 -0
  1700. executorch/backends/vulkan/runtime/graph/ops/glsl/sdpa_kv_cache_update.yaml +23 -0
  1701. executorch/backends/vulkan/runtime/graph/ops/glsl/set_zero.yaml +8 -0
  1702. executorch/backends/vulkan/runtime/graph/ops/glsl/softmax.yaml +21 -0
  1703. executorch/backends/vulkan/runtime/graph/ops/glsl/split_buffer.yaml +18 -0
  1704. executorch/backends/vulkan/runtime/graph/ops/glsl/split_texture.yaml +17 -0
  1705. executorch/backends/vulkan/runtime/graph/ops/glsl/tan.yaml +13 -0
  1706. executorch/backends/vulkan/runtime/graph/ops/glsl/transfer_buffer.yaml +22 -0
  1707. executorch/backends/vulkan/runtime/graph/ops/glsl/transfer_texture.yaml +22 -0
  1708. executorch/backends/vulkan/runtime/graph/ops/glsl/unary_op.yaml +48 -0
  1709. executorch/backends/vulkan/runtime/graph/ops/glsl/unpack_4w4c_and_dequantize.yaml +23 -0
  1710. executorch/backends/vulkan/runtime/graph/ops/glsl/update_concat_offset.yaml +13 -0
  1711. executorch/backends/vulkan/runtime/graph/ops/glsl/upsample_2d.yaml +19 -0
  1712. executorch/backends/vulkan/runtime/graph/ops/glsl/var_buffer.yaml +16 -0
  1713. executorch/backends/vulkan/runtime/graph/ops/glsl/var_texture3d.yaml +16 -0
  1714. executorch/backends/vulkan/runtime/graph/ops/glsl/view.yaml +13 -0
  1715. executorch/backends/vulkan/runtime/graph/ops/glsl/view_buffer.yaml +20 -0
  1716. executorch/backends/vulkan/runtime/graph/ops/glsl/view_convert_buffer.yaml +22 -0
  1717. executorch/backends/vulkan/runtime/graph/ops/glsl/where.yaml +12 -0
  1718. executorch/backends/vulkan/serialization/schema.fbs +158 -0
  1719. executorch/backends/vulkan/serialization/vulkan_graph_builder.py +505 -0
  1720. executorch/backends/vulkan/serialization/vulkan_graph_schema.py +161 -0
  1721. executorch/backends/vulkan/serialization/vulkan_graph_serialize.py +274 -0
  1722. executorch/backends/vulkan/test/custom_ops/glsl/add.yaml +29 -0
  1723. executorch/backends/vulkan/test/glsl/all_shaders.yaml +68 -0
  1724. executorch/backends/vulkan/test/glsl/dynamic_dispatch_test.yaml +7 -0
  1725. executorch/backends/vulkan/test/glsl/reference_matmul_common.yaml +9 -0
  1726. executorch/backends/vulkan/test/op_tests/cases.py +2026 -0
  1727. executorch/backends/vulkan/test/op_tests/generate_op_benchmarks.py +88 -0
  1728. executorch/backends/vulkan/test/op_tests/generate_op_correctness_tests.py +90 -0
  1729. executorch/backends/vulkan/test/op_tests/utils/aten_types.py +31 -0
  1730. executorch/backends/vulkan/test/op_tests/utils/gen_benchmark_vk.py +350 -0
  1731. executorch/backends/vulkan/test/op_tests/utils/gen_computegraph.py +788 -0
  1732. executorch/backends/vulkan/test/op_tests/utils/gen_correctness_base.py +421 -0
  1733. executorch/backends/vulkan/test/op_tests/utils/gen_correctness_vk.py +164 -0
  1734. executorch/backends/vulkan/test/op_tests/utils/test_suite.py +53 -0
  1735. executorch/backends/vulkan/test/test_serialization.py +135 -0
  1736. executorch/backends/vulkan/test/test_vulkan_delegate.py +2696 -0
  1737. executorch/backends/vulkan/test/test_vulkan_delegate_header.py +104 -0
  1738. executorch/backends/vulkan/test/test_vulkan_passes.py +193 -0
  1739. executorch/backends/vulkan/test/tester.py +91 -0
  1740. executorch/backends/vulkan/test/utils.py +1111 -0
  1741. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/apiconventions.py +21 -0
  1742. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/base_generator.py +937 -0
  1743. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/cgenerator.py +549 -0
  1744. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/generator.py +1424 -0
  1745. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/parse_dependency.py +404 -0
  1746. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/reg.py +1885 -0
  1747. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/conventions.py +562 -0
  1748. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/spec_tools/util.py +58 -0
  1749. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/stripAPI.py +42 -0
  1750. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vkconventions.py +314 -0
  1751. executorch/backends/vulkan/third-party/Vulkan-Headers/registry/vulkan_object.py +484 -0
  1752. executorch/backends/vulkan/third-party/VulkanMemoryAllocator/tools/GpuMemDumpVis/GpuMemDumpVis.py +333 -0
  1753. executorch/backends/vulkan/third-party/volk/generate.py +212 -0
  1754. executorch/backends/vulkan/tools/gpuinfo/glsl/buf_bandwidth.yaml +18 -0
  1755. executorch/backends/vulkan/tools/gpuinfo/glsl/buf_cacheline_size.yaml +12 -0
  1756. executorch/backends/vulkan/tools/gpuinfo/glsl/reg_count.yaml +16 -0
  1757. executorch/backends/vulkan/tools/gpuinfo/glsl/tex_bandwidth.yaml +15 -0
  1758. executorch/backends/vulkan/tools/gpuinfo/glsl/tex_cacheline_concurr.yaml +14 -0
  1759. executorch/backends/vulkan/tools/gpuinfo/glsl/warp_size.yaml +16 -0
  1760. executorch/backends/vulkan/utils.py +1474 -0
  1761. executorch/backends/vulkan/vulkan_preprocess.py +249 -0
  1762. executorch/backends/xnnpack/__init__.py +34 -0
  1763. executorch/backends/xnnpack/_passes/__init__.py +109 -0
  1764. executorch/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py +561 -0
  1765. executorch/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py +203 -0
  1766. executorch/backends/xnnpack/_passes/convert_to_linear.py +198 -0
  1767. executorch/backends/xnnpack/_passes/convert_to_sdpa.py +114 -0
  1768. executorch/backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py +65 -0
  1769. executorch/backends/xnnpack/_passes/decompose_cat.py +105 -0
  1770. executorch/backends/xnnpack/_passes/fuse_activation_pass.py +87 -0
  1771. executorch/backends/xnnpack/_passes/fuse_batch_norm.py +261 -0
  1772. executorch/backends/xnnpack/_passes/prelu_reshape_pass.py +75 -0
  1773. executorch/backends/xnnpack/_passes/propagate_custom_meta_pass.py +44 -0
  1774. executorch/backends/xnnpack/_passes/remove_redundant_copy_pass.py +158 -0
  1775. executorch/backends/xnnpack/_passes/xnnpack_pass.py +22 -0
  1776. executorch/backends/xnnpack/operators/__init__.py +61 -0
  1777. executorch/backends/xnnpack/operators/node_visitor.py +758 -0
  1778. executorch/backends/xnnpack/operators/op_abs.py +52 -0
  1779. executorch/backends/xnnpack/operators/op_add.py +77 -0
  1780. executorch/backends/xnnpack/operators/op_addmm.py +70 -0
  1781. executorch/backends/xnnpack/operators/op_avg_pooling2d.py +75 -0
  1782. executorch/backends/xnnpack/operators/op_bmm.py +54 -0
  1783. executorch/backends/xnnpack/operators/op_cat.py +121 -0
  1784. executorch/backends/xnnpack/operators/op_ceiling.py +52 -0
  1785. executorch/backends/xnnpack/operators/op_clamp.py +64 -0
  1786. executorch/backends/xnnpack/operators/op_clone.py +60 -0
  1787. executorch/backends/xnnpack/operators/op_conv2d.py +186 -0
  1788. executorch/backends/xnnpack/operators/op_cos.py +52 -0
  1789. executorch/backends/xnnpack/operators/op_div.py +56 -0
  1790. executorch/backends/xnnpack/operators/op_dynamic_dequantize_ops.py +114 -0
  1791. executorch/backends/xnnpack/operators/op_dynamic_quantize_ops.py +179 -0
  1792. executorch/backends/xnnpack/operators/op_elu.py +56 -0
  1793. executorch/backends/xnnpack/operators/op_exp.py +52 -0
  1794. executorch/backends/xnnpack/operators/op_floor.py +48 -0
  1795. executorch/backends/xnnpack/operators/op_gelu.py +52 -0
  1796. executorch/backends/xnnpack/operators/op_hardswish.py +52 -0
  1797. executorch/backends/xnnpack/operators/op_hardtanh.py +67 -0
  1798. executorch/backends/xnnpack/operators/op_leaky_relu.py +65 -0
  1799. executorch/backends/xnnpack/operators/op_linear.py +110 -0
  1800. executorch/backends/xnnpack/operators/op_log.py +52 -0
  1801. executorch/backends/xnnpack/operators/op_matrix_multiplication.py +66 -0
  1802. executorch/backends/xnnpack/operators/op_max_dim.py +206 -0
  1803. executorch/backends/xnnpack/operators/op_max_pool2d.py +136 -0
  1804. executorch/backends/xnnpack/operators/op_maximum.py +55 -0
  1805. executorch/backends/xnnpack/operators/op_mean_dim.py +78 -0
  1806. executorch/backends/xnnpack/operators/op_minimum.py +54 -0
  1807. executorch/backends/xnnpack/operators/op_multiply.py +84 -0
  1808. executorch/backends/xnnpack/operators/op_negate.py +51 -0
  1809. executorch/backends/xnnpack/operators/op_permute.py +87 -0
  1810. executorch/backends/xnnpack/operators/op_prelu.py +56 -0
  1811. executorch/backends/xnnpack/operators/op_quant_dequant.py +196 -0
  1812. executorch/backends/xnnpack/operators/op_relu.py +61 -0
  1813. executorch/backends/xnnpack/operators/op_rsqrt.py +52 -0
  1814. executorch/backends/xnnpack/operators/op_sigmoid.py +48 -0
  1815. executorch/backends/xnnpack/operators/op_sin.py +52 -0
  1816. executorch/backends/xnnpack/operators/op_skip_ops.py +89 -0
  1817. executorch/backends/xnnpack/operators/op_slice_copy.py +100 -0
  1818. executorch/backends/xnnpack/operators/op_softmax.py +58 -0
  1819. executorch/backends/xnnpack/operators/op_square.py +52 -0
  1820. executorch/backends/xnnpack/operators/op_square_root.py +52 -0
  1821. executorch/backends/xnnpack/operators/op_squeeze.py +145 -0
  1822. executorch/backends/xnnpack/operators/op_static_constant_pad.py +145 -0
  1823. executorch/backends/xnnpack/operators/op_static_resize_bilinear_2d.py +61 -0
  1824. executorch/backends/xnnpack/operators/op_sub.py +77 -0
  1825. executorch/backends/xnnpack/operators/op_tanh.py +52 -0
  1826. executorch/backends/xnnpack/operators/op_to_copy.py +91 -0
  1827. executorch/backends/xnnpack/operators/op_view_copy.py +96 -0
  1828. executorch/backends/xnnpack/operators/quant_params.py +412 -0
  1829. executorch/backends/xnnpack/partition/config/__init__.py +127 -0
  1830. executorch/backends/xnnpack/partition/config/gemm_configs.py +575 -0
  1831. executorch/backends/xnnpack/partition/config/generic_node_configs.py +711 -0
  1832. executorch/backends/xnnpack/partition/config/node_configs.py +148 -0
  1833. executorch/backends/xnnpack/partition/config/quant_affine_configs.py +56 -0
  1834. executorch/backends/xnnpack/partition/config/xnnpack_config.py +252 -0
  1835. executorch/backends/xnnpack/partition/graphs/bilinear_2d.py +55 -0
  1836. executorch/backends/xnnpack/partition/graphs/sdpa.py +86 -0
  1837. executorch/backends/xnnpack/partition/xnnpack_partitioner.py +160 -0
  1838. executorch/backends/xnnpack/quantizer/xnnpack_quantizer.py +462 -0
  1839. executorch/backends/xnnpack/quantizer/xnnpack_quantizer_utils.py +1121 -0
  1840. executorch/backends/xnnpack/recipes/__init__.py +19 -0
  1841. executorch/backends/xnnpack/recipes/xnnpack_recipe_provider.py +200 -0
  1842. executorch/backends/xnnpack/recipes/xnnpack_recipe_types.py +37 -0
  1843. executorch/backends/xnnpack/serialization/runtime_schema.fbs +389 -0
  1844. executorch/backends/xnnpack/serialization/schema.fbs +381 -0
  1845. executorch/backends/xnnpack/serialization/xnnpack_graph_schema.py +542 -0
  1846. executorch/backends/xnnpack/serialization/xnnpack_graph_serialize.py +373 -0
  1847. executorch/backends/xnnpack/test/__init__.py +0 -0
  1848. executorch/backends/xnnpack/test/models/deeplab_v3.py +42 -0
  1849. executorch/backends/xnnpack/test/models/edsr.py +55 -0
  1850. executorch/backends/xnnpack/test/models/emformer_rnnt.py +98 -0
  1851. executorch/backends/xnnpack/test/models/inception_v3.py +84 -0
  1852. executorch/backends/xnnpack/test/models/inception_v4.py +62 -0
  1853. executorch/backends/xnnpack/test/models/llama2_et_example.py +49 -0
  1854. executorch/backends/xnnpack/test/models/mobilebert.py +55 -0
  1855. executorch/backends/xnnpack/test/models/mobilenet_v2.py +103 -0
  1856. executorch/backends/xnnpack/test/models/mobilenet_v3.py +84 -0
  1857. executorch/backends/xnnpack/test/models/resnet.py +90 -0
  1858. executorch/backends/xnnpack/test/models/torchvision_vit.py +105 -0
  1859. executorch/backends/xnnpack/test/models/very_big_model.py +45 -0
  1860. executorch/backends/xnnpack/test/models/w2l.py +60 -0
  1861. executorch/backends/xnnpack/test/ops/test_abs.py +87 -0
  1862. executorch/backends/xnnpack/test/ops/test_add.py +266 -0
  1863. executorch/backends/xnnpack/test/ops/test_avgpool2d.py +92 -0
  1864. executorch/backends/xnnpack/test/ops/test_bilinear2d.py +152 -0
  1865. executorch/backends/xnnpack/test/ops/test_bmm.py +49 -0
  1866. executorch/backends/xnnpack/test/ops/test_cat.py +254 -0
  1867. executorch/backends/xnnpack/test/ops/test_ceil.py +63 -0
  1868. executorch/backends/xnnpack/test/ops/test_check_quant_params.py +107 -0
  1869. executorch/backends/xnnpack/test/ops/test_clamp.py +79 -0
  1870. executorch/backends/xnnpack/test/ops/test_clone.py +137 -0
  1871. executorch/backends/xnnpack/test/ops/test_conv1d.py +190 -0
  1872. executorch/backends/xnnpack/test/ops/test_conv2d.py +747 -0
  1873. executorch/backends/xnnpack/test/ops/test_cos.py +87 -0
  1874. executorch/backends/xnnpack/test/ops/test_div.py +78 -0
  1875. executorch/backends/xnnpack/test/ops/test_elu.py +98 -0
  1876. executorch/backends/xnnpack/test/ops/test_exp.py +70 -0
  1877. executorch/backends/xnnpack/test/ops/test_floor.py +58 -0
  1878. executorch/backends/xnnpack/test/ops/test_gelu.py +71 -0
  1879. executorch/backends/xnnpack/test/ops/test_hardswish.py +70 -0
  1880. executorch/backends/xnnpack/test/ops/test_hardtanh.py +83 -0
  1881. executorch/backends/xnnpack/test/ops/test_leaky_relu.py +131 -0
  1882. executorch/backends/xnnpack/test/ops/test_linear.py +1059 -0
  1883. executorch/backends/xnnpack/test/ops/test_log.py +45 -0
  1884. executorch/backends/xnnpack/test/ops/test_lstm.py +67 -0
  1885. executorch/backends/xnnpack/test/ops/test_max_dim.py +66 -0
  1886. executorch/backends/xnnpack/test/ops/test_maximum.py +66 -0
  1887. executorch/backends/xnnpack/test/ops/test_maxpool2d.py +221 -0
  1888. executorch/backends/xnnpack/test/ops/test_mean_dim.py +98 -0
  1889. executorch/backends/xnnpack/test/ops/test_minimum.py +49 -0
  1890. executorch/backends/xnnpack/test/ops/test_multiply.py +149 -0
  1891. executorch/backends/xnnpack/test/ops/test_negate.py +58 -0
  1892. executorch/backends/xnnpack/test/ops/test_permute.py +134 -0
  1893. executorch/backends/xnnpack/test/ops/test_pow.py +62 -0
  1894. executorch/backends/xnnpack/test/ops/test_prelu.py +50 -0
  1895. executorch/backends/xnnpack/test/ops/test_quantize_per_tensor.py +70 -0
  1896. executorch/backends/xnnpack/test/ops/test_relu.py +38 -0
  1897. executorch/backends/xnnpack/test/ops/test_rsqrt.py +45 -0
  1898. executorch/backends/xnnpack/test/ops/test_sigmoid.py +45 -0
  1899. executorch/backends/xnnpack/test/ops/test_sin.py +87 -0
  1900. executorch/backends/xnnpack/test/ops/test_slice_copy.py +170 -0
  1901. executorch/backends/xnnpack/test/ops/test_softmax.py +73 -0
  1902. executorch/backends/xnnpack/test/ops/test_sqrt.py +45 -0
  1903. executorch/backends/xnnpack/test/ops/test_square.py +48 -0
  1904. executorch/backends/xnnpack/test/ops/test_static_constant_pad.py +294 -0
  1905. executorch/backends/xnnpack/test/ops/test_sub.py +178 -0
  1906. executorch/backends/xnnpack/test/ops/test_tanh.py +43 -0
  1907. executorch/backends/xnnpack/test/ops/test_to_copy.py +113 -0
  1908. executorch/backends/xnnpack/test/passes/__init__.py +0 -0
  1909. executorch/backends/xnnpack/test/passes/test_activation_fusion.py +232 -0
  1910. executorch/backends/xnnpack/test/passes/test_batch_norm_fusion.py +179 -0
  1911. executorch/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py +635 -0
  1912. executorch/backends/xnnpack/test/passes/test_convert_to_linear.py +43 -0
  1913. executorch/backends/xnnpack/test/passes/test_decompose_cat_pass.py +112 -0
  1914. executorch/backends/xnnpack/test/passes/test_propagate_custom_meta_pass.py +185 -0
  1915. executorch/backends/xnnpack/test/passes/test_remove_get_item_pass.py +99 -0
  1916. executorch/backends/xnnpack/test/passes/test_remove_redundant_copy_pass.py +182 -0
  1917. executorch/backends/xnnpack/test/quantizer/test_pt2e_quantization.py +818 -0
  1918. executorch/backends/xnnpack/test/quantizer/test_representation.py +308 -0
  1919. executorch/backends/xnnpack/test/quantizer/test_xnnpack_quantizer.py +1217 -0
  1920. executorch/backends/xnnpack/test/recipes/test_xnnpack_recipes.py +320 -0
  1921. executorch/backends/xnnpack/test/serialization/test_serialization.py +50 -0
  1922. executorch/backends/xnnpack/test/serialization/test_xnnheader.py +104 -0
  1923. executorch/backends/xnnpack/test/test_xnnpack_partitioner.py +163 -0
  1924. executorch/backends/xnnpack/test/test_xnnpack_utils.py +532 -0
  1925. executorch/backends/xnnpack/test/test_xnnpack_utils_classes.py +44 -0
  1926. executorch/backends/xnnpack/test/tester/__init__.py +29 -0
  1927. executorch/backends/xnnpack/test/tester/tester.py +130 -0
  1928. executorch/backends/xnnpack/third-party/FP16/configure.py +65 -0
  1929. executorch/backends/xnnpack/third-party/FP16/confu.yaml +8 -0
  1930. executorch/backends/xnnpack/third-party/FP16/include/fp16/__init__.py +0 -0
  1931. executorch/backends/xnnpack/third-party/FP16/include/fp16/avx.py +50 -0
  1932. executorch/backends/xnnpack/third-party/FP16/include/fp16/avx2.py +53 -0
  1933. executorch/backends/xnnpack/third-party/FP16/test/peachpy/stubs.py +38 -0
  1934. executorch/backends/xnnpack/third-party/FXdiv/configure.py +30 -0
  1935. executorch/backends/xnnpack/third-party/FXdiv/confu.yaml +6 -0
  1936. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/aarch32_template.py +361 -0
  1937. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/aarch64_template.py +347 -0
  1938. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/arm_template.py +78 -0
  1939. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512bf16_template.py +81 -0
  1940. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512f_template.py +390 -0
  1941. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/avx512vnni_template.py +703 -0
  1942. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/base_architecture.py +276 -0
  1943. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/fma3_template.py +260 -0
  1944. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate.py +71 -0
  1945. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_bf16_f32_gemm_microkernels.py +39 -0
  1946. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_f32_gemm_microkernels.py +104 -0
  1947. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_gemm_microkernels_main.py +29 -0
  1948. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qd8_f32_qc4w_gemm_microkernels.py +69 -0
  1949. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qd8_f32_qc8w_gemm_microkernels.py +93 -0
  1950. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qs8_qc4w_gemm_microkernels.py +42 -0
  1951. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/generate_qs8_qc8w_gemm_microkernels.py +43 -0
  1952. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neondot_template.py +463 -0
  1953. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neonfma_template.py +248 -0
  1954. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/neonmlal_aarch32_template.py +394 -0
  1955. executorch/backends/xnnpack/third-party/XNNPACK/gemm_compiler/x64_template.py +512 -0
  1956. executorch/backends/xnnpack/third-party/XNNPACK/scripts/check_config.py +152 -0
  1957. executorch/backends/xnnpack/third-party/XNNPACK/scripts/check_files_changed.py +53 -0
  1958. executorch/backends/xnnpack/third-party/XNNPACK/scripts/generate-build-identifier.py +106 -0
  1959. executorch/backends/xnnpack/third-party/XNNPACK/scripts/sort-filenames.py +134 -0
  1960. executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-f32-gemm-minmax.yaml +121 -0
  1961. executorch/backends/xnnpack/third-party/XNNPACK/test/bf16-gemm-minmax.yaml +106 -0
  1962. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-conv-hwc2chw.yaml +8 -0
  1963. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-dwconv2d-chw.yaml +88 -0
  1964. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-gemm-minmax.yaml +42 -0
  1965. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-f32acc-igemm-minmax.yaml +42 -0
  1966. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-gemm-minmax.yaml +219 -0
  1967. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear-chw.yaml +9 -0
  1968. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-ibilinear.yaml +12 -0
  1969. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-igemm-minmax.yaml +165 -0
  1970. executorch/backends/xnnpack/third-party/XNNPACK/test/f16-raddstoreexpminusmax.yaml +52 -0
  1971. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-argmaxpool.yaml +15 -0
  1972. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-conv-hwc2chw.yaml +32 -0
  1973. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-dwconv2d-chw.yaml +712 -0
  1974. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-minmax.yaml +1572 -0
  1975. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm-relu.yaml +123 -0
  1976. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-gemm.yaml +127 -0
  1977. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear-chw.yaml +22 -0
  1978. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ibilinear.yaml +23 -0
  1979. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-minmax.yaml +1001 -0
  1980. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm-relu.yaml +123 -0
  1981. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-igemm.yaml +123 -0
  1982. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-ppmm-minmax.yaml +122 -0
  1983. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc4w-gemm-minmax.yaml +277 -0
  1984. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-minmax.yaml +757 -0
  1985. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm-relu.yaml +67 -0
  1986. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-qc8w-gemm.yaml +115 -0
  1987. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddexpminusmax.yaml +38 -0
  1988. executorch/backends/xnnpack/third-party/XNNPACK/test/f32-raddstoreexpminusmax.yaml +88 -0
  1989. executorch/backends/xnnpack/third-party/XNNPACK/test/pf16-gemm-minmax.yaml +20 -0
  1990. executorch/backends/xnnpack/third-party/XNNPACK/test/pf32-gemm-minmax.yaml +34 -0
  1991. executorch/backends/xnnpack/third-party/XNNPACK/test/pqs8-qc8w-gemm-minmax.yaml +20 -0
  1992. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qb4w-gemm-minmax.yaml +260 -0
  1993. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc4w-gemm-minmax.yaml +678 -0
  1994. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-gemm-minmax.yaml +412 -0
  1995. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f16-qc8w-igemm-minmax.yaml +360 -0
  1996. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qb4w-gemm-minmax.yaml +537 -0
  1997. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc4w-gemm-minmax.yaml +2176 -0
  1998. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-gemm-minmax.yaml +1564 -0
  1999. executorch/backends/xnnpack/third-party/XNNPACK/test/qd8-f32-qc8w-igemm-minmax.yaml +1035 -0
  2000. executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qb4w-gemm-minmax.yaml +54 -0
  2001. executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qc4w-gemm-minmax.yaml +66 -0
  2002. executorch/backends/xnnpack/third-party/XNNPACK/test/qp8-f32-qc8w-gemm-minmax.yaml +42 -0
  2003. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc4w-gemm-minmax-fp32.yaml +345 -0
  2004. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-gemm-minmax-fp32.yaml +2029 -0
  2005. executorch/backends/xnnpack/third-party/XNNPACK/test/qs8-qc8w-igemm-minmax-fp32.yaml +1831 -0
  2006. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-fp32.yaml +584 -0
  2007. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-gemm-minmax-rndnu.yaml +148 -0
  2008. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-fp32.yaml +581 -0
  2009. executorch/backends/xnnpack/third-party/XNNPACK/test/qu8-igemm-minmax-rndnu.yaml +110 -0
  2010. executorch/backends/xnnpack/third-party/XNNPACK/test/s8-ibilinear.yaml +22 -0
  2011. executorch/backends/xnnpack/third-party/XNNPACK/test/u8-ibilinear.yaml +22 -0
  2012. executorch/backends/xnnpack/third-party/XNNPACK/test/x8-lut.yaml +47 -0
  2013. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-argmaxpool-test.py +692 -0
  2014. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc-test.py +543 -0
  2015. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-conv-hwc2chw-test.py +591 -0
  2016. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv-test.py +339 -0
  2017. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-dwconv2d-chw-test.py +463 -0
  2018. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-gemm-test.py +1150 -0
  2019. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-chw-test.py +236 -0
  2020. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-ibilinear-test.py +237 -0
  2021. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-lut-test.py +164 -0
  2022. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddexpminusmax-test.py +159 -0
  2023. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-raddstoreexpminusmax-test.py +210 -0
  2024. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-discontiguous-test.py +495 -0
  2025. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-reduce-test.py +289 -0
  2026. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-spmm-test.py +554 -0
  2027. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vbinary-test.py +179 -0
  2028. executorch/backends/xnnpack/third-party/XNNPACK/tools/generate-vunary-test.py +280 -0
  2029. executorch/backends/xnnpack/third-party/XNNPACK/tools/parse-microkernel-bench.py +189 -0
  2030. executorch/backends/xnnpack/third-party/XNNPACK/tools/primes.py +1015 -0
  2031. executorch/backends/xnnpack/third-party/XNNPACK/tools/update-microkernels.py +567 -0
  2032. executorch/backends/xnnpack/third-party/XNNPACK/tools/xngen.py +159 -0
  2033. executorch/backends/xnnpack/third-party/XNNPACK/tools/xnncommon.py +275 -0
  2034. executorch/backends/xnnpack/third-party/cpuinfo/configure.py +110 -0
  2035. executorch/backends/xnnpack/third-party/cpuinfo/confu.yaml +9 -0
  2036. executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/configure.py +26 -0
  2037. executorch/backends/xnnpack/third-party/cpuinfo/deps/clog/confu.yaml +5 -0
  2038. executorch/backends/xnnpack/third-party/cpuinfo/scripts/android-device-dump.py +400 -0
  2039. executorch/backends/xnnpack/third-party/cpuinfo/scripts/arm-linux-filesystem-dump.py +107 -0
  2040. executorch/backends/xnnpack/third-party/cpuinfo/scripts/parse-x86-cpuid-dump.py +47 -0
  2041. executorch/backends/xnnpack/third-party/generate-cpuinfo-wrappers.py +93 -0
  2042. executorch/backends/xnnpack/third-party/pthreadpool/configure.py +38 -0
  2043. executorch/backends/xnnpack/third-party/pthreadpool/confu.yaml +8 -0
  2044. executorch/backends/xnnpack/utils/configs.py +49 -0
  2045. executorch/backends/xnnpack/utils/quant_utils.py +301 -0
  2046. executorch/backends/xnnpack/utils/utils.py +221 -0
  2047. executorch/backends/xnnpack/utils/xnnpack_constants.py +37 -0
  2048. executorch/backends/xnnpack/xnnpack_preprocess.py +194 -0
  2049. executorch/codegen/__init__.py +0 -0
  2050. executorch/codegen/api/__init__.py +0 -0
  2051. executorch/codegen/api/custom_ops.py +151 -0
  2052. executorch/codegen/api/et_cpp.py +368 -0
  2053. executorch/codegen/api/types/__init__.py +5 -0
  2054. executorch/codegen/api/types/signatures.py +77 -0
  2055. executorch/codegen/api/types/types.py +77 -0
  2056. executorch/codegen/api/unboxing.py +232 -0
  2057. executorch/codegen/gen.py +1049 -0
  2058. executorch/codegen/model.py +220 -0
  2059. executorch/codegen/parse.py +158 -0
  2060. executorch/codegen/test/test_executorch_custom_ops.py +153 -0
  2061. executorch/codegen/test/test_executorch_gen.py +698 -0
  2062. executorch/codegen/test/test_executorch_signatures.py +65 -0
  2063. executorch/codegen/test/test_executorch_types.py +121 -0
  2064. executorch/codegen/test/test_executorch_unboxing.py +165 -0
  2065. executorch/codegen/test/test_selective_build.py +51 -0
  2066. executorch/codegen/tools/__init__.py +0 -0
  2067. executorch/codegen/tools/combine_prim_ops_headers.py +164 -0
  2068. executorch/codegen/tools/gen_all_oplist.py +252 -0
  2069. executorch/codegen/tools/gen_oplist.py +369 -0
  2070. executorch/codegen/tools/gen_ops_def.py +96 -0
  2071. executorch/codegen/tools/gen_selected_op_variants.py +133 -0
  2072. executorch/codegen/tools/gen_selected_prim_ops.py +96 -0
  2073. executorch/codegen/tools/merge_yaml.py +125 -0
  2074. executorch/codegen/tools/selective_build.cp313-win_amd64.pyd +0 -0
  2075. executorch/codegen/tools/selective_build.pyi +23 -0
  2076. executorch/codegen/tools/test/test_gen_all_oplist.py +122 -0
  2077. executorch/codegen/tools/test/test_gen_oplist.py +263 -0
  2078. executorch/codegen/tools/test/test_gen_oplist_real_model.py +50 -0
  2079. executorch/codegen/tools/test/test_gen_selected_op_variants.py +204 -0
  2080. executorch/codegen/tools/test/test_tools_selective_build.py +129 -0
  2081. executorch/codegen/tools/yaml_util.py +15 -0
  2082. executorch/data/bin/__init__.py +44 -0
  2083. executorch/data/bin/flatc.exe +0 -0
  2084. executorch/data/lib/aoti_cuda_shims.lib +0 -0
  2085. executorch/devtools/__init__.py +19 -0
  2086. executorch/devtools/backend_debug/__init__.py +13 -0
  2087. executorch/devtools/backend_debug/delegation_info.py +183 -0
  2088. executorch/devtools/backend_debug/tests/test_delegation_info.py +79 -0
  2089. executorch/devtools/bundled_program/config.py +120 -0
  2090. executorch/devtools/bundled_program/core.py +395 -0
  2091. executorch/devtools/bundled_program/schema/__init__.py +9 -0
  2092. executorch/devtools/bundled_program/schema/bundled_program_schema.fbs +97 -0
  2093. executorch/devtools/bundled_program/schema/bundled_program_schema.py +99 -0
  2094. executorch/devtools/bundled_program/schema/scalar_type.fbs +43 -0
  2095. executorch/devtools/bundled_program/schema/test/test_schema.py +27 -0
  2096. executorch/devtools/bundled_program/serialize/__init__.py +122 -0
  2097. executorch/devtools/bundled_program/serialize/bundled_program_schema.fbs +97 -0
  2098. executorch/devtools/bundled_program/serialize/scalar_type.fbs +43 -0
  2099. executorch/devtools/bundled_program/serialize/test/test_serialize.py +37 -0
  2100. executorch/devtools/bundled_program/test/test_bundle_data.py +168 -0
  2101. executorch/devtools/bundled_program/test/test_config.py +131 -0
  2102. executorch/devtools/bundled_program/test/test_end2end.py +64 -0
  2103. executorch/devtools/bundled_program/util/test_util.py +289 -0
  2104. executorch/devtools/bundled_program/version.py +13 -0
  2105. executorch/devtools/debug_format/base_schema.py +61 -0
  2106. executorch/devtools/debug_format/et_schema.py +432 -0
  2107. executorch/devtools/etdump/etdump_schema_flatcc.fbs +181 -0
  2108. executorch/devtools/etdump/scalar_type.fbs +43 -0
  2109. executorch/devtools/etdump/schema_flatcc.py +154 -0
  2110. executorch/devtools/etdump/serialize.py +108 -0
  2111. executorch/devtools/etdump/tests/serialize_test.py +142 -0
  2112. executorch/devtools/etrecord/__init__.py +13 -0
  2113. executorch/devtools/etrecord/_etrecord.py +776 -0
  2114. executorch/devtools/etrecord/tests/etrecord_test.py +1748 -0
  2115. executorch/devtools/inspector/__init__.py +24 -0
  2116. executorch/devtools/inspector/_inspector.py +1495 -0
  2117. executorch/devtools/inspector/_inspector_utils.py +1286 -0
  2118. executorch/devtools/inspector/_intermediate_output_capturer.py +62 -0
  2119. executorch/devtools/inspector/inspector_cli.py +76 -0
  2120. executorch/devtools/inspector/numerical_comparator/__init__.py +25 -0
  2121. executorch/devtools/inspector/numerical_comparator/l1_numerical_comparator.py +27 -0
  2122. executorch/devtools/inspector/numerical_comparator/mse_numerical_comparator.py +29 -0
  2123. executorch/devtools/inspector/numerical_comparator/numerical_comparator_base.py +26 -0
  2124. executorch/devtools/inspector/numerical_comparator/snr_numerical_comparator.py +39 -0
  2125. executorch/devtools/inspector/tests/event_blocks_test.py +657 -0
  2126. executorch/devtools/inspector/tests/inspector_test.py +1263 -0
  2127. executorch/devtools/inspector/tests/inspector_test_utils.py +189 -0
  2128. executorch/devtools/inspector/tests/inspector_utils_test.py +896 -0
  2129. executorch/devtools/inspector/tests/intermediate_output_capturer_test.py +101 -0
  2130. executorch/devtools/inspector/tests/l1_comparator_test.py +49 -0
  2131. executorch/devtools/inspector/tests/mse_comparator_test.py +49 -0
  2132. executorch/devtools/inspector/tests/snr_comparator_test.py +52 -0
  2133. executorch/devtools/scripts/generate_profiling_csv.py +62 -0
  2134. executorch/devtools/size_analysis_tool/size_analysis_tool.py +180 -0
  2135. executorch/devtools/size_analysis_tool/size_analysis_tool_test.py +101 -0
  2136. executorch/devtools/visualization/__init__.py +13 -0
  2137. executorch/devtools/visualization/visualization_utils.py +301 -0
  2138. executorch/devtools/visualization/visualization_utils_test.py +177 -0
  2139. executorch/examples/apple/coreml/llama/export.py +224 -0
  2140. executorch/examples/apple/coreml/llama/export_static_llm_coreml.py +504 -0
  2141. executorch/examples/apple/coreml/llama/llama_transformer.py +958 -0
  2142. executorch/examples/apple/coreml/llama/run.py +206 -0
  2143. executorch/examples/apple/coreml/llama/run_lookahead.py +284 -0
  2144. executorch/examples/apple/coreml/llama/run_static_llm.py +293 -0
  2145. executorch/examples/apple/coreml/llama/test.py +48 -0
  2146. executorch/examples/apple/coreml/llama/utils.py +116 -0
  2147. executorch/examples/apple/coreml/scripts/debugger_cli.py +181 -0
  2148. executorch/examples/apple/coreml/scripts/export.py +280 -0
  2149. executorch/examples/apple/coreml/scripts/extract_coreml_models.py +77 -0
  2150. executorch/examples/apple/coreml/scripts/inspector_cli.py +64 -0
  2151. executorch/examples/apple/coreml/scripts/inspector_utils.py +425 -0
  2152. executorch/examples/apple/mps/scripts/bench_utils.py +108 -0
  2153. executorch/examples/apple/mps/scripts/mps_example.py +230 -0
  2154. executorch/examples/cuda/scripts/__init__.py +0 -0
  2155. executorch/examples/cuda/scripts/export.py +107 -0
  2156. executorch/examples/llm_pte_finetuning/__init__.py +19 -0
  2157. executorch/examples/llm_pte_finetuning/llama3_config.yaml +96 -0
  2158. executorch/examples/llm_pte_finetuning/model_exporter.py +87 -0
  2159. executorch/examples/llm_pte_finetuning/model_loading_lib.py +143 -0
  2160. executorch/examples/llm_pte_finetuning/phi3_alpaca_code_config.yaml +44 -0
  2161. executorch/examples/llm_pte_finetuning/phi3_config.yaml +42 -0
  2162. executorch/examples/llm_pte_finetuning/qwen_05b_config.yaml +43 -0
  2163. executorch/examples/llm_pte_finetuning/runner.py +135 -0
  2164. executorch/examples/llm_pte_finetuning/training_lib.py +157 -0
  2165. executorch/examples/models/__init__.py +98 -0
  2166. executorch/examples/models/checkpoint.py +114 -0
  2167. executorch/examples/models/codegen/__init__.py +16 -0
  2168. executorch/examples/models/codegen/convert_weight.py +93 -0
  2169. executorch/examples/models/deeplab_v3/__init__.py +9 -0
  2170. executorch/examples/models/deeplab_v3/model.py +50 -0
  2171. executorch/examples/models/deepseek-r1-distill-llama-8B/config/deepseek_xnnpack_q8da4w.yaml +16 -0
  2172. executorch/examples/models/deit_tiny/__init__.py +8 -0
  2173. executorch/examples/models/deit_tiny/model.py +36 -0
  2174. executorch/examples/models/edsr/__init__.py +11 -0
  2175. executorch/examples/models/edsr/model.py +28 -0
  2176. executorch/examples/models/efficient_sam/__init__.py +11 -0
  2177. executorch/examples/models/efficient_sam/efficient_sam_core/build_efficient_sam.py +25 -0
  2178. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam.py +316 -0
  2179. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_decoder.py +373 -0
  2180. executorch/examples/models/efficient_sam/efficient_sam_core/efficient_sam_encoder.py +261 -0
  2181. executorch/examples/models/efficient_sam/efficient_sam_core/mlp.py +31 -0
  2182. executorch/examples/models/efficient_sam/efficient_sam_core/two_way_transformer.py +268 -0
  2183. executorch/examples/models/efficient_sam/model.py +34 -0
  2184. executorch/examples/models/emformer_rnnt/__init__.py +17 -0
  2185. executorch/examples/models/emformer_rnnt/model.py +132 -0
  2186. executorch/examples/models/gemma/__init__.py +16 -0
  2187. executorch/examples/models/gemma/convert_weights.py +104 -0
  2188. executorch/examples/models/gemma2/__init__.py +19 -0
  2189. executorch/examples/models/gemma2/convert_weights.py +113 -0
  2190. executorch/examples/models/gemma3/__init__.py +16 -0
  2191. executorch/examples/models/gemma3/convert_weights.py +110 -0
  2192. executorch/examples/models/glm/__init__.py +16 -0
  2193. executorch/examples/models/glm/convert_weights.py +79 -0
  2194. executorch/examples/models/granite/__init__.py +16 -0
  2195. executorch/examples/models/granite/convert_weights.py +106 -0
  2196. executorch/examples/models/inception_v3/__init__.py +11 -0
  2197. executorch/examples/models/inception_v3/model.py +28 -0
  2198. executorch/examples/models/inception_v4/__init__.py +11 -0
  2199. executorch/examples/models/inception_v4/model.py +26 -0
  2200. executorch/examples/models/internvl3/__init__.py +16 -0
  2201. executorch/examples/models/internvl3/convert_weights.py +82 -0
  2202. executorch/examples/models/lfm2/__init__.py +10 -0
  2203. executorch/examples/models/lfm2/config/lfm2_xnnpack_fp32.yaml +12 -0
  2204. executorch/examples/models/lfm2/config/lfm2_xnnpack_q8da4w.yaml +15 -0
  2205. executorch/examples/models/lfm2/convert_weights.py +74 -0
  2206. executorch/examples/models/lfm2/short_conv.py +112 -0
  2207. executorch/examples/models/llama/__init__.py +11 -0
  2208. executorch/examples/models/llama/attention.py +536 -0
  2209. executorch/examples/models/llama/config/llama_bf16.yaml +7 -0
  2210. executorch/examples/models/llama/config/llama_q8da4w.yaml +11 -0
  2211. executorch/examples/models/llama/config/llama_xnnpack.yaml +17 -0
  2212. executorch/examples/models/llama/config/llama_xnnpack_qat.yaml +23 -0
  2213. executorch/examples/models/llama/config/llama_xnnpack_spinquant.yaml +22 -0
  2214. executorch/examples/models/llama/config/test_llm_config.py +104 -0
  2215. executorch/examples/models/llama/convert_weights.py +61 -0
  2216. executorch/examples/models/llama/eval_llama.py +38 -0
  2217. executorch/examples/models/llama/eval_llama_lib.py +395 -0
  2218. executorch/examples/models/llama/evaluate/__init__.py +11 -0
  2219. executorch/examples/models/llama/evaluate/eager_eval.py +87 -0
  2220. executorch/examples/models/llama/experimental/__init__.py +0 -0
  2221. executorch/examples/models/llama/experimental/generate.py +190 -0
  2222. executorch/examples/models/llama/experimental/load_gguf_q4_0.py +184 -0
  2223. executorch/examples/models/llama/experimental/subclass.py +413 -0
  2224. executorch/examples/models/llama/experimental/test_subclass.py +28 -0
  2225. executorch/examples/models/llama/export_llama.py +56 -0
  2226. executorch/examples/models/llama/export_llama_lib.py +1560 -0
  2227. executorch/examples/models/llama/fairseq2.py +63 -0
  2228. executorch/examples/models/llama/feed_forward.py +68 -0
  2229. executorch/examples/models/llama/hf_download.py +50 -0
  2230. executorch/examples/models/llama/install_requirement_helper.py +29 -0
  2231. executorch/examples/models/llama/llama_transformer.py +289 -0
  2232. executorch/examples/models/llama/lora.py +48 -0
  2233. executorch/examples/models/llama/model.py +378 -0
  2234. executorch/examples/models/llama/model_args.py +173 -0
  2235. executorch/examples/models/llama/norm.py +55 -0
  2236. executorch/examples/models/llama/rope.py +327 -0
  2237. executorch/examples/models/llama/runner/eager.py +142 -0
  2238. executorch/examples/models/llama/runner/generation.py +234 -0
  2239. executorch/examples/models/llama/runner/native.py +145 -0
  2240. executorch/examples/models/llama/source_transformation/__init__.py +0 -0
  2241. executorch/examples/models/llama/source_transformation/apply_spin_quant_r1_r2.py +202 -0
  2242. executorch/examples/models/llama/source_transformation/attention.py +223 -0
  2243. executorch/examples/models/llama/source_transformation/attention_sink.py +312 -0
  2244. executorch/examples/models/llama/source_transformation/custom_kv_cache.py +598 -0
  2245. executorch/examples/models/llama/source_transformation/lora.py +153 -0
  2246. executorch/examples/models/llama/source_transformation/pre_quantization.py +204 -0
  2247. executorch/examples/models/llama/source_transformation/prune_vocab.py +119 -0
  2248. executorch/examples/models/llama/source_transformation/quantize.py +910 -0
  2249. executorch/examples/models/llama/source_transformation/rms_norm.py +23 -0
  2250. executorch/examples/models/llama/source_transformation/rope.py +39 -0
  2251. executorch/examples/models/llama/source_transformation/sdpa.py +550 -0
  2252. executorch/examples/models/llama/source_transformation/spin_quant.py +88 -0
  2253. executorch/examples/models/llama/source_transformation/test_attention_sink.py +514 -0
  2254. executorch/examples/models/llama/source_transformation/test_quantized_kv_cache.py +126 -0
  2255. executorch/examples/models/llama/source_transformation/test_quantized_sdpa.py +167 -0
  2256. executorch/examples/models/llama/source_transformation/test_sdpa_with_quantized_kv_cache.py +97 -0
  2257. executorch/examples/models/llama/static_attention.py +1257 -0
  2258. executorch/examples/models/llama/tests/test_export_llama_lib.py +50 -0
  2259. executorch/examples/models/llama/tests/test_pre_quantization_transforms.py +188 -0
  2260. executorch/examples/models/llama/tests/test_replace_kv_cache.py +158 -0
  2261. executorch/examples/models/llama/tests/test_ring_attention.py +359 -0
  2262. executorch/examples/models/llama/tests/test_ring_kv_cache.py +492 -0
  2263. executorch/examples/models/llama/tests/test_simple_sdpa.py +66 -0
  2264. executorch/examples/models/llama/tests/test_static_attention.py +363 -0
  2265. executorch/examples/models/llama/tokenizer/tiktoken.py +224 -0
  2266. executorch/examples/models/llama3_2_vision/__init__.py +14 -0
  2267. executorch/examples/models/llama3_2_vision/preprocess/__init__.py +0 -0
  2268. executorch/examples/models/llama3_2_vision/preprocess/export_preprocess.py +45 -0
  2269. executorch/examples/models/llama3_2_vision/preprocess/model.py +72 -0
  2270. executorch/examples/models/llama3_2_vision/preprocess/test_preprocess.py +338 -0
  2271. executorch/examples/models/llama3_2_vision/runner/eager.py +59 -0
  2272. executorch/examples/models/llama3_2_vision/runner/exported.py +94 -0
  2273. executorch/examples/models/llama3_2_vision/runner/generation.py +102 -0
  2274. executorch/examples/models/llama3_2_vision/runner/native.py +143 -0
  2275. executorch/examples/models/llama3_2_vision/text_decoder/model.py +199 -0
  2276. executorch/examples/models/llama3_2_vision/text_decoder/test/__init__.py +0 -0
  2277. executorch/examples/models/llama3_2_vision/text_decoder/test/test_text_decoder.py +89 -0
  2278. executorch/examples/models/llama3_2_vision/vision_encoder/__init__.py +12 -0
  2279. executorch/examples/models/llama3_2_vision/vision_encoder/model.py +96 -0
  2280. executorch/examples/models/llama3_2_vision/vision_encoder/test/__init__.py +0 -0
  2281. executorch/examples/models/llama3_2_vision/vision_encoder/test/test_vision_encoder.py +46 -0
  2282. executorch/examples/models/llava/__init__.py +11 -0
  2283. executorch/examples/models/llava/export_llava.py +365 -0
  2284. executorch/examples/models/llava/model.py +415 -0
  2285. executorch/examples/models/llava/test/test_llava.py +151 -0
  2286. executorch/examples/models/llava/test/test_pte.py +106 -0
  2287. executorch/examples/models/lstm/__init__.py +12 -0
  2288. executorch/examples/models/lstm/model.py +31 -0
  2289. executorch/examples/models/mobilebert/__init__.py +11 -0
  2290. executorch/examples/models/mobilebert/model.py +31 -0
  2291. executorch/examples/models/mobilenet_v2/__init__.py +12 -0
  2292. executorch/examples/models/mobilenet_v2/model.py +73 -0
  2293. executorch/examples/models/mobilenet_v3/__init__.py +11 -0
  2294. executorch/examples/models/mobilenet_v3/model.py +30 -0
  2295. executorch/examples/models/model_base.py +47 -0
  2296. executorch/examples/models/model_factory.py +60 -0
  2297. executorch/examples/models/moshi/mimi/test_mimi.py +245 -0
  2298. executorch/examples/models/parakeet/export_parakeet_tdt.py +591 -0
  2299. executorch/examples/models/phi-3-mini/__init__.py +11 -0
  2300. executorch/examples/models/phi-3-mini-lora/export_model.py +144 -0
  2301. executorch/examples/models/phi_4_mini/__init__.py +16 -0
  2302. executorch/examples/models/phi_4_mini/config/phi_4_mini_xnnpack.yaml +12 -0
  2303. executorch/examples/models/phi_4_mini/convert_weights.py +151 -0
  2304. executorch/examples/models/qwen2_5/__init__.py +16 -0
  2305. executorch/examples/models/qwen2_5/config/qwen2_5_xnnpack_q8da4w.yaml +14 -0
  2306. executorch/examples/models/qwen2_5/convert_weights.py +90 -0
  2307. executorch/examples/models/qwen3/__init__.py +16 -0
  2308. executorch/examples/models/qwen3/config/qwen3_xnnpack.yaml +18 -0
  2309. executorch/examples/models/qwen3/config/qwen3_xnnpack_q8da4w.yaml +20 -0
  2310. executorch/examples/models/qwen3/convert_weights.py +140 -0
  2311. executorch/examples/models/resnet/__init__.py +12 -0
  2312. executorch/examples/models/resnet/model.py +48 -0
  2313. executorch/examples/models/smollm2/__init__.py +16 -0
  2314. executorch/examples/models/smollm2/convert_weights.py +84 -0
  2315. executorch/examples/models/smollm3/__init__.py +16 -0
  2316. executorch/examples/models/smollm3/convert_weights.py +112 -0
  2317. executorch/examples/models/smolvlm/__init__.py +16 -0
  2318. executorch/examples/models/smolvlm/convert_weights.py +77 -0
  2319. executorch/examples/models/stable_diffusion/__init__.py +9 -0
  2320. executorch/examples/models/stable_diffusion/model.py +193 -0
  2321. executorch/examples/models/test/__init__.py +0 -0
  2322. executorch/examples/models/test/test_export.py +161 -0
  2323. executorch/examples/models/torchvision_vit/__init__.py +11 -0
  2324. executorch/examples/models/torchvision_vit/model.py +28 -0
  2325. executorch/examples/models/toy_model/__init__.py +25 -0
  2326. executorch/examples/models/toy_model/model.py +143 -0
  2327. executorch/examples/models/wav2letter/__init__.py +11 -0
  2328. executorch/examples/models/wav2letter/model.py +29 -0
  2329. executorch/examples/models/yolo12/export_and_validate.py +397 -0
  2330. executorch/examples/nxp/experimental/cifar_net/cifar_net.py +270 -0
  2331. executorch/examples/xnnpack/__init__.py +51 -0
  2332. executorch/examples/xnnpack/aot_compiler.py +148 -0
  2333. executorch/examples/xnnpack/quantization/example.py +205 -0
  2334. executorch/examples/xnnpack/quantization/utils.py +42 -0
  2335. executorch/exir/__init__.py +57 -0
  2336. executorch/exir/_serialize/__init__.py +20 -0
  2337. executorch/exir/_serialize/_cord.py +49 -0
  2338. executorch/exir/_serialize/_dataclass.py +145 -0
  2339. executorch/exir/_serialize/_flatbuffer.py +357 -0
  2340. executorch/exir/_serialize/_named_data_store.py +222 -0
  2341. executorch/exir/_serialize/_program.py +767 -0
  2342. executorch/exir/_serialize/_serialize.py +123 -0
  2343. executorch/exir/_serialize/data_serializer.py +80 -0
  2344. executorch/exir/_serialize/padding.py +39 -0
  2345. executorch/exir/_serialize/program.fbs +489 -0
  2346. executorch/exir/_serialize/scalar_type.fbs +43 -0
  2347. executorch/exir/_serialize/test/__init__.py +0 -0
  2348. executorch/exir/_serialize/test/test_cord.py +63 -0
  2349. executorch/exir/_serialize/test/test_flatbuffer.py +331 -0
  2350. executorch/exir/_serialize/test/test_named_data_store.py +212 -0
  2351. executorch/exir/_serialize/test/test_program.py +1265 -0
  2352. executorch/exir/_serialize/test/test_serialize.py +289 -0
  2353. executorch/exir/_warnings.py +44 -0
  2354. executorch/exir/backend/backend_api.py +794 -0
  2355. executorch/exir/backend/backend_details.py +150 -0
  2356. executorch/exir/backend/canonical_partitioners/all_node_partitioner.py +55 -0
  2357. executorch/exir/backend/canonical_partitioners/config_partitioner.py +262 -0
  2358. executorch/exir/backend/canonical_partitioners/duplicate_constant_node_pass.py +156 -0
  2359. executorch/exir/backend/canonical_partitioners/duplicate_dequant_node_pass.py +111 -0
  2360. executorch/exir/backend/canonical_partitioners/group_partitioner.py +371 -0
  2361. executorch/exir/backend/canonical_partitioners/pattern_op_partitioner.py +185 -0
  2362. executorch/exir/backend/compile_spec_schema.py +17 -0
  2363. executorch/exir/backend/operator_support.py +127 -0
  2364. executorch/exir/backend/partitioner.py +114 -0
  2365. executorch/exir/backend/test/backend_with_compiler_demo.py +142 -0
  2366. executorch/exir/backend/test/backend_with_delegate_mapping_demo.py +210 -0
  2367. executorch/exir/backend/test/backend_with_named_data_map.py +115 -0
  2368. executorch/exir/backend/test/backend_with_preprocess_all_demo.py +297 -0
  2369. executorch/exir/backend/test/demo_backend.py +35 -0
  2370. executorch/exir/backend/test/demos/rpc/executor_backend_partitioner.py +77 -0
  2371. executorch/exir/backend/test/demos/rpc/executor_backend_preprocess.py +39 -0
  2372. executorch/exir/backend/test/demos/rpc/test_rpc.py +189 -0
  2373. executorch/exir/backend/test/demos/test_delegate_aten_mode.py +72 -0
  2374. executorch/exir/backend/test/hta_partitioner_demo.py +288 -0
  2375. executorch/exir/backend/test/op_partitioner_demo.py +266 -0
  2376. executorch/exir/backend/test/test_backend_with_named_data_map.py +85 -0
  2377. executorch/exir/backend/test/test_backends.py +1463 -0
  2378. executorch/exir/backend/test/test_backends_lifted.py +1326 -0
  2379. executorch/exir/backend/test/test_backends_nested.py +258 -0
  2380. executorch/exir/backend/test/test_compatibility.py +118 -0
  2381. executorch/exir/backend/test/test_debug_handle_map.py +143 -0
  2382. executorch/exir/backend/test/test_delegate_map_builder.py +257 -0
  2383. executorch/exir/backend/test/test_graph_partition.py +248 -0
  2384. executorch/exir/backend/test/test_group_partitioner.py +1674 -0
  2385. executorch/exir/backend/test/test_lowered_backend_module.py +207 -0
  2386. executorch/exir/backend/test/test_partitioner.py +731 -0
  2387. executorch/exir/backend/test/test_passes.py +48 -0
  2388. executorch/exir/backend/test/test_to_backend_multi_method.py +595 -0
  2389. executorch/exir/backend/test/test_utils.py +264 -0
  2390. executorch/exir/backend/utils.py +661 -0
  2391. executorch/exir/capture/__init__.py +28 -0
  2392. executorch/exir/capture/_capture.py +381 -0
  2393. executorch/exir/capture/_config.py +119 -0
  2394. executorch/exir/capture/_unlift.py +159 -0
  2395. executorch/exir/common.py +140 -0
  2396. executorch/exir/control_flow.py +204 -0
  2397. executorch/exir/debug_handle_utils.py +29 -0
  2398. executorch/exir/delegate.py +171 -0
  2399. executorch/exir/delegate.pyi +21 -0
  2400. executorch/exir/dialects/__init__.py +0 -0
  2401. executorch/exir/dialects/_ops.py +166 -0
  2402. executorch/exir/dialects/backend/_ops.py +123 -0
  2403. executorch/exir/dialects/backend/test/test_backend_ops.py +88 -0
  2404. executorch/exir/dialects/edge/_ops.py +405 -0
  2405. executorch/exir/dialects/edge/arg/model.py +238 -0
  2406. executorch/exir/dialects/edge/arg/type.py +46 -0
  2407. executorch/exir/dialects/edge/dtype/runner.py +122 -0
  2408. executorch/exir/dialects/edge/dtype/supported.py +47 -0
  2409. executorch/exir/dialects/edge/dtype/utils.py +36 -0
  2410. executorch/exir/dialects/edge/edge.yaml +8388 -0
  2411. executorch/exir/dialects/edge/op/api.py +86 -0
  2412. executorch/exir/dialects/edge/op/sample_input.py +1283 -0
  2413. executorch/exir/dialects/edge/op/test/test_api.py +51 -0
  2414. executorch/exir/dialects/edge/spec/gen.py +523 -0
  2415. executorch/exir/dialects/edge/spec/utils.py +328 -0
  2416. executorch/exir/dialects/edge/test/test_edge_ops.py +443 -0
  2417. executorch/exir/dialects/edge/test/test_edge_yaml.py +225 -0
  2418. executorch/exir/dialects/test/test_exir_dialect_ops.py +22 -0
  2419. executorch/exir/dim_order_utils.py +85 -0
  2420. executorch/exir/dynamic_shape.py +12 -0
  2421. executorch/exir/emit/__init__.py +11 -0
  2422. executorch/exir/emit/_emit_program.py +216 -0
  2423. executorch/exir/emit/_emitter.py +2071 -0
  2424. executorch/exir/emit/test/test_emit.py +2405 -0
  2425. executorch/exir/error.py +55 -0
  2426. executorch/exir/graph.py +86 -0
  2427. executorch/exir/graph_module.py +153 -0
  2428. executorch/exir/lowered_backend_module.py +966 -0
  2429. executorch/exir/memory.py +50 -0
  2430. executorch/exir/memory_planning.py +1250 -0
  2431. executorch/exir/operator/convert.py +307 -0
  2432. executorch/exir/operator/manip.py +89 -0
  2433. executorch/exir/operator/test/test_operator.py +84 -0
  2434. executorch/exir/operator/util.py +68 -0
  2435. executorch/exir/pass_base.py +808 -0
  2436. executorch/exir/pass_manager.py +78 -0
  2437. executorch/exir/passes/__init__.py +528 -0
  2438. executorch/exir/passes/_quant_patterns_and_replacements.py +1563 -0
  2439. executorch/exir/passes/const_prop_pass.py +84 -0
  2440. executorch/exir/passes/constant_prop_pass.py +402 -0
  2441. executorch/exir/passes/debug_handle_generator_pass.py +81 -0
  2442. executorch/exir/passes/dim_order_ops_registry.py +90 -0
  2443. executorch/exir/passes/dynamic_shape_prop_pass.py +301 -0
  2444. executorch/exir/passes/executorch_prim_ops_registry.py +166 -0
  2445. executorch/exir/passes/external_constants_pass.py +113 -0
  2446. executorch/exir/passes/init_mutable_pass.py +32 -0
  2447. executorch/exir/passes/insert_write_back_for_buffers_pass.py +185 -0
  2448. executorch/exir/passes/memory_format_ops_pass.py +119 -0
  2449. executorch/exir/passes/memory_planning_pass.py +315 -0
  2450. executorch/exir/passes/normalize_transpose_pass.py +24 -0
  2451. executorch/exir/passes/normalize_view_copy_base_pass.py +62 -0
  2452. executorch/exir/passes/pass_registry.py +89 -0
  2453. executorch/exir/passes/prune_empty_tensors_pass.py +67 -0
  2454. executorch/exir/passes/quant_fusion_pass.py +174 -0
  2455. executorch/exir/passes/quantize_io_pass.py +414 -0
  2456. executorch/exir/passes/reinplace.py +103 -0
  2457. executorch/exir/passes/remove_graph_asserts_pass.py +62 -0
  2458. executorch/exir/passes/remove_mixed_type_operators.py +95 -0
  2459. executorch/exir/passes/remove_noop_pass.py +123 -0
  2460. executorch/exir/passes/remove_unused_parameters_pass.py +55 -0
  2461. executorch/exir/passes/replace_aten_with_edge_pass.py +59 -0
  2462. executorch/exir/passes/replace_broken_ops_with_function_ops_pass.py +42 -0
  2463. executorch/exir/passes/replace_edge_with_backend_pass.py +56 -0
  2464. executorch/exir/passes/replace_sym_size_op_pass.py +35 -0
  2465. executorch/exir/passes/replace_view_copy_with_view_pass.py +325 -0
  2466. executorch/exir/passes/scalar_to_tensor_pass.py +32 -0
  2467. executorch/exir/passes/spec_prop_pass.py +123 -0
  2468. executorch/exir/passes/sym_shape_eval_pass.py +289 -0
  2469. executorch/exir/passes/sym_to_tensor_pass.py +64 -0
  2470. executorch/exir/passes/weights_to_outputs_pass.py +88 -0
  2471. executorch/exir/print_program.py +420 -0
  2472. executorch/exir/program/__init__.py +32 -0
  2473. executorch/exir/program/_fake_program.py +67 -0
  2474. executorch/exir/program/_program.py +1995 -0
  2475. executorch/exir/program/test/__init__.py +0 -0
  2476. executorch/exir/program/test/test_fake_program.py +78 -0
  2477. executorch/exir/program/test/test_program.py +922 -0
  2478. executorch/exir/scalar_type.py +38 -0
  2479. executorch/exir/schema.py +308 -0
  2480. executorch/exir/serde/__init__.py +0 -0
  2481. executorch/exir/serde/export_serialize.py +2872 -0
  2482. executorch/exir/serde/schema.py +406 -0
  2483. executorch/exir/serde/schema_check.py +293 -0
  2484. executorch/exir/serde/serialize.py +838 -0
  2485. executorch/exir/serde/union.py +77 -0
  2486. executorch/exir/sym_util.py +95 -0
  2487. executorch/exir/tensor.py +392 -0
  2488. executorch/exir/tensor_layout.py +39 -0
  2489. executorch/exir/tests/asr_joiner.py +82 -0
  2490. executorch/exir/tests/common.py +96 -0
  2491. executorch/exir/tests/control_flow_models.py +105 -0
  2492. executorch/exir/tests/dynamic_shape_models.py +51 -0
  2493. executorch/exir/tests/models.py +576 -0
  2494. executorch/exir/tests/test_arg_validator.py +72 -0
  2495. executorch/exir/tests/test_capture.py +29 -0
  2496. executorch/exir/tests/test_common.py +81 -0
  2497. executorch/exir/tests/test_delegate.py +308 -0
  2498. executorch/exir/tests/test_dim_order_utils.py +49 -0
  2499. executorch/exir/tests/test_dynamic_shape_propagation.py +174 -0
  2500. executorch/exir/tests/test_error.py +19 -0
  2501. executorch/exir/tests/test_extract_io_quant_params.py +93 -0
  2502. executorch/exir/tests/test_joint_graph.py +124 -0
  2503. executorch/exir/tests/test_memory_format_ops_pass.py +443 -0
  2504. executorch/exir/tests/test_memory_format_ops_pass_aten.py +142 -0
  2505. executorch/exir/tests/test_memory_format_ops_pass_utils.py +266 -0
  2506. executorch/exir/tests/test_memory_planning.py +1135 -0
  2507. executorch/exir/tests/test_op_convert.py +88 -0
  2508. executorch/exir/tests/test_pass_infra.py +179 -0
  2509. executorch/exir/tests/test_passes.py +2332 -0
  2510. executorch/exir/tests/test_print_program.py +54 -0
  2511. executorch/exir/tests/test_prune_empty_tensors_pass.py +77 -0
  2512. executorch/exir/tests/test_quant_fusion_pass.py +528 -0
  2513. executorch/exir/tests/test_quantization.py +120 -0
  2514. executorch/exir/tests/test_quantize_io_pass.py +156 -0
  2515. executorch/exir/tests/test_reinplace_pass.py +124 -0
  2516. executorch/exir/tests/test_remove_unused_parameters_pass.py +205 -0
  2517. executorch/exir/tests/test_remove_view_copy.py +234 -0
  2518. executorch/exir/tests/test_serde.py +352 -0
  2519. executorch/exir/tests/test_tensor.py +341 -0
  2520. executorch/exir/tests/test_tracer.py +497 -0
  2521. executorch/exir/tests/test_verification.py +275 -0
  2522. executorch/exir/tests/test_warnings.py +169 -0
  2523. executorch/exir/tests/transformer.py +122 -0
  2524. executorch/exir/tracer.py +803 -0
  2525. executorch/exir/types.py +18 -0
  2526. executorch/exir/verification/arg_validator.py +140 -0
  2527. executorch/exir/verification/dev_html.py +68 -0
  2528. executorch/exir/verification/interpreter.py +425 -0
  2529. executorch/exir/verification/test/test_verifier.py +177 -0
  2530. executorch/exir/verification/verifier.py +352 -0
  2531. executorch/exir/version.py +9 -0
  2532. executorch/exir/wrap.py +32 -0
  2533. executorch/export/__init__.py +40 -0
  2534. executorch/export/export.py +696 -0
  2535. executorch/export/recipe.py +328 -0
  2536. executorch/export/recipe_provider.py +60 -0
  2537. executorch/export/recipe_registry.py +86 -0
  2538. executorch/export/stages.py +686 -0
  2539. executorch/export/target_recipes.py +185 -0
  2540. executorch/export/tests/test_executorch_export.py +34 -0
  2541. executorch/export/tests/test_export_recipe.py +131 -0
  2542. executorch/export/tests/test_export_session.py +973 -0
  2543. executorch/export/tests/test_export_stages.py +534 -0
  2544. executorch/export/tests/test_recipe_provider.py +98 -0
  2545. executorch/export/tests/test_recipe_registry.py +139 -0
  2546. executorch/export/tests/test_target_recipes.py +539 -0
  2547. executorch/export/types.py +22 -0
  2548. executorch/export/utils.py +51 -0
  2549. executorch/extension/audio/mel_spectrogram.py +279 -0
  2550. executorch/extension/export_util/__init__.py +13 -0
  2551. executorch/extension/export_util/utils.py +147 -0
  2552. executorch/extension/flat_tensor/__init__.py +0 -0
  2553. executorch/extension/flat_tensor/serialize/__init__.py +0 -0
  2554. executorch/extension/flat_tensor/serialize/flat_tensor.fbs +73 -0
  2555. executorch/extension/flat_tensor/serialize/flat_tensor_schema.py +34 -0
  2556. executorch/extension/flat_tensor/serialize/scalar_type.fbs +38 -0
  2557. executorch/extension/flat_tensor/serialize/serialize.py +446 -0
  2558. executorch/extension/flat_tensor/test/test_serialize.py +326 -0
  2559. executorch/extension/gguf_util/convert_main.py +53 -0
  2560. executorch/extension/gguf_util/converter.py +27 -0
  2561. executorch/extension/gguf_util/converters/llama_converter.py +123 -0
  2562. executorch/extension/gguf_util/load_gguf.py +103 -0
  2563. executorch/extension/llm/custom_ops/__init__.py +0 -0
  2564. executorch/extension/llm/custom_ops/custom_ops.py +495 -0
  2565. executorch/extension/llm/custom_ops/custom_ops_aot_lib.dll +0 -0
  2566. executorch/extension/llm/custom_ops/model_sharding.py +117 -0
  2567. executorch/extension/llm/custom_ops/op_tile_crop_aot.py +38 -0
  2568. executorch/extension/llm/custom_ops/preprocess_custom_ops.py +69 -0
  2569. executorch/extension/llm/custom_ops/spinquant/special_hadamard_code_gen.py +279 -0
  2570. executorch/extension/llm/custom_ops/spinquant/third-party/FFHT/example.py +20 -0
  2571. executorch/extension/llm/custom_ops/spinquant/third-party/FFHT/gen.py +869 -0
  2572. executorch/extension/llm/custom_ops/test_preprocess_custom_ops.py +34 -0
  2573. executorch/extension/llm/custom_ops/test_quantized_sdpa.py +550 -0
  2574. executorch/extension/llm/custom_ops/test_sdpa_with_kv_cache.py +651 -0
  2575. executorch/extension/llm/custom_ops/test_update_cache.py +433 -0
  2576. executorch/extension/llm/custom_ops/test_update_cross_attn_cache.py +284 -0
  2577. executorch/extension/llm/export/__init__.py +11 -0
  2578. executorch/extension/llm/export/builder.py +535 -0
  2579. executorch/extension/llm/export/config/llm_config.py +727 -0
  2580. executorch/extension/llm/export/export_llm.py +106 -0
  2581. executorch/extension/llm/export/export_passes.py +202 -0
  2582. executorch/extension/llm/export/partitioner_lib.py +238 -0
  2583. executorch/extension/llm/export/quantizer_lib.py +322 -0
  2584. executorch/extension/llm/export/test/__init__.py +0 -0
  2585. executorch/extension/llm/export/test/test_builder.py +118 -0
  2586. executorch/extension/llm/export/test/test_export_llm.py +155 -0
  2587. executorch/extension/llm/export/test_export_passes.py +209 -0
  2588. executorch/extension/llm/modules/__init__.py +24 -0
  2589. executorch/extension/llm/modules/_position_embeddings.py +729 -0
  2590. executorch/extension/llm/modules/attention.py +415 -0
  2591. executorch/extension/llm/modules/kv_cache.py +151 -0
  2592. executorch/extension/llm/modules/test/__init__.py +0 -0
  2593. executorch/extension/llm/modules/test/test_attention.py +353 -0
  2594. executorch/extension/llm/modules/test/test_kv_cache.py +218 -0
  2595. executorch/extension/llm/modules/test/test_position_embeddings.py +230 -0
  2596. executorch/extension/llm/runner/__init__.py +235 -0
  2597. executorch/extension/llm/runner/_llm_runner.pyi +523 -0
  2598. executorch/extension/llm/runner/test/test_runner_pybindings.py +258 -0
  2599. executorch/extension/llm/tokenizers/pytorch_tokenizers/__init__.py +63 -0
  2600. executorch/extension/llm/tokenizers/pytorch_tokenizers/constants.py +31 -0
  2601. executorch/extension/llm/tokenizers/pytorch_tokenizers/hf_tokenizer.py +57 -0
  2602. executorch/extension/llm/tokenizers/pytorch_tokenizers/llama2c.py +111 -0
  2603. executorch/extension/llm/tokenizers/pytorch_tokenizers/tiktoken.py +198 -0
  2604. executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/__init__.py +0 -0
  2605. executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/llama2c/__init__.py +0 -0
  2606. executorch/extension/llm/tokenizers/pytorch_tokenizers/tools/llama2c/convert.py +49 -0
  2607. executorch/extension/llm/tokenizers/setup.py +199 -0
  2608. executorch/extension/llm/tokenizers/test/test_hf_tokenizer.py +83 -0
  2609. executorch/extension/llm/tokenizers/test/test_python_bindings.py +131 -0
  2610. executorch/extension/llm/tokenizers/test/test_tekken_python.py +453 -0
  2611. executorch/extension/llm/tokenizers/test/test_tiktoken.py +49 -0
  2612. executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/abseil.podspec.gen.py +243 -0
  2613. executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/copts/copts.py +194 -0
  2614. executorch/extension/llm/tokenizers/third-party/abseil-cpp/absl/copts/generate_copts.py +109 -0
  2615. executorch/extension/llm/tokenizers/third-party/abseil-cpp/conanfile.py +51 -0
  2616. executorch/extension/llm/tokenizers/third-party/abseil-cpp/create_lts.py +139 -0
  2617. executorch/extension/llm/tokenizers/third-party/json/docs/mkdocs/scripts/check_structure.py +179 -0
  2618. executorch/extension/llm/tokenizers/third-party/json/tests/thirdparty/imapdl/filterbr.py +109 -0
  2619. executorch/extension/llm/tokenizers/third-party/json/tools/amalgamate/amalgamate.py +299 -0
  2620. executorch/extension/llm/tokenizers/third-party/json/tools/gdb_pretty_printer/nlohmann-json.py +32 -0
  2621. executorch/extension/llm/tokenizers/third-party/json/tools/generate_natvis/generate_natvis.py +41 -0
  2622. executorch/extension/llm/tokenizers/third-party/json/tools/serve_header/serve_header.py +410 -0
  2623. executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateCommon.py +354 -0
  2624. executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateTest.py +186 -0
  2625. executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcd.py +999 -0
  2626. executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcpHeader.py +98 -0
  2627. executorch/extension/llm/tokenizers/third-party/pcre2/maint/GenerateUcpTables.py +203 -0
  2628. executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateCommon.py +31 -0
  2629. executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateDates.py +59 -0
  2630. executorch/extension/llm/tokenizers/third-party/pcre2/maint/UpdateRelease.py +29 -0
  2631. executorch/extension/llm/tokenizers/third-party/re2/benchlog/benchplot.py +98 -0
  2632. executorch/extension/llm/tokenizers/third-party/re2/python/re2.py +583 -0
  2633. executorch/extension/llm/tokenizers/third-party/re2/python/re2_test.py +489 -0
  2634. executorch/extension/llm/tokenizers/third-party/re2/python/setup.py +158 -0
  2635. executorch/extension/llm/tokenizers/third-party/re2/python/toolchains/generate.py +98 -0
  2636. executorch/extension/llm/tokenizers/third-party/re2/re2/make_unicode_casefold.py +151 -0
  2637. executorch/extension/llm/tokenizers/third-party/re2/re2/make_unicode_groups.py +117 -0
  2638. executorch/extension/llm/tokenizers/third-party/re2/re2/unicode.py +284 -0
  2639. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/setup.py +215 -0
  2640. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/__init__.py +1224 -0
  2641. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/_version.py +1 -0
  2642. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/sentencepiece_model_pb2.py +44 -0
  2643. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/src/sentencepiece/sentencepiece_pb2.py +30 -0
  2644. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/test/__init__.py +0 -0
  2645. executorch/extension/llm/tokenizers/third-party/sentencepiece/python/test/sentencepiece_test.py +937 -0
  2646. executorch/extension/module/test/resources/gen_bundled_program.py +99 -0
  2647. executorch/extension/pybindings/_portable_lib.cp313-win_amd64.pyd +0 -0
  2648. executorch/extension/pybindings/portable_lib.py +82 -0
  2649. executorch/extension/pybindings/pybindings.pyi +299 -0
  2650. executorch/extension/pybindings/test/make_test.py +186 -0
  2651. executorch/extension/pybindings/test/test_backend_pybinding.py +27 -0
  2652. executorch/extension/pybindings/test/test_pybindings.py +735 -0
  2653. executorch/extension/pytree/__init__.py +54 -0
  2654. executorch/extension/pytree/test/test.py +331 -0
  2655. executorch/extension/training/__init__.py +22 -0
  2656. executorch/extension/training/examples/CIFAR/data_utils.py +389 -0
  2657. executorch/extension/training/examples/CIFAR/export.py +220 -0
  2658. executorch/extension/training/examples/CIFAR/main.py +188 -0
  2659. executorch/extension/training/examples/CIFAR/model.py +73 -0
  2660. executorch/extension/training/examples/CIFAR/train_utils.py +622 -0
  2661. executorch/extension/training/examples/XOR/export_model.py +74 -0
  2662. executorch/extension/training/examples/XOR/model.py +34 -0
  2663. executorch/extension/training/examples/XOR/test/test_export.py +19 -0
  2664. executorch/extension/training/pybindings/_training_lib.pyi +45 -0
  2665. executorch/extension/training/pybindings/_training_module.py +86 -0
  2666. executorch/extension/training/pybindings/test/test.py +67 -0
  2667. executorch/extension/wasm/test/test_model.py +34 -0
  2668. executorch/include/executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h +260 -0
  2669. executorch/include/executorch/extension/kernel_util/meta_programming.h +119 -0
  2670. executorch/include/executorch/extension/kernel_util/type_list.h +145 -0
  2671. executorch/include/executorch/extension/tensor/tensor.h +14 -0
  2672. executorch/include/executorch/extension/tensor/tensor_accessor.h +218 -0
  2673. executorch/include/executorch/extension/tensor/tensor_ptr.h +485 -0
  2674. executorch/include/executorch/extension/tensor/tensor_ptr_maker.h +687 -0
  2675. executorch/include/executorch/extension/threadpool/cpuinfo_utils.h +24 -0
  2676. executorch/include/executorch/extension/threadpool/threadpool.h +124 -0
  2677. executorch/include/executorch/extension/threadpool/threadpool_guard.h +37 -0
  2678. executorch/include/executorch/runtime/core/array_ref.h +262 -0
  2679. executorch/include/executorch/runtime/core/data_loader.h +141 -0
  2680. executorch/include/executorch/runtime/core/defines.h +20 -0
  2681. executorch/include/executorch/runtime/core/error.h +257 -0
  2682. executorch/include/executorch/runtime/core/evalue.h +608 -0
  2683. executorch/include/executorch/runtime/core/event_tracer.h +592 -0
  2684. executorch/include/executorch/runtime/core/event_tracer_hooks.h +340 -0
  2685. executorch/include/executorch/runtime/core/event_tracer_hooks_delegate.h +204 -0
  2686. executorch/include/executorch/runtime/core/exec_aten/exec_aten.h +175 -0
  2687. executorch/include/executorch/runtime/core/exec_aten/testing_util/tensor_factory.h +1133 -0
  2688. executorch/include/executorch/runtime/core/exec_aten/testing_util/tensor_util.h +378 -0
  2689. executorch/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +278 -0
  2690. executorch/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1430 -0
  2691. executorch/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  2692. executorch/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +68 -0
  2693. executorch/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1415 -0
  2694. executorch/include/executorch/runtime/core/freeable_buffer.h +218 -0
  2695. executorch/include/executorch/runtime/core/function_ref.h +108 -0
  2696. executorch/include/executorch/runtime/core/hierarchical_allocator.h +125 -0
  2697. executorch/include/executorch/runtime/core/memory_allocator.h +233 -0
  2698. executorch/include/executorch/runtime/core/named_data_map.h +77 -0
  2699. executorch/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  2700. executorch/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  2701. executorch/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
  2702. executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +1 -0
  2703. executorch/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +1 -0
  2704. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +1 -0
  2705. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +299 -0
  2706. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +1 -0
  2707. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +1 -0
  2708. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +8 -0
  2709. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +1 -0
  2710. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +1 -0
  2711. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex.h +78 -0
  2712. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_math.h +406 -0
  2713. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/complex_utils.h +46 -0
  2714. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +1 -0
  2715. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +123 -0
  2716. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/llvmMathExtras.h +905 -0
  2717. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/overflows.h +100 -0
  2718. executorch/include/executorch/runtime/core/portable_type/c10/c10/util/safe_numerics.h +114 -0
  2719. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h +153 -0
  2720. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h +694 -0
  2721. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h +480 -0
  2722. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/Half.h +788 -0
  2723. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/TypeSafeSignMath.h +148 -0
  2724. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/bit_cast.h +50 -0
  2725. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/complex.h +616 -0
  2726. executorch/include/executorch/runtime/core/portable_type/c10/torch/headeronly/util/floating_point_utils.h +38 -0
  2727. executorch/include/executorch/runtime/core/portable_type/complex.h +21 -0
  2728. executorch/include/executorch/runtime/core/portable_type/device.h +74 -0
  2729. executorch/include/executorch/runtime/core/portable_type/half.h +27 -0
  2730. executorch/include/executorch/runtime/core/portable_type/optional.h +36 -0
  2731. executorch/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
  2732. executorch/include/executorch/runtime/core/portable_type/scalar.h +123 -0
  2733. executorch/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  2734. executorch/include/executorch/runtime/core/portable_type/string_view.h +29 -0
  2735. executorch/include/executorch/runtime/core/portable_type/tensor.h +175 -0
  2736. executorch/include/executorch/runtime/core/portable_type/tensor_impl.h +304 -0
  2737. executorch/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  2738. executorch/include/executorch/runtime/core/result.h +268 -0
  2739. executorch/include/executorch/runtime/core/span.h +110 -0
  2740. executorch/include/executorch/runtime/core/tag.h +90 -0
  2741. executorch/include/executorch/runtime/core/tensor_layout.h +93 -0
  2742. executorch/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  2743. executorch/include/executorch/runtime/core/testing_util/error_matchers.h +303 -0
  2744. executorch/include/executorch/runtime/kernel/kernel_includes.h +23 -0
  2745. executorch/include/executorch/runtime/kernel/kernel_runtime_context.h +131 -0
  2746. executorch/include/executorch/runtime/kernel/operator_registry.h +298 -0
  2747. executorch/include/executorch/runtime/kernel/test/test_util.h +40 -0
  2748. executorch/include/executorch/runtime/kernel/thread_parallel_interface.h +107 -0
  2749. executorch/include/executorch/runtime/platform/abort.h +36 -0
  2750. executorch/include/executorch/runtime/platform/assert.h +124 -0
  2751. executorch/include/executorch/runtime/platform/clock.h +43 -0
  2752. executorch/include/executorch/runtime/platform/compat_unistd.h +75 -0
  2753. executorch/include/executorch/runtime/platform/compiler.h +214 -0
  2754. executorch/include/executorch/runtime/platform/log.h +216 -0
  2755. executorch/include/executorch/runtime/platform/platform.h +276 -0
  2756. executorch/include/executorch/runtime/platform/profiler.h +289 -0
  2757. executorch/include/executorch/runtime/platform/runtime.h +35 -0
  2758. executorch/include/executorch/runtime/platform/system.h +49 -0
  2759. executorch/include/executorch/runtime/platform/test/pal_spy.h +86 -0
  2760. executorch/include/executorch/runtime/platform/test/stub_platform.h +76 -0
  2761. executorch/include/executorch/runtime/platform/types.h +24 -0
  2762. executorch/kernels/quantized/__init__.py +21 -0
  2763. executorch/kernels/quantized/quantized.yaml +113 -0
  2764. executorch/kernels/quantized/quantized_ops_aot_lib.dll +0 -0
  2765. executorch/kernels/quantized/test/supported_features_def.yaml +1 -0
  2766. executorch/kernels/quantized/test/test_out_variants.py +100 -0
  2767. executorch/kernels/quantized/test/test_quant_dequant_per_token.py +149 -0
  2768. executorch/runtime/__init__.py +334 -0
  2769. executorch/runtime/kernel/test/functions.yaml +13 -0
  2770. executorch/runtime/test/test_runtime.py +106 -0
  2771. executorch/runtime/test/test_runtime_etdump_gen.py +163 -0
  2772. executorch/schema/program.fbs +489 -0
  2773. executorch/schema/scalar_type.fbs +43 -0
  2774. executorch/share/cmake/executorch-config.cmake +77 -0
  2775. executorch/util/activation_memory_profiler.py +177 -0
  2776. executorch/util/collect_env.py +748 -0
  2777. executorch/util/python_profiler.py +96 -0
  2778. executorch/version.py +4 -0
  2779. executorch-1.1.0.dist-info/METADATA +87 -0
  2780. executorch-1.1.0.dist-info/RECORD +2784 -0
  2781. executorch-1.1.0.dist-info/WHEEL +5 -0
  2782. executorch-1.1.0.dist-info/entry_points.txt +2 -0
  2783. executorch-1.1.0.dist-info/licenses/LICENSE +37 -0
  2784. executorch-1.1.0.dist-info/top_level.txt +7 -0
@@ -0,0 +1,4361 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ import math
8
+
9
+ import facto.specdb.dtypes as dt
10
+ import facto.specdb.function as fn
11
+ import torch
12
+ from facto.inputgen.argument.type import ArgType
13
+ from facto.inputgen.specs.model import (
14
+ ConstraintProducer as cp,
15
+ InKwArg,
16
+ InPosArg,
17
+ OutArg,
18
+ Spec,
19
+ )
20
+ from facto.inputgen.variable.type import ScalarDtype
21
+ from facto.specdb.default import (
22
+ DimDefault,
23
+ DimListDefault,
24
+ IndexDefault,
25
+ MemoryFormatDefault,
26
+ ShapeDefault,
27
+ )
28
+
29
+
30
+ SpecDB = [
31
+ Spec(
32
+ op="_cdist_forward.default", # (Tensor x1, Tensor x2, float p, int? compute_mode) -> Tensor
33
+ inspec=[
34
+ InPosArg(
35
+ ArgType.Tensor,
36
+ name="x1",
37
+ constraints=[
38
+ cp.Dtype.In(lambda deps: dt._floating),
39
+ cp.Rank.Ge(lambda deps: 2),
40
+ ],
41
+ ),
42
+ InPosArg(
43
+ ArgType.Tensor,
44
+ name="x2",
45
+ deps=[0],
46
+ constraints=[
47
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
48
+ cp.Rank.Ge(lambda deps: 2),
49
+ cp.Size.Eq(
50
+ lambda deps, r, d: (
51
+ fn.safe_size(deps[0], deps[0].dim() - 1)
52
+ if d == r - 1
53
+ else None
54
+ )
55
+ ),
56
+ cp.Size.In(
57
+ lambda deps, r, d: (
58
+ fn.broadcast_with(deps[0].shape[:-2], r - 2, d)
59
+ if d < r - 2
60
+ else None
61
+ )
62
+ ),
63
+ ],
64
+ ),
65
+ InPosArg(
66
+ ArgType.Float,
67
+ name="p",
68
+ constraints=[
69
+ cp.Value.Ge(lambda deps: 0),
70
+ cp.Value.Be(
71
+ lambda deps: [
72
+ 0,
73
+ 0.1,
74
+ 0.5,
75
+ 1,
76
+ 1.5,
77
+ 2,
78
+ 2.5,
79
+ 3,
80
+ 5,
81
+ 10,
82
+ float("inf"),
83
+ ]
84
+ ),
85
+ ],
86
+ ),
87
+ InPosArg(
88
+ ArgType.IntOpt,
89
+ name="compute_mode",
90
+ constraints=[
91
+ cp.Value.In(lambda deps: [0, 1, 2]),
92
+ ],
93
+ ),
94
+ ],
95
+ outspec=[
96
+ OutArg(
97
+ ArgType.Tensor,
98
+ constraints=[
99
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
100
+ ],
101
+ )
102
+ ],
103
+ ),
104
+ Spec( # TODO(mcandales): Calibrate.
105
+ op="_log_softmax.default", # (Tensor self, int dim, bool half_to_float) -> Tensor
106
+ inspec=[
107
+ InPosArg(
108
+ ArgType.Tensor,
109
+ name="self",
110
+ constraints=[
111
+ cp.Dtype.In(lambda deps: dt._floating),
112
+ ],
113
+ ),
114
+ InPosArg(
115
+ ArgType.Dim,
116
+ name="dim",
117
+ deps=[0],
118
+ constraints=DimDefault,
119
+ ),
120
+ InPosArg(
121
+ ArgType.Bool,
122
+ name="half_to_float",
123
+ # TODO(mcandales): CPU specific constraint
124
+ constraints=[
125
+ cp.Value.Eq(lambda deps: False),
126
+ ],
127
+ ),
128
+ ],
129
+ outspec=[
130
+ OutArg(ArgType.Tensor),
131
+ ],
132
+ ),
133
+ Spec( # TODO(mcandales): Calibrate ATen's implementation.
134
+ op="_native_batch_norm_legit_no_training.default", # (Tensor input, Tensor? weight, Tensor? bias, Tensor running_mean, Tensor running_var, float momentum, float eps) -> (Tensor, Tensor, Tensor)
135
+ inspec=[
136
+ InPosArg(
137
+ ArgType.Tensor,
138
+ name="input",
139
+ constraints=[
140
+ cp.Rank.Ge(lambda deps: 2),
141
+ ],
142
+ ),
143
+ InPosArg(
144
+ ArgType.TensorOpt,
145
+ name="weight",
146
+ deps=[0],
147
+ constraints=[
148
+ cp.Rank.Eq(lambda deps: 1),
149
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
150
+ ],
151
+ ),
152
+ InPosArg(
153
+ ArgType.TensorOpt,
154
+ name="bias",
155
+ deps=[0],
156
+ constraints=[
157
+ cp.Rank.Eq(lambda deps: 1),
158
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
159
+ ],
160
+ ),
161
+ InPosArg(
162
+ ArgType.Tensor,
163
+ name="running_mean",
164
+ deps=[0],
165
+ constraints=[
166
+ cp.Rank.Eq(lambda deps: 1),
167
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
168
+ ],
169
+ ),
170
+ InPosArg(
171
+ ArgType.Tensor,
172
+ name="running_var",
173
+ deps=[0],
174
+ constraints=[
175
+ cp.Rank.Eq(lambda deps: 1),
176
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
177
+ ],
178
+ ),
179
+ InPosArg(ArgType.Float, name="momentum"),
180
+ InPosArg(ArgType.Float, name="eps"),
181
+ ],
182
+ outspec=[
183
+ OutArg(ArgType.Tensor, name="out0"),
184
+ OutArg(ArgType.Tensor, name="out1"),
185
+ OutArg(ArgType.Tensor, name="out2"),
186
+ ],
187
+ ),
188
+ Spec(
189
+ op="_pdist_forward.default", # (Tensor self, float p=2) -> Tensor
190
+ inspec=[
191
+ InPosArg(
192
+ ArgType.Tensor,
193
+ name="self",
194
+ constraints=[
195
+ cp.Dtype.In(lambda deps: dt._floating),
196
+ cp.Rank.Eq(lambda deps: 2),
197
+ ],
198
+ ),
199
+ InPosArg(
200
+ ArgType.Float,
201
+ name="p",
202
+ constraints=[
203
+ cp.Value.Ge(lambda deps: 0),
204
+ cp.Value.Be(
205
+ lambda deps: [
206
+ 0,
207
+ 0.1,
208
+ 0.5,
209
+ 1,
210
+ 1.5,
211
+ 2,
212
+ 2.5,
213
+ 3,
214
+ 5,
215
+ 10,
216
+ float("inf"),
217
+ ]
218
+ ),
219
+ ],
220
+ ),
221
+ ],
222
+ outspec=[
223
+ OutArg(
224
+ ArgType.Tensor,
225
+ constraints=[
226
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
227
+ ],
228
+ )
229
+ ],
230
+ ),
231
+ Spec( # TODO(mcandales): Calibrate.
232
+ op="_softmax.default", # (Tensor self, int dim, bool half_to_float) -> Tensor
233
+ inspec=[
234
+ InPosArg(
235
+ ArgType.Tensor,
236
+ name="self",
237
+ constraints=[
238
+ cp.Dtype.In(lambda deps: dt._floating),
239
+ ],
240
+ ),
241
+ InPosArg(
242
+ ArgType.Dim,
243
+ name="dim",
244
+ deps=[0],
245
+ constraints=DimDefault,
246
+ ),
247
+ InPosArg(
248
+ ArgType.Bool,
249
+ name="half_to_float",
250
+ # TODO(mcandales): CPU specific constraint
251
+ constraints=[
252
+ cp.Value.Eq(lambda deps: False),
253
+ ],
254
+ ),
255
+ ],
256
+ outspec=[
257
+ OutArg(ArgType.Tensor),
258
+ ],
259
+ ),
260
+ Spec(
261
+ op="_to_copy.default", # (Tensor self, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, bool non_blocking=False, MemoryFormat? memory_format=None) -> Tensor
262
+ inspec=[
263
+ InPosArg(ArgType.Tensor, name="self"),
264
+ InKwArg(
265
+ ArgType.Bool,
266
+ name="non_blocking",
267
+ # TODO(mcandales): Executorch specific constraint
268
+ # constraints=[cp.Value.In(lambda deps: [False])],
269
+ ),
270
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
271
+ InKwArg(
272
+ ArgType.MemoryFormat,
273
+ name="memory_format",
274
+ constraints=MemoryFormatDefault,
275
+ ),
276
+ ],
277
+ outspec=[
278
+ OutArg(ArgType.Tensor),
279
+ ],
280
+ ),
281
+ Spec(
282
+ op="abs.default", # (Tensor self) -> Tensor
283
+ inspec=[
284
+ InPosArg(
285
+ ArgType.Tensor,
286
+ name="self",
287
+ constraints=[
288
+ cp.Dtype.Ne(lambda deps: torch.bool),
289
+ ],
290
+ ),
291
+ ],
292
+ outspec=[
293
+ OutArg(ArgType.Tensor),
294
+ ],
295
+ ),
296
+ Spec(
297
+ op="acos.default", # (Tensor self) -> Tensor
298
+ inspec=[
299
+ InPosArg(ArgType.Tensor, name="self"),
300
+ ],
301
+ outspec=[
302
+ OutArg(ArgType.Tensor),
303
+ ],
304
+ ),
305
+ Spec(
306
+ op="acosh.default", # (Tensor self) -> Tensor
307
+ inspec=[
308
+ InPosArg(ArgType.Tensor, name="self"),
309
+ ],
310
+ outspec=[
311
+ OutArg(ArgType.Tensor),
312
+ ],
313
+ ),
314
+ Spec(
315
+ op="add.Tensor", # (Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor
316
+ inspec=[
317
+ InPosArg(ArgType.Tensor, name="self"),
318
+ InPosArg(
319
+ ArgType.Tensor,
320
+ name="other",
321
+ deps=[0],
322
+ constraints=[
323
+ cp.Size.In(
324
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
325
+ ),
326
+ ],
327
+ ),
328
+ InKwArg(
329
+ ArgType.Scalar,
330
+ name="alpha",
331
+ deps=[0, 1],
332
+ constraints=[
333
+ cp.Dtype.In(
334
+ lambda deps: fn.add_alpha_st(
335
+ fn.dt_to_st(
336
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
337
+ )
338
+ )
339
+ ),
340
+ ],
341
+ ),
342
+ ],
343
+ outspec=[
344
+ OutArg(
345
+ ArgType.Tensor,
346
+ constraints=[
347
+ cp.Dtype.In(
348
+ lambda deps: dt.can_cast_from(
349
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
350
+ )
351
+ ),
352
+ ],
353
+ ),
354
+ ],
355
+ ),
356
+ Spec(
357
+ op="add.Scalar", # (Tensor self, Scalar other, Scalar alpha=1) -> Tensor
358
+ inspec=[
359
+ InPosArg(ArgType.Tensor, name="self"),
360
+ InPosArg(ArgType.Scalar, name="other"),
361
+ InPosArg(
362
+ ArgType.Scalar,
363
+ name="alpha",
364
+ deps=[0, 1],
365
+ constraints=[
366
+ cp.Dtype.Ne(
367
+ lambda deps: (
368
+ ScalarDtype.bool
369
+ if deps[0].dtype != torch.bool
370
+ or deps[1] != ScalarDtype.bool
371
+ else None
372
+ )
373
+ ),
374
+ cp.Dtype.In(
375
+ lambda deps: fn.st_le(
376
+ fn.dt_to_st(
377
+ fn.promote_type_with_scalar(deps[0].dtype, deps[1])
378
+ )
379
+ )
380
+ ),
381
+ ],
382
+ ),
383
+ ],
384
+ outspec=[
385
+ OutArg(
386
+ ArgType.Tensor,
387
+ constraints=[
388
+ cp.Dtype.Eq(
389
+ lambda deps: (
390
+ fn.promote_type_with_scalar(deps[0].dtype, deps[1])
391
+ )
392
+ ),
393
+ ],
394
+ )
395
+ ],
396
+ ),
397
+ Spec(
398
+ op="addmm.default", # (Tensor self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
399
+ inspec=[
400
+ InPosArg(
401
+ ArgType.Tensor,
402
+ name="self",
403
+ deps=[1, 2],
404
+ constraints=[
405
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
406
+ cp.Rank.Le(lambda deps: 2),
407
+ cp.Size.In(
408
+ lambda deps, r, d: fn.broadcast_to(
409
+ (fn.safe_size(deps[0], 0), fn.safe_size(deps[1], 1)), r, d
410
+ )
411
+ ),
412
+ ],
413
+ ),
414
+ InPosArg(
415
+ ArgType.Tensor,
416
+ name="mat1",
417
+ constraints=[
418
+ cp.Dtype.Ne(lambda deps: torch.bool),
419
+ cp.Rank.Eq(lambda deps: 2),
420
+ ],
421
+ ),
422
+ InPosArg(
423
+ ArgType.Tensor,
424
+ name="mat2",
425
+ deps=[1],
426
+ constraints=[
427
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
428
+ cp.Rank.Eq(lambda deps: 2),
429
+ cp.Size.Eq(
430
+ lambda deps, r, d: fn.safe_size(deps[0], 1) if d == 0 else None
431
+ ),
432
+ ],
433
+ ),
434
+ InKwArg(
435
+ ArgType.Scalar,
436
+ name="beta",
437
+ deps=[1],
438
+ constraints=[
439
+ cp.Value.Ge(
440
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
441
+ ),
442
+ cp.Value.Le(
443
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
444
+ ),
445
+ ],
446
+ ),
447
+ InKwArg(
448
+ ArgType.Scalar,
449
+ name="alpha",
450
+ deps=[1],
451
+ constraints=[
452
+ cp.Value.Ge(
453
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
454
+ ),
455
+ cp.Value.Le(
456
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
457
+ ),
458
+ ],
459
+ ),
460
+ ],
461
+ outspec=[
462
+ OutArg(ArgType.Tensor),
463
+ ],
464
+ ),
465
+ Spec(
466
+ op="alias_copy.default", # (Tensor self) -> Tensor
467
+ inspec=[
468
+ InPosArg(ArgType.Tensor, name="self"),
469
+ ],
470
+ outspec=[OutArg(ArgType.Tensor)],
471
+ ),
472
+ Spec(
473
+ op="amax.default", # (Tensor self, int[1] dim=[], bool keepdim=False) -> Tensor
474
+ inspec=[
475
+ InPosArg(ArgType.Tensor, name="self"),
476
+ InPosArg(
477
+ ArgType.DimList,
478
+ name="dim",
479
+ deps=[0],
480
+ constraints=[
481
+ cp.Length.Ge(lambda deps: 1 if deps[0].numel() == 0 else 0),
482
+ cp.Value.Gen(
483
+ lambda deps, length: (
484
+ fn.valid_dim_list_non_zero_size(deps[0], length),
485
+ fn.invalid_dim_list_non_zero_size(deps[0], length),
486
+ )
487
+ ),
488
+ ],
489
+ ),
490
+ InPosArg(ArgType.Bool, name="keepdim"),
491
+ ],
492
+ outspec=[
493
+ OutArg(ArgType.Tensor),
494
+ ],
495
+ ),
496
+ Spec(
497
+ op="amin.default", # (Tensor self, int[1] dim=[], bool keepdim=False) -> Tensor
498
+ inspec=[
499
+ InPosArg(ArgType.Tensor, name="self"),
500
+ InPosArg(
501
+ ArgType.DimList,
502
+ name="dim",
503
+ deps=[0],
504
+ constraints=[
505
+ cp.Length.Ge(lambda deps: 1 if deps[0].numel() == 0 else 0),
506
+ cp.Value.Gen(
507
+ lambda deps, length: (
508
+ fn.valid_dim_list_non_zero_size(deps[0], length),
509
+ fn.invalid_dim_list_non_zero_size(deps[0], length),
510
+ )
511
+ ),
512
+ ],
513
+ ),
514
+ InPosArg(ArgType.Bool, name="keepdim"),
515
+ ],
516
+ outspec=[
517
+ OutArg(ArgType.Tensor),
518
+ ],
519
+ ),
520
+ Spec(
521
+ op="any.default", # (Tensor self) -> Tensor
522
+ inspec=[
523
+ InPosArg(ArgType.Tensor, name="self"),
524
+ ],
525
+ outspec=[
526
+ OutArg(
527
+ ArgType.Tensor,
528
+ constraints=[
529
+ cp.Dtype.In(lambda deps: [torch.bool, torch.uint8]),
530
+ ],
531
+ ),
532
+ ],
533
+ ),
534
+ Spec(
535
+ op="any.dim", # (Tensor self, int dim, bool keepdim=False) -> Tensor
536
+ inspec=[
537
+ InPosArg(ArgType.Tensor, name="self"),
538
+ InPosArg(
539
+ ArgType.Dim,
540
+ name="dim",
541
+ deps=[0],
542
+ constraints=DimDefault,
543
+ ),
544
+ InPosArg(ArgType.Bool, name="keepdim"),
545
+ ],
546
+ outspec=[
547
+ OutArg(
548
+ ArgType.Tensor,
549
+ constraints=[
550
+ cp.Dtype.In(lambda deps: [torch.bool, torch.uint8]),
551
+ ],
552
+ ),
553
+ ],
554
+ ),
555
+ Spec(
556
+ op="any.dims", # (Tensor self, int[]? dim=None, bool keepdim=False) -> Tensor
557
+ inspec=[
558
+ InPosArg(ArgType.Tensor, name="self"),
559
+ InPosArg(
560
+ ArgType.DimListOpt,
561
+ name="dim",
562
+ deps=[0],
563
+ constraints=DimListDefault,
564
+ ),
565
+ InPosArg(ArgType.Bool, name="keepdim"),
566
+ ],
567
+ outspec=[
568
+ OutArg(
569
+ ArgType.Tensor,
570
+ constraints=[
571
+ cp.Dtype.In(lambda deps: [torch.bool, torch.uint8]),
572
+ ],
573
+ ),
574
+ ],
575
+ ),
576
+ Spec( # TODO(mcandales): Calibrate.
577
+ op="arange.default", # (Scalar end, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
578
+ inspec=[
579
+ InPosArg(
580
+ ArgType.Scalar,
581
+ name="end",
582
+ constraints=[
583
+ cp.Value.Ge(lambda deps, dtype: 0),
584
+ cp.Value.NotIn(lambda deps, dtype: [float("-inf"), float("inf")]),
585
+ ],
586
+ ),
587
+ InKwArg(
588
+ ArgType.ScalarTypeOpt,
589
+ name="dtype",
590
+ constraints=[
591
+ cp.Value.Ne(lambda deps: torch.bool),
592
+ ],
593
+ ),
594
+ ],
595
+ outspec=[
596
+ OutArg(ArgType.Tensor),
597
+ ],
598
+ ),
599
+ Spec( # TODO(mcandales): Calibrate.
600
+ op="arange.start_step", # (Scalar start, Scalar end, Scalar step=1, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
601
+ inspec=[
602
+ InPosArg(
603
+ ArgType.Scalar,
604
+ name="start",
605
+ constraints=[
606
+ cp.Value.NotIn(lambda deps, dtype: [float("-inf"), float("inf")]),
607
+ ],
608
+ ),
609
+ InPosArg(
610
+ ArgType.Scalar,
611
+ name="end",
612
+ constraints=[
613
+ cp.Value.NotIn(lambda deps, dtype: [float("-inf"), float("inf")]),
614
+ ],
615
+ ),
616
+ InPosArg(
617
+ ArgType.Scalar,
618
+ name="step",
619
+ deps=[0, 1],
620
+ constraints=[
621
+ cp.Value.Gt(lambda deps, dtype: 0 if deps[0] < deps[1] else None),
622
+ cp.Value.Lt(lambda deps, dtype: 0 if deps[0] > deps[1] else None),
623
+ ],
624
+ ),
625
+ InKwArg(
626
+ ArgType.ScalarTypeOpt,
627
+ name="dtype",
628
+ constraints=[
629
+ cp.Value.Ne(lambda deps: torch.bool),
630
+ ],
631
+ ),
632
+ ],
633
+ outspec=[
634
+ OutArg(ArgType.Tensor),
635
+ ],
636
+ ),
637
+ Spec( # TODO(mcandales): Calibrate.
638
+ op="argmax.default", # (Tensor self, int? dim=None, bool keepdim=False) -> Tensor
639
+ inspec=[
640
+ InPosArg(
641
+ ArgType.Tensor,
642
+ name="self",
643
+ constraints=[
644
+ cp.Dtype.Ne(lambda deps: torch.bool),
645
+ ],
646
+ ),
647
+ InPosArg(
648
+ ArgType.DimOpt,
649
+ name="dim",
650
+ deps=[0],
651
+ constraints=[
652
+ cp.Optional.Eq(
653
+ lambda deps: False if deps[0].numel() == 0 else None
654
+ ),
655
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
656
+ ],
657
+ ),
658
+ InPosArg(ArgType.Bool, name="keepdim"),
659
+ ],
660
+ outspec=[
661
+ OutArg(ArgType.Tensor),
662
+ ],
663
+ ),
664
+ Spec( # TODO(mcandales): Calibrate.
665
+ op="argmin.default", # (Tensor self, int? dim=None, bool keepdim=False) -> Tensor
666
+ inspec=[
667
+ InPosArg(
668
+ ArgType.Tensor,
669
+ name="self",
670
+ constraints=[
671
+ # TODO(mcandales): Enable self-context
672
+ # cp.Dtype.Ne(lambda deps, ctx: torch.bool if not ctx.Empty else None),
673
+ cp.Dtype.Ne(lambda deps: torch.bool),
674
+ ],
675
+ ),
676
+ InPosArg(
677
+ ArgType.DimOpt,
678
+ name="dim",
679
+ deps=[0],
680
+ constraints=[
681
+ cp.Optional.Eq(
682
+ lambda deps: False if deps[0].numel() == 0 else None
683
+ ),
684
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
685
+ ],
686
+ ),
687
+ InPosArg(ArgType.Bool, name="keepdim"),
688
+ ],
689
+ outspec=[
690
+ OutArg(ArgType.Tensor),
691
+ ],
692
+ ),
693
+ Spec( # TODO(mcandales) Implement numel constraint prefix
694
+ op="as_strided_copy.default", # (Tensor self, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor
695
+ inspec=[
696
+ InPosArg(
697
+ ArgType.Tensor,
698
+ name="self",
699
+ deps=[1, 2, 3],
700
+ constraints=[
701
+ cp.Rank.Ge(
702
+ lambda deps: (
703
+ 1
704
+ if fn.as_strided_min_numel(deps[0], deps[1], deps[2]) > 1
705
+ else 0
706
+ )
707
+ ),
708
+ cp.Size.Gen(
709
+ lambda deps, rank: (
710
+ fn.valid_as_strided_sizes(deps[0], deps[1], deps[2], rank),
711
+ fn.invalid_as_strided_sizes(
712
+ deps[0], deps[1], deps[2], rank
713
+ ),
714
+ )
715
+ ),
716
+ ],
717
+ ),
718
+ InPosArg(
719
+ ArgType.Shape,
720
+ name="size",
721
+ constraints=ShapeDefault,
722
+ ),
723
+ InPosArg(
724
+ ArgType.LengthList,
725
+ name="stride",
726
+ deps=[1],
727
+ constraints=[
728
+ cp.Length.Eq(lambda deps: len(deps[0])),
729
+ cp.Value.Ge(lambda deps, length, ix: 0),
730
+ ],
731
+ ),
732
+ InPosArg(
733
+ ArgType.LengthOpt,
734
+ name="storage_offset",
735
+ constraints=[
736
+ cp.Value.Ge(lambda deps: 0),
737
+ ],
738
+ ),
739
+ ],
740
+ outspec=[
741
+ OutArg(ArgType.Tensor),
742
+ ],
743
+ ),
744
+ Spec(
745
+ op="asin.default", # (Tensor self) -> Tensor
746
+ inspec=[
747
+ InPosArg(ArgType.Tensor, name="self"),
748
+ ],
749
+ outspec=[
750
+ OutArg(ArgType.Tensor),
751
+ ],
752
+ ),
753
+ Spec(
754
+ op="asinh.default", # (Tensor self) -> Tensor
755
+ inspec=[
756
+ InPosArg(ArgType.Tensor, name="self"),
757
+ ],
758
+ outspec=[
759
+ OutArg(ArgType.Tensor),
760
+ ],
761
+ ),
762
+ Spec(
763
+ op="atan.default", # (Tensor self) -> Tensor
764
+ inspec=[
765
+ InPosArg(ArgType.Tensor, name="self"),
766
+ ],
767
+ outspec=[
768
+ OutArg(ArgType.Tensor),
769
+ ],
770
+ ),
771
+ Spec(
772
+ op="atan2.default", # (Tensor self, Tensor other) -> Tensor
773
+ inspec=[
774
+ InPosArg(ArgType.Tensor, name="self"),
775
+ InPosArg(
776
+ ArgType.Tensor,
777
+ name="other",
778
+ deps=[0],
779
+ constraints=[
780
+ cp.Size.In(
781
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
782
+ ),
783
+ ],
784
+ ),
785
+ ],
786
+ outspec=[
787
+ OutArg(
788
+ ArgType.Tensor,
789
+ constraints=[
790
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
791
+ cp.Dtype.In(
792
+ lambda deps: dt.can_cast_from(
793
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
794
+ )
795
+ ),
796
+ ],
797
+ )
798
+ ],
799
+ ),
800
+ Spec(
801
+ op="atanh.default", # (Tensor self) -> Tensor
802
+ inspec=[
803
+ InPosArg(ArgType.Tensor, name="self"),
804
+ ],
805
+ outspec=[
806
+ OutArg(ArgType.Tensor),
807
+ ],
808
+ ),
809
+ Spec( # TODO(mcandales) Add input constraints to ensure valid output shape
810
+ op="avg_pool2d.default", # (Tensor self, int[2] kernel_size, int[2] stride=[], int[2] padding=0, bool ceil_mode=False, bool count_include_pad=True, int? divisor_override=None) -> Tensor
811
+ inspec=[
812
+ InPosArg( # self
813
+ ArgType.Tensor,
814
+ name="self",
815
+ deps=[1, 2, 3, 4],
816
+ constraints=[
817
+ cp.Dtype.In(lambda deps: dt._floating + [torch.long]),
818
+ cp.Rank.In(lambda deps: [3, 4]),
819
+ cp.Size.Ge(
820
+ lambda deps, r, d: fn.pool_input_size_min(
821
+ 2, deps[0], deps[1], deps[2], [], deps[3], r, d
822
+ )
823
+ ),
824
+ ],
825
+ ),
826
+ InPosArg( # kernel_size
827
+ ArgType.LengthList,
828
+ name="kernel_size",
829
+ constraints=[
830
+ cp.Length.In(lambda deps: [1, 2]),
831
+ cp.Value.Ge(lambda deps, length, ix: 1),
832
+ ],
833
+ ),
834
+ InPosArg( # stride
835
+ ArgType.LengthList,
836
+ name="stride",
837
+ constraints=[
838
+ cp.Length.In(lambda deps: [0, 1, 2]),
839
+ cp.Value.Ge(lambda deps, length, ix: 1),
840
+ ],
841
+ ),
842
+ InPosArg( # padding
843
+ ArgType.LengthList,
844
+ name="padding",
845
+ deps=[1],
846
+ constraints=[
847
+ cp.Length.In(lambda deps: [1, 2]),
848
+ cp.Value.Ge(lambda deps, length, ix: 0),
849
+ cp.Value.Le(
850
+ lambda deps, length, ix: fn.pool_padding_max(
851
+ deps[0], length, ix
852
+ )
853
+ ),
854
+ ],
855
+ ),
856
+ InPosArg(ArgType.Bool, name="ceil_mode"), # ceil_mode
857
+ InPosArg(ArgType.Bool, name="count_include_pad"), # count_include_pad
858
+ InPosArg( # divisor_override
859
+ ArgType.IntOpt,
860
+ name="divisor_override",
861
+ constraints=[
862
+ cp.Value.Ne(lambda deps: 0),
863
+ ],
864
+ ),
865
+ ],
866
+ outspec=[
867
+ OutArg(ArgType.Tensor),
868
+ ],
869
+ ),
870
+ Spec(
871
+ op="bitwise_and.Scalar", # (Tensor self, Scalar other) -> Tensor
872
+ inspec=[
873
+ InPosArg(
874
+ ArgType.Tensor,
875
+ name="self",
876
+ constraints=[
877
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
878
+ ],
879
+ ),
880
+ InPosArg(
881
+ ArgType.Scalar,
882
+ name="other",
883
+ constraints=[
884
+ cp.Dtype.In(lambda deps: [ScalarDtype.bool, ScalarDtype.int]),
885
+ ],
886
+ ),
887
+ ],
888
+ outspec=[
889
+ OutArg(ArgType.Tensor),
890
+ ],
891
+ ),
892
+ Spec(
893
+ op="bitwise_and.Tensor", # (Tensor self, Tensor other) -> Tensor
894
+ inspec=[
895
+ InPosArg(
896
+ ArgType.Tensor,
897
+ name="self",
898
+ constraints=[
899
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
900
+ ],
901
+ ),
902
+ InPosArg(
903
+ ArgType.Tensor,
904
+ name="other",
905
+ deps=[0],
906
+ constraints=[
907
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
908
+ cp.Size.In(
909
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
910
+ ),
911
+ ],
912
+ ),
913
+ ],
914
+ outspec=[
915
+ OutArg(ArgType.Tensor),
916
+ ],
917
+ ),
918
+ Spec(
919
+ op="bitwise_not.default", # (Tensor self) -> Tensor
920
+ inspec=[
921
+ InPosArg(
922
+ ArgType.Tensor,
923
+ name="self",
924
+ constraints=[
925
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
926
+ ],
927
+ ),
928
+ ],
929
+ outspec=[
930
+ OutArg(ArgType.Tensor),
931
+ ],
932
+ ),
933
+ Spec(
934
+ op="bitwise_or.Scalar", # (Tensor self, Scalar other) -> Tensor
935
+ inspec=[
936
+ InPosArg(
937
+ ArgType.Tensor,
938
+ name="self",
939
+ constraints=[
940
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
941
+ ],
942
+ ),
943
+ InPosArg(
944
+ ArgType.Scalar,
945
+ name="other",
946
+ constraints=[
947
+ cp.Dtype.In(lambda deps: [ScalarDtype.bool, ScalarDtype.int]),
948
+ ],
949
+ ),
950
+ ],
951
+ outspec=[
952
+ OutArg(ArgType.Tensor),
953
+ ],
954
+ ),
955
+ Spec(
956
+ op="bitwise_or.Tensor", # (Tensor self, Tensor other) -> Tensor
957
+ inspec=[
958
+ InPosArg(
959
+ ArgType.Tensor,
960
+ name="self",
961
+ constraints=[
962
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
963
+ ],
964
+ ),
965
+ InPosArg(
966
+ ArgType.Tensor,
967
+ name="other",
968
+ deps=[0],
969
+ constraints=[
970
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
971
+ cp.Size.In(
972
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
973
+ ),
974
+ ],
975
+ ),
976
+ ],
977
+ outspec=[
978
+ OutArg(ArgType.Tensor),
979
+ ],
980
+ ),
981
+ Spec(
982
+ op="bitwise_xor.Scalar", # (Tensor self, Scalar other) -> Tensor
983
+ inspec=[
984
+ InPosArg(
985
+ ArgType.Tensor,
986
+ name="self",
987
+ constraints=[
988
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
989
+ ],
990
+ ),
991
+ InPosArg(
992
+ ArgType.Scalar,
993
+ name="other",
994
+ constraints=[
995
+ cp.Dtype.In(lambda deps: [ScalarDtype.bool, ScalarDtype.int]),
996
+ ],
997
+ ),
998
+ ],
999
+ outspec=[
1000
+ OutArg(ArgType.Tensor),
1001
+ ],
1002
+ ),
1003
+ Spec(
1004
+ op="bitwise_xor.Tensor", # (Tensor self, Tensor other) -> Tensor
1005
+ inspec=[
1006
+ InPosArg(
1007
+ ArgType.Tensor,
1008
+ name="self",
1009
+ constraints=[
1010
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
1011
+ ],
1012
+ ),
1013
+ InPosArg(
1014
+ ArgType.Tensor,
1015
+ name="other",
1016
+ deps=[0],
1017
+ constraints=[
1018
+ cp.Dtype.In(lambda deps: dt._int_and_bool),
1019
+ cp.Size.In(
1020
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1021
+ ),
1022
+ ],
1023
+ ),
1024
+ ],
1025
+ outspec=[
1026
+ OutArg(ArgType.Tensor),
1027
+ ],
1028
+ ),
1029
+ Spec( # TODO(mcandales): Calibrate.
1030
+ op="bmm.default", # (Tensor self, Tensor mat2) -> Tensor
1031
+ inspec=[
1032
+ InPosArg(
1033
+ ArgType.Tensor,
1034
+ name="self",
1035
+ constraints=[
1036
+ cp.Dtype.Ne(lambda deps: torch.bool),
1037
+ cp.Rank.Eq(lambda deps: 3),
1038
+ ],
1039
+ ),
1040
+ InPosArg(
1041
+ ArgType.Tensor,
1042
+ name="mat2",
1043
+ deps=[0],
1044
+ constraints=[
1045
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1046
+ cp.Rank.Eq(lambda deps: 3),
1047
+ cp.Size.Eq(lambda deps, r, d: fn.bmm_mat2_size_eq(deps[0], d)),
1048
+ ],
1049
+ ),
1050
+ ],
1051
+ outspec=[
1052
+ OutArg(ArgType.Tensor),
1053
+ ],
1054
+ ),
1055
+ Spec(
1056
+ op="ceil.default", # (Tensor self) -> Tensor
1057
+ inspec=[
1058
+ InPosArg(
1059
+ ArgType.Tensor,
1060
+ name="self",
1061
+ constraints=[
1062
+ cp.Dtype.Ne(lambda deps: torch.bool),
1063
+ ],
1064
+ ),
1065
+ ],
1066
+ outspec=[OutArg(ArgType.Tensor)],
1067
+ ),
1068
+ Spec(
1069
+ op="clamp.default", # (Tensor self, Scalar? min=None, Scalar? max=None) -> Tensor
1070
+ inspec=[
1071
+ InPosArg(ArgType.Tensor, name="self"),
1072
+ InPosArg(ArgType.ScalarOpt, name="min"),
1073
+ InPosArg(
1074
+ ArgType.ScalarOpt,
1075
+ name="max",
1076
+ deps=[0, 1],
1077
+ constraints=[
1078
+ cp.Optional.Eq(
1079
+ lambda deps: fn.clamp_max_is_optional(deps[0], deps[1])
1080
+ ),
1081
+ cp.Dtype.Ne(
1082
+ lambda deps: fn.dt_to_st(
1083
+ fn.clamp_max_ne_dtype(deps[0], deps[1])
1084
+ )
1085
+ ),
1086
+ ],
1087
+ ),
1088
+ ],
1089
+ outspec=[
1090
+ OutArg(
1091
+ ArgType.Tensor,
1092
+ constraints=[
1093
+ cp.Dtype.Eq(
1094
+ lambda deps: fn.promote_type_with_opt_scalar(
1095
+ fn.promote_type_with_opt_scalar(deps[0].dtype, deps[1]),
1096
+ deps[2],
1097
+ )
1098
+ ),
1099
+ ],
1100
+ )
1101
+ ],
1102
+ ),
1103
+ Spec(
1104
+ op="clamp.Tensor", # (Tensor self, Tensor? min=None, Tensor? max=None) -> Tensor
1105
+ inspec=[
1106
+ InPosArg(ArgType.Tensor, name="self"),
1107
+ InPosArg(
1108
+ ArgType.TensorOpt,
1109
+ name="min",
1110
+ deps=[0],
1111
+ constraints=[
1112
+ cp.Size.In(
1113
+ lambda deps, r, d: (fn.broadcast_with(deps[0].shape, r, d))
1114
+ ),
1115
+ ],
1116
+ ),
1117
+ InPosArg(
1118
+ ArgType.TensorOpt,
1119
+ name="max",
1120
+ deps=[0, 1],
1121
+ constraints=[
1122
+ cp.Optional.Eq(lambda deps: False if deps[1] is None else True),
1123
+ cp.Size.In(
1124
+ lambda deps, r, d: fn.broadcast_with(
1125
+ (
1126
+ fn.broadcasted_shape(deps[0].shape, deps[1].shape)
1127
+ if deps[1] is not None
1128
+ else deps[0].shape
1129
+ ),
1130
+ r,
1131
+ d,
1132
+ )
1133
+ ),
1134
+ ],
1135
+ ),
1136
+ ],
1137
+ outspec=[
1138
+ OutArg(
1139
+ ArgType.Tensor,
1140
+ constraints=[
1141
+ cp.Dtype.In(
1142
+ lambda deps: dt.can_cast_from(
1143
+ torch.promote_types(
1144
+ torch.promote_types(
1145
+ deps[0].dtype,
1146
+ (
1147
+ deps[1].dtype
1148
+ if deps[1] is not None
1149
+ else deps[0].dtype
1150
+ ),
1151
+ ),
1152
+ deps[2].dtype if deps[2] is not None else deps[0].dtype,
1153
+ )
1154
+ )
1155
+ ),
1156
+ ],
1157
+ )
1158
+ ],
1159
+ ),
1160
+ Spec(
1161
+ op="clone.default", # (Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
1162
+ inspec=[
1163
+ InPosArg(ArgType.Tensor, name="self"),
1164
+ InKwArg(
1165
+ ArgType.MemoryFormat,
1166
+ name="memory_format",
1167
+ constraints=MemoryFormatDefault,
1168
+ ),
1169
+ ],
1170
+ outspec=[
1171
+ OutArg(ArgType.Tensor),
1172
+ ],
1173
+ ),
1174
+ Spec( # TODO(mcandales): Calibrate.
1175
+ op="constant_pad_nd.default", # (Tensor self, SymInt[] pad, Scalar value=0) -> Tensor
1176
+ inspec=[
1177
+ InPosArg(ArgType.Tensor, name="self"),
1178
+ InPosArg(
1179
+ ArgType.LengthList,
1180
+ name="pad",
1181
+ deps=[0],
1182
+ constraints=[
1183
+ cp.Length.In(
1184
+ lambda deps: [2 * i for i in range(deps[0].dim() + 1)]
1185
+ ),
1186
+ ],
1187
+ ),
1188
+ InPosArg(
1189
+ ArgType.Scalar,
1190
+ name="value",
1191
+ deps=[0],
1192
+ constraints=[
1193
+ cp.Value.Ge(
1194
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
1195
+ ),
1196
+ cp.Value.Le(
1197
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
1198
+ ),
1199
+ ],
1200
+ ),
1201
+ ],
1202
+ outspec=[
1203
+ OutArg(ArgType.Tensor),
1204
+ ],
1205
+ ),
1206
+ Spec( # TODO(mcandales): Calibrate.
1207
+ op="convolution.default", # (Tensor input, Tensor weight, Tensor? bias, int[] stride, SymInt[] padding, int[] dilation, bool transposed, SymInt[] output_padding, int groups) -> Tensor
1208
+ inspec=[
1209
+ InPosArg( # input
1210
+ ArgType.Tensor,
1211
+ name="input",
1212
+ deps=[1, 3, 4, 5, 6, 7, 8],
1213
+ constraints=[
1214
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1215
+ cp.Rank.Eq(lambda deps: deps[0].dim()),
1216
+ cp.Size.Eq(
1217
+ lambda deps, r, d: fn.conv_input_size_eq(
1218
+ deps[0], deps[4], deps[6], d
1219
+ )
1220
+ ),
1221
+ cp.Size.Ge(
1222
+ lambda deps, r, d: fn.conv_input_size_min(
1223
+ deps[0], deps[1], deps[2], deps[3], deps[4], deps[5], d
1224
+ )
1225
+ ),
1226
+ ],
1227
+ ),
1228
+ InPosArg( # weight
1229
+ ArgType.Tensor,
1230
+ name="weight",
1231
+ deps=[6],
1232
+ constraints=[
1233
+ cp.Dtype.In(
1234
+ lambda deps: dt._floating
1235
+ ), # TODO(mcandales): Calibrate.
1236
+ cp.Rank.Ge(lambda deps: 3),
1237
+ cp.Rank.Le(lambda deps: 5),
1238
+ cp.Size.Ge(lambda deps, r, d: 0 if (d == 1 and not deps[0]) else 1),
1239
+ # TODO(mcandales): Executorch specific constraint
1240
+ # cp.Rank.In(lambda deps: [3, 4]),
1241
+ ],
1242
+ ),
1243
+ InPosArg( # bias
1244
+ ArgType.TensorOpt,
1245
+ name="bias",
1246
+ deps=[1, 6, 8],
1247
+ constraints=[
1248
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1249
+ # cp.Dtype.In(
1250
+ # lambda deps: [deps[0].dtype] if deps[1] else dt._floating
1251
+ # ), # TODO(mcandales): Calibrate.
1252
+ cp.Rank.Eq(lambda deps: 1),
1253
+ cp.Size.Eq(
1254
+ lambda deps, r, d: fn.conv_bias_size_eq(
1255
+ deps[0], deps[1], deps[2]
1256
+ )
1257
+ ),
1258
+ ],
1259
+ ),
1260
+ InPosArg( # stride
1261
+ ArgType.LengthList,
1262
+ name="stride",
1263
+ deps=[1],
1264
+ constraints=[
1265
+ cp.Length.In(lambda deps: list({1, deps[0].dim() - 2})),
1266
+ cp.Value.Ge(lambda deps, length, ix: 1),
1267
+ ],
1268
+ ),
1269
+ InPosArg( # padding
1270
+ ArgType.LengthList,
1271
+ name="padding",
1272
+ deps=[1],
1273
+ constraints=[
1274
+ cp.Length.In(lambda deps: list({1, deps[0].dim() - 2})),
1275
+ cp.Value.Ge(lambda deps, length, ix: 0),
1276
+ ],
1277
+ ),
1278
+ InPosArg( # dilation
1279
+ ArgType.LengthList,
1280
+ name="dilation",
1281
+ deps=[1],
1282
+ constraints=[
1283
+ cp.Length.In(lambda deps: list({1, deps[0].dim() - 2})),
1284
+ cp.Value.Ge(lambda deps, length, ix: 1),
1285
+ ],
1286
+ ),
1287
+ InPosArg(ArgType.Bool, name="transposed"),
1288
+ InPosArg( # output_padding
1289
+ ArgType.LengthList,
1290
+ name="output_padding",
1291
+ deps=[1, 3, 5, 6],
1292
+ constraints=[
1293
+ cp.Length.In(lambda deps: list({1, deps[0].dim() - 2})),
1294
+ cp.Value.Ge(lambda deps, length, ix: 0),
1295
+ cp.Value.Le(
1296
+ lambda deps, length, ix: fn.conv_output_padding_max(
1297
+ deps[1], deps[2], deps[3], length, ix
1298
+ )
1299
+ ),
1300
+ ],
1301
+ ),
1302
+ InPosArg( # groups
1303
+ ArgType.Int,
1304
+ name="groups",
1305
+ deps=[1],
1306
+ constraints=[
1307
+ cp.Value.In(
1308
+ lambda deps: [
1309
+ d
1310
+ for d in range(1, fn.safe_size(deps[0], 0) + 1)
1311
+ if fn.safe_size(deps[0], 0) % d == 0
1312
+ ]
1313
+ ),
1314
+ ],
1315
+ ),
1316
+ ],
1317
+ outspec=[
1318
+ OutArg(
1319
+ ArgType.Tensor,
1320
+ constraints=[
1321
+ cp.Dtype.Eq(
1322
+ lambda deps: deps[0].dtype,
1323
+ ),
1324
+ ],
1325
+ )
1326
+ ],
1327
+ ),
1328
+ Spec(
1329
+ op="copy.default", # (Tensor self, Tensor src, bool non_blocking=False) -> Tensor
1330
+ inspec=[
1331
+ InPosArg(ArgType.Tensor, name="self"),
1332
+ InPosArg(
1333
+ ArgType.Tensor,
1334
+ name="src",
1335
+ deps=[0],
1336
+ constraints=[
1337
+ cp.Rank.Le(lambda deps: deps[0].dim()),
1338
+ cp.Size.In(lambda deps, r, d: fn.broadcast_to(deps[0].shape, r, d)),
1339
+ ],
1340
+ ),
1341
+ InPosArg(
1342
+ ArgType.Bool,
1343
+ name="non_blocking",
1344
+ # TODO(mcandales): Executorch specific constraint
1345
+ # constraints=[cp.Value.In(lambda deps: [False])],
1346
+ ),
1347
+ ],
1348
+ outspec=[
1349
+ OutArg(ArgType.Tensor),
1350
+ ],
1351
+ ),
1352
+ Spec(
1353
+ op="cos.default", # (Tensor self) -> Tensor
1354
+ inspec=[
1355
+ InPosArg(ArgType.Tensor, name="self"),
1356
+ ],
1357
+ outspec=[OutArg(ArgType.Tensor)],
1358
+ ),
1359
+ Spec(
1360
+ op="cosh.default", # (Tensor self) -> Tensor
1361
+ inspec=[
1362
+ InPosArg(ArgType.Tensor, name="self"),
1363
+ ],
1364
+ outspec=[OutArg(ArgType.Tensor)],
1365
+ ),
1366
+ Spec( # TODO(mcandales): Calibrate.
1367
+ op="cumsum.default", # (Tensor self, int dim, *, ScalarType? dtype=None) -> Tensor
1368
+ inspec=[
1369
+ InPosArg(ArgType.Tensor, name="self"),
1370
+ InPosArg(
1371
+ ArgType.Dim,
1372
+ name="dim",
1373
+ deps=[0],
1374
+ constraints=DimDefault,
1375
+ ),
1376
+ InKwArg(
1377
+ ArgType.ScalarTypeOpt,
1378
+ name="dtype",
1379
+ deps=[0],
1380
+ constraints=[
1381
+ cp.Value.Ne(
1382
+ lambda deps: (
1383
+ torch.bool
1384
+ if deps[0].dim() > 0 and deps[0].numel() > 0
1385
+ else None
1386
+ )
1387
+ ),
1388
+ ],
1389
+ ),
1390
+ ],
1391
+ outspec=[
1392
+ OutArg(ArgType.Tensor),
1393
+ ],
1394
+ ),
1395
+ Spec(
1396
+ op="detach_copy.default", # (Tensor self) -> Tensor
1397
+ inspec=[
1398
+ InPosArg(ArgType.Tensor, name="self"),
1399
+ ],
1400
+ outspec=[OutArg(ArgType.Tensor)],
1401
+ ),
1402
+ Spec(
1403
+ op="diagonal_copy.default", # (Tensor self, int offset=0, int dim1=0, int dim2=1) -> Tensor
1404
+ inspec=[
1405
+ InPosArg(
1406
+ ArgType.Tensor,
1407
+ name="self",
1408
+ constraints=[
1409
+ cp.Rank.Ge(lambda deps: 2),
1410
+ ],
1411
+ ),
1412
+ InPosArg(ArgType.Int, name="offset"),
1413
+ InPosArg(
1414
+ ArgType.Dim,
1415
+ name="dim1",
1416
+ deps=[0],
1417
+ constraints=DimDefault,
1418
+ ),
1419
+ InPosArg(
1420
+ ArgType.Dim,
1421
+ name="dim2",
1422
+ deps=[0, 2],
1423
+ constraints=DimDefault
1424
+ + [
1425
+ cp.Value.Ne(lambda deps: fn.normalize(deps[1], deps[0].dim())),
1426
+ cp.Value.Ne(
1427
+ lambda deps: fn.normalize(deps[1], deps[0].dim())
1428
+ - deps[0].dim()
1429
+ ),
1430
+ ],
1431
+ ),
1432
+ ],
1433
+ outspec=[
1434
+ OutArg(
1435
+ ArgType.Tensor,
1436
+ constraints=[
1437
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1438
+ ],
1439
+ )
1440
+ ],
1441
+ ),
1442
+ Spec(
1443
+ op="div.Scalar", # (Tensor self, Scalar other) -> Tensor
1444
+ inspec=[
1445
+ InPosArg(ArgType.Tensor, name="self"),
1446
+ InPosArg(ArgType.Scalar, name="other"),
1447
+ ],
1448
+ outspec=[
1449
+ OutArg(
1450
+ ArgType.Tensor,
1451
+ constraints=[
1452
+ cp.Dtype.Eq(
1453
+ lambda deps: (
1454
+ deps[0].dtype
1455
+ if deps[0].dtype in dt._floating
1456
+ else torch.float32
1457
+ )
1458
+ ),
1459
+ ],
1460
+ )
1461
+ ],
1462
+ ),
1463
+ Spec(
1464
+ op="div.Scalar_mode", # (Tensor self, Scalar other, *, str? rounding_mode) -> Tensor
1465
+ inspec=[
1466
+ InPosArg(ArgType.Tensor, name="self"),
1467
+ InPosArg(
1468
+ ArgType.Scalar,
1469
+ name="other",
1470
+ deps=[0, 2],
1471
+ constraints=[
1472
+ cp.Dtype.Ne(
1473
+ lambda deps: (
1474
+ ScalarDtype.bool if deps[0].dtype == torch.bool else None
1475
+ )
1476
+ ),
1477
+ cp.Value.Ne(
1478
+ lambda deps, dtype: (
1479
+ 0
1480
+ if deps[0].numel() > 0
1481
+ and deps[1] is not None
1482
+ and fn.promote_type_with_scalar_dtype(deps[0].dtype, dtype)
1483
+ not in dt._floating
1484
+ else None
1485
+ )
1486
+ ),
1487
+ ],
1488
+ ),
1489
+ InKwArg(
1490
+ ArgType.StringOpt,
1491
+ name="rounding_mode",
1492
+ constraints=[
1493
+ cp.Value.In(lambda deps: ["trunc", "floor"]),
1494
+ ],
1495
+ ),
1496
+ ],
1497
+ outspec=[
1498
+ OutArg(
1499
+ ArgType.Tensor,
1500
+ constraints=[
1501
+ cp.Dtype.Eq(
1502
+ lambda deps: (
1503
+ fn.promote_type_with_scalar(deps[0].dtype, deps[1])
1504
+ )
1505
+ ),
1506
+ ],
1507
+ )
1508
+ ],
1509
+ ),
1510
+ Spec(
1511
+ op="div.Tensor", # (Tensor self, Tensor other) -> Tensor
1512
+ inspec=[
1513
+ InPosArg(ArgType.Tensor, name="self"),
1514
+ InPosArg(
1515
+ ArgType.Tensor,
1516
+ name="other",
1517
+ deps=[0],
1518
+ constraints=[
1519
+ cp.Size.In(
1520
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1521
+ ),
1522
+ ],
1523
+ ),
1524
+ ],
1525
+ outspec=[
1526
+ OutArg(
1527
+ ArgType.Tensor,
1528
+ constraints=[
1529
+ cp.Dtype.In(lambda deps: dt._floating),
1530
+ ],
1531
+ ),
1532
+ ],
1533
+ ),
1534
+ Spec(
1535
+ op="div.Tensor_mode", # (Tensor self, Tensor other, *, str? rounding_mode) -> Tensor
1536
+ inspec=[
1537
+ InPosArg(ArgType.Tensor, name="self"),
1538
+ InPosArg(
1539
+ ArgType.Tensor,
1540
+ name="other",
1541
+ deps=[0, 2],
1542
+ constraints=[
1543
+ cp.Dtype.Ne(
1544
+ lambda deps: torch.bool if deps[0].dtype == torch.bool else None
1545
+ ),
1546
+ cp.Size.In(
1547
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1548
+ ),
1549
+ cp.Value.Ne(
1550
+ lambda deps, dtype, struct: (
1551
+ 0
1552
+ if (deps[0].numel() > 0 and math.prod(struct) > 0)
1553
+ and deps[1] is not None
1554
+ and torch.promote_types(deps[0].dtype, dtype)
1555
+ not in dt._floating
1556
+ else None
1557
+ )
1558
+ ),
1559
+ ],
1560
+ ),
1561
+ InKwArg(
1562
+ ArgType.StringOpt,
1563
+ name="rounding_mode",
1564
+ constraints=[
1565
+ cp.Value.In(lambda deps: ["trunc", "floor"]),
1566
+ ],
1567
+ ),
1568
+ ],
1569
+ outspec=[
1570
+ OutArg(
1571
+ ArgType.Tensor,
1572
+ constraints=[
1573
+ cp.Dtype.In(
1574
+ lambda deps: dt.can_cast_from(
1575
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
1576
+ )
1577
+ ),
1578
+ ],
1579
+ ),
1580
+ ],
1581
+ ),
1582
+ Spec( # TODO(mcandales): Calibrate.
1583
+ op="embedding.default", # (Tensor weight, Tensor indices, SymInt padding_idx=-1, bool scale_grad_by_freq=False, bool sparse=False) -> Tensor
1584
+ inspec=[
1585
+ InPosArg(
1586
+ ArgType.Tensor,
1587
+ name="weight",
1588
+ constraints=[
1589
+ cp.Rank.Eq(lambda deps: 2),
1590
+ cp.Size.Ge(lambda deps, r, d: 1 if d == 0 else None),
1591
+ ],
1592
+ ),
1593
+ InPosArg(
1594
+ ArgType.Tensor,
1595
+ name="indices",
1596
+ deps=[0],
1597
+ constraints=[
1598
+ cp.Dtype.In(lambda deps: [torch.long, torch.int]),
1599
+ cp.Value.Ge(
1600
+ lambda deps, dtype, struct: 0 if math.prod(struct) > 0 else None
1601
+ ),
1602
+ cp.Value.Le(
1603
+ lambda deps, dtype, struct: (
1604
+ max(fn.safe_size(deps[0], 0) - 1, 0)
1605
+ if math.prod(struct) > 0
1606
+ else None
1607
+ )
1608
+ ),
1609
+ ],
1610
+ ),
1611
+ InPosArg(ArgType.Int, name="padding_idx"),
1612
+ InPosArg(ArgType.Bool, name="scale_grad_by_freq"),
1613
+ InPosArg(ArgType.Bool, name="sparse"),
1614
+ ],
1615
+ outspec=[
1616
+ OutArg(ArgType.Tensor),
1617
+ ],
1618
+ ),
1619
+ Spec(
1620
+ op="empty.memory_format", # (SymInt[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor
1621
+ inspec=[
1622
+ InPosArg(
1623
+ ArgType.Shape,
1624
+ name="size",
1625
+ constraints=ShapeDefault,
1626
+ ),
1627
+ InKwArg(
1628
+ ArgType.MemoryFormat,
1629
+ name="memory_format",
1630
+ constraints=MemoryFormatDefault,
1631
+ ),
1632
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
1633
+ ],
1634
+ outspec=[
1635
+ OutArg(ArgType.Tensor),
1636
+ ],
1637
+ ),
1638
+ Spec(
1639
+ op="eq.Scalar", # (Tensor self, Scalar other) -> Tensor
1640
+ inspec=[
1641
+ InPosArg(ArgType.Tensor, name="self"),
1642
+ InPosArg(ArgType.Scalar, name="other"),
1643
+ ],
1644
+ outspec=[OutArg(ArgType.Tensor)],
1645
+ ),
1646
+ Spec(
1647
+ op="eq.Tensor", # (Tensor self, Tensor other) -> Tensor
1648
+ inspec=[
1649
+ InPosArg(ArgType.Tensor, name="self"),
1650
+ InPosArg(
1651
+ ArgType.Tensor,
1652
+ name="other",
1653
+ deps=[0],
1654
+ constraints=[
1655
+ cp.Size.In(
1656
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1657
+ ),
1658
+ ],
1659
+ ),
1660
+ ],
1661
+ outspec=[OutArg(ArgType.Tensor)],
1662
+ ),
1663
+ Spec(
1664
+ op="erf.default", # (Tensor self) -> Tensor
1665
+ inspec=[
1666
+ InPosArg(ArgType.Tensor, name="self"),
1667
+ ],
1668
+ outspec=[OutArg(ArgType.Tensor)],
1669
+ ),
1670
+ Spec(
1671
+ op="exp.default", # (Tensor self) -> Tensor
1672
+ inspec=[
1673
+ InPosArg(ArgType.Tensor, name="self"),
1674
+ ],
1675
+ outspec=[OutArg(ArgType.Tensor)],
1676
+ ),
1677
+ Spec(
1678
+ op="expand_copy.default", # (Tensor self, SymInt[] size, *, bool implicit=False) -> Tensor
1679
+ inspec=[
1680
+ InPosArg(ArgType.Tensor, name="self"),
1681
+ InPosArg(
1682
+ ArgType.Shape,
1683
+ name="size",
1684
+ deps=[0],
1685
+ constraints=[
1686
+ cp.Length.Ge(lambda deps: deps[0].dim()),
1687
+ cp.Value.Ge(lambda deps, length, ix: -1),
1688
+ cp.Value.Ge(
1689
+ lambda deps, length, ix: (
1690
+ 0 if ix < length - deps[0].dim() else None
1691
+ )
1692
+ ),
1693
+ cp.Value.In(
1694
+ lambda deps, length, ix: fn.expand_copy_size_in(
1695
+ deps[0].shape, length, ix
1696
+ )
1697
+ ),
1698
+ ],
1699
+ ),
1700
+ InKwArg(
1701
+ ArgType.Bool,
1702
+ name="implicit",
1703
+ # TODO(mcandales): Executorch specific constraint
1704
+ # constraints=[cp.Value.In(lambda deps: [False])],
1705
+ ),
1706
+ ],
1707
+ outspec=[
1708
+ OutArg(ArgType.Tensor),
1709
+ ],
1710
+ ),
1711
+ Spec(
1712
+ op="expm1.default", # (Tensor self) -> Tensor
1713
+ inspec=[
1714
+ InPosArg(ArgType.Tensor, name="self"),
1715
+ ],
1716
+ outspec=[
1717
+ OutArg(
1718
+ ArgType.Tensor,
1719
+ constraints=[
1720
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
1721
+ cp.Dtype.In(lambda deps: dt.can_cast_from(deps[0].dtype)),
1722
+ ],
1723
+ )
1724
+ ],
1725
+ ),
1726
+ Spec(
1727
+ op="fill.Scalar", # (Tensor self, Scalar value) -> Tensor
1728
+ inspec=[
1729
+ InPosArg(ArgType.Tensor, name="self"),
1730
+ InPosArg(
1731
+ ArgType.Scalar,
1732
+ name="value",
1733
+ deps=[0],
1734
+ constraints=[
1735
+ cp.Value.Ge(
1736
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
1737
+ ),
1738
+ cp.Value.Le(
1739
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
1740
+ ),
1741
+ ],
1742
+ ),
1743
+ ],
1744
+ outspec=[
1745
+ OutArg(ArgType.Tensor),
1746
+ ],
1747
+ ),
1748
+ Spec(
1749
+ op="fill.Tensor", # (Tensor self, Tensor value) -> Tensor
1750
+ inspec=[
1751
+ InPosArg(ArgType.Tensor, name="self"),
1752
+ InPosArg(
1753
+ ArgType.Tensor,
1754
+ name="value",
1755
+ constraints=[
1756
+ cp.Rank.Eq(lambda deps: 0),
1757
+ ],
1758
+ ),
1759
+ ],
1760
+ outspec=[
1761
+ OutArg(ArgType.Tensor),
1762
+ ],
1763
+ ),
1764
+ Spec(
1765
+ op="flip.default", # (Tensor self, int[] dims) -> Tensor
1766
+ inspec=[
1767
+ InPosArg(ArgType.Tensor, name="self"),
1768
+ InPosArg(
1769
+ ArgType.DimList,
1770
+ name="dims",
1771
+ deps=[0],
1772
+ constraints=DimListDefault,
1773
+ ),
1774
+ ],
1775
+ outspec=[
1776
+ OutArg(
1777
+ ArgType.Tensor,
1778
+ constraints=[
1779
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1780
+ ],
1781
+ )
1782
+ ],
1783
+ ),
1784
+ Spec(
1785
+ op="floor.default", # (Tensor self) -> Tensor
1786
+ inspec=[
1787
+ InPosArg(
1788
+ ArgType.Tensor,
1789
+ name="self",
1790
+ constraints=[
1791
+ cp.Dtype.Ne(lambda deps: torch.bool),
1792
+ ],
1793
+ ),
1794
+ ],
1795
+ outspec=[OutArg(ArgType.Tensor)],
1796
+ ),
1797
+ Spec(
1798
+ op="floor_divide.default", # (Tensor self, Tensor other) -> Tensor
1799
+ inspec=[
1800
+ InPosArg(ArgType.Tensor, name="self"),
1801
+ InPosArg(
1802
+ ArgType.Tensor,
1803
+ name="other",
1804
+ deps=[0],
1805
+ constraints=[
1806
+ cp.Dtype.Ne(
1807
+ lambda deps: torch.bool if deps[0].dtype == torch.bool else None
1808
+ ),
1809
+ cp.Size.In(
1810
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1811
+ ),
1812
+ cp.Value.Ne(
1813
+ lambda deps, dtype, struct: (
1814
+ 0
1815
+ if (deps[0].numel() > 0 and math.prod(struct) > 0)
1816
+ and torch.promote_types(deps[0].dtype, dtype)
1817
+ not in dt._floating
1818
+ else None
1819
+ )
1820
+ ),
1821
+ ],
1822
+ ),
1823
+ ],
1824
+ outspec=[
1825
+ OutArg(ArgType.Tensor),
1826
+ ],
1827
+ ),
1828
+ Spec(
1829
+ op="fmod.Tensor", # (Tensor self, Tensor other) -> Tensor
1830
+ inspec=[
1831
+ InPosArg(ArgType.Tensor, name="self"),
1832
+ InPosArg(
1833
+ ArgType.Tensor,
1834
+ name="other",
1835
+ deps=[0],
1836
+ constraints=[
1837
+ cp.Dtype.Ne(
1838
+ lambda deps: torch.bool if deps[0].dtype == torch.bool else None
1839
+ ),
1840
+ cp.Size.In(
1841
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
1842
+ ),
1843
+ cp.Value.Ne(
1844
+ lambda deps, dtype, struct: (
1845
+ 0
1846
+ if (deps[0].numel() > 0 and math.prod(struct) > 0)
1847
+ and torch.promote_types(deps[0].dtype, dtype)
1848
+ not in dt._floating
1849
+ else None
1850
+ )
1851
+ ),
1852
+ ],
1853
+ ),
1854
+ ],
1855
+ outspec=[
1856
+ OutArg(ArgType.Tensor),
1857
+ ],
1858
+ ),
1859
+ Spec(
1860
+ op="fmod.Scalar", # (Tensor self, Scalar other) -> Tensor
1861
+ inspec=[
1862
+ InPosArg(ArgType.Tensor, name="self"),
1863
+ InPosArg(
1864
+ ArgType.Scalar,
1865
+ name="other",
1866
+ deps=[0],
1867
+ constraints=[
1868
+ cp.Dtype.Ne(
1869
+ lambda deps: (
1870
+ ScalarDtype.bool if deps[0].dtype == torch.bool else None
1871
+ )
1872
+ ),
1873
+ cp.Value.Ne(
1874
+ lambda deps, dtype: (
1875
+ 0
1876
+ if (
1877
+ deps[0].numel() > 0
1878
+ and fn.promote_type_with_scalar(deps[0].dtype, dtype)
1879
+ not in dt._floating
1880
+ )
1881
+ else None
1882
+ )
1883
+ ),
1884
+ ],
1885
+ ),
1886
+ ],
1887
+ outspec=[
1888
+ OutArg(ArgType.Tensor),
1889
+ ],
1890
+ ),
1891
+ Spec(
1892
+ op="full.default", # (SymInt[] size, Scalar fill_value, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
1893
+ inspec=[
1894
+ InPosArg(
1895
+ ArgType.Shape,
1896
+ name="size",
1897
+ constraints=ShapeDefault,
1898
+ ),
1899
+ InPosArg(
1900
+ ArgType.Scalar,
1901
+ name="fill_value",
1902
+ deps=[2],
1903
+ constraints=[
1904
+ cp.Value.Ge(lambda deps, dtype: fn.dtype_lower_bound(deps[0])),
1905
+ cp.Value.Le(lambda deps, dtype: fn.dtype_upper_bound(deps[0])),
1906
+ ],
1907
+ ),
1908
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
1909
+ ],
1910
+ outspec=[
1911
+ OutArg(ArgType.Tensor),
1912
+ ],
1913
+ ),
1914
+ Spec(
1915
+ op="full_like.default", # (Tensor self, Scalar fill_value, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor
1916
+ inspec=[
1917
+ InPosArg(ArgType.Tensor, name="self"),
1918
+ InPosArg(
1919
+ ArgType.Scalar,
1920
+ name="fill_value",
1921
+ deps=[0, 2],
1922
+ constraints=[
1923
+ cp.Value.Ge(
1924
+ lambda deps, dtype: fn.dtype_lower_bound(
1925
+ deps[0].dtype if deps[1] is None else deps[1]
1926
+ )
1927
+ ),
1928
+ cp.Value.Le(
1929
+ lambda deps, dtype: fn.dtype_upper_bound(
1930
+ deps[0].dtype if deps[1] is None else deps[1]
1931
+ )
1932
+ ),
1933
+ ],
1934
+ ),
1935
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
1936
+ InKwArg(
1937
+ ArgType.MemoryFormat,
1938
+ name="memory_format",
1939
+ constraints=MemoryFormatDefault,
1940
+ ),
1941
+ ],
1942
+ outspec=[
1943
+ OutArg(ArgType.Tensor),
1944
+ ],
1945
+ ),
1946
+ Spec( # TODO(mcandales): Calibrate.
1947
+ op="gather.default", # (Tensor self, int dim, Tensor index, *, bool sparse_grad=False) -> Tensor
1948
+ inspec=[
1949
+ InPosArg(ArgType.Tensor, name="self"),
1950
+ InPosArg(
1951
+ ArgType.Dim,
1952
+ name="dim",
1953
+ deps=[0],
1954
+ constraints=[
1955
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
1956
+ ],
1957
+ ),
1958
+ InPosArg(
1959
+ ArgType.Tensor,
1960
+ name="index",
1961
+ deps=[0, 1],
1962
+ # TODO(mcandales) Handle index.numel() == 0 case
1963
+ constraints=[
1964
+ cp.Dtype.Eq(lambda deps: torch.long),
1965
+ cp.Rank.Eq(
1966
+ lambda deps: deps[0].dim() if deps[0].dim() >= 2 else None
1967
+ ),
1968
+ cp.Rank.In(
1969
+ lambda deps: [0, 1] if deps[0].dim() in [0, 1] else None
1970
+ ),
1971
+ cp.Size.Le(
1972
+ lambda deps, r, d: (
1973
+ fn.safe_size(deps[0], d)
1974
+ if d != fn.normalize(deps[1], deps[0].dim())
1975
+ else None
1976
+ )
1977
+ ),
1978
+ cp.Value.Ge(lambda deps, dtype, struct: 0),
1979
+ cp.Value.Le(
1980
+ lambda deps, dtype, struct: (
1981
+ 0
1982
+ if deps[0].dim() == 0
1983
+ else max(0, fn.safe_size(deps[0], deps[1]) - 1)
1984
+ )
1985
+ ),
1986
+ ],
1987
+ ),
1988
+ InKwArg(ArgType.Bool, name="sparse_grad"),
1989
+ ],
1990
+ outspec=[
1991
+ OutArg(
1992
+ ArgType.Tensor,
1993
+ constraints=[
1994
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
1995
+ ],
1996
+ ),
1997
+ ],
1998
+ ),
1999
+ Spec(
2000
+ op="ge.Scalar", # (Tensor self, Scalar other) -> Tensor
2001
+ inspec=[
2002
+ InPosArg(ArgType.Tensor, name="self"),
2003
+ InPosArg(ArgType.Scalar, name="other"),
2004
+ ],
2005
+ outspec=[OutArg(ArgType.Tensor)],
2006
+ ),
2007
+ Spec(
2008
+ op="ge.Tensor", # (Tensor self, Tensor other) -> Tensor
2009
+ inspec=[
2010
+ InPosArg(ArgType.Tensor, name="self"),
2011
+ InPosArg(
2012
+ ArgType.Tensor,
2013
+ name="other",
2014
+ deps=[0],
2015
+ constraints=[
2016
+ cp.Size.In(
2017
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2018
+ ),
2019
+ ],
2020
+ ),
2021
+ ],
2022
+ outspec=[OutArg(ArgType.Tensor)],
2023
+ ),
2024
+ Spec(
2025
+ op="gelu.default", # (Tensor self, *, str approximate="none") -> Tensor
2026
+ inspec=[
2027
+ InPosArg(
2028
+ ArgType.Tensor,
2029
+ name="self",
2030
+ constraints=[cp.Dtype.In(lambda deps: dt._floating)],
2031
+ ),
2032
+ InKwArg(
2033
+ ArgType.String,
2034
+ name="approximate",
2035
+ constraints=[
2036
+ cp.Value.In(lambda deps: ["none", "tanh"]),
2037
+ ],
2038
+ ),
2039
+ ],
2040
+ outspec=[
2041
+ OutArg(ArgType.Tensor),
2042
+ ],
2043
+ ),
2044
+ Spec(
2045
+ op="glu.default", # (Tensor self, int dim=-1) -> Tensor
2046
+ inspec=[
2047
+ InPosArg(
2048
+ ArgType.Tensor,
2049
+ name="self",
2050
+ constraints=[
2051
+ cp.Dtype.In(lambda deps: dt._floating),
2052
+ cp.Rank.Ge(lambda deps: 1),
2053
+ ],
2054
+ ),
2055
+ InPosArg(
2056
+ ArgType.Dim,
2057
+ name="dim",
2058
+ deps=[0],
2059
+ constraints=[
2060
+ cp.Value.In(
2061
+ lambda deps: [
2062
+ d
2063
+ for d in range(-deps[0].dim(), deps[0].dim())
2064
+ if fn.safe_size(deps[0], d) % 2 == 0
2065
+ ]
2066
+ ),
2067
+ ],
2068
+ ),
2069
+ ],
2070
+ outspec=[
2071
+ OutArg(ArgType.Tensor),
2072
+ ],
2073
+ ),
2074
+ Spec(
2075
+ op="gt.Scalar", # (Tensor self, Scalar other) -> Tensor
2076
+ inspec=[
2077
+ InPosArg(ArgType.Tensor, name="self"),
2078
+ InPosArg(ArgType.Scalar, name="other"),
2079
+ ],
2080
+ outspec=[OutArg(ArgType.Tensor)],
2081
+ ),
2082
+ Spec(
2083
+ op="gt.Tensor", # (Tensor self, Tensor other) -> Tensor
2084
+ inspec=[
2085
+ InPosArg(ArgType.Tensor, name="self"),
2086
+ InPosArg(
2087
+ ArgType.Tensor,
2088
+ name="other",
2089
+ deps=[0],
2090
+ constraints=[
2091
+ cp.Size.In(
2092
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2093
+ ),
2094
+ ],
2095
+ ),
2096
+ ],
2097
+ outspec=[OutArg(ArgType.Tensor)],
2098
+ ),
2099
+ Spec(
2100
+ op="hardtanh.default", # (Tensor self, Scalar min_val=-1, Scalar max_val=1) -> Tensor
2101
+ inspec=[
2102
+ InPosArg(
2103
+ ArgType.Tensor,
2104
+ name="self",
2105
+ constraints=[
2106
+ cp.Dtype.Ne(lambda deps: torch.bool),
2107
+ ],
2108
+ ),
2109
+ InPosArg(
2110
+ ArgType.Scalar,
2111
+ name="min_val",
2112
+ deps=[0],
2113
+ constraints=[
2114
+ cp.Value.Gt(
2115
+ lambda deps, dtype: fn.dtype_strict_lower_bound(deps[0].dtype)
2116
+ ),
2117
+ cp.Value.Lt(
2118
+ lambda deps, dtype: fn.dtype_strict_upper_bound(deps[0].dtype)
2119
+ ),
2120
+ ],
2121
+ ),
2122
+ InPosArg(
2123
+ ArgType.Scalar,
2124
+ name="max_val",
2125
+ deps=[0],
2126
+ constraints=[
2127
+ cp.Value.Gt(
2128
+ lambda deps, dtype: fn.dtype_strict_lower_bound(deps[0].dtype)
2129
+ ),
2130
+ cp.Value.Lt(
2131
+ lambda deps, dtype: fn.dtype_strict_lower_bound(deps[0].dtype)
2132
+ ),
2133
+ ],
2134
+ ),
2135
+ ],
2136
+ outspec=[
2137
+ OutArg(ArgType.Tensor),
2138
+ ],
2139
+ ),
2140
+ Spec( # TODO(mcandales): Calibrate.
2141
+ op="index_select.default", # (Tensor self, int dim, Tensor index) -> Tensor
2142
+ inspec=[
2143
+ InPosArg(ArgType.Tensor, name="self"),
2144
+ InPosArg(
2145
+ ArgType.Dim,
2146
+ name="dim",
2147
+ deps=[0],
2148
+ constraints=[
2149
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
2150
+ ],
2151
+ ),
2152
+ InPosArg(
2153
+ ArgType.Tensor,
2154
+ name="index",
2155
+ deps=[0, 1],
2156
+ constraints=[
2157
+ cp.Dtype.In(lambda deps: [torch.int, torch.long]),
2158
+ cp.Rank.Le(lambda deps: 1),
2159
+ cp.Size.Eq(lambda deps, r, d: 1 if deps[0].dim() == 0 else None),
2160
+ cp.Value.Ge(lambda deps, dtype, struct: 0),
2161
+ cp.Value.Le(
2162
+ lambda deps, dtype, struct: (
2163
+ 0
2164
+ if deps[0].dim() == 0
2165
+ else fn.safe_size(deps[0], deps[1]) - 1
2166
+ )
2167
+ ),
2168
+ ],
2169
+ ),
2170
+ ],
2171
+ outspec=[
2172
+ OutArg(ArgType.Tensor),
2173
+ ],
2174
+ ),
2175
+ Spec(
2176
+ op="isinf.default", # (Tensor self) -> Tensor
2177
+ inspec=[
2178
+ InPosArg(ArgType.Tensor, name="self"),
2179
+ ],
2180
+ outspec=[OutArg(ArgType.Tensor)],
2181
+ ),
2182
+ Spec(
2183
+ op="isnan.default", # (Tensor self) -> Tensor
2184
+ inspec=[
2185
+ InPosArg(ArgType.Tensor, name="self"),
2186
+ ],
2187
+ outspec=[OutArg(ArgType.Tensor)],
2188
+ ),
2189
+ Spec(
2190
+ op="le.Scalar", # (Tensor self, Scalar other) -> Tensor
2191
+ inspec=[
2192
+ InPosArg(ArgType.Tensor, name="self"),
2193
+ InPosArg(ArgType.Scalar, name="other"),
2194
+ ],
2195
+ outspec=[OutArg(ArgType.Tensor)],
2196
+ ),
2197
+ Spec(
2198
+ op="le.Tensor", # (Tensor self, Tensor other) -> Tensor
2199
+ inspec=[
2200
+ InPosArg(ArgType.Tensor, name="self"),
2201
+ InPosArg(
2202
+ ArgType.Tensor,
2203
+ name="other",
2204
+ deps=[0],
2205
+ constraints=[
2206
+ cp.Size.In(
2207
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2208
+ ),
2209
+ ],
2210
+ ),
2211
+ ],
2212
+ outspec=[OutArg(ArgType.Tensor)],
2213
+ ),
2214
+ Spec(
2215
+ op="leaky_relu.default", # (Tensor self, Scalar negative_slope=0.01) -> Tensor
2216
+ inspec=[
2217
+ InPosArg(
2218
+ ArgType.Tensor,
2219
+ name="self",
2220
+ constraints=[
2221
+ cp.Dtype.In(lambda deps: dt._floating),
2222
+ ],
2223
+ ),
2224
+ InPosArg(ArgType.Scalar, name="negative_slope"),
2225
+ ],
2226
+ outspec=[OutArg(ArgType.Tensor)],
2227
+ ),
2228
+ Spec(
2229
+ op="lift_fresh_copy.default", # (Tensor self) -> Tensor
2230
+ inspec=[
2231
+ InPosArg(ArgType.Tensor, name="self"),
2232
+ ],
2233
+ outspec=[OutArg(ArgType.Tensor)],
2234
+ ),
2235
+ Spec(
2236
+ op="log.default", # (Tensor self) -> Tensor
2237
+ inspec=[
2238
+ InPosArg(ArgType.Tensor, name="self"),
2239
+ ],
2240
+ outspec=[
2241
+ OutArg(
2242
+ ArgType.Tensor,
2243
+ constraints=[
2244
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
2245
+ cp.Dtype.In(lambda deps: dt.can_cast_from(deps[0].dtype)),
2246
+ ],
2247
+ )
2248
+ ],
2249
+ ),
2250
+ Spec(
2251
+ op="log10.default", # (Tensor self) -> Tensor
2252
+ inspec=[
2253
+ InPosArg(ArgType.Tensor, name="self"),
2254
+ ],
2255
+ outspec=[
2256
+ OutArg(
2257
+ ArgType.Tensor,
2258
+ constraints=[
2259
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
2260
+ cp.Dtype.In(lambda deps: dt.can_cast_from(deps[0].dtype)),
2261
+ ],
2262
+ )
2263
+ ],
2264
+ ),
2265
+ Spec(
2266
+ op="log1p.default", # (Tensor self) -> Tensor
2267
+ inspec=[
2268
+ InPosArg(ArgType.Tensor, name="self"),
2269
+ ],
2270
+ outspec=[
2271
+ OutArg(
2272
+ ArgType.Tensor,
2273
+ constraints=[
2274
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
2275
+ cp.Dtype.In(lambda deps: dt.can_cast_from(deps[0].dtype)),
2276
+ ],
2277
+ )
2278
+ ],
2279
+ ),
2280
+ Spec(
2281
+ op="log2.default", # (Tensor self) -> Tensor
2282
+ inspec=[
2283
+ InPosArg(ArgType.Tensor, name="self"),
2284
+ ],
2285
+ outspec=[
2286
+ OutArg(
2287
+ ArgType.Tensor,
2288
+ constraints=[
2289
+ cp.Dtype.In(lambda deps: dt.can_cast_from(torch.float)),
2290
+ cp.Dtype.In(lambda deps: dt.can_cast_from(deps[0].dtype)),
2291
+ ],
2292
+ )
2293
+ ],
2294
+ ),
2295
+ Spec(
2296
+ op="logical_and.default", # (Tensor self, Tensor other) -> Tensor
2297
+ inspec=[
2298
+ InPosArg(ArgType.Tensor, name="self"),
2299
+ InPosArg(
2300
+ ArgType.Tensor,
2301
+ name="other",
2302
+ deps=[0],
2303
+ constraints=[
2304
+ cp.Size.In(
2305
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2306
+ ),
2307
+ ],
2308
+ ),
2309
+ ],
2310
+ outspec=[OutArg(ArgType.Tensor)],
2311
+ ),
2312
+ Spec(
2313
+ op="logical_not.default", # (Tensor self) -> Tensor
2314
+ inspec=[
2315
+ InPosArg(ArgType.Tensor, name="self"),
2316
+ ],
2317
+ outspec=[OutArg(ArgType.Tensor)],
2318
+ ),
2319
+ Spec(
2320
+ op="logical_or.default", # (Tensor self, Tensor other) -> Tensor
2321
+ inspec=[
2322
+ InPosArg(ArgType.Tensor, name="self"),
2323
+ InPosArg(
2324
+ ArgType.Tensor,
2325
+ name="other",
2326
+ deps=[0],
2327
+ constraints=[
2328
+ cp.Size.In(
2329
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2330
+ ),
2331
+ ],
2332
+ ),
2333
+ ],
2334
+ outspec=[OutArg(ArgType.Tensor)],
2335
+ ),
2336
+ Spec(
2337
+ op="logical_xor.default", # (Tensor self, Tensor other) -> Tensor
2338
+ inspec=[
2339
+ InPosArg(ArgType.Tensor, name="self"),
2340
+ InPosArg(
2341
+ ArgType.Tensor,
2342
+ name="other",
2343
+ deps=[0],
2344
+ constraints=[
2345
+ cp.Size.In(
2346
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2347
+ ),
2348
+ ],
2349
+ ),
2350
+ ],
2351
+ outspec=[OutArg(ArgType.Tensor)],
2352
+ ),
2353
+ Spec(
2354
+ op="logit.default", # (Tensor self, float? eps=None) -> Tensor
2355
+ inspec=[
2356
+ InPosArg(ArgType.Tensor, name="self"),
2357
+ InPosArg(ArgType.FloatOpt, name="eps"),
2358
+ ],
2359
+ outspec=[
2360
+ OutArg(ArgType.Tensor),
2361
+ ],
2362
+ ),
2363
+ Spec(
2364
+ op="lt.Scalar", # (Tensor self, Scalar other) -> Tensor
2365
+ inspec=[
2366
+ InPosArg(ArgType.Tensor, name="self"),
2367
+ InPosArg(ArgType.Scalar, name="other"),
2368
+ ],
2369
+ outspec=[OutArg(ArgType.Tensor)],
2370
+ ),
2371
+ Spec(
2372
+ op="lt.Tensor", # (Tensor self, Tensor other) -> Tensor
2373
+ inspec=[
2374
+ InPosArg(ArgType.Tensor, name="self"),
2375
+ InPosArg(
2376
+ ArgType.Tensor,
2377
+ name="other",
2378
+ deps=[0],
2379
+ constraints=[
2380
+ cp.Size.In(
2381
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2382
+ ),
2383
+ ],
2384
+ ),
2385
+ ],
2386
+ outspec=[OutArg(ArgType.Tensor)],
2387
+ ),
2388
+ Spec(
2389
+ op="masked_fill.Scalar", # (Tensor self, Tensor mask, Scalar value) -> Tensor
2390
+ inspec=[
2391
+ InPosArg(ArgType.Tensor, name="self"),
2392
+ InPosArg(
2393
+ ArgType.Tensor,
2394
+ name="mask",
2395
+ deps=[0],
2396
+ constraints=[
2397
+ cp.Dtype.Eq(lambda deps: torch.bool),
2398
+ cp.Size.In(
2399
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2400
+ ),
2401
+ ],
2402
+ ),
2403
+ InPosArg(
2404
+ ArgType.Scalar,
2405
+ name="value",
2406
+ deps=[0],
2407
+ constraints=[
2408
+ cp.Value.Ge(
2409
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
2410
+ ),
2411
+ cp.Value.Le(
2412
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
2413
+ ),
2414
+ ],
2415
+ ),
2416
+ ],
2417
+ outspec=[
2418
+ OutArg(ArgType.Tensor),
2419
+ ],
2420
+ ),
2421
+ Spec(
2422
+ op="max.dim", # (Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)
2423
+ inspec=[
2424
+ InPosArg(ArgType.Tensor, name="self"),
2425
+ InPosArg(
2426
+ ArgType.Dim,
2427
+ name="dim",
2428
+ deps=[0],
2429
+ constraints=[
2430
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
2431
+ ],
2432
+ ),
2433
+ InPosArg(ArgType.Bool, name="keepdim"),
2434
+ ],
2435
+ outspec=[
2436
+ OutArg(ArgType.Tensor, name="values"),
2437
+ OutArg(ArgType.Tensor, name="indices"),
2438
+ ],
2439
+ ),
2440
+ Spec( # TODO(mcandales): Calibrate.
2441
+ op="max_pool2d_with_indices.default", # (Tensor self, int[2] kernel_size, int[2] stride=[], int[2] padding=0, int[2] dilation=1, bool ceil_mode=False) -> (Tensor, Tensor)
2442
+ inspec=[
2443
+ InPosArg( # self
2444
+ ArgType.Tensor,
2445
+ name="self",
2446
+ deps=[1, 2, 3, 4, 5],
2447
+ constraints=[
2448
+ cp.Dtype.Ne(lambda deps: torch.bool),
2449
+ cp.Rank.In(lambda deps: [3, 4]),
2450
+ # cp.Size.Ge(lambda deps, r, d: 0 if d == 0 and r == 4 else 1),
2451
+ cp.Size.Ge(
2452
+ lambda deps, r, d: fn.pool_input_size_min(
2453
+ 2, deps[0], deps[1], deps[2], deps[3], deps[4], r, d
2454
+ )
2455
+ ),
2456
+ ],
2457
+ ),
2458
+ InPosArg( # kernel_size
2459
+ ArgType.LengthList,
2460
+ name="kernel_size",
2461
+ constraints=[
2462
+ cp.Length.In(lambda deps: [1, 2]),
2463
+ cp.Value.Ge(lambda deps, length, ix: 1),
2464
+ ],
2465
+ ),
2466
+ InPosArg( # stride
2467
+ ArgType.LengthList,
2468
+ name="stride",
2469
+ constraints=[
2470
+ cp.Length.In(lambda deps: [0, 1, 2]),
2471
+ cp.Value.Ge(lambda deps, length, ix: 1),
2472
+ ],
2473
+ ),
2474
+ InPosArg( # padding
2475
+ ArgType.LengthList,
2476
+ name="padding",
2477
+ deps=[1],
2478
+ constraints=[
2479
+ cp.Length.In(lambda deps: [1, 2]),
2480
+ cp.Value.Ge(lambda deps, length, ix: 0),
2481
+ cp.Value.Le(
2482
+ lambda deps, length, ix: fn.pool_padding_max(
2483
+ deps[0], length, ix
2484
+ )
2485
+ ),
2486
+ ],
2487
+ ),
2488
+ InPosArg( # dilation
2489
+ ArgType.LengthList,
2490
+ name="dilation",
2491
+ constraints=[
2492
+ cp.Length.In(lambda deps: [1, 2]),
2493
+ cp.Value.Ge(lambda deps, length, ix: 1),
2494
+ ],
2495
+ ),
2496
+ InPosArg(ArgType.Bool, name="ceil_mode"), # ceil_mode
2497
+ ],
2498
+ outspec=[
2499
+ OutArg(ArgType.Tensor, name="out"),
2500
+ OutArg(ArgType.Tensor, name="indices"),
2501
+ ],
2502
+ ),
2503
+ Spec(
2504
+ op="maximum.default", # (Tensor self, Tensor other) -> Tensor
2505
+ inspec=[
2506
+ InPosArg(ArgType.Tensor, name="self"),
2507
+ InPosArg(
2508
+ ArgType.Tensor,
2509
+ name="other",
2510
+ deps=[0],
2511
+ constraints=[
2512
+ cp.Size.In(
2513
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2514
+ ),
2515
+ ],
2516
+ ),
2517
+ ],
2518
+ outspec=[
2519
+ OutArg(
2520
+ ArgType.Tensor,
2521
+ constraints=[
2522
+ cp.Dtype.In(
2523
+ lambda deps: dt.can_cast_from(
2524
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
2525
+ )
2526
+ ),
2527
+ ],
2528
+ )
2529
+ ],
2530
+ ),
2531
+ Spec(
2532
+ op="mean.dim", # (Tensor self, int[1]? dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
2533
+ inspec=[
2534
+ InPosArg(ArgType.Tensor, name="self"),
2535
+ InPosArg(
2536
+ ArgType.DimListOpt,
2537
+ name="dim",
2538
+ deps=[0],
2539
+ constraints=DimListDefault,
2540
+ ),
2541
+ InPosArg(ArgType.Bool, name="keepdim"),
2542
+ InKwArg(
2543
+ ArgType.ScalarTypeOpt,
2544
+ name="dtype",
2545
+ deps=[0],
2546
+ constraints=[
2547
+ cp.Optional.Eq(
2548
+ lambda deps: (
2549
+ False if deps[0].dtype not in dt._floating else None
2550
+ )
2551
+ ),
2552
+ cp.Value.In(lambda deps: dt._floating),
2553
+ ],
2554
+ ),
2555
+ ],
2556
+ outspec=[
2557
+ OutArg(ArgType.Tensor),
2558
+ ],
2559
+ ),
2560
+ Spec(
2561
+ op="min.dim", # (Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)
2562
+ inspec=[
2563
+ InPosArg(ArgType.Tensor, name="self"),
2564
+ InPosArg(
2565
+ ArgType.Dim,
2566
+ name="dim",
2567
+ deps=[0],
2568
+ constraints=[
2569
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
2570
+ ],
2571
+ ),
2572
+ InPosArg(ArgType.Bool, name="keepdim"),
2573
+ ],
2574
+ outspec=[
2575
+ OutArg(ArgType.Tensor, name="values"),
2576
+ OutArg(ArgType.Tensor, name="indices"),
2577
+ ],
2578
+ ),
2579
+ Spec(
2580
+ op="minimum.default", # (Tensor self, Tensor other) -> Tensor
2581
+ inspec=[
2582
+ InPosArg(ArgType.Tensor, name="self"),
2583
+ InPosArg(
2584
+ ArgType.Tensor,
2585
+ name="other",
2586
+ deps=[0],
2587
+ constraints=[
2588
+ cp.Size.In(
2589
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2590
+ ),
2591
+ ],
2592
+ ),
2593
+ ],
2594
+ outspec=[
2595
+ OutArg(
2596
+ ArgType.Tensor,
2597
+ constraints=[
2598
+ cp.Dtype.In(
2599
+ lambda deps: dt.can_cast_from(
2600
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
2601
+ )
2602
+ ),
2603
+ ],
2604
+ )
2605
+ ],
2606
+ ),
2607
+ Spec(
2608
+ op="mm.default", # (Tensor self, Tensor mat2) -> Tensor
2609
+ inspec=[
2610
+ InPosArg(
2611
+ ArgType.Tensor,
2612
+ name="self",
2613
+ constraints=[
2614
+ cp.Dtype.Ne(lambda deps: torch.bool),
2615
+ cp.Rank.Eq(lambda deps: 2),
2616
+ ],
2617
+ ),
2618
+ InPosArg(
2619
+ ArgType.Tensor,
2620
+ name="mat2",
2621
+ deps=[0],
2622
+ constraints=[
2623
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2624
+ cp.Rank.Eq(lambda deps: 2),
2625
+ cp.Size.Eq(
2626
+ lambda deps, r, d: fn.safe_size(deps[0], 1) if d == 0 else None
2627
+ ),
2628
+ ],
2629
+ ),
2630
+ ],
2631
+ outspec=[OutArg(ArgType.Tensor)],
2632
+ ),
2633
+ Spec(
2634
+ op="mul.Tensor", # (Tensor self, Tensor other) -> Tensor
2635
+ inspec=[
2636
+ InPosArg(ArgType.Tensor, name="self"),
2637
+ InPosArg(
2638
+ ArgType.Tensor,
2639
+ name="other",
2640
+ deps=[0],
2641
+ constraints=[
2642
+ cp.Size.In(
2643
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2644
+ ),
2645
+ ],
2646
+ ),
2647
+ ],
2648
+ outspec=[OutArg(ArgType.Tensor)],
2649
+ ),
2650
+ Spec(
2651
+ op="mul.Scalar", # (Tensor self, Scalar other) -> Tensor
2652
+ inspec=[
2653
+ InPosArg(ArgType.Tensor, name="self"),
2654
+ InPosArg(ArgType.Scalar, name="other"),
2655
+ ],
2656
+ outspec=[OutArg(ArgType.Tensor)],
2657
+ ),
2658
+ Spec(
2659
+ op="native_group_norm.default", # (Tensor input, Tensor? weight, Tensor? bias, SymInt N, SymInt C, SymInt HxW, int group, float eps) -> (Tensor, Tensor, Tensor)
2660
+ inspec=[
2661
+ InPosArg(
2662
+ ArgType.Tensor,
2663
+ name="input",
2664
+ constraints=[
2665
+ cp.Dtype.In(lambda deps: dt._floating),
2666
+ cp.Rank.Ge(lambda deps: 2),
2667
+ ],
2668
+ ),
2669
+ InPosArg(
2670
+ ArgType.TensorOpt,
2671
+ name="weight",
2672
+ deps=[0],
2673
+ constraints=[
2674
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2675
+ cp.Rank.Eq(lambda deps: 1),
2676
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
2677
+ ],
2678
+ ),
2679
+ InPosArg(
2680
+ ArgType.TensorOpt,
2681
+ name="bias",
2682
+ deps=[0],
2683
+ constraints=[
2684
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2685
+ cp.Rank.Eq(lambda deps: 1),
2686
+ cp.Size.Eq(lambda deps, r, d: fn.safe_size(deps[0], 1)),
2687
+ ],
2688
+ ),
2689
+ InPosArg(
2690
+ ArgType.Int,
2691
+ name="N",
2692
+ deps=[0],
2693
+ constraints=[
2694
+ cp.Value.Eq(lambda deps: fn.safe_size(deps[0], 0)),
2695
+ ],
2696
+ ),
2697
+ InPosArg(
2698
+ ArgType.Int,
2699
+ name="C",
2700
+ deps=[0],
2701
+ constraints=[
2702
+ cp.Value.Eq(lambda deps: fn.safe_size(deps[0], 1)),
2703
+ ],
2704
+ ),
2705
+ InPosArg(
2706
+ ArgType.Int,
2707
+ name="HxW",
2708
+ deps=[0],
2709
+ constraints=[
2710
+ cp.Value.Eq(
2711
+ lambda deps: math.prod(
2712
+ fn.safe_size(deps[0], d) for d in range(2, deps[0].dim())
2713
+ ),
2714
+ ),
2715
+ ],
2716
+ ),
2717
+ InPosArg(
2718
+ ArgType.Int,
2719
+ name="groups",
2720
+ deps=[0],
2721
+ constraints=[
2722
+ cp.Value.In(
2723
+ lambda deps: [
2724
+ d
2725
+ for d in range(1, fn.safe_size(deps[0], 1) + 1)
2726
+ if fn.safe_size(deps[0], 1) % d == 0
2727
+ ]
2728
+ ),
2729
+ ],
2730
+ ),
2731
+ InPosArg(ArgType.Float, name="eps"),
2732
+ ],
2733
+ outspec=[
2734
+ OutArg(
2735
+ ArgType.Tensor,
2736
+ name="out0",
2737
+ constraints=[
2738
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2739
+ ],
2740
+ ),
2741
+ OutArg(
2742
+ ArgType.Tensor,
2743
+ name="out1",
2744
+ constraints=[
2745
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2746
+ ],
2747
+ ),
2748
+ OutArg(
2749
+ ArgType.Tensor,
2750
+ name="out2",
2751
+ constraints=[
2752
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2753
+ ],
2754
+ ),
2755
+ ],
2756
+ ),
2757
+ Spec(
2758
+ op="native_layer_norm.default", # (Tensor input, SymInt[] normalized_shape, Tensor? weight, Tensor? bias, float eps) -> (Tensor, Tensor, Tensor)
2759
+ inspec=[
2760
+ InPosArg(
2761
+ ArgType.Tensor,
2762
+ name="input",
2763
+ deps=[1],
2764
+ constraints=[
2765
+ cp.Dtype.In(lambda deps: dt._floating),
2766
+ cp.Rank.Ge(lambda deps: len(deps[0])),
2767
+ cp.Size.Eq(lambda deps, r, d: fn.nlm_input_size(deps[0], r, d)),
2768
+ ],
2769
+ ),
2770
+ InPosArg(
2771
+ ArgType.Shape,
2772
+ name="normalized_shape",
2773
+ constraints=[
2774
+ cp.Length.Ge(lambda deps: 1),
2775
+ cp.Value.Ge(lambda deps, length, ix: 0),
2776
+ ],
2777
+ ),
2778
+ InPosArg(
2779
+ ArgType.TensorOpt,
2780
+ name="weight",
2781
+ deps=[0, 1],
2782
+ constraints=[
2783
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2784
+ cp.Rank.Eq(lambda deps: len(deps[1])),
2785
+ cp.Size.Eq(lambda deps, r, d: fn.safe_ix(deps[1], d)),
2786
+ ],
2787
+ ),
2788
+ InPosArg(
2789
+ ArgType.TensorOpt,
2790
+ name="bias",
2791
+ deps=[0, 1],
2792
+ constraints=[
2793
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
2794
+ cp.Rank.Eq(lambda deps: len(deps[1])),
2795
+ cp.Size.Eq(lambda deps, r, d: fn.safe_ix(deps[1], d)),
2796
+ ],
2797
+ ),
2798
+ InPosArg(ArgType.Float, name="eps"),
2799
+ ],
2800
+ outspec=[
2801
+ OutArg(ArgType.Tensor, name="out0"),
2802
+ OutArg(ArgType.Tensor, name="out1"),
2803
+ OutArg(ArgType.Tensor, name="out2"),
2804
+ ],
2805
+ ),
2806
+ Spec(
2807
+ op="ne.Scalar", # (Tensor self, Scalar other) -> Tensor
2808
+ inspec=[
2809
+ InPosArg(ArgType.Tensor, name="self"),
2810
+ InPosArg(ArgType.Scalar, name="other"),
2811
+ ],
2812
+ outspec=[OutArg(ArgType.Tensor)],
2813
+ ),
2814
+ Spec(
2815
+ op="ne.Tensor", # (Tensor self, Tensor other) -> Tensor
2816
+ inspec=[
2817
+ InPosArg(ArgType.Tensor, name="self"),
2818
+ InPosArg(
2819
+ ArgType.Tensor,
2820
+ name="other",
2821
+ deps=[0],
2822
+ constraints=[
2823
+ cp.Size.In(
2824
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2825
+ ),
2826
+ ],
2827
+ ),
2828
+ ],
2829
+ outspec=[OutArg(ArgType.Tensor)],
2830
+ ),
2831
+ Spec(
2832
+ op="neg.default", # (Tensor self) -> Tensor
2833
+ inspec=[
2834
+ InPosArg(
2835
+ ArgType.Tensor,
2836
+ name="self",
2837
+ constraints=[
2838
+ cp.Dtype.Ne(lambda deps: torch.bool),
2839
+ ],
2840
+ ),
2841
+ ],
2842
+ outspec=[OutArg(ArgType.Tensor)],
2843
+ ),
2844
+ Spec(
2845
+ op="nonzero.default", # (Tensor self) -> Tensor
2846
+ inspec=[
2847
+ InPosArg(ArgType.Tensor, name="self"),
2848
+ ],
2849
+ outspec=[
2850
+ OutArg(ArgType.Tensor),
2851
+ ],
2852
+ ),
2853
+ Spec(
2854
+ op="ones.default", # (SymInt[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
2855
+ inspec=[
2856
+ InPosArg(
2857
+ ArgType.Shape,
2858
+ name="size",
2859
+ constraints=ShapeDefault,
2860
+ ),
2861
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
2862
+ ],
2863
+ outspec=[OutArg(ArgType.Tensor)],
2864
+ ),
2865
+ Spec(
2866
+ op="permute_copy.default", # (Tensor self, int[] dims) -> Tensor
2867
+ inspec=[
2868
+ InPosArg(ArgType.Tensor, name="self"),
2869
+ InPosArg(
2870
+ ArgType.DimList,
2871
+ name="dims",
2872
+ deps=[0],
2873
+ constraints=DimListDefault
2874
+ + [
2875
+ cp.Length.Eq(lambda deps: deps[0].dim()),
2876
+ ],
2877
+ ),
2878
+ ],
2879
+ outspec=[
2880
+ OutArg(ArgType.Tensor),
2881
+ ],
2882
+ ),
2883
+ Spec(
2884
+ op="pixel_shuffle.default", # (Tensor self, int upscale_factor) -> Tensor
2885
+ inspec=[
2886
+ InPosArg(
2887
+ ArgType.Tensor,
2888
+ name="self",
2889
+ constraints=[
2890
+ cp.Rank.Ge(lambda deps: 3),
2891
+ cp.Size.Be(
2892
+ lambda deps, r, d: (
2893
+ [
2894
+ 0,
2895
+ 1,
2896
+ 2,
2897
+ 3,
2898
+ 4,
2899
+ 8,
2900
+ 9,
2901
+ 12,
2902
+ 16,
2903
+ 18,
2904
+ 25,
2905
+ ]
2906
+ if d == r - 3
2907
+ else None
2908
+ )
2909
+ ),
2910
+ ],
2911
+ ),
2912
+ InPosArg(
2913
+ ArgType.Int,
2914
+ name="upscale_factor",
2915
+ deps=[0],
2916
+ constraints=[
2917
+ cp.Value.In(
2918
+ lambda deps: [
2919
+ d
2920
+ for d in range(1, fn.safe_size(deps[0], -3) + 1)
2921
+ if fn.safe_size(deps[0], -3) % (d * d) == 0
2922
+ ]
2923
+ ),
2924
+ ],
2925
+ ),
2926
+ ],
2927
+ outspec=[
2928
+ OutArg(ArgType.Tensor),
2929
+ ],
2930
+ ),
2931
+ Spec(
2932
+ op="pow.Tensor_Scalar", # (Tensor self, Scalar exponent) -> Tensor
2933
+ inspec=[
2934
+ InPosArg(ArgType.Tensor, name="self"),
2935
+ InPosArg(
2936
+ ArgType.Scalar,
2937
+ name="exponent",
2938
+ deps=[0],
2939
+ constraints=[
2940
+ cp.Dtype.Ne(
2941
+ lambda deps: (
2942
+ ScalarDtype.bool if deps[0].dtype == torch.bool else None
2943
+ )
2944
+ ),
2945
+ cp.Value.Ge(
2946
+ lambda deps, dtype: 0 if dtype == ScalarDtype.int else None
2947
+ ),
2948
+ ],
2949
+ ),
2950
+ ],
2951
+ outspec=[
2952
+ OutArg(ArgType.Tensor),
2953
+ ],
2954
+ ),
2955
+ Spec(
2956
+ op="pow.Tensor_Tensor", # (Tensor self, Tensor exponent) -> Tensor
2957
+ inspec=[
2958
+ InPosArg(ArgType.Tensor, name="self"),
2959
+ InPosArg(
2960
+ ArgType.Tensor,
2961
+ name="exponent",
2962
+ deps=[0],
2963
+ constraints=[
2964
+ cp.Dtype.Ne(
2965
+ lambda deps: torch.bool if deps[0].dtype == torch.bool else None
2966
+ ),
2967
+ cp.Size.In(
2968
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
2969
+ ),
2970
+ ],
2971
+ ),
2972
+ ],
2973
+ outspec=[OutArg(ArgType.Tensor)],
2974
+ ),
2975
+ Spec(
2976
+ op="prod.default", # (Tensor self, *, ScalarType? dtype=None) -> Tensor
2977
+ inspec=[
2978
+ InPosArg(ArgType.Tensor, name="self"),
2979
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
2980
+ ],
2981
+ outspec=[
2982
+ OutArg(
2983
+ ArgType.Tensor,
2984
+ deps=[0, 1],
2985
+ constraints=[
2986
+ cp.Dtype.Eq(lambda deps: deps[1] if deps[1] is not None else None),
2987
+ cp.Dtype.Eq(
2988
+ lambda deps: (
2989
+ torch.long
2990
+ if deps[1] is None and deps[0].dtype in dt._int_and_bool
2991
+ else None
2992
+ )
2993
+ ),
2994
+ cp.Dtype.Eq(
2995
+ lambda deps: (
2996
+ deps[0].dtype
2997
+ if deps[1] is None and deps[0].dtype not in dt._int_and_bool
2998
+ else None
2999
+ )
3000
+ ),
3001
+ ],
3002
+ ),
3003
+ ],
3004
+ ),
3005
+ Spec(
3006
+ op="prod.dim_int", # (Tensor self, int dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
3007
+ inspec=[
3008
+ InPosArg(ArgType.Tensor, name="self"),
3009
+ InPosArg(
3010
+ ArgType.Dim,
3011
+ name="dim",
3012
+ deps=[0],
3013
+ constraints=DimDefault,
3014
+ ),
3015
+ InPosArg(ArgType.Bool, name="keepdim"),
3016
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
3017
+ ],
3018
+ outspec=[
3019
+ OutArg(
3020
+ ArgType.Tensor,
3021
+ constraints=[
3022
+ cp.Dtype.Eq(lambda deps: deps[3] if deps[3] is not None else None),
3023
+ cp.Dtype.Eq(
3024
+ lambda deps: (
3025
+ torch.long
3026
+ if deps[3] is None and deps[0].dtype in dt._int_and_bool
3027
+ else None
3028
+ )
3029
+ ),
3030
+ cp.Dtype.Eq(
3031
+ lambda deps: (
3032
+ deps[0].dtype
3033
+ if deps[3] is None and deps[0].dtype not in dt._int_and_bool
3034
+ else None
3035
+ )
3036
+ ),
3037
+ ],
3038
+ ),
3039
+ ],
3040
+ ),
3041
+ Spec(
3042
+ op="reciprocal.default", # (Tensor self) -> Tensor
3043
+ inspec=[
3044
+ InPosArg(ArgType.Tensor, name="self"),
3045
+ ],
3046
+ outspec=[OutArg(ArgType.Tensor)],
3047
+ ),
3048
+ Spec(
3049
+ op="reflection_pad1d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3050
+ inspec=[
3051
+ InPosArg(
3052
+ ArgType.Tensor,
3053
+ name="self",
3054
+ constraints=[
3055
+ cp.Rank.In(lambda deps: [2, 3]),
3056
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3057
+ ],
3058
+ ),
3059
+ InPosArg(
3060
+ ArgType.LengthList,
3061
+ name="padding",
3062
+ deps=[0],
3063
+ constraints=[
3064
+ cp.Length.Eq(lambda deps: 2),
3065
+ cp.Value.Lt(
3066
+ lambda deps, length, ix: (
3067
+ deps[0].size(-ix - 1) if ix < 1 else None
3068
+ )
3069
+ ),
3070
+ # TODO(mcandales): Calibrate.
3071
+ # self.size(-1) + padding[0] + padding[1] >= 0
3072
+ ],
3073
+ ),
3074
+ ],
3075
+ outspec=[
3076
+ OutArg(
3077
+ ArgType.Tensor,
3078
+ constraints=[
3079
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3080
+ ],
3081
+ )
3082
+ ],
3083
+ ),
3084
+ Spec(
3085
+ op="reflection_pad2d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3086
+ inspec=[
3087
+ InPosArg(
3088
+ ArgType.Tensor,
3089
+ name="self",
3090
+ constraints=[
3091
+ cp.Rank.In(lambda deps: [3, 4]),
3092
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3093
+ ],
3094
+ ),
3095
+ InPosArg(
3096
+ ArgType.LengthList,
3097
+ name="padding",
3098
+ deps=[0],
3099
+ constraints=[
3100
+ cp.Length.Eq(lambda deps: 4),
3101
+ cp.Value.Lt(
3102
+ lambda deps, length, ix: (
3103
+ deps[0].size(-ix - 1) if ix < 2 else None
3104
+ )
3105
+ ),
3106
+ # TODO(mcandales): Calibrate.
3107
+ # self.size(-1) + padding[0] + padding[1] >= 0
3108
+ # self.size(-2) + padding[2] + padding[3] >= 0
3109
+ ],
3110
+ ),
3111
+ ],
3112
+ outspec=[
3113
+ OutArg(
3114
+ ArgType.Tensor,
3115
+ constraints=[
3116
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3117
+ ],
3118
+ )
3119
+ ],
3120
+ ),
3121
+ Spec(
3122
+ op="reflection_pad3d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3123
+ inspec=[
3124
+ InPosArg(
3125
+ ArgType.Tensor,
3126
+ name="self",
3127
+ constraints=[
3128
+ cp.Rank.In(lambda deps: [4, 5]),
3129
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3130
+ ],
3131
+ ),
3132
+ InPosArg(
3133
+ ArgType.LengthList,
3134
+ name="padding",
3135
+ deps=[0],
3136
+ constraints=[
3137
+ cp.Length.Eq(lambda deps: 6),
3138
+ cp.Value.Lt(
3139
+ lambda deps, length, ix: (
3140
+ deps[0].size(-ix - 1) if ix < 3 else None
3141
+ )
3142
+ ),
3143
+ # TODO(mcandales): Calibrate.
3144
+ # self.size(-1) + padding[0] + padding[1] >= 0
3145
+ # self.size(-2) + padding[2] + padding[3] >= 0
3146
+ # self.size(-3) + padding[4] + padding[5] >= 0
3147
+ ],
3148
+ ),
3149
+ ],
3150
+ outspec=[
3151
+ OutArg(
3152
+ ArgType.Tensor,
3153
+ constraints=[
3154
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3155
+ ],
3156
+ )
3157
+ ],
3158
+ ),
3159
+ Spec(
3160
+ op="relu.default", # (Tensor self) -> Tensor
3161
+ inspec=[
3162
+ InPosArg(
3163
+ ArgType.Tensor,
3164
+ name="self",
3165
+ constraints=[
3166
+ cp.Dtype.Ne(lambda deps: torch.bool),
3167
+ ],
3168
+ ),
3169
+ ],
3170
+ outspec=[OutArg(ArgType.Tensor)],
3171
+ ),
3172
+ Spec(
3173
+ op="remainder.Tensor", # (Tensor self, Tensor other) -> Tensor
3174
+ inspec=[
3175
+ InPosArg(ArgType.Tensor, name="self"),
3176
+ InPosArg(
3177
+ ArgType.Tensor,
3178
+ name="other",
3179
+ deps=[0],
3180
+ constraints=[
3181
+ cp.Dtype.Ne(
3182
+ lambda deps: torch.bool if deps[0].dtype == torch.bool else None
3183
+ ),
3184
+ cp.Size.In(
3185
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
3186
+ ),
3187
+ cp.Value.Ne(
3188
+ lambda deps, dtype, struct: (
3189
+ 0
3190
+ if (deps[0].numel() > 0 and math.prod(struct) > 0)
3191
+ and torch.promote_types(deps[0].dtype, dtype)
3192
+ not in dt._floating
3193
+ else None
3194
+ )
3195
+ ),
3196
+ ],
3197
+ ),
3198
+ ],
3199
+ outspec=[
3200
+ OutArg(ArgType.Tensor),
3201
+ ],
3202
+ ),
3203
+ Spec(
3204
+ op="remainder.Scalar", # (Tensor self, Scalar other) -> Tensor
3205
+ inspec=[
3206
+ InPosArg(ArgType.Tensor, name="self"),
3207
+ InPosArg(
3208
+ ArgType.Scalar,
3209
+ name="other",
3210
+ deps=[0],
3211
+ constraints=[
3212
+ cp.Dtype.Ne(
3213
+ lambda deps: (
3214
+ ScalarDtype.bool if deps[0].dtype == torch.bool else None
3215
+ )
3216
+ ),
3217
+ cp.Value.Ne(
3218
+ lambda deps, dtype: (
3219
+ 0
3220
+ if (
3221
+ deps[0].numel() > 0
3222
+ and fn.promote_type_with_scalar(deps[0].dtype, dtype)
3223
+ not in dt._floating
3224
+ )
3225
+ else None
3226
+ )
3227
+ ),
3228
+ ],
3229
+ ),
3230
+ ],
3231
+ outspec=[
3232
+ OutArg(ArgType.Tensor),
3233
+ ],
3234
+ ),
3235
+ Spec(
3236
+ op="repeat.default", # (Tensor self, SymInt[] repeats) -> Tensor
3237
+ inspec=[
3238
+ InPosArg(ArgType.Tensor, name="self"),
3239
+ InPosArg(
3240
+ ArgType.LengthList,
3241
+ name="repeats",
3242
+ deps=[0],
3243
+ constraints=[
3244
+ cp.Length.Ge(lambda deps: deps[0].dim()),
3245
+ cp.Value.Be(lambda deps, length, ix: [0, 1, 2, 3]),
3246
+ ],
3247
+ ),
3248
+ ],
3249
+ outspec=[
3250
+ OutArg(ArgType.Tensor),
3251
+ ],
3252
+ ),
3253
+ Spec(
3254
+ op="replication_pad1d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3255
+ inspec=[
3256
+ InPosArg(
3257
+ ArgType.Tensor,
3258
+ name="self",
3259
+ constraints=[
3260
+ cp.Rank.In(lambda deps: [2, 3]),
3261
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3262
+ ],
3263
+ ),
3264
+ InPosArg(
3265
+ ArgType.LengthList,
3266
+ name="padding",
3267
+ deps=[0],
3268
+ constraints=[
3269
+ cp.Length.Eq(lambda deps: 2),
3270
+ # TODO(mcandales): Calibrate.
3271
+ # self.size(-1) + padding[0] + padding[1] >= 0
3272
+ ],
3273
+ ),
3274
+ ],
3275
+ outspec=[
3276
+ OutArg(
3277
+ ArgType.Tensor,
3278
+ constraints=[
3279
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3280
+ ],
3281
+ )
3282
+ ],
3283
+ ),
3284
+ Spec(
3285
+ op="replication_pad2d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3286
+ inspec=[
3287
+ InPosArg(
3288
+ ArgType.Tensor,
3289
+ name="self",
3290
+ constraints=[
3291
+ cp.Rank.In(lambda deps: [3, 4]),
3292
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3293
+ ],
3294
+ ),
3295
+ InPosArg(
3296
+ ArgType.LengthList,
3297
+ name="padding",
3298
+ deps=[0],
3299
+ constraints=[
3300
+ cp.Length.Eq(lambda deps: 4),
3301
+ # TODO(mcandales): Calibrate.
3302
+ # self.size(-1) + padding[0] + padding[1] >= 0
3303
+ # self.size(-2) + padding[2] + padding[3] >= 0
3304
+ ],
3305
+ ),
3306
+ ],
3307
+ outspec=[
3308
+ OutArg(
3309
+ ArgType.Tensor,
3310
+ constraints=[
3311
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3312
+ ],
3313
+ )
3314
+ ],
3315
+ ),
3316
+ Spec(
3317
+ op="replication_pad3d.default", # (Tensor self, SymInt[2] padding) -> Tensor
3318
+ inspec=[
3319
+ InPosArg(
3320
+ ArgType.Tensor,
3321
+ name="self",
3322
+ constraints=[
3323
+ cp.Rank.In(lambda deps: [4, 5]),
3324
+ cp.Size.Gt(lambda deps, r, d: 0 if d > 0 else None),
3325
+ ],
3326
+ ),
3327
+ InPosArg(
3328
+ ArgType.LengthList,
3329
+ name="padding",
3330
+ deps=[0],
3331
+ constraints=[
3332
+ cp.Length.Eq(lambda deps: 6),
3333
+ # TODO(mcandales): Calibrate.
3334
+ # self.size(-1) + padding[0] + padding[1] >= 0
3335
+ # self.size(-2) + padding[2] + padding[3] >= 0
3336
+ # self.size(-3) + padding[4] + padding[5] >= 0
3337
+ ],
3338
+ ),
3339
+ ],
3340
+ outspec=[
3341
+ OutArg(
3342
+ ArgType.Tensor,
3343
+ constraints=[
3344
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3345
+ ],
3346
+ )
3347
+ ],
3348
+ ),
3349
+ Spec(
3350
+ op="round.default", # (Tensor self) -> Tensor
3351
+ inspec=[
3352
+ InPosArg(
3353
+ ArgType.Tensor,
3354
+ name="self",
3355
+ constraints=[
3356
+ cp.Dtype.Ne(lambda deps: torch.bool),
3357
+ ],
3358
+ ),
3359
+ ],
3360
+ outspec=[OutArg(ArgType.Tensor)],
3361
+ ),
3362
+ Spec(
3363
+ op="roll.default", # (Tensor self, SymInt[1] shifts, int[1] dims=[]) -> Tensor
3364
+ inspec=[
3365
+ InPosArg(
3366
+ ArgType.Tensor,
3367
+ name="self",
3368
+ constraints=[
3369
+ cp.Rank.Ge(lambda deps: 1),
3370
+ ],
3371
+ ),
3372
+ InPosArg(
3373
+ ArgType.LengthList,
3374
+ name="shifts",
3375
+ constraints=[
3376
+ cp.Length.Ge(lambda deps: 1),
3377
+ ],
3378
+ ),
3379
+ InPosArg(
3380
+ ArgType.DimList,
3381
+ name="dims",
3382
+ deps=[0, 1],
3383
+ constraints=[
3384
+ cp.Length.Eq(lambda deps: len(deps[1])),
3385
+ cp.Value.Ge(
3386
+ lambda deps, length, ix: (
3387
+ -deps[0].dim()
3388
+ if deps[0].dim() > 0 and deps[0].numel() != 0
3389
+ else None
3390
+ )
3391
+ ),
3392
+ cp.Value.Ge(
3393
+ lambda deps, length, ix: (
3394
+ -1 if deps[0].dim() == 0 and deps[0].numel() != 0 else None
3395
+ )
3396
+ ),
3397
+ cp.Value.Le(
3398
+ lambda deps, length, ix: (
3399
+ deps[0].dim() - 1
3400
+ if deps[0].dim() > 0 and deps[0].numel() != 0
3401
+ else None
3402
+ )
3403
+ ),
3404
+ cp.Value.Le(
3405
+ lambda deps, length, ix: (
3406
+ 0 if deps[0].dim() == 0 and deps[0].numel() != 0 else None
3407
+ )
3408
+ ),
3409
+ ],
3410
+ ),
3411
+ ],
3412
+ outspec=[
3413
+ OutArg(
3414
+ ArgType.Tensor,
3415
+ constraints=[
3416
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3417
+ ],
3418
+ )
3419
+ ],
3420
+ ),
3421
+ Spec(
3422
+ op="rsqrt.default", # (Tensor self) -> Tensor
3423
+ inspec=[
3424
+ InPosArg(ArgType.Tensor, name="self"),
3425
+ ],
3426
+ outspec=[OutArg(ArgType.Tensor)],
3427
+ ),
3428
+ Spec(
3429
+ op="rsub.Scalar", # (Tensor self, Scalar other, Scalar alpha=1) -> Tensor
3430
+ inspec=[
3431
+ InPosArg(
3432
+ ArgType.Tensor,
3433
+ name="self",
3434
+ constraints=[
3435
+ cp.Dtype.Ne(lambda deps: torch.bool),
3436
+ ],
3437
+ ),
3438
+ InPosArg(
3439
+ ArgType.Scalar,
3440
+ name="other",
3441
+ constraints=[
3442
+ cp.Dtype.Ne(lambda deps: ScalarDtype.bool),
3443
+ ],
3444
+ ),
3445
+ InPosArg(
3446
+ ArgType.Scalar,
3447
+ name="alpha",
3448
+ deps=[0, 1],
3449
+ constraints=[
3450
+ cp.Dtype.Ne(lambda deps: ScalarDtype.bool),
3451
+ cp.Dtype.In(
3452
+ lambda deps: fn.st_le(
3453
+ fn.dt_to_st(
3454
+ fn.promote_type_with_scalar(deps[0].dtype, deps[1])
3455
+ )
3456
+ )
3457
+ ),
3458
+ ],
3459
+ ),
3460
+ ],
3461
+ outspec=[
3462
+ OutArg(ArgType.Tensor),
3463
+ ],
3464
+ ),
3465
+ Spec(
3466
+ op="scalar_tensor.default", # (Scalar s, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
3467
+ inspec=[
3468
+ InPosArg(
3469
+ ArgType.Scalar,
3470
+ name="s",
3471
+ deps=[1],
3472
+ constraints=[
3473
+ cp.Value.Ge(lambda deps, dtype: fn.dtype_lower_bound(deps[0])),
3474
+ cp.Value.Le(lambda deps, dtype: fn.dtype_upper_bound(deps[0])),
3475
+ ],
3476
+ ),
3477
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
3478
+ ],
3479
+ outspec=[OutArg(ArgType.Tensor)],
3480
+ ),
3481
+ Spec( # TODO(mcandales): Calibrate.
3482
+ op="scatter.value", # (Tensor self, int dim, Tensor index, Scalar value) -> Tensor
3483
+ inspec=[
3484
+ InPosArg(ArgType.Tensor, name="self"),
3485
+ InPosArg(
3486
+ ArgType.Dim,
3487
+ name="dim",
3488
+ deps=[0],
3489
+ constraints=[
3490
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
3491
+ ],
3492
+ ),
3493
+ InPosArg(
3494
+ ArgType.Tensor,
3495
+ name="index",
3496
+ deps=[0, 1],
3497
+ # TODO(mcandales) Handle index.numel() == 0 case
3498
+ constraints=[
3499
+ cp.Dtype.Eq(lambda deps: torch.long),
3500
+ cp.Rank.Eq(
3501
+ lambda deps: deps[0].dim() if deps[0].dim() >= 2 else None
3502
+ ),
3503
+ cp.Rank.In(
3504
+ lambda deps: [0, 1] if deps[0].dim() in [0, 1] else None
3505
+ ),
3506
+ cp.Size.Le(
3507
+ lambda deps, r, d: (
3508
+ fn.safe_size(deps[0], d)
3509
+ if d != fn.normalize(deps[1], deps[0].dim())
3510
+ else None
3511
+ )
3512
+ ),
3513
+ cp.Value.Ge(lambda deps, dtype, struct: 0),
3514
+ cp.Value.Le(
3515
+ lambda deps, dtype, struct: (
3516
+ 0
3517
+ if deps[0].dim() == 0
3518
+ else max(0, fn.safe_size(deps[0], deps[1]) - 1)
3519
+ )
3520
+ ),
3521
+ ],
3522
+ ),
3523
+ InPosArg(
3524
+ ArgType.Scalar,
3525
+ name="value",
3526
+ deps=[0],
3527
+ constraints=[
3528
+ cp.Value.NotIn(
3529
+ lambda deps, dtype: (
3530
+ [float("-inf"), float("inf")]
3531
+ if deps[0].dtype not in dt._floating
3532
+ else None
3533
+ )
3534
+ ),
3535
+ cp.Value.Ge(
3536
+ lambda deps, dtype: fn.dtype_lower_bound(deps[0].dtype)
3537
+ ),
3538
+ cp.Value.Le(
3539
+ lambda deps, dtype: fn.dtype_upper_bound(deps[0].dtype)
3540
+ ),
3541
+ ],
3542
+ ),
3543
+ ],
3544
+ outspec=[
3545
+ OutArg(
3546
+ ArgType.Tensor,
3547
+ constraints=[
3548
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3549
+ ],
3550
+ ),
3551
+ ],
3552
+ ),
3553
+ Spec( # TODO(mcandales): Calibrate.
3554
+ op="scatter_add.default", # (Tensor self, int dim, Tensor index, Tensor src) -> Tensor
3555
+ inspec=[
3556
+ InPosArg(ArgType.Tensor, name="self"),
3557
+ InPosArg(
3558
+ ArgType.Dim,
3559
+ name="dim",
3560
+ deps=[0],
3561
+ constraints=[
3562
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
3563
+ ],
3564
+ ),
3565
+ InPosArg(
3566
+ ArgType.Tensor,
3567
+ name="index",
3568
+ deps=[0, 1],
3569
+ # TODO(mcandales) Handle index.numel() == 0 case
3570
+ constraints=[
3571
+ cp.Dtype.Eq(lambda deps: torch.long),
3572
+ cp.Rank.Eq(lambda deps: deps[0].dim()),
3573
+ # cp.Size.Le(lambda deps, r, d: fn.scatter_add_index_size_max(
3574
+ # deps[0], deps[1], deps[2], d
3575
+ # )),
3576
+ cp.Size.Le(
3577
+ lambda deps, r, d: (
3578
+ fn.safe_size(deps[0], d)
3579
+ if d != fn.normalize(deps[1], deps[0].dim())
3580
+ else None
3581
+ )
3582
+ ),
3583
+ cp.Value.Ge(lambda deps, dtype, struct: 0),
3584
+ cp.Value.Le(
3585
+ lambda deps, dtype, struct: (
3586
+ 0
3587
+ if deps[0].dim() == 0
3588
+ else max(0, fn.safe_size(deps[0], deps[1]) - 1)
3589
+ )
3590
+ ),
3591
+ ],
3592
+ ),
3593
+ InPosArg(
3594
+ ArgType.Tensor,
3595
+ name="src",
3596
+ deps=[0, 2],
3597
+ constraints=[
3598
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
3599
+ cp.Rank.Eq(
3600
+ lambda deps: deps[1].dim() if deps[1].numel() != 0 else None
3601
+ ),
3602
+ cp.Size.Ge(
3603
+ lambda deps, r, d: (
3604
+ fn.safe_size(deps[1], d) if deps[1].numel() != 0 else None
3605
+ )
3606
+ ),
3607
+ ],
3608
+ ),
3609
+ ],
3610
+ outspec=[
3611
+ OutArg(ArgType.Tensor),
3612
+ ],
3613
+ ),
3614
+ Spec(
3615
+ op="select_copy.int", # (Tensor self, int dim, SymInt index) -> Tensor
3616
+ inspec=[
3617
+ InPosArg(
3618
+ ArgType.Tensor,
3619
+ name="self",
3620
+ constraints=[
3621
+ cp.Rank.Ge(lambda deps: 1),
3622
+ ],
3623
+ ),
3624
+ InPosArg(
3625
+ ArgType.Dim,
3626
+ name="dim",
3627
+ deps=[0],
3628
+ constraints=[
3629
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
3630
+ ],
3631
+ ),
3632
+ InPosArg(
3633
+ ArgType.Index,
3634
+ name="index",
3635
+ deps=[0, 1],
3636
+ constraints=IndexDefault,
3637
+ ),
3638
+ ],
3639
+ outspec=[
3640
+ OutArg(ArgType.Tensor),
3641
+ ],
3642
+ ),
3643
+ Spec(
3644
+ op="select_scatter.default", # (Tensor self, Tensor src, int dim, SymInt index) -> Tensor
3645
+ inspec=[
3646
+ InPosArg(
3647
+ ArgType.Tensor,
3648
+ name="self",
3649
+ constraints=[
3650
+ cp.Rank.Ge(lambda deps: 1),
3651
+ ],
3652
+ ),
3653
+ InPosArg(
3654
+ ArgType.Tensor,
3655
+ name="src",
3656
+ deps=[0, 2, 3],
3657
+ constraints=[
3658
+ cp.Rank.Eq(
3659
+ lambda deps: torch.ops.aten.select(
3660
+ deps[0], deps[1], deps[2]
3661
+ ).dim()
3662
+ ),
3663
+ cp.Size.Eq(
3664
+ lambda deps, r, d: fn.safe_size(
3665
+ torch.ops.aten.select(deps[0], deps[1], deps[2]), d
3666
+ )
3667
+ ),
3668
+ ],
3669
+ ),
3670
+ InPosArg(
3671
+ ArgType.Dim,
3672
+ name="dim",
3673
+ deps=[0],
3674
+ constraints=[
3675
+ cp.Value.In(lambda deps: fn.dim_non_zero_size(deps[0])),
3676
+ ],
3677
+ ),
3678
+ InPosArg(
3679
+ ArgType.Index,
3680
+ name="index",
3681
+ deps=[0, 2],
3682
+ constraints=IndexDefault,
3683
+ ),
3684
+ ],
3685
+ outspec=[
3686
+ OutArg(ArgType.Tensor),
3687
+ ],
3688
+ ),
3689
+ Spec(
3690
+ op="sigmoid.default", # (Tensor self) -> Tensor
3691
+ inspec=[
3692
+ InPosArg(ArgType.Tensor, name="self"),
3693
+ ],
3694
+ outspec=[OutArg(ArgType.Tensor)],
3695
+ ),
3696
+ Spec(
3697
+ op="sign.default", # (Tensor self) -> Tensor
3698
+ inspec=[
3699
+ InPosArg(ArgType.Tensor, name="self"),
3700
+ ],
3701
+ outspec=[OutArg(ArgType.Tensor)],
3702
+ ),
3703
+ Spec(
3704
+ op="sin.default", # (Tensor self) -> Tensor
3705
+ inspec=[
3706
+ InPosArg(ArgType.Tensor, name="self"),
3707
+ ],
3708
+ outspec=[OutArg(ArgType.Tensor)],
3709
+ ),
3710
+ Spec(
3711
+ op="sinh.default", # (Tensor self) -> Tensor
3712
+ inspec=[
3713
+ InPosArg(ArgType.Tensor, name="self"),
3714
+ ],
3715
+ outspec=[OutArg(ArgType.Tensor)],
3716
+ ),
3717
+ Spec(
3718
+ op="slice_copy.Tensor", # (Tensor self, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor
3719
+ inspec=[
3720
+ InPosArg(
3721
+ ArgType.Tensor,
3722
+ name="self",
3723
+ constraints=[
3724
+ cp.Rank.Ge(lambda deps: 1),
3725
+ ],
3726
+ ),
3727
+ InPosArg(
3728
+ ArgType.Dim,
3729
+ name="dim",
3730
+ deps=[0],
3731
+ constraints=DimDefault,
3732
+ ),
3733
+ InPosArg(
3734
+ ArgType.IndexOpt,
3735
+ name="start",
3736
+ deps=[0, 1],
3737
+ constraints=[
3738
+ cp.Value.Be(
3739
+ lambda deps: list(
3740
+ range(
3741
+ -fn.safe_size(deps[0], deps[1]) - 2,
3742
+ fn.safe_size(deps[0], deps[1]) + 2,
3743
+ )
3744
+ )
3745
+ ),
3746
+ ],
3747
+ ),
3748
+ InPosArg(
3749
+ ArgType.IndexOpt,
3750
+ name="end",
3751
+ deps=[0, 1],
3752
+ constraints=[
3753
+ cp.Value.Be(
3754
+ lambda deps: list(
3755
+ range(
3756
+ -fn.safe_size(deps[0], deps[1]) - 2,
3757
+ fn.safe_size(deps[0], deps[1]) + 2,
3758
+ )
3759
+ )
3760
+ ),
3761
+ ],
3762
+ ),
3763
+ InPosArg(
3764
+ ArgType.Length,
3765
+ name="step",
3766
+ deps=[0, 1],
3767
+ constraints=[
3768
+ cp.Value.Ge(lambda deps: 1),
3769
+ cp.Value.Be(
3770
+ lambda deps: list(range(1, fn.safe_size(deps[0], deps[1]) + 2))
3771
+ ),
3772
+ ],
3773
+ ),
3774
+ ],
3775
+ outspec=[
3776
+ OutArg(ArgType.Tensor),
3777
+ ],
3778
+ ),
3779
+ Spec(
3780
+ op="slice_scatter.default", # (Tensor self, Tensor src, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor
3781
+ inspec=[
3782
+ InPosArg(
3783
+ ArgType.Tensor,
3784
+ name="self",
3785
+ constraints=[
3786
+ cp.Rank.Ge(lambda deps: 1),
3787
+ ],
3788
+ ),
3789
+ InPosArg(
3790
+ ArgType.Tensor,
3791
+ name="src",
3792
+ deps=[0, 2, 3, 4, 5],
3793
+ constraints=[
3794
+ cp.Rank.Eq(
3795
+ lambda deps: torch.ops.aten.slice_copy.Tensor(
3796
+ deps[0], deps[1], deps[2], deps[3], deps[4]
3797
+ ).dim()
3798
+ ),
3799
+ cp.Size.Eq(
3800
+ lambda deps, r, d: fn.safe_size(
3801
+ torch.ops.aten.slice_copy.Tensor(
3802
+ deps[0], deps[1], deps[2], deps[3], deps[4]
3803
+ ),
3804
+ d,
3805
+ )
3806
+ ),
3807
+ ],
3808
+ ),
3809
+ InPosArg(
3810
+ ArgType.Dim,
3811
+ name="dim",
3812
+ deps=[0],
3813
+ constraints=DimDefault,
3814
+ ),
3815
+ InPosArg(
3816
+ ArgType.IndexOpt,
3817
+ name="start",
3818
+ deps=[0, 2],
3819
+ constraints=[
3820
+ cp.Value.Be(
3821
+ lambda deps: list(
3822
+ range(
3823
+ -fn.safe_size(deps[0], deps[1]) - 2,
3824
+ fn.safe_size(deps[0], deps[1]) + 2,
3825
+ )
3826
+ )
3827
+ ),
3828
+ ],
3829
+ ),
3830
+ InPosArg(
3831
+ ArgType.IndexOpt,
3832
+ name="end",
3833
+ deps=[0, 2],
3834
+ constraints=[
3835
+ cp.Value.Be(
3836
+ lambda deps: list(
3837
+ range(
3838
+ -fn.safe_size(deps[0], deps[1]) - 2,
3839
+ fn.safe_size(deps[0], deps[1]) + 2,
3840
+ )
3841
+ )
3842
+ ),
3843
+ ],
3844
+ ),
3845
+ InPosArg(
3846
+ ArgType.Length,
3847
+ name="step",
3848
+ deps=[0, 2],
3849
+ constraints=[
3850
+ cp.Value.Ge(lambda deps: 1),
3851
+ cp.Value.Be(
3852
+ lambda deps: list(range(1, fn.safe_size(deps[0], deps[1]) + 2))
3853
+ ),
3854
+ ],
3855
+ ),
3856
+ ],
3857
+ outspec=[
3858
+ OutArg(ArgType.Tensor),
3859
+ ],
3860
+ ),
3861
+ Spec(
3862
+ op="split_copy.Tensor", # (Tensor self, SymInt split_size, int dim=0) -> Tensor[]
3863
+ inspec=[
3864
+ InPosArg(
3865
+ ArgType.Tensor,
3866
+ name="self",
3867
+ constraints=[
3868
+ cp.Rank.Ge(lambda deps: 1),
3869
+ ],
3870
+ ),
3871
+ InPosArg(
3872
+ ArgType.Length,
3873
+ name="split_size",
3874
+ deps=[0, 2],
3875
+ constraints=[
3876
+ cp.Value.Ge(
3877
+ lambda deps: 0 if fn.safe_size(deps[0], deps[1]) == 0 else 1
3878
+ ),
3879
+ ],
3880
+ ),
3881
+ InPosArg(
3882
+ ArgType.Dim,
3883
+ name="dim",
3884
+ deps=[0],
3885
+ constraints=DimDefault,
3886
+ ),
3887
+ ],
3888
+ outspec=[
3889
+ OutArg(ArgType.TensorList),
3890
+ ],
3891
+ ),
3892
+ Spec(
3893
+ op="split_with_sizes_copy.default", # (Tensor self, SymInt[] split_sizes, int dim=0) -> Tensor[]
3894
+ inspec=[
3895
+ InPosArg(
3896
+ ArgType.Tensor,
3897
+ name="self",
3898
+ constraints=[
3899
+ cp.Rank.Ge(lambda deps: 1),
3900
+ ],
3901
+ ),
3902
+ InPosArg(
3903
+ ArgType.LengthList,
3904
+ name="split_sizes",
3905
+ deps=[0, 2],
3906
+ constraints=[
3907
+ cp.Value.Ge(lambda deps, length: 0),
3908
+ cp.Value.Le(lambda deps, length: fn.safe_size(deps[0], deps[1])),
3909
+ ],
3910
+ ),
3911
+ InPosArg(
3912
+ ArgType.Dim,
3913
+ name="dim",
3914
+ deps=[0],
3915
+ constraints=DimDefault,
3916
+ ),
3917
+ ],
3918
+ outspec=[
3919
+ OutArg(ArgType.TensorList),
3920
+ ],
3921
+ ),
3922
+ Spec(
3923
+ op="sqrt.default", # (Tensor self) -> Tensor
3924
+ inspec=[
3925
+ InPosArg(ArgType.Tensor, name="self"),
3926
+ ],
3927
+ outspec=[OutArg(ArgType.Tensor)],
3928
+ ),
3929
+ Spec(
3930
+ op="squeeze_copy.dim", # (Tensor self, int dim) -> Tensor
3931
+ inspec=[
3932
+ InPosArg(ArgType.Tensor, name="self"),
3933
+ InPosArg(
3934
+ ArgType.Dim,
3935
+ name="dim",
3936
+ deps=[0],
3937
+ constraints=DimDefault,
3938
+ ),
3939
+ ],
3940
+ outspec=[
3941
+ OutArg(ArgType.Tensor),
3942
+ ],
3943
+ ),
3944
+ Spec(
3945
+ op="squeeze_copy.dims", # (Tensor self, int[] dim) -> Tensor
3946
+ inspec=[
3947
+ InPosArg(ArgType.Tensor, name="self"),
3948
+ InPosArg(
3949
+ ArgType.DimList,
3950
+ name="dim",
3951
+ deps=[0],
3952
+ constraints=DimListDefault,
3953
+ ),
3954
+ ],
3955
+ outspec=[
3956
+ OutArg(ArgType.Tensor),
3957
+ ],
3958
+ ),
3959
+ Spec(
3960
+ op="sub.Tensor", # (Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor
3961
+ inspec=[
3962
+ InPosArg(
3963
+ ArgType.Tensor,
3964
+ name="self",
3965
+ constraints=[
3966
+ cp.Dtype.Ne(lambda deps: torch.bool),
3967
+ ],
3968
+ ),
3969
+ InPosArg(
3970
+ ArgType.Tensor,
3971
+ name="other",
3972
+ deps=[0],
3973
+ constraints=[
3974
+ cp.Dtype.Ne(lambda deps: torch.bool),
3975
+ cp.Size.In(
3976
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
3977
+ ),
3978
+ ],
3979
+ ),
3980
+ InKwArg(
3981
+ ArgType.Scalar,
3982
+ name="alpha",
3983
+ deps=[0, 1],
3984
+ constraints=[
3985
+ cp.Dtype.Ne(lambda deps: ScalarDtype.bool),
3986
+ cp.Dtype.In(
3987
+ lambda deps: fn.st_le(
3988
+ fn.dt_to_st(
3989
+ torch.promote_types(deps[0].dtype, deps[1].dtype)
3990
+ )
3991
+ )
3992
+ ),
3993
+ ],
3994
+ ),
3995
+ ],
3996
+ outspec=[
3997
+ OutArg(ArgType.Tensor),
3998
+ ],
3999
+ ),
4000
+ Spec(
4001
+ op="sub.Scalar", # (Tensor self, Scalar other, Scalar alpha=1) -> Tensor
4002
+ inspec=[
4003
+ InPosArg(
4004
+ ArgType.Tensor,
4005
+ name="self",
4006
+ constraints=[
4007
+ cp.Dtype.Ne(lambda deps: torch.bool),
4008
+ ],
4009
+ ),
4010
+ InPosArg(
4011
+ ArgType.Scalar,
4012
+ name="other",
4013
+ constraints=[
4014
+ cp.Dtype.Ne(lambda deps: ScalarDtype.bool),
4015
+ ],
4016
+ ),
4017
+ InPosArg(
4018
+ ArgType.Scalar,
4019
+ name="alpha",
4020
+ deps=[0, 1],
4021
+ constraints=[
4022
+ cp.Dtype.Ne(lambda deps: ScalarDtype.bool),
4023
+ cp.Dtype.In(
4024
+ lambda deps: fn.st_le(
4025
+ fn.dt_to_st(
4026
+ fn.promote_type_with_scalar(deps[0].dtype, deps[1])
4027
+ )
4028
+ )
4029
+ ),
4030
+ ],
4031
+ ),
4032
+ ],
4033
+ outspec=[
4034
+ OutArg(ArgType.Tensor),
4035
+ ],
4036
+ ),
4037
+ Spec(
4038
+ op="sum.dim_IntList", # (Tensor self, int[1]? dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
4039
+ inspec=[
4040
+ InPosArg(ArgType.Tensor, name="self"),
4041
+ InPosArg(
4042
+ ArgType.DimListOpt,
4043
+ name="dim",
4044
+ deps=[0],
4045
+ constraints=DimListDefault,
4046
+ ),
4047
+ InPosArg(ArgType.Bool, name="keepdim"),
4048
+ InKwArg(ArgType.ScalarTypeOpt, name="dtype"),
4049
+ ],
4050
+ outspec=[
4051
+ OutArg(ArgType.Tensor),
4052
+ ],
4053
+ ),
4054
+ Spec(
4055
+ op="t_copy.default", # (Tensor self) -> Tensor
4056
+ inspec=[
4057
+ InPosArg(
4058
+ ArgType.Tensor,
4059
+ name="self",
4060
+ constraints=[
4061
+ cp.Rank.Le(lambda deps: 2),
4062
+ ],
4063
+ ),
4064
+ ],
4065
+ outspec=[OutArg(ArgType.Tensor)],
4066
+ ),
4067
+ Spec(
4068
+ op="tan.default", # (Tensor self) -> Tensor
4069
+ inspec=[
4070
+ InPosArg(ArgType.Tensor, name="self"),
4071
+ ],
4072
+ outspec=[OutArg(ArgType.Tensor)],
4073
+ ),
4074
+ Spec(
4075
+ op="tanh.default", # (Tensor self) -> Tensor
4076
+ inspec=[
4077
+ InPosArg(ArgType.Tensor, name="self"),
4078
+ ],
4079
+ outspec=[OutArg(ArgType.Tensor)],
4080
+ ),
4081
+ Spec(
4082
+ op="topk.default", # (Tensor self, SymInt k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)
4083
+ inspec=[
4084
+ InPosArg(
4085
+ ArgType.Tensor,
4086
+ name="self",
4087
+ constraints=[cp.Dtype.Ne(lambda deps: torch.bool)],
4088
+ ),
4089
+ InPosArg(
4090
+ ArgType.Length,
4091
+ name="k",
4092
+ deps=[0, 2],
4093
+ constraints=[
4094
+ cp.Value.Ge(lambda deps: 0),
4095
+ cp.Value.Le(lambda deps: fn.safe_size(deps[0], deps[1])),
4096
+ ],
4097
+ ),
4098
+ InPosArg(
4099
+ ArgType.Dim,
4100
+ name="dim",
4101
+ deps=[0],
4102
+ constraints=DimDefault,
4103
+ ),
4104
+ InPosArg(ArgType.Bool, name="largest"),
4105
+ InPosArg(ArgType.Bool, name="sorted"),
4106
+ ],
4107
+ outspec=[
4108
+ OutArg(
4109
+ ArgType.Tensor,
4110
+ name="values",
4111
+ constraints=[cp.Dtype.Eq(lambda deps: deps[0].dtype)],
4112
+ ),
4113
+ OutArg(
4114
+ ArgType.Tensor,
4115
+ name="indices",
4116
+ constraints=[cp.Dtype.Eq(lambda deps: torch.long)],
4117
+ ),
4118
+ ],
4119
+ ),
4120
+ Spec(
4121
+ op="transpose_copy.int", # (Tensor self, int dim0, int dim1) -> Tensor
4122
+ inspec=[
4123
+ InPosArg(ArgType.Tensor, name="self"),
4124
+ InPosArg(
4125
+ ArgType.Dim,
4126
+ name="dim0",
4127
+ deps=[0],
4128
+ constraints=DimDefault,
4129
+ ),
4130
+ InPosArg(
4131
+ ArgType.Dim,
4132
+ name="dim1",
4133
+ deps=[0],
4134
+ constraints=DimDefault,
4135
+ ),
4136
+ ],
4137
+ outspec=[
4138
+ OutArg(ArgType.Tensor),
4139
+ ],
4140
+ ),
4141
+ Spec(
4142
+ op="tril.default", # (Tensor self, int diagonal=0) -> Tensor
4143
+ inspec=[
4144
+ InPosArg(
4145
+ ArgType.Tensor,
4146
+ name="self",
4147
+ constraints=[
4148
+ cp.Rank.Ge(lambda deps: 2),
4149
+ ],
4150
+ ),
4151
+ InPosArg(
4152
+ ArgType.Int,
4153
+ name="diagonal",
4154
+ deps=[0],
4155
+ constraints=[
4156
+ cp.Value.Be(
4157
+ lambda deps: list(
4158
+ range(
4159
+ -fn.safe_size(deps[0], 0) - 1,
4160
+ fn.safe_size(deps[0], 0) + 1,
4161
+ )
4162
+ )
4163
+ ),
4164
+ ],
4165
+ ),
4166
+ ],
4167
+ outspec=[
4168
+ OutArg(ArgType.Tensor),
4169
+ ],
4170
+ ),
4171
+ Spec(
4172
+ op="trunc.default", # (Tensor self) -> Tensor
4173
+ inspec=[
4174
+ InPosArg(
4175
+ ArgType.Tensor,
4176
+ name="self",
4177
+ constraints=[
4178
+ cp.Dtype.Ne(lambda deps: torch.bool),
4179
+ ],
4180
+ ),
4181
+ ],
4182
+ outspec=[
4183
+ OutArg(
4184
+ ArgType.Tensor,
4185
+ constraints=[
4186
+ cp.Dtype.Eq(lambda deps: deps[0].dtype),
4187
+ ],
4188
+ )
4189
+ ],
4190
+ ),
4191
+ Spec(
4192
+ op="unbind_copy.int", # (Tensor self, int dim=0) -> Tensor[]
4193
+ inspec=[
4194
+ InPosArg(
4195
+ ArgType.Tensor,
4196
+ name="self",
4197
+ constraints=[
4198
+ cp.Rank.Ge(lambda deps: 1),
4199
+ ],
4200
+ ),
4201
+ InPosArg(
4202
+ ArgType.Dim,
4203
+ name="dim",
4204
+ deps=[0],
4205
+ constraints=DimDefault,
4206
+ ),
4207
+ ],
4208
+ outspec=[
4209
+ OutArg(ArgType.TensorList),
4210
+ ],
4211
+ ),
4212
+ Spec(
4213
+ op="unsqueeze_copy.default", # (Tensor self, int dim) -> Tensor
4214
+ inspec=[
4215
+ InPosArg(ArgType.Tensor, name="self"),
4216
+ InPosArg(
4217
+ ArgType.Dim,
4218
+ name="dim",
4219
+ deps=[0],
4220
+ constraints=[
4221
+ cp.Value.Ge(lambda deps: -deps[0].dim() - 1),
4222
+ cp.Value.Le(lambda deps: deps[0].dim()),
4223
+ ],
4224
+ ),
4225
+ ],
4226
+ outspec=[
4227
+ OutArg(ArgType.Tensor),
4228
+ ],
4229
+ ),
4230
+ Spec(
4231
+ op="var.correction", # (Tensor self, int[1]? dim=None, *, Scalar? correction=None, bool keepdim=False) -> Tensor
4232
+ inspec=[
4233
+ InPosArg(
4234
+ ArgType.Tensor,
4235
+ name="self",
4236
+ constraints=[
4237
+ cp.Dtype.In(lambda deps: dt._floating),
4238
+ ],
4239
+ ),
4240
+ InPosArg(
4241
+ ArgType.DimListOpt,
4242
+ name="dim",
4243
+ deps=[0],
4244
+ constraints=DimListDefault,
4245
+ ),
4246
+ InKwArg(ArgType.ScalarOpt, name="correction"),
4247
+ InKwArg(ArgType.Bool, name="keepdim"),
4248
+ ],
4249
+ outspec=[
4250
+ OutArg(
4251
+ ArgType.Tensor,
4252
+ constraints=[
4253
+ cp.Dtype.In(lambda deps: dt._floating),
4254
+ ],
4255
+ ),
4256
+ ],
4257
+ ),
4258
+ Spec(
4259
+ op="var.dim", # (Tensor self, int[1]? dim, bool unbiased=True, bool keepdim=False) -> Tensor
4260
+ inspec=[
4261
+ InPosArg(
4262
+ ArgType.Tensor,
4263
+ name="self",
4264
+ constraints=[
4265
+ cp.Dtype.In(lambda deps: dt._floating),
4266
+ ],
4267
+ ),
4268
+ InPosArg(
4269
+ ArgType.DimListOpt,
4270
+ name="dim",
4271
+ deps=[0],
4272
+ constraints=DimListDefault,
4273
+ ),
4274
+ InPosArg(ArgType.Bool, name="unbiased"),
4275
+ InPosArg(ArgType.Bool, name="keepdim"),
4276
+ ],
4277
+ outspec=[
4278
+ OutArg(
4279
+ ArgType.Tensor,
4280
+ constraints=[
4281
+ cp.Dtype.In(lambda deps: dt._floating),
4282
+ ],
4283
+ ),
4284
+ ],
4285
+ ),
4286
+ Spec( # TODO(mcandales) Implement numel constraint prefix
4287
+ op="view_copy.default", # (Tensor self, SymInt[] size) -> Tensor
4288
+ inspec=[
4289
+ InPosArg(ArgType.Tensor, name="self"),
4290
+ InPosArg(
4291
+ ArgType.Shape,
4292
+ name="size",
4293
+ deps=[0],
4294
+ constraints=[
4295
+ cp.Length.Ge(lambda deps: 1 if deps[0].numel() != 1 else 0),
4296
+ cp.Value.Gen(
4297
+ lambda deps, length: (
4298
+ fn.valid_view_copy_size(deps[0], length),
4299
+ fn.invalid_view_copy_size(deps[0], length),
4300
+ )
4301
+ ),
4302
+ ],
4303
+ ),
4304
+ ],
4305
+ outspec=[
4306
+ OutArg(ArgType.Tensor),
4307
+ ],
4308
+ ),
4309
+ Spec(
4310
+ op="where.self", # (Tensor condition, Tensor self, Tensor other) -> Tensor
4311
+ inspec=[
4312
+ InPosArg(
4313
+ ArgType.Tensor,
4314
+ name="condition",
4315
+ constraints=[
4316
+ cp.Dtype.In(lambda deps: [torch.bool, torch.uint8]),
4317
+ ],
4318
+ ),
4319
+ InPosArg(
4320
+ ArgType.Tensor,
4321
+ name="self",
4322
+ deps=[0],
4323
+ constraints=[
4324
+ cp.Size.In(
4325
+ lambda deps, r, d: fn.broadcast_with(deps[0].shape, r, d)
4326
+ ),
4327
+ ],
4328
+ ),
4329
+ InPosArg(
4330
+ ArgType.Tensor,
4331
+ name="other",
4332
+ deps=[0, 1],
4333
+ constraints=[
4334
+ cp.Size.In(
4335
+ lambda deps, r, d: fn.broadcast_with(
4336
+ fn.broadcasted_shape(deps[0].shape, deps[1].shape), r, d
4337
+ )
4338
+ ),
4339
+ ],
4340
+ ),
4341
+ ],
4342
+ outspec=[
4343
+ OutArg(ArgType.Tensor),
4344
+ ],
4345
+ ),
4346
+ Spec(
4347
+ op="zeros.default", # (SymInt[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
4348
+ inspec=[
4349
+ InPosArg(
4350
+ ArgType.Shape,
4351
+ name="size",
4352
+ constraints=ShapeDefault,
4353
+ ),
4354
+ InKwArg(ArgType.ScalarTypeOpt, "dtype"),
4355
+ ],
4356
+ outspec=[OutArg(ArgType.Tensor)],
4357
+ ),
4358
+ ]
4359
+
4360
+
4361
+ SpecDictDB = {s.op: s for s in SpecDB}