
    ^j                         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)    )getattr_static)AnyTYPE_CHECKING	TypeGuard)Source
SDPAParams)Proxy   )create_call_function)unimplemented)
AttrSource   )VariableTracker)	PyCodegen)InstructionTranslatorBase)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e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         g/var/www/ramen.bs-engineer-server.com/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(   r0   zSDPAParamsVariable.__init__-   s#     
$"6"    c                     t         S Nr   r1   s    r(   python_typezSDPAParamsVariable.python_type4   s    r3   c                    | j                   t        d      | j                  t        d      j                  fd       j	                  | j                         j                  t        t        | j                        d             y )Nz>SDPAParamsVariable should not have a source during reconstructz.SDPAParamsVariable.param_vars must not be Nonec                  (     j                  dd      S )Nztorch._C_SDPAParams)load_import_from)codegens   r(   <lambda>z0SDPAParamsVariable.reconstruct.<locals>.<lambda>?   s    G,,ZG r3   F)r   AssertionErrorr+   add_push_nullforeachextend_outputr   len)r1   r<   s    `r(   reconstructzSDPAParamsVariable.reconstruct7   sw    ;;" P  ??" !QRRG	
 	(23t3GOPr3   c                     | j                   S r5   )r*   r6   s    r(   as_proxyzSDPAParamsVariable.as_proxyD   s    zzr3   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builderrH   miscrI   r   _Cr:   AttributeErrortorch._dynamo.graph_break_hints_dynamograph_break_hintsr   
USER_ERRORcreate_getattr_proxyrE   r   r   )r1   r   rF   r!   rH   rI   rU   r*   s           r(   var_getattrzSDPAParamsVariable.var_getattrG   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 r5   r   )r   s    r(   is_sdpa_paramsz!SDPAParamsVariable.is_sdpa_paramse   s    
""r3   )r<   r   r   N)__name__
__module____qualname____doc__staticmethodr   r   r   r)   r
   listr0   typer7   rC   rE   strrX   r   rZ   __classcell__)r2   s   @r(   r   r      s    & 	V'	V03	V=C	V		V 	V##(,_(=#IL#	#T Q% 5-5585	5< #c #i&= # #r3   r   N)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.   r3   r(   <module>rn      sC    " 0 0   *   :   ! /HJ# J#r3   