
    )`i                         d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	  G d de
          Zeee         gd	f         Zd
ee         dd	fdZd
ee         dd	fdZdee         fdZdd
ee         dee         dd	fd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.
    )CallableList   )Op)	SoftmaxOp)
TensorTypec                       e Zd ZdS )CompileErrorN)__name__
__module____qualname__     z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/flashinfer/logits_processor/validators.pyr
   r
      s        Dr   r
   Nopsreturnc                 b    t          d | D                       }|dk    rt          d          dS )uS   
    R1: Single-Softmax rule.

    Softmax appears ≤ 1 time in the pipeline.
    c              3   D   K   | ]}t          |t                    d V  dS )r   N)
isinstancer   ).0ops     r   	<genexpr>z&single_softmax_rule.<locals>.<genexpr>%   s1      EEb:b)+D+DEEEEEEEr   r   zKMultiple Softmax operators found. Only one Softmax is allowed per pipeline.N)sumr
   )r   softmax_counts     r   single_softmax_ruler      sH     EECEEEEEMqY
 
 	
 r   c                     t          | dd                   D ]O\  }}t          j        |j        k    r5| |dz            }t	          d|j        j         d|j        j         d          PdS )ze
    R3': Indices-terminal rule.

    If an operator outputs Indices, no operator may follow it.
    Nr   z7No operator may follow one that outputs Indices. Found z after z which outputs Indices.)	enumerater   INDICESOUTr
   	__class__r   )r   ir   next_ops       r   indices_terminal_ruler$   ?   s     3ss8$$  2''!a%jG* *3* *<>L<Q* * *   ( r   c                      t           t          gS N)r   r$   r   r   r   get_default_validity_checksr'   O   s     r   custom_checksc                     | st          d          t                      D ]} ||            |r|D ]} ||            d S d S )NzPipeline cannot be empty)r
   r'   )r   r(   checks      r   validate_pipeliner+   W   sw     75666,..  c



 " 	 	EE#JJJJ 	 	r   r&   )__doc__typingr   r   r   r   	operatorsr   typesr   	Exceptionr
   ValidityCheckr   r$   r'   r+   r   r   r   <module>r2      sO     " ! ! ! ! ! ! !                        	 	 	 	 	9 	 	 	 $r(T)*

T"X 

$ 

 

 

 

@tBx D     T-%8    	 	48 	D4G 	SW 	 	 	 	 	 	r   