o
    پi                     @   s   d dl mZmZ d dlZd dlmZmZmZ e se r#d dlm	Z	 ne r-d dl
mZ	 neddeejeej eej f deejee ee ef fd	d
ZdS )    )AnyUnionN)is_cudais_hipis_npuweak_ref_tensor)_weak_ref_tensorz5weak_ref_tensor is implemented only for CUDA and NPU.tensorsreturnc                 C   sP   t | tjr
t| S t | trdd | D S t | tr$tdd | D S td)z
    Convenience function to create weak references to tensors,
    for single tensor, list of tensors or tuple of tensors.
    c                 S   s   g | ]}t |qS  r   .0tr   r   Z/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/compilation/weak_ref_tensor.py
<listcomp>   s    z$weak_ref_tensors.<locals>.<listcomp>c                 s   s    | ]}t |V  qd S )Nr   r   r   r   r   	<genexpr>   s    z#weak_ref_tensors.<locals>.<genexpr>zInvalid type for tensors)
isinstancetorchTensorr   listtuple
ValueError)r
   r   r   r   weak_ref_tensors   s   

r   )typingr   r   r   sglang.srt.utils.commonr   r   r   
sgl_kernelr   torch_npu._Cr	   NotImplementedErrorr   r   r   r   r   r   r   r   <module>   s    