o
    toi                     @  sn   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZmZ G dd dej	Z
edkr5e  dS dS )    )annotationsN)TensorProtohelperc                   @  s   e Zd ZdddZdS )TestUtilityFunctionsreturnNonec                 C  s,  dd }|d}|d}|d}|d}|d}|d}|d	}|d
}	t dddgdg}
t dddgdg}t dddgdg}t dddgdg}t dddgd	g}t ddd	gd
g}t |
|||||gd||g|	g}t j|dd}t }tj|d}t	
|| tj|d}g d}dd	g}t	j|||| t	|}| |jd | |j|j | |j|j | t|jjd | t|jjd | t|jjd | |jjd | | |jjd | | |jjd | | |jjd | | |jjd | tj|dd d S )Nc                 S  s   t | tjddgS )N      )r   make_tensor_value_infor   FLOAT)name r   H/home/ubuntu/.local/lib/python3.10/site-packages/onnx/test/utils_test.pycreate_tensor   s   z>TestUtilityFunctions.test_extract_model.<locals>.create_tensorA0A1B0B1B2C0C1D0AddSubMultest)producer_namezoriginal.onnxzextracted.onnx)r   r   r   zonnx.utils.extract_modelr	      r   r   T)ignore_errors)r   	make_node
make_graph
make_modeltempfilemkdtempospathjoinonnxsaveutilsextract_modelloadassertEqualr   
ir_versionopset_importlengraphnodeinputoutputshutilrmtree)selfr   r   r   r   r   r   r   r   r   L0_0L0_1L0_2L1_0L1_1L2_0g0m0tdirp0p1input_namesoutput_namesm1r   r   r   test_extract_model   sN   
z'TestUtilityFunctions.test_extract_modelN)r   r   )__name__
__module____qualname__rE   r   r   r   r   r      s    r   __main__)
__future__r   r$   r4   r"   unittestr'   r   r   TestCaser   rF   mainr   r   r   r   <module>   s   0