o
    U۷ie                  
   @   sR   d dl mZmZ d dlZ		d
dejdeedf deej deej fdd	ZdS )    )TupleOptionalNq_tensoro_shape.dtypedevicec           	         s   |    t|}ttttt | fddd}dg| }d}|D ]}|||< ||| 9 }q$tj|t||dur=|n| j|durG|dS | j	dS )z
    Create an empty tensor with the given shape that mimics the layout/strides of
    the provided `q_tensor` as closely as possible.
    c                    s    |  S )N )i	q_stridesr   Y/home/ubuntu/vllm_env/lib/python3.10/site-packages/cudnn/native_sparse_attention/utils.py<lambda>   s    z*make_tensor_strided_like.<locals>.<lambda>)keyr      N)r   r   )
stridelentuplesortedrangemintorchempty_stridedr   r   )	r   r   r   r   rank_outorderstridescurrentdimr   r
   r   make_tensor_strided_like   s    
&

r   )NN)	typingr   r   r   Tensorintr   r   r   r   r   r   r   <module>   s    
