§
    ú¸¸j\#  ã                  ó˜   — d dl mZ d dlZd dlmZ d dlZd dlmZ d dlm	Z	m
Z
mZ  G d„ de¦  «        Zedk    r ej        ¦   «          dS dS )	é    )ÚannotationsN)ÚTestShapeInferenceHelper)ÚTensorProto)Ú	make_nodeÚmake_tensorÚmake_tensor_value_infoc                  ó^   — e Zd Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„ZdS )ÚTestDataPropagationÚreturnÚNonec           	     óN  — |                       dt          j        dfdt          j        dfgt          ddgdg¦  «        t          dddgdg¦  «        gg ¦  «        }|                      |t          dt          j        d	¦  «        t          dt          j        d
¦  «        gd¬¦  «         d S )NÚx)é   é   é   Úy)r   é   r   ÚShapeÚshapeÚExpandÚz©r   )r   r   r   T©Ú	data_prop)Ú_make_graphr   ÚINT32r   Ú_assert_inferredr   ÚINT64©ÚselfÚgraphs     úo/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/onnx/test/data_propagation_test.pyÚtest_expand_symbolic_inputz.TestDataPropagation.test_expand_symbolic_input   s¿   € Ø× Ò Ø•;Ô$ iÐ0°3½Ô8IÈ9Ð2UÐVå˜' C 5¨7¨)Ñ4Ô4Ý˜( S¨' N°S°EÑ:Ô:ðð ñ
ô 
ˆð 	×ÒØå& wµÔ0AÀ4ÑHÔHÝ& s­KÔ,=¸yÑIÔIðð ð 	ñ 	
ô 	
ð 	
ð 	
ð 	
ó    c                óh  — |                       dt          j        dfgt          ddgdg¦  «        t          ddgdgt	          dt          j        dd	¦  «        ¬
¦  «        gg ¦  «        }|                      |t          dt          j        d¦  «        t          dt          j        d¦  «        gd¬¦  «         d S )Nr   ©r   r   é   r   r   ÚConstantOfShaper   Úvalue©r   ©r   ©r)   r   Tr   ©	r   r   ÚFLOATr   r   r   r   r   r   r   s     r"   Ú(test_constantofshape_with_symbolic_shapez<TestDataPropagation.test_constantofshape_with_symbolic_shape#   sÑ   € Ø× Ò Ø•;Ô$ iÐ0Ð1å˜' C 5¨7¨)Ñ4Ô4ÝØ%Ø�IØ�EÝ% g­{Ô/@À$ÈÑMÔMð	ñ ô ðð ñ
ô 
ˆð 	×ÒØå& wµÔ0AÀ4ÑHÔHÝ& s­KÔ,=¸yÑIÔIðð ð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r$   c           	     óÜ   — t           j                             d¦  «        }|                      |t	          dt
          j        d¦  «        t	          dt
          j        d¦  «        gd¬¦  «         dS )	z8Infer the shape of z by propagating the value of xshape.zÙ
            <ir_version: 7, opset_import: [ "" : 18]>
            agraph (float[4, 1, 16] x, float[1, 8, 16] y) => () {
                xshape = Shape (x)
                z = Expand (y, xshape)
            }
        Úxshaper   r   ©r   é   é   Tr   N©ÚonnxÚparserÚparse_modelr   r   r   r   r.   ©r    Úmodels     r"   Útest_model_data_propagationz/TestDataPropagation.test_model_data_propagation:   sx   € å”×'Ò'ðñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸zÑJÔJðð ð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r$   c           	     óÜ   — t           j                             d¦  «        }|                      |t	          dt
          j        d¦  «        t	          dt
          j        d¦  «        gd¬¦  «         dS )	zˆTest value-propagation through function calls.
        Underlying core example is same as previous test_model_data_propagation.
        a„  
            <ir_version: 7, opset_import: [ "" : 18, "local" : 1 ]>
            agraph (float[4, 1, 16] x, float[1, 8, 16] y) => () {
                xshape = local.GetShape (x)
                z = Expand (y, xshape)
            }
            <domain: "local", opset_import: [ "" : 18 ]>
            GetShape (x) => (shapeval) {
                shapeval = Shape(x)
            }
        r1   r   r   r2   Tr   Nr5   r9   s     r"   Útest_data_prop_via_functionz/TestDataPropagation.test_data_prop_via_functionN   sz   € õ ”×'Ò'ð
ñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸zÑJÔJðð ð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r$   c                óD  — t           j                             d¦  «        }|                      |t	          dt
          j        d¦  «        t	          dt
          j        d¦  «        t	          dt
          j        d¦  «        t	          dt
          j        d¦  «        gd	¬
¦  «         dS )z£Test value-propagation handles multiple calls to same function correctly.
        Underlying core example is same as previous test_model_data_propagation.
        a×  
            <ir_version: 7, opset_import: [ "" : 18, "local" : 1 ]>
            agraph (float[4, 1, 16] x, float[1, 8, 16] y) => () {
                yshape = local.GetShape (y)
                xshape = local.GetShape (x)
                z = Expand (y, xshape)
                w = Expand (y, yshape)
            }
            <domain: "local", opset_import: [ "" : 18 ]>
            GetShape (x) => (shapeval) {
                shapeval = Shape(x)
            }
        Úyshaper   r1   r   r2   Úw)r   r3   r4   Tr   Nr5   r9   s     r"   Útest_multiple_calls_to_functionz3TestDataPropagation.test_multiple_calls_to_functionh   sž   € õ ”×'Ò'ðñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸zÑJÔJÝ& s­KÔ,=¸zÑJÔJð	ð ð 	ñ 		
ô 		
ð 		
ð 		
ð 		
r$   c                ó6  — |                       dt          j        dfdt          j        dfgt          ddgdg¦  «        t          ddgdg¦  «        t          dddgd	g¦  «        t          d
d	gdgt	          dt          j        dd¦  «        ¬¦  «        gg ¦  «        }|                      |t          dt          j        d¦  «        t          dt          j        d¦  «        t          d	t          j        d¦  «        t          dt          j        d¦  «        gd¬¦  «         d S )Nr   r&   r   )r   r   r   r   r1   r?   ÚAddÚzshaper(   r   r)   r*   r+   r,   r   )r   é   r3   Tr   r-   r   s     r"   Útest_shape_arithmeticz)TestDataPropagation.test_shape_arithmetic†   s*  € Ø× Ò Ø•;Ô$ iÐ0°3½Ô8IÈ9Ð2UÐVå˜' C 5¨8¨*Ñ5Ô5Ý˜' C 5¨8¨*Ñ5Ô5Ý˜% (¨HÐ!5¸°zÑBÔBÝØ%Ø�JØ�EÝ% g­{Ô/@À$ÈÑMÔMð	ñ ô ð	
ð ñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸yÑIÔIð	ð ð 	ñ 		
ô 		
ð 		
ð 		
ð 		
r$   c                ó6  — |                       dt          j        dfdt          j        dfgt          ddgdg¦  «        t          ddgdg¦  «        t          dddgd	g¦  «        t          d
d	gdgt	          dt          j        dd¦  «        ¬¦  «        gg ¦  «        }|                      |t          dt          j        d¦  «        t          dt          j        d¦  «        t          d	t          j        d¦  «        t          dt          j        d¦  «        gd¬¦  «         d S )Nr   r&   r   r   r   r1   r?   rC   rD   r(   r   r)   r*   r+   r,   )rE   é   r3   Tr   r-   r   s     r"   Ú$test_shape_arithmetic_with_broadcastz8TestDataPropagation.test_shape_arithmetic_with_broadcast¡   s*  € Ø× Ò Ø•;Ô$ iÐ0°3½Ô8IÈ4Ð2PÐQå˜' C 5¨8¨*Ñ5Ô5Ý˜' C 5¨8¨*Ñ5Ô5Ý˜% (¨HÐ!5¸°zÑBÔBÝØ%Ø�JØ�EÝ% g­{Ô/@À$ÈÑMÔMð	ñ ô ð	
ð ñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸yÑIÔIð	ð ð 	ñ 		
ô 		
ð 		
ð 		
ð 		
r$   c                ó6  — |                       dt          j        dfdt          j        dfgt          ddgdg¦  «        t          ddgdg¦  «        t          dddgd	g¦  «        t          d
d	gdgt	          dt          j        dd¦  «        ¬¦  «        gg ¦  «        }|                      |t          dt          j        d¦  «        t          dt          j        d¦  «        t          d	t          j        d¦  «        t          dt          j        d¦  «        gd¬¦  «         d S )Nr   © r   r   r   r1   r?   rC   rD   r(   r   r)   r*   r+   r,   )r   Tr   r-   r   s     r"   Ú)test_shape_arithmetic_with_zero_broadcastz=TestDataPropagation.test_shape_arithmetic_with_zero_broadcast¼   s*  € Ø× Ò Ø•;Ô$ bÐ)¨CµÔ1BÀDÐ+IÐJå˜' C 5¨8¨*Ñ5Ô5Ý˜' C 5¨8¨*Ñ5Ô5Ý˜% (¨HÐ!5¸°zÑBÔBÝØ%Ø�JØ�EÝ% g­{Ô/@À$ÈÑMÔMð	ñ ô ð	
ð ñ
ô 
ˆð 	×ÒØå& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& xµÔ1BÀDÑIÔIÝ& s­KÔ,=¸rÑBÔBð	ð ð 	ñ 		
ô 		
ð 		
ð 		
ð 		
r$   c                ó  — t           j                             d¦  «        }t           j                             |ddd¦  «        }|j        j        d         }|                      |j        j	        j
        j        d         j        d¦  «         dS )zZTest that a Concat with an empty tensor as input is handled correctly by data-propagation.zÖ
            <ir_version: 7, opset_import: [ "" : 17]>
            agraph (float[256] y) => (float[N] z)
            <float[0] x = {}>
            {
                z = Concat <axis=0> (x, y)
            }
        Tr   é   N©r6   r7   r8   Úshape_inferenceÚinfer_shapesr!   ÚoutputÚassertEqualÚtypeÚtensor_typer   ÚdimÚ	dim_value©r    r:   Úinferred_modelrR   s       r"   Útest_empty_tensorz%TestDataPropagation.test_empty_tensor×   s{   € å”×'Ò'ðñ	
ô 	
ˆõ Ô-×:Ò:¸5À$ÈÈdÑSÔSˆØÔ%Ô,¨QÔ/ˆØ×Ò˜œÔ0Ô6Ô:¸1Ô=ÔGÈÑMÔMÐMÐMÐMr$   c                ó  — t           j                             d¦  «        }t           j                             |ddd¦  «        }|j        j        d         }|                      |j        j	        j
        j        d         j        d¦  «         dS )z‹Test that a Concat with an empty tensor as input is handled correctly by data-propagation.
        This time with a negative axis.
        z×
            <ir_version: 7, opset_import: [ "" : 17]>
            agraph (float[256] y) => (float[N] z)
            <float[0] x = {}>
            {
                z = Concat <axis=-1> (x, y)
            }
        Tr   rN   NrO   rX   s       r"   Útest_empty_tensor_negative_axisz3TestDataPropagation.test_empty_tensor_negative_axisç   s}   € õ ”×'Ò'ðñ	
ô 	
ˆõ Ô-×:Ò:¸5À$ÈÈdÑSÔSˆØÔ%Ô,¨QÔ/ˆØ×Ò˜œÔ0Ô6Ô:¸1Ô=ÔGÈÑMÔMÐMÐMÐMr$   N)r   r   )Ú__name__Ú
__module__Ú__qualname__r#   r/   r;   r=   rA   rF   rI   rL   rZ   r\   rK   r$   r"   r
   r
      sæ   € € € € € ð
ð 
ð 
ð 
ð$
ð 
ð 
ð 
ð.
ð 
ð 
ð 
ð(
ð 
ð 
ð 
ð4
ð 
ð 
ð 
ð<
ð 
ð 
ð 
ð6
ð 
ð 
ð 
ð6
ð 
ð 
ð 
ð6Nð Nð Nð Nð Nð Nð Nð Nð Nð Nr$   r
   Ú__main__)Ú
__future__r   ÚunittestÚshape_inference_testr   Úonnx.parserr6   r   Úonnx.helperr   r   r   r
   r]   ÚmainrK   r$   r"   ú<module>rg      sÒ   ðð
 #Ð "Ð "Ð "Ð "Ð "à €€€à 9Ð 9Ð 9Ð 9Ð 9Ð 9à Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FðgNð gNð gNð gNð gNÐ2ñ gNô gNð gNðT ˆzÒÐØ€H„M�O„O€O€O€Oð Ðr$   