
    Vh	                         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
j                         Z G d de      Zy)    )getattr_static)TYPE_CHECKING   )create_call_function)Unsupported)
AttrSource   )VariableTracker)InstructionTranslatorz6query key value attn_mask dropout is_causal enable_gqac                   f     e Zd ZdZedd       Zd fdZd Zd Zddd	e	de
fd
Zed        Z xZS )SDPAParamsVariablezeRepresents the c++ params struct for scaled dot product attention.
    This is a read-only container.txr   c                     ddl m} ddlm} t        D cg c]-  }t        j                  | t        ||      t        ||            / }} ||      j                  | |i       S c c}w )Nr   
SDPAParamsr	   )TorchInGraphFunctionVariable)
torch.backends.cudar   torchr   PARAM_NAMESr
   buildgetattrr   call_function)r   valuesourcer   r   pparamss          L/home/dcms/DCMS/lib/python3.12/site-packages/torch/_dynamo/variables/sdpa.pycreatezSDPAParamsVariable.create   sf    27 !
 !!"geQ&7FA9NO
 
 ,J7EEb&RTUU	
s   2A"returnc                 @    || _         || _        t        |   di | y )N )proxy
param_varssuper__init__)selfr"   r#   kwargs	__class__s       r   r%   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>+   s    G,,ZG r)   F)r   r#   add_push_nullforeachextend_outputr   len)r&   r.   s    `r   reconstructzSDPAParamsVariable.reconstruct'   se    {{"""***G	
 	(23t3GOPr)   c                     | j                   S )N)r"   )r&   s    r   as_proxyzSDPAParamsVariable.as_proxy0   s    zzr)   namec                 F   dd l }ddlm} ddlm} 	 t        |j                  j                  |       |j                  | j                         |      }| j                   |||t        | j                  |            S  |||      S # t        $ r t        d|       d w xY w)Nr   r	   )wrap_fx_proxy)GetAttrVariablez+Unsupported torch._C._SDPAParams attribute )r   r"   r   )r   r"   )torch._Cbuilderr9   miscr:   r   _Cr,   AttributeErrorr   create_getattr_proxyr6   r   r   )r&   r   r7   r   r9   r:   r"   s          r   var_getattrzSDPAParamsVariable.var_getattr3   s    *)	588//6  44T]]_dK;;" U:dkk4+H  !Be44  	=dVD	s    B B c                     ddl m} | |u S )Nr   r   )r   r   )r   r   s     r   is_sdpa_paramsz!SDPAParamsVariable.is_sdpa_paramsI   s    2
""r)   )r   r   )r   N)__name__
__module____qualname____doc__staticmethodr   r%   r4   r6   strr
   rA   rC   __classcell__)r(   s   @r   r   r      s]    & 	V 	V#
Q55 5S 5_ 5, # #r)   r   N)inspectr   typingr   bytecode_transformationr   excr   r   r   baser
   torch._dynamo.symbolic_convertr   splitr   r   r!   r)   r   <module>rR      s;    #   :   ! DFLLN;# ;#r)   