
    i                         d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ erd dlmZ d dlmZ g dZ G d de      Zy)    )Sequence)getattr_static)AnyTYPE_CHECKING	TypeGuard)Source
SDPAParams)Proxy   )create_call_function)unimplemented)
AttrSource   )VariableTracker)	PyCodegen)InstructionTranslator)querykeyvalue	attn_maskdropout	is_causal
enable_gqac            	            e Zd ZdZedddededefd       Zde	d	e
e   d
eddf fdZddZde	fdZdddedefdZededed   fd       Z xZS )SDPAParamsVariablezeRepresents the c++ params struct for scaled dot product attention.
    This is a read-only container.txr   r   sourcereturnc                     ddl m} t        D cg c]-  }t        j                  | t        ||      t        ||            / }} |t              j                  | |i       S c c}w )Nr   )TorchInGraphFunctionVariable)	torchr!   PARAM_NAMESr   buildgetattrr   r
   call_function)r   r   r   r!   pparamss         V/var/www/html/engine/venv/lib/python3.12/site-packages/torch/_dynamo/variables/sdpa.pycreatezSDPAParamsVariable.create"   se     	8 !
 !!"geQ&7FA9NO
 
 ,J7EEb&RTUU	
s   2A proxy
param_varskwargsNc                 @    || _         || _        t        |   di | y )N )r+   r,   super__init__)selfr+   r,   r-   	__class__s       r)   r1   zSDPAParamsVariable.__init__.   s#     
$"6"    c                     | j                   J | j                  J j                  fd       j                  | j                         j	                  t        t        | j                        d             y )Nc                  (     j                  dd      S )Nztorch._C_SDPAParams)load_import_from)codegens   r)   <lambda>z0SDPAParamsVariable.reconstruct.<locals>.<lambda>9   s    G,,ZG r4   F)r   r,   add_push_nullforeachextend_outputr   len)r2   r9   s    `r)   reconstructzSDPAParamsVariable.reconstruct5   se    {{"""***G	
 	(23t3GOPr4   c                     | j                   S N)r+   )r2   s    r)   as_proxyzSDPAParamsVariable.as_proxy>   s    zzr4   namec                    dd l }ddlm} ddlm} 	 t        |j                  j                  |       |j                  | j                         |      }| j                    |||t#        | j                   |      
      S  |||      S # t        $ r. dd l	m
c m} t        dd| d| dg |j                  	       Y w xY w)Nr   r   )wrap_fx_proxy)GetAttrVariablez*unsupported torch._C._SDPAParams attributezname: zUnable to fetch attribute z from torch._C._SDPAParams.)gb_typecontextexplanationhints)r   r+   r   )r   r+   )torch._CbuilderrE   miscrF   r   _Cr7   AttributeErrortorch._dynamo.graph_break_hints_dynamograph_break_hintsr   
USER_ERRORcreate_getattr_proxyrB   r   r   )r2   r   rC   r"   rE   rF   rR   r+   s           r)   var_getattrzSDPAParamsVariable.var_getattrA   s    *)	588//6  44T]]_dK;;" U:dkk4+H  !Be44%  
	GGD 8>YZ&11	
	s    B 4B>=B>r
   c                     | t         u S rA   r	   )r   s    r)   is_sdpa_paramsz!SDPAParamsVariable.is_sdpa_params]   s    
""r4   )r9   r   r   N)__name__
__module____qualname____doc__staticmethodr   r   r   r*   r   r   r1   r?   rB   strrU   r   rW   __classcell__)r3   s   @r)   r   r      s    & 	V#	V,/	V9?	V		V 	V##(0(A#MP#	#Q% 55 5S 5_ 58 #c #i&= # #r4   r   N)collections.abcr   inspectr   typingr   r   r   torch._guardsr   torch.backends.cudar
   torch.fx.proxyr   bytecode_transformationr   excr   r   r   baser   torch._dynamo.codegenr   torch._dynamo.symbolic_convertr   r#   r   r/   r4   r)   <module>rj      sF    $ " 0 0   *   :   ! /DA# A#r4   