
    Ngi                     `    d dl Zd dlZd dlmZ d dlmZ dej        fdZ G d de          Z	dS )    N)Base)expectc                    t          j        |           }t          |j                  }t          j        |          }|dk     r||dz   z  }|j        d|         }|j        ||         }t          j        |dt          |          z  |j        z   dt          |          z  z             }	t          j        t          j        ||          g |d|R           }t          j        |	|k    |          S )z/Compute one hot from indices at a specific axisr      )r   dtype)npasarraylenshapearangereshapemod)
indicesdepthaxisr	   valuesrankdepth_rangelsrstargetss
             ^/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/backend/test/case/node/onehot.pyone_hotr      s    Z  Fv|D)E""Kaxxq	af	B	d4i	 BjTCGG^k&77$R.H G Zvu--}}Q}}}==F:g'u5555    c                   n    e Zd Zedd            Zedd            Zedd            Zedd            ZdS )OneHotreturnNc                  t   d} d}t           j        }t          j                            dg ddg          }t          j        g dt           j                  }t          j        d	          }t          j        || g|          }t          |||          }|| |z
  z  |z   }t          ||||g|gd
           d S )N      r   r   r   r   y)inputsoutputs)r         r      test_onehot_without_axisr%   r&   name)
r
   int32onnxhelper	make_nodearrayint64float32r   r   )on_value	off_valueoutput_typenoder   r   r   r$   s           r   export_without_axiszOneHot.export_without_axis   s    	h{$$;;;cU % 
 
 (999BH555
29h/{CCCGU+666I%&2UF+C+		
 	
 	
 	
 	
 	
r   c                     d} d}d}t           j        }t          j                            dg ddg|           }t          j        ddgdd	ggt           j        
          }t          j        d          }t          j        ||g|
          }t          ||| |          }|||z
  z  |z   }t          ||||g|gd           d S )Nr      r   r#   r$   r%   r&   r   	   r"      r   
   r   r	   test_onehot_with_axisr+   r
   r3   r.   r/   r0   r1   r   r   		axisValuer4   r5   r6   r7   r   r   r   r$   s	            r   export_with_axiszOneHot.export_with_axis1   s    		j{$$111E	 % 
 
 (QFQF+2:>>>
29h/{CCCGU+FFFI%&2UF+C(		
 	
 	
 	
 	
 	
r   c                  |   d} d}d}t           j        }t          j                            dg ddg|           }t          j        g dt           j                  }t          j        d	          }t          j        ||g|          }t          ||| |
          }|||z
  z  |z   }t          ||||g|gd           d S )Nr   r:   r   r#   r$   r;   )r   iir   r>   r?   test_onehot_negative_indicesr+   )	r
   r3   r.   r/   r0   r1   r2   r   r   rB   s	            r   export_with_negative_indicesz#OneHot.export_with_negative_indicesI   s    		j{$$111E	 % 
 
 (;;;bh777 
29h/{CCCGU+FFFI%&2UF+C/		
 	
 	
 	
 	
 	
r   c                     d} d}d}t           j        }t          j                            dg ddg|           }t          j        ddgd	d
ggt           j                  }t          j        d          }t          j        ||g|          }t          ||| |          }|||z
  z  |z   }t          ||||g|gd           d S )Nr:   r   r   r#   r$   r;   r<   r"   r=   r   r>   r?   test_onehot_with_negative_axisr+   rA   rB   s	            r   export_with_negative_axisz OneHot.export_with_negative_axisg   s    		j{$$111E	 % 
 
 (QFQF+2:>>>
29h/{CCCGU+FFFI%&2UF+C1		
 	
 	
 	
 	
 	
r   )r   N)__name__
__module____qualname__staticmethodr8   rD   rG   rK    r   r   r   r      s        
 
 
 \
& 
 
 
 \
. 
 
 
 \
: 
 
 
 \
 
 
r   r   )
numpyr
   r.   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r3   r   r   rP   r   r   <module>rT      s   
      , , , , , , . . . . . . "$2: 6 6 6 6 a
 a
 a
 a
 a
T a
 a
 a
 a
 a
r   