o
    r::jç
  ã                   @  sV   d dl m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r)e 	¡  dS dS )é    )ÚannotationsN)ÚparserÚprinterc                   @  s>   e Zd Zddd„Zddd„Zdd	d
„Zddd„Zddd„ZdS )ÚTestBasicFunctionsÚgraphúonnx.GraphProtoÚreturnÚNonec                 C  sR   |   t|jƒd¡ |   |jd jd¡ |   |jd jd¡ |   |jd jd¡ d S )Né   r   ÚMatMulé   ÚAddé   ÚSoftmax)ÚassertEqualÚlenÚnodeÚop_type)Úselfr   © r   ú]/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/onnx/test/printer_test.pyÚcheck_graph   s   zTestBasicFunctions.check_graphc                 C  sF   d}t  |¡}t |¡}t  |¡}t |¡}|  ||¡ |  |¡ d S )NzÐ
           agraph (float[N, 128] X, float[128,10] W, float[10] B) => (float[N] C)
           {
              T = MatMul(X, W)
              S = Add(T, B)
              C = Softmax(S)
           }
           )r   Úparse_graphr   Úto_textr   r   ©r   Útext0Úgraph1Útext1Úgraph2Útext2r   r   r   Útest_parse_graph   s   



z#TestBasicFunctions.test_parse_graphc                 C  sH   d}t  |¡}t |¡}t  |¡}t |¡}|  ||¡ |  d|¡ d S )NzCagraph (float["M + N"] x) => (float["M + N"] y) { y = Identity(x) }z"M + N")r   r   r   r   r   ÚassertInr   r   r   r   Ú)test_quoted_string_symbolic_dim_roundtrip&   s   



z<TestBasicFunctions.test_quoted_string_symbolic_dim_roundtripc                 C  sr   d}t  |¡}t |¡}t  |¡}t |¡}|  ||¡ |  |jd¡ |  t|jƒdg¡ |  t|jƒdg¡ d S )NzC = Softmax(S)r   ÚCÚS)	r   Ú
parse_noder   r   r   r   ÚlistÚoutputÚinput)r   r   Únode1r   Únode2r   r   r   r   Útest_parse_node_roundtrip2   s   



z,TestBasicFunctions.test_parse_node_roundtripc                 C  s>   |   t¡ t t ¡ ¡ W d   ƒ d S 1 sw   Y  d S )N)ÚassertRaisesÚ	TypeErrorr   r   ÚonnxÚAttributeProto)r   r   r   r   Ú$test_to_text_unsupported_type_raises@   s   "ÿz7TestBasicFunctions.test_to_text_unsupported_type_raisesN)r   r   r   r	   )r   r	   )Ú__name__Ú
__module__Ú__qualname__r   r    r"   r+   r0   r   r   r   r   r      s    



r   Ú__main__)
Ú
__future__r   Úunittestr.   r   r   ÚTestCaser   r1   Úmainr   r   r   r   Ú<module>   s   ;ÿ