
    
Ng+                        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                  6    e Z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     [/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/test/data_propagation_test.pytest_expand_symbolic_inputz.TestDataPropagation.test_expand_symbolic_input   s      ;$i038I92UV'C57)44(S'NSE:: 
 
 	&w0A4HH&sK,=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'C57)44%IE%g{/@$MM	   
 
 	&w0A4HH&sK,=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1BDII&sK,=zJJ  	 	
 	
 	
 	
 	
r$   c           	         t           j                            d          }|                     |t	          dt
          j        d          t	          dt
          j        d          gd           dS )	zTest 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)
            }
        r,   r   r   r-   Tr   Nr0   r4   s     r"   test_data_prop_via_functionz/TestDataPropagation.test_data_prop_via_functionO   sz     ''

 
 	&x1BDII&sK,=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 )zTest 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   r,   r   r-   w)r   r.   r/   Tr   Nr0   r4   s     r"   test_multiple_calls_to_functionz3TestDataPropagation.test_multiple_calls_to_functioni   s     ''
 
 	&x1BDII&x1BDII&sK,=zJJ&sK,=zJJ	  	 		
 		
 		
 		
 		
r$   N)r   r   )__name__
__module____qualname__r#   r*   r6   r8   r<    r$   r"   r
   r
      sx        
 
 
 
$
 
 
 
.
 
 
 
(
 
 
 
4
 
 
 
 
 
r$   r
   __main__)
__future__r   unittestshape_inference_testr   onnx.parserr1   r   onnx.helperr   r   r   r
   r=   mainr@   r$   r"   <module>rH      s   
 # " " " " "  : 9 9 9 9 9           F F F F F F F F F Ft
 t
 t
 t
 t
2 t
 t
 t
n zHMOOOOO r$   