
     Ti
                    d    S r SSKJr  S/rSSKrSS jr          S	S jr        S
S jrg)z4Identify implicit uses of values in ONNX sub-graphs.    )annotationsanalyze_implicit_usageNc                :    U /n0 nU  H  n[        X2U5        M     U$ )aX  Analyze implicit usage of values in sub-graphs.

This function returns a mapping from each sub-graph to a set of
:class:`~onnx_ir.Value`s that are captured from outer scopes (i.e., not defined
within the sub-graph itself).

Args:
    graph: The graph to analyze.

Returns:
    A dictionary mapping sub-graphs to sets of implicitly used values.
)_process_node)graphgraph_stackimplicit_usagesnodes       _/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx_ir/analysis/_implicit_usage.pyr   r      s*     $)'K57Od[9     c                    U R                    HM  nUb  UR                  UL a  M  [        U5       H'  nXTR                  L a    M6  X5   R                  U5        M)     MO     g )N)inputsr   reversedadd)r
   subgraphr   r	   inpgs         r   _collect_implicit_usagesr   "   sQ     {{;#))x/+&AII~""3' '	 r   c           	        U R                   R                  5        GH%  nUR                  [        R                  R
                  :X  ae  UR                  5       nUR                  U5        XA;  a  [        5       X'   U H  n [        XX!5        [        XU5        M     UR                  5         M  UR                  [        R                  R                  :X  d  M  UR                  5        HV  nUR                  U5        XA;  a  [        5       X'   U H  n [        XX!5        [        XU5        M     UR                  5         MX     GM(     g)z7Perform a DFS to find all implicit usages in subgraphs.N)
attributesvaluestypeirAttributeTypeGRAPHas_graphappendsetr   r   popGRAPHS	as_graphs)r
   r	   r   attrr   s        r   r   r   2   s     &&(99((...}}Hx(.,/E) (Vd[A ! OOYY"**111 NN,""8,203O-$D,T[Z!$E % ! - )r   )r   ir.Graphreturndict[ir.Graph, set[ir.Value]])
r
   ir.Noder   r#   r   list[ir.Graph]r	   r%   r$   None)r
   r&   r	   r%   r   r'   r$   r(   )	__doc__
__future__r   __all__onnx_irr   r   r   r    r   r   <module>r.      s    ; "  ((
((  ( 3	(
 
( "
"2"  " 
	"r   