U
    qh                     @  sb   d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	 G dd dej
Zedkr^e  dS )    )annotationsN)TensorProtohelpernumpy_helpershape_inferencec                   @  s   e Zd ZddddZdS )TestTrainingToolNone)returnc               
   C  s4  ddg}d}t jj| t j}tj||d}t|t	j
|}ddg}d}t jj| t j}tj||d}	t|t	j
|}
ddg}d}t|t	j
|}tjd||g|gd}t|gd||
g|g||	g}ddg}d	}t jj| t j}tj||d}t|t	j
|}ddg}d
}t|t	j
|}tjd||g|gd}t|gd|g|g|g}t|||fgd d }t|}tj| |j }|| tt|jjt|jd jj dt|jjt|jd jj t|jjt|jd jj t|jjt|jd jj }t|}t|}tj| d S )N   A)nameBCZMatMul)inputsoutputsZsimple_inferenceXYZsimple_trainingr   full_training_graph)nprandomZrandZastypeZfloat32r   Z
from_arrayr   Zmake_tensor_value_infor   FLOATZ	make_nodeZ
make_graphZmake_training_infoZ
make_modelonnxcheckerZcheck_modeltraining_infoaddZCopyFromlistgraphnode	algorithminputoutputZinitializerr   Zinfer_shapes) selfZA_shapeZA_namer   ZA_initializerZA_value_infoZB_shapeZB_namer   ZB_initializerZB_value_infoZC_shapeZC_nameZC_value_infoZinference_nodeZinference_graphZX_shapeZX_namer   ZX_initializerZX_value_infoZY_shapeZY_nameZY_value_infor   Ztraining_graphr   modelZnew_training_infor   Zfull_training_modelZfull_training_model_with_shapes r#   @/tmp/pip-unpacked-wheel-xnis5xre/onnx/test/training_tool_test.pytest_training_info_proto   s      	       





z)TestTrainingTool.test_training_info_protoN)__name__
__module____qualname__r%   r#   r#   r#   r$   r      s   r   __main__)
__future__r   ZunittestZnumpyr   r   r   r   r   r   ZTestCaser   r&   mainr#   r#   r#   r$   <module>   s   V