o
    i4                     @   sX   d Z ddlmZmZ ddlmZmZ ddlmZm	Z	 G dd deZ
G dd	 d	e
Zd
S )a3  
Copyright (c) 2025 by FlashInfer team.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    )ABCabstractmethod)AnyDict   )TaggedTensor
TensorTypec                   @   sh   e Zd ZU dZeed< dZeed< dd Zede	de
de	fd	d
Zde	defddZdefddZdS )OpNINOUTc                 C   s,   | j d u s
| jd u rtd| jj dd S )N	Operator z$ must define IN and OUT tensor types)r
   r   
ValueError	__class____name__self r   T/home/ubuntu/vllm_env/lib/python3.10/site-packages/flashinfer/logits_processor/op.py__init__   s
   zOp.__init__tensorkwargsreturnc                 K   s   t N)NotImplementedError)r   r   r   r   r   r   __call__!   s   zOp.__call__c                 C   s4   |j | jkrtd| jj d|j  d| j | jS )Nr   z cannot accept input type z. Expected: )typer
   r   r   r   r   )r   r   r   r   r   _validate_input_type%   s   zOp._validate_input_typec                 C   s   | j j d| j d| j dS )N(z -> ))r   r   r
   r   r   r   r   r   __repr__-   s   zOp.__repr__)r   
__module____qualname__r
   r   __annotations__r   r   r   r   r   r   r   strr   r   r   r   r   r	      s   
 r	   c                	       sH   e Zd Zdef fddZ	ddedeeef dedefd	d
Z  Z	S )ParameterizedOpdefault_paramsc                    s   t    || _d S r   )superr   r%   )r   r%   r   r   r   r   2   s   

zParameterizedOp.__init__Tnamer   requiredr   c                 C   sF   ||v r	| |S || jv r| j| S |r!td| d| jj d S )NzRequired parameter 'z' not provided for )popr%   r   r   r   )r   r(   r   r)   r   r   r   
_get_param6   s   


zParameterizedOp._get_param)T)
r   r    r!   r   r   r#   r   boolr+   __classcell__r   r   r'   r   r$   1   s    
r$   N)__doc__abcr   r   typingr   r   typesr   r   r	   r$   r   r   r   r   <module>   s    