
    i6                         S r SSKrSSKJrJr  SSKJr  SSKJrJ	r	  SSK
JrJr  S\S\\	   S	\4S
 jr SS\S	\4S jjr SS\S	\4S jjrg)z
Target-specific recipe functions for simplified multi-backend deployment.

This module provides platform-specific functions that abstract away backend 
selection and combine multiple backends optimally for target hardware.
    N)DictList)XNNPackRecipeType)ExportRecipe
RecipeType))is_supported_platform_for_coreml_lowering&is_supported_platform_for_qnn_loweringtarget_configrecipesreturnc           
      F   U(       d  [        SU  35      e/ nU H,  n [        R                  " U40 UD6nUR                  U5        M.     [        U5      S:X  a  US   $ [        R                  " X0S9$ ! [         a$  n[        SUR
                   SU  SU 35      UeSnAff = f)	a/  
Create a combined recipe for a target.

Args:
    target_config: Human-readable hardware configuration name
    recipes: List of backend recipe types to combine
    **kwargs: Additional parameters - each backend will use what it needs

Returns:
    Combined ExportRecipe for the hardware configuration
zNo backends configured for: zFailed to create z recipe for z: N   r   )recipe_name)
ValueErrorr   
get_recipeappend	Exceptionvaluelencombine)r
   r   kwargsbackend_recipesrecipe_typebackend_recipees          _/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/export/target_recipes.py_create_target_reciper      s     7GHH O	)44[KFKN"">2  ?q q!!KK  	#K$5$5#6l=/QSTUSVW	s   (A22
B <BB c                    [        5       (       d  [        S5      eSSKnSSKJn  UR
                  [        R
                  /UR                  [        R
                  /UR                  /S.nX;  a*  [        UR                  5       5      n[        SU  SU 35      eU=(       d    0 nU S:X  a  S	U;  a  UR                  R                  US	'   X@   n[        X40 UD6$ )
aY  
Get iOS-optimized recipe for specified hardware configuration.

Supported configurations:
- 'ios-arm64-coreml-fp32': CoreML + XNNPACK fallback (FP32)
- 'ios-arm64-coreml-fp16': CoreML fp16 recipe
- 'ios-arm64-coreml-int8': CoreML INT8 quantization recipe

Args:
    target_config: iOS configuration string
    **kwargs: Additional parameters for backend recipes

Returns:
    ExportRecipe configured for iOS deployment

Raises:
    ValueError: If target configuration is not supported

Example:
    recipe = get_ios_recipe('ios-arm64-coreml-int8')
    session = export(model, recipe, example_inputs)
z(CoreML is not supported on this platformr   N)CoreMLRecipeType)zios-arm64-coreml-fp32ios-arm64-coreml-fp16ios-arm64-coreml-int8z Unsupported iOS configuration: ''. Supported: r!   minimum_deployment_target)r   r   coremltools(executorch.backends.apple.coreml.recipesr   FP32r   FP16PT2E_INT8_STATIClistkeystargetiOS17r   )r
   r   ctr   ios_configs	supportedr   s          r   get_ios_reciper0   <   s    4 566CDDI #3"7"79J9O9O!P"2"7"79J9O9O!P"2"C"C!D0K '))+,	.}o >#&
 	

 \rF//&f424))//F./!0O J6JJ    c                    [        5       (       d  [        S5      e SSKJn  [        R
                  " SS5      c  [        S5      e SUR                  [        R                  /0nX;  a*  [        UR                  5       5      n[        S	U  S
U 35      eU=(       d    0 nU S:X  a  SU;  a  SUS'   X@   n[        X40 UD6$ ! [         a  n[        S5      UeSnAff = f)a  
Get Android-optimized recipe for specified hardware configuration.

Supported configurations:
- 'android-arm64-snapdragon-fp16': QNN fp16 recipe

Args:
    target_config: Android configuration string
    **kwargs: Additional parameters for backend recipes

Returns:
    ExportRecipe configured for Android deployment

Raises:
    ValueError: If target configuration is not supported

Example:
    recipe = get_android_recipe('android-arm64-snapdragon-fp16')
    session = export(model, recipe, example_inputs)
z@QNN is not supported or not properly configured on this platformr   )QNNRecipeTypeQNN_SDK_ROOTNztQNN SDK not found, cannot use QNN recipes. First run `./backends/qualcomm/scripts/build.sh`, if building from sourcezgQNN backend is not available. Please ensure the Qualcomm backend is properly installed and configured, android-arm64-snapdragon-fp16z$Unsupported Android configuration: 'r"   	soc_modelSM8650)r	   r   $executorch.backends.qualcomm.recipesr3   osgetenvr   r'   r   r&   r)   r*   r   )r
   r   r3   r   android_configsr/   r   s          r   get_android_reciper<   w   s   0 233N
 	
 	G 99^T*2 G  3 	(-*<*<>O>T>T)U4O
 +--/0	2=/ B#&
 	

 \rF77f$"*F;%4O J6JJ3  5
 	s   )B? ?
C	CC)r    )r5   )__doc__r9   typingr   r   #executorch.backends.xnnpack.recipesr   executorch.export.reciper   r   executorch.export.utilsr   r	   strr   r0   r<    r1   r   <module>rD      s    
  A =LL!%j!1LLH 17K7K7Kx 9BKBKBKr1   