
    h                        S SK r S SKJr  S SKJr  S SKrS SKrS SKrS SKrS SKJ	r	J
r
  \R                  R                  SS5      r\R                  R                  SS5      r\R                  R                  SS5      r\R                  R                  SS5      r\R                  R                  S	S5      r\
" 5       r " S
 S\5      r\S:X  a  \ R*                  " 5         gg)    N)Sequence)TestShapeInferenceHelper)AttributeProto	TypeProto            
   c            	       t    \ rS rSrS\S\\   S\\   S\\   4S jrS\S\\   S\\   4S jr	S r
S	 rS
 rSrg)TestFunctionInference   function_textinput_types
attributesexpected_output_typesc                    [         R                  R                  U5      n[         R                  R	                  XRU5      nU R                  [        U5      [        U5      5        [        XF5       H  u  pxU R                  Xx5        M     g N)	onnxparserparse_functionshape_inferenceinfer_function_output_typesassertEquallenzip_compare_value_infos)	selfr   r   r   r   functionresultexpectedactuals	            [/var/www/fran/franai/venv/lib/python3.13/site-packages/onnx/test/function_inference_test.py_checkTestFunctionInference._check   sq     ;;--m<%%AA:
 	23S[A #$9 BH%%h7 !C    c                    ^^^ [         R                  R                  U5      mUUU4S jnU R                  [         R                  R
                  U5        g )Nc                  H   > [         R                  R                  TTT 5        g r   )r   r   r   )r   r   r   s   r#   invoke_inference<TestFunctionInference._check_fails.<locals>.invoke_inference/   s      <<+zr&   )r   r   r   assertRaisesr   InferenceError)r   r   r   r   r)   r   s     `` @r#   _check_fails"TestFunctionInference._check_fails'   s=     ;;--m<	
 	$..==?OPr&   c                     SnU R                  U[        [        // [        /5        U R                  U[        [        // [        /5        U R                  U[        [        // 5        g )Nz
            <opset_import: [ "" : 18 ], domain: "local">
            f (y, z) => (w) {
                x = Add(y, z)
                w = Mul(x, y)
            }
        )r$   float_type_int32_type_r-   r   codes     r#   test_fi_basic#TestFunctionInference.test_fi_basic6   sT     	D;4b;-HD;4b;-H$k :B?r&   c                    Sn[         R                  R                  SS5      nU R                  U[        /U/[
        /5        [         R                  R                  SS5      nU R                  U[        /U/[        /5        g )Nz
            <opset_import: [ "" : 18 ], domain: "local">
            CastTo <dtype> (x) => (y) {
                y = Cast <to : int = @dtype> (x)
            }
        dtyper
   r   )r   helpermake_attributer$   r0   r1   float16_type_)r   r3   dtype_6dtype_10s       r#   test_fi_attribute'TestFunctionInference.test_fi_attributeB   sg     ++,,Wa8D;-'[MB;;--gr:D;-(m_Er&   c                    SnU R                  U[        // [        /5        U R                  U[        [        // [        /5        SnU R                  U[        [        [        // [        /5        U R                  U[        [        [        // [        /5        U R                  U[        [        [        // [        /5        SnU R                  U[        [        [        // [        /5        U R                  U[        [        [        // 5        g )Nz
            <opset_import: [ "" : 18 ], domain: "local">
            DoReduce (x, axes) => (y) {
                y = ReduceMax (x, axes)
            }
        z
            <opset_import: [ "" : 18 ], domain: "local">
            Quantize (x, scale, zero_point) => (y) {
                y = QuantizeLinear (x, scale, zero_point)
            }
        z
            <opset_import: [ "" : 18 ], domain: "local">
            DoClip (x, min, max) => (y) {
                y = Clip (x, min, max)
            }
        )r$   r0   no_type_
int8_type_uint8_type_r-   r2   s     r#   test_fi_optional_input,TestFunctionInference.test_fi_optional_inputO   s     	D;-k];D;12}E 	D;Z@"zlSD;[A2}UD;X>[MR 	D;+>[MR 	$h
 CRHr&    N)__name__
__module____qualname____firstlineno__strr   r   r   r$   r-   r4   r=   rC   __static_attributes__rE   r&   r#   r   r      s}    88 i(8 ^,	8
  (	28QQ i(Q ^,	Q
@F"Ir&   r   __main__)unittesttypingr   shape_inference_testr   r   onnx.helperonnx.parseronnx.shape_inferencer   r   r8   make_tensor_type_protor0   rB   rA   r1   r:   r@   r   rF   mainrE   r&   r#   <module>rU      s      9     *kk00D9kk00D9[[//48
kk00D9222t<;ZI4 ZIz zMMO r&   