U
    qh                     @  sD   d dl mZ d dlZd dlmZ dejfddZG dd deZdS )	    )annotationsN)OpRunc                 C  s   t | }t|j}t |}|dk r2||d 7 }|jd| }|j|| }dt| |j dt|  }	t ||	}
t t |||d|}t j|
|k|dS )Nr      )r   )dtype)r   )npZasarraylenshapeZarangeZreshapemod)indicesdepthaxisr   valuesZrankZdepth_rangeZlsrsZ	new_shapetargets r   A/tmp/pip-unpacked-wheel-xnis5xre/onnx/reference/ops/op_one_hot.py_one_hot   s    


r   c                   @  s   e Zd ZdddZdS )OneHotNc                 C  s0   |\}}t ||||jd}|||  | }|fS )N)r   r   )r   r   )selfr   r   r   r   Z	off_valueZon_valueyr   r   r   _run   s    zOneHot._run)N)__name__
__module____qualname__r   r   r   r   r   r      s   r   )	
__future__r   Znumpyr   Zonnx.reference.op_runr   Zfloat32r   r   r   r   r   r   <module>   s   