U
    qh                     @  s4   d dl mZ d dlZd dlmZ G dd deZdS )    )annotationsN)OpRunc                   @  s   e Zd ZdddddZdS )CumSumN)	exclusivereversec          	      G  sp  |sd n|d }|d kr4|s |r(t dt|fS t|tjtjfst|jdkspt|jdkr|jd dkrtd| d|j dt|jdkr|d }|rdd |jD }t	d d d	||< |t
| }|rJd
d |jD }dd |jD }t	dd	||< t	d|j| ||< tj|j|jd}tj|t
| ||t
| d ntj||d}|rj|t
| }|fS )Nr   z(reverse=1 or exclusive=1 not implemented   z(axis must be an array of one number not z (shape z).c                 S  s   g | ]}t d |qS r   slice.0s r   A/tmp/pip-unpacked-wheel-xnis5xre/onnx/reference/ops/op_cum_sum.py
<listcomp>   s     zCumSum._run.<locals>.<listcomp>c                 S  s   g | ]}t d |qS r   r	   r   r   r   r   r      s     c                 S  s   g | ]}t d |qS r   r	   r   r   r   r   r      s     )dtype)axisout)r   )NotImplementedErrornpZcumsum
isinstanceZint32Zint64lenshapeRuntimeErrorr
   tuplezerosr   )	selfxr   r   r   Zrev_indicesZ	indices_cZ	indices_dresr   r   r   _run   s6    *"zCumSum._run)__name__
__module____qualname__r    r   r   r   r   r      s   r   )
__future__r   Znumpyr   Zonnx.reference.op_runr   r   r   r   r   r   <module>   s   