
    Vh                    \    d Z ddlmZ ddlmZ ddlZddlZddlZddlm	Z	 	 	 ddZ
	 	 d	dZy)
z2Dispatcher for AtenLib functions from onnx-script.    )annotations)CallableN)registrationc                   t               }| j                         D cg c]9  }|j                  d      r&|j                  d      d   j                  d      d   ; }}t        j
                  j                  t        j
                  j                  fD ]/  }t        |      }|t        j
                  j                  u r||z  }|D ]  }t        ||      st        ||      }t        |t        j                  j                        sA|j                         D ]  }t        ||      }	t        j                   j#                  |	j%                               }
| j'                  |
j(                  |
j*                  |
j,                        s)| j'                  |
j(                  |
j*                  d      s|j/                  |	         2 |S c c}w )	a1  
    Creates a set of OperatorBase and Callable objects that represent ONNX-supported PyTorch operations.

    Args:
        registry (OnnxRegistry): The ONNX registry for PyTorch.

    Returns:
        A collection of OperatorBase and Callable objects representing ONNX-supported PyTorch operations.
    zaten::z::   .r   )qualified_name)	namespaceop_nameoverloadN)set_all_registered_ops
startswithsplittorchopsatenprimsdirhasattrgetattr
isinstance_opsOpOverloadPacket	overloadsr   OpNamefrom_qualified_namenameis_registered_opr
   r   r   add)registrytablek onnx_supported_aten_lookup_tableop_namespace
attr_names	attr_nameop_overload_packetoverload_nameop_overloadinternal_op_names              [/home/dcms/DCMS/lib/python3.12/site-packages/torch/onnx/_internal/fx/decomposition_table.py'_create_onnx_supports_op_overload_tabler-      s    69UE --/(<<! 	
as#A&($ ( 9 +&
599>>)::J# 	+I<3!(y!A0%**2M2MN!3!=!=!? +%&8-H#/#6#6#J#J#.#3#3#5 $K $ 
 ,,.88,44-66 -  ...88,44! /  IIk*'+	+	+@ LM(s   >Gc                ,   i }t        |       }t        j                  j                  j	                         D ]  \  }}d|j
                  v s||v r|||<    t        j                  j                         j	                         D ]  \  }}||v r|||<    |S )aJ  
    This function creates a dictionary of op overloads and their decomposition functions
    for ops that do not have ONNX symbolic functions. If an op already has an ONNX symbolic function,
    its decomposition function is excluded from the table. The decomposition table is a subset of PyTorch's
    built-in aten-to-aten decomposition.

    Args:
        registry (torch.onnx.OnnxRegistry): The ONNX registry for PyTorch.

    Returns:
        Dict[torch._ops.OperatorBase, Callable]: A dictionary that maps op overloads to their corresponding
        decomposition functions.
    ztorch._refs)r-   r   _decompdecomposition_tableitems
__module__core_aten_decompositions)r!   r0   _ONNX_SUPPORT_OP_OVERLOADSr*   	decomp_fns        r,   (create_onnx_friendly_decomposition_tabler6   I   s      DF "I!R
 #(--"C"C"I"I"K 
5Y Y11188+4K(
5 #(--"H"H"J"P"P"R 5Y44+4K(5     )returnz'set[torch._ops.OperatorBase | Callable])r8   z'dict[torch._ops.OperatorBase, Callable])__doc__
__future__r   typingr   r   
torch._opstorch.fxtorch.onnx._internal.fxr   r-   r6    r7   r,   <module>r@      s5    8 "     08,8v+,+r7   