§
    %P„j¬  ã                   ó˜   — d Z ddlmZmZmZmZ ddlmZ dgZ	 ddee	         de	ded	eeee
                  df         d
ee	ef         f
d„ZdS )z0Determines if a contraction can use BLAS or not.é    )ÚListÚSequenceÚTupleÚUnion)ÚArrayIndexTypeÚcan_blasNÚinputsÚresultÚidx_removedÚshapesÚreturnc                 ó´  — t          | ¦  «        dk    rdS | \  }}t          ||z   ¦  «        D ]b}|                     |¦  «        |                     |¦  «        }}|dk    s|dk    s	||z   dk    r dS ||z   dz
  t          ||v ¦  «        k    r dS Œc|�L|D ]I}|d         |                     |¦  «                 |d         |                     |¦  «                 k    r dS ŒJt          |¦  «        dk    rdS d„ | D ¦   «         }	|	d         |z
  }
|	d         |z
  }t          |¦  «        }| d         | d         k    rdS |	d         |	d         k    rd	S || d…         |d|…         k    rd
S |d|…         || d…         k    rd
S || d…         || d…         k    rd
S |d|…         |d|…         k    rd
S t          |
¦  «        dk    st          |¦  «        dk    rdS dS )aˆ  Checks if we can use a BLAS call.

    Parameters
    ----------
    inputs : list of str
        Specifies the subscripts for summation.
    result : str
        Resulting summation.
    idx_removed : set
        Indices that are removed in the summation
    shapes : sequence of tuple[int], optional
        If given, check also that none of the indices are broadcast dimensions.

    Returns:
    -------
    type : str or bool
        The type of BLAS call to be used or False if none.

    Notes:
    -----
    We assume several operations are not efficient such as a transposed
    DDOT, therefore 'ijk,jki->' should prefer einsum. These return the blas
    type appended with "/EINSUM" to differentiate when they can still be done
    with tensordot if required, e.g. when a backend has no einsum.

    Examples:
    --------
    >>> can_blas(['ij', 'jk'], 'ik', set('j'))
    'GEMM'

    >>> can_blas(['ijj', 'jk'], 'ik', set('j'))
    False

    >>> can_blas(['ab', 'cd'], 'abcd', set())
    'OUTER/EINSUM'

    >>> # looks like GEMM but actually 'j' is broadcast:
    >>> can_blas(['ij', 'jk'], 'ik', set('j'), shapes=[(4, 1), (5, 6)])
    False
    é   Fé   Nr   zOUTER/EINSUMc                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Úset)Ú.0Úxs     úT/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/opt_einsum/blas.pyú
<listcomp>zcan_blas.<locals>.<listcomp>W   s   € Ð#Ð#Ð#�q�C�‰FŒFÐ#Ð#Ð#ó    ÚDOTz
DOT/EINSUMÚGEMMzGEMV/EINSUMÚTDOT)Úlenr   ÚcountÚintÚfind)r	   r
   r   r   Ú
input_leftÚinput_rightÚcÚnlÚnrÚsetsÚ	keep_leftÚ
keep_rightÚrss                r   r   r   
   sc  € õ^ ˆ6�{„{�aÒÐØˆuà$Ñ€J�å�˜kÑ)Ñ*Ô*ð 
ð 
ˆà×!Ò! !Ñ$Ô$ k×&7Ò&7¸Ñ&:Ô&:ˆBˆØ�ŠFˆF˜˜Qš˜ B¨¡G¨a¢K KØ�5�5ð
 �‰7�Q‰;�#˜a 6˜kÑ*Ô*Ò*Ð*Ø�5�5ð +ð
 ÐØð 	ð 	ˆAØ�aŒy˜Ÿš¨Ñ+Ô+Ô,°°q´	¸+×:JÒ:JÈ1Ñ:MÔ:MÔ0NÒNÐNØ�u�uð Oõ
 ˆ;ÑÔ˜1ÒÐØˆ~ð $Ð#˜FÐ#Ñ#Ô#€DØ�Q”˜+Ñ%€IØ�a”˜;Ñ&€JÝ	ˆ[Ñ	Ô	€Bð ˆa„y�F˜1”IÒÐØˆuð 
ˆaŒ�D˜”GÒ	Ð	Øˆ|ð �2�#�$�$Ô˜; s¨ sÔ+Ò+Ð+Øˆvð 
�C�R�CŒ˜K¨¨¨¨Ô-Ò	-Ð	-Øˆvð 
�R�C�D�DÔ	˜[¨"¨¨¨Ô.Ò	.Ð	.Øˆvð 
�C�R�CŒ˜K¨¨¨Ô,Ò	,Ð	,Øˆvõ ˆi‰.Œ.˜AÒ
Ð
¥3 z¡?¤?°aÒ#7Ð#7Øˆ}ð ˆvr   )N)Ú__doc__Útypingr   r   r   r   Úopt_einsum.typingr   Ú__all__Ústrr   Úboolr   r   r   r   ú<module>r/      sÊ   ðØ 6Ð 6à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à ,Ð ,Ð ,Ð ,Ð ,Ð ,àˆ,€ð 15ð	pð pØ�ŒIðpàðpð  ðpð �(˜5 œ:Ô&¨Ð,Ô-ð	pð
 ˆ3�ˆ9Ôðpð pð pð pð pð pr   