o
    Xip                     @  s   d dl mZ d dlZd dlZd dlmZ d dlmZmZ e	e
Zdd Zdd Zd	d
 Zdd ZdddZ	 eeeeeeeeegZdS )    )annotationsN)ir)RewriteRuleRewriteRuleSetc                 C  s2   | j |tjjd}| j||d}| j |tjjdS )NtoaxisCastonnxTensorProtoFLOATSoftmaxFLOAT16)opinputr	   upcastsoftmax r   [/home/ubuntu/.local/lib/python3.10/site-packages/onnxscript/rewriter/ort_fusions/softmax.pysoftmax_with_fp32_upcast   s   r   c                 C  s   | j ||dS )Nr   r   )r   r   r	   r   r   r   r      s   r   c                 C  s.   | j |tjjd}| |}| j |tjjdS )Nr   r
   )r   r   r   r   r   r   r   %softmax_with_fp32_upcast_without_axis   s   
r   c                 C  s
   |  |S )Nr   )r   r   r   r   r   softmax_without_axis   s   
r   returnboolc                 K  s$   |d u rt d dS |jtjjkS )NzgCannot perform softmax upcast removal: cannot retrieve match_bindings for 'input' for dtype validation.F)loggerwarningdtyper   DataTyper   )contextr   _r   r   r   check_if_fp16_input#   s   r#   )r   r   )
__future__r   loggingr   
onnxscriptr   !onnxscript.rewriter._rewrite_ruler   r   	getLogger__name__r   r   r   r   r   r#   rulesr   r   r   r   <module>   s*   


