U
    9%e҅                     @   s  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZ d dlZd dlmZ d dlmZ d dlmZmZmZmZ d dlmZmZmZ d d	l m!Z! d d
l"m#Z#m$Z$ d dl%m&Z&m'Z' d dl(m)Z) d dl*m+Z+m,Z,m-Z- d dl.m/Z/m0Z0m1Z1 d dl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC d dlDmEZE d dlFmGZGmHZHmIZImJZJmKZK eee'f eLdddZMeee'f e@ee: eLdddZNeddG dd dZOeddG dd dZPee@ eHeEeQe+ddd d!ZReeeAe@f e+eeL d"d#d$ZSdd%ee@ e+eEeQeee@  eLd&d'd(ZTee@ e+e	eeAe@f e+geeL f e
eLeeL f d)d*d+ZUee@ eQee@ eEe+eHeQdd,d-d.ZVee@ eEe+eHeQdd/d0d1ZWeLeLeeL eQedd2d3d4ZXd@eeL eLe	e@geQf eQeee@ ee
e=e
eBe;f f e+f f d6d7d8ZYeLeLeeL eeL eEeQee-ee- f d9d:d;ZZdd<d=d>Z[e\d?kr~e[  dS )A    N)defaultdict)	dataclass)	AnyCallableDictListOptionalSequenceTextIOTupleUnion)dest)cpp)CppSignatureCppSignatureGroupCType
NamedCType)method_with_native_function"method_with_nested_native_functionwith_native_function_and_index)et_cpp)ComputeNativeFunctionStubgen_custom_ops_registration)
contextArgExecutorchCppSignature)Unboxing)ETKernelIndexETKernelKeyETParsedYaml)	ET_FIELDSparse_et_yamlparse_et_yaml_struct)get_custom_build_selector get_native_function_declarations8get_native_function_declarations_from_ns_grouped_kernels(get_native_function_schema_registrations
LineLoaderparse_native_yaml)
BackendIndexBackendMetadataDEFAULT_KERNEL_NAMESPACEDispatchKeyFunctionSchemaLocationNativeFunctionNativeFunctionsGroupOperatorNameVariant)SelectiveBuilder)contextFileManagermake_file_managermapMaybeNamespaceHelper)sigreturnc                 C   sh   t | tr|  S t| jj }dd |  D }d	t
 g| }| d|   d| d}|S )z
    A wrapper function to basically get `sig.decl(include_context=True)`.
    For ATen kernel, the codegen has no idea about ET contextArg, so we
    use this wrapper to add it.
    c                 S   s   g | ]}|  qS  )decl.0ar:   r:   V/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/torchgen/gen_executorch.py
<listcomp>D   s     z%_sig_decl_wrapper.<locals>.<listcomp>,  ())
isinstancer   r;   aten_cppreturns_typefuncreturnscpp_type	argumentsjoinr   name)r8   rG   Zcpp_argsZcpp_args_strZsig_declr:   r:   r?   _sig_decl_wrapper:   s    
rN   )r8   fbackend_indicesr9   c              	      s   t |dks jrdS  fdd|D }d}t |dkr|d  }|rddd	 |  D }d
|j d|j d| d}nd jj dt | d}d j	 d j dt
|  d| d	S )a  
    For a given `NativeFunction`, find out the corresponding native function and dispatch to it. If zero or more than one
    native function exists, error out. A simplified version of register_dispatch_key.py
    Arguments:
        sig: A CppSignature for this native function we want to use.
        f: NativeFunction to generate static dispatch.
        backend_indices: All available backends.
    Return:
        C++ code to call backend-specific functions, e.g., "return at::native::add(self, other, scale);"
    r    c                    s   g | ]}|  r|qS r:   )Z
has_kernel)r=   brO   r:   r?   r@   \   s     
 z#static_dispatch.<locals>.<listcomp>N   rA   c                 s   s   | ]}|j V  qd S NrM   r<   r:   r:   r?   	<genexpr>a   s     z"static_dispatch.<locals>.<genexpr>z	return ::::rC   z);zH
ET_ASSERT_UNREACHABLE_MSG("The number of native function(s) binding to z is z	.");
    
// 
TORCH_API inline z {
    z
}
)lenZmanual_kernel_registrationZ
get_kernelrL   rK   cpp_namespacekernelrH   rM   	namespacerN   )r8   rO   rP   backendsZstatic_blockbackend_metadataargsr:   rS   r?   static_dispatchJ   s.    rb   T)frozenc                   @   sT   e Zd ZU ee ed< eed< eed< ee	gef ed< e
e	ee dddZdS )	ComputeFunctionstatic_dispatch_backend_indicesselectoruse_aten_libis_custom_oprO   r9   c                 C   s   | j |j d|jj s d S tj|jkr0d S | jrLt	j
|d|jd nt
|}| jr| |sd}d|j d|j dt| d|  d|d	d
 | D  dS t||| jdS d S )NrX   FmethodZfallback_bindingrA   rY   rZ   z {
    return at::rC   c                 s   s   | ]}|j V  qd S rU   rV   r=   er:   r:   r?   rW      s     z+ComputeFunction.__call__.<locals>.<genexpr>z);
}
)rP   )rf   is_root_operatorr^   rH   rM   r1   functionvariantsrg   r   from_native_functionmanual_cpp_bindingmost_faithful_signaturer   rh   rN   rL   rK   rb   re   )selfrO   r8   commar:   r:   r?   __call__|   s<      
zComputeFunction.__call__N)__name__
__module____qualname__r   r(   __annotations__r2   boolr   r.   r   r   strrv   r:   r:   r:   r?   rd   r   s   
rd   c                   @   sB   e Zd ZU eed< eed< eeeee	e
f f edddZdS )ComputeCodegenUnboxedKernelsrf   rg   )unbox_kernel_entryr9   c              
      s  |d |d d }|d d }j  djj }| j|sDdS t|tsT|g}| j|dd |D }|stdS | jrt	j
djd }tj}tj}| }	d	j  d|  n4t
}tj}tj}|jdd
}	|j d|j t|d|	\}
dd}|dd |
D   tjjdkrtjjjdkrZtdj djjjd }dt|
 d|j ddnBtjjjdkrdt|
 d|jj d ndddd fdd|D S )Nr   rT   rX   rQ   c                 S   s   g | ]}|  qS r:   )to_native_stringr=   kr:   r:   r?   r@      s     z9ComputeCodegenUnboxedKernels.__call__.<locals>.<listcomp>Frj   ztorch::executor::)include_context)argument_type_genz
	rA   c                 s   s   | ]}|j V  qd S rU   rV   rl   r:   r:   r?   rW      s     z8ComputeCodegenUnboxedKernels.__call__.<locals>.<genexpr>zCan't handle native function z  with no returns and no out yet.zstack[z] = &;z*stack[z] = EValue(result_);z result_ = z
    
c                    sx   g | ]p}d j  djj d|dkr4d |d  nd dt  d djj d	  d
  d dqS )z
Kernel(
    "rX   z",default"rQ   z
    [](z, EValue** stack) {
        z-

        EXECUTORCH_SCOPE_PROF("native_call_z");
        z
(context, z);

        z

    }
),
)r^   rH   rM   r   ZdefnrL   r   args_strZcode_connectorZ	code_listrO   Zkernel_callnewlineZ
ret_prefixZreturn_assignmentr:   r?   r@      s,   	)r^   rH   rM   rf   rn   rE   listZet_get_selected_kernelsrg   r   rq   rr   rs   rF   Zargumenttype_typerG   rK   r   r   r\   r]   r   Zconvert_argumentsrL   r[   rI   out	ExceptionrJ   )rt   r~   
kernel_keyZkernel_metaop_nameZused_kernel_keysr8   r   Zreturn_type_genrK   Zbinding_listZarg_connectorr   r:   r   r?   rv      sr    
   

z%ComputeCodegenUnboxedKernels.__call__N)rw   rx   ry   r2   rz   r{   r   r   r.   r   r)   r|   rv   r:   r:   r:   r?   r}      s   
r}   )native_functionscpu_fmrf   rg   kernel_indexr9   c                    sl   t tt ttf f tddd}fdd| D r:dndg |jd| fd	d
dddhd d S )N)itemr9   c                 S   s   | d j d | d d   S )Nr   :rT   )Z	root_namer   )r   r:   r:   r?   key_func  s    zgen_unboxing.<locals>.key_funcc                    s0   g | ](}  | D ]\}}|||ffqqS r:   )get_kernelsitems)r=   native_functionr   metadata)r   r:   r?   r@     s    z gen_unboxing.<locals>.<listcomp>Functions.hNativeFunctions.hz!RegisterCodegenUnboxedKernels.cppc                    s&   t | g| d kr ng dS )Nr   )unboxed_kernels	fn_header)r}   )r~   )headerr   rf   rg   r:   r?   <lambda>  s    
zgen_unboxing.<locals>.<lambda>rT   r   r   )Zkey_fnZenv_callableZ
num_shardsZsharded_keys)r   r.   r   r)   r|   Zwrite_sharded)r   r   rf   rg   r   r   r:   )r   r   r   rf   rg   r?   gen_unboxing   s    

r   )gr   r9   c                    sd   t | tsttj| d||  d kr4g S dttt	dfdd  fdddD S )	NrS   Z	TORCH_API)r   r   r9   c                    s     dj | j|d dS )NrB   )rM   r   r   )r;   r]   )r   r   )prefixr8   r:   r?   gen_decl-  s    z5compute_native_function_declaration.<locals>.gen_declc                    s    g | ]}D ]} ||qqS r:   r:   )r=   r   r   )r   metadata_listr:   r?   r@   0  s    z7compute_native_function_declaration.<locals>.<listcomp>)FT)
rE   r.   AssertionErrorr   rq   r   valuesr)   r{   r|   )r   r   r:   )r   r   r   r8   r?   #compute_native_function_declaration   s    r   custom_ops_native_functions)r   r   rf   rg   r   r9   c              
      s   t j}| }tt}| D ]}||j | qd}	d}
|D ]`}t|ddd}ttt	|g|| fddd|| }|	d|j
 d|
| d|j d7 }	q<|	S )	a  
    Generates namespace separated C++ function API inline declaration/definitions.
    Native functions are grouped by namespaces and the generated code is wrapped inside
    namespace blocks.

    E.g., for `custom_1::foo.out` in yaml file we will generate a C++ API as a symbol
    in `torch::executor::custom_1::foo_out`. This way we avoid symbol conflict when
    the other `custom_2::foo.out` is available.
    rQ   r      )Znamespace_strentity_nameZ	max_levelc                    s    d k	o|  kS rU   r:   rS   r   r:   r?   r   `  s   z,gen_functions_declarations.<locals>.<lambda>)re   rf   rg   rh   z	
        )r+   CPU_to_backend_indexr   r   r^   appendr7   r6   rd   ZprologuerL   epilogue)r   r   rf   rg   r   dispatch_keyZbackend_indexZns_grouped_functionsr   Zfunctions_declarationsr   r^   Z	ns_helperZdeclarationsr:   r   r?   gen_functions_declarations7  s@    
r   )r   r   native_function_decl_genr9   c           	      C   s|   t t}| D ]j}t }||}| D ]L}|rB|j}|| nt}t|dks`t	d| || 
||| q(q|S )NrT   z6Codegen only supports one namespace per operator, got )r   r   setr   r   r\   addr*   r[   r   extend)	r   r   r   ns_grouped_kernelsrO   Znative_function_namespacesZ
op_kernelsr`   r^   r:   r:   r?   get_ns_grouped_kernelsn  s"    

r   )r   gen_custom_ops_headerr   rf   r   r   rg   r9   c              	      s   dg t j i|r:|ddfdd  d |d fdd d	d
ddgir|dfdd n$ttd|dfdd dS )a%  Generate headers.

    Args:
        native_functions (Sequence[NativeFunction]): a collection of NativeFunction for ATen ops.
        gen_custom_ops_header (bool): whether we should generate CustomOpsNativeFunctions.h
        custom_ops_native_functions (Sequence[NativeFunction]): a collection of NativeFunction for custom ops.
        kernel_index (ETKernelIndex): kernel collection
        cpu_fm (FileManager): file manager manages output stream
        use_aten_lib (bool): whether we are generating for PyTorch types or Executorch types.
    z#include <ATen/Functions.h>zCustomOpsNativeFunctions.hr   c                      s   t  tjdddgdS )NZgrouped_native_functionsrP   r   z#include <ATen/ATen.h>z#include <torch/torch.h>)nativeFunctions_declarationsheaders)r#   r   r   r:   )rP   r   r:   r?   r     s    zgen_headers.<locals>.<lambda>%#include "CustomOpsNativeFunctions.h"r   c                      s"   r ndgt ddS )Nz#include "NativeFunctions.h")r   r   rf   rg   r   )Zstatic_dispatch_extra_headersZFunctions_declarations)r   r:   )aten_headersr   r   r   rf   rg   r:   r?   r     s    r   zK#include <executorch/runtime/core/exec_aten/exec_aten.h> // at::Tensor etc.z3#include <executorch/codegen/macros.h> // TORCH_APIz=#include <executorch/runtime/kernel/kernel_runtime_context.h>c                      s   t dt tjdifS )Nr   r   )dictr#   r   r   r:   )rP   r   r   r:   r?   r     s    )r   r   r   c                      s   t dtdif S )Nr   )r   )r   r$   r:   )r   r   r:   r?   r     s    N)r+   r   r   write_with_templater   writer   r   r   r   r   rf   r   r   rg   r:   )	r   rP   r   r   r   r   r   rf   rg   r?   gen_headers  sB    
r   )r   rf   r   r   rocmr9   c                    s   t jt|||d\ |d dd fdd |d ddfdd t|d	\|d
fdd d S )N)r   rf   r   r   ZRegisterzCustomOps.cppz RegisterDispatchKeyCustomOps.cppc                      s   d  d dS )Nr   rQ   Zops_headersr+   Zdispatch_namespaceZdispatch_namespaced_definitionsZdispatch_anonymous_definitions"static_init_dispatch_registrations)lowerr:   )anonymous_definitionr   r   r:   r?   r      s    z gen_custom_ops.<locals>.<lambda>zStub.cppc                      s"   d    dttt dS )NrQ   r   )r   r   r6   r   r:   )r   r   r   r:   r?   r     s    
)r   Zschema_selectorzRegisterSchema.cppc                      s
    dS )N)schema_registrationsaten_schema_registrationsr:   r:   )r   r   r:   r?   r   !  s    )r+   r   r   r   r%   r   r   rf   r   r   r   r:   )r   r   r   r   r   r   r?   gen_custom_ops  s>    

r   )tags_yaml_pathaten_yaml_pathnative_yaml_pathrg   out_filer9   c                    s  |r*t |}||  W 5 Q R X dS t|| ddd\}}dd |D }dd | D dd | D }	fdd| D }
|rtj|rt|j	d	krdS t |(}t
j|td
}|sW 5 Q R  dS |D ]}t|dtst|t||d t fdd d|kr*d|d< d|kr@W 5 Q R  qt|dtsZt||d}d|krvd| }||	kst|	||d< ||
kr|
|  D ]\}}|||< qW 5 Q R X qt
j||dd W 5 Q R X dS )a  Translates Executorch DSL dialect to use the same syntax as
    native_functions.yaml. The major difference is that Executorch DSL dialect
    supports "op" key, where it refers to the operator name in native_functions.yaml.

    For example, a functions.yaml may have the following entry:

    - op: add.out
      ...

    It needs to be translated to the following:

    - func: add.out(Tensor self, Tensor other, *, Scalar alpha=1, Tensor(a!) out) -> Tensor(a!)
      ...

    We go in aten_yaml_path and find the operator schema for "add.out" and add it
    to the original functions.yaml. We also add required field "variants", where for
    Executorch it will always be "function".

    For ATen mode we don't have to do the translation because native_yaml_path is
    the same as native_functions.yaml.

    Args:
        tags_yaml_path: Path to a tags.yaml file to satisfy codegen parsing.
            It is not optional.
        aten_yaml_path: Path to ATen operator yaml file native_functions.yaml.
        native_yaml_path: Path to a functions.yaml file to parse.
            If the path does not exist in the filesystem, it is treated as an
            empty file. If `custom_ops_yaml_path` exists, the contents of that
            file are appended to the yaml input to be parsed.
        use_aten_lib: We use this flag to determine if we want to generate native
            functions. In ATen mode we should generate out= variants.
        out_file: The IO object that we are writing into.
    Returns:
        None
    NF)skip_native_fns_genc                 S   s$   i | ]}|j |j d |j j qS )rX   )rH   r^   rM   r=   rO   r:   r:   r?   
<dictcomp>^  s     z)translate_native_yaml.<locals>.<dictcomp>c                 S   s   i | ]\}}|j |qS r:   rV   r=   rH   rM   r:   r:   r?   r   a  s     c                 S   s   i | ]\}}|t |qS r:   )r|   r   r:   r:   r?   r   e  s      c                    s   i | ]\}} | |qS r:   r:   )r=   opv)op_to_scoped_namer:   r?   r   f  s     r   LoaderZ__line__c                      s   d  dS )Nzin z:
  r:   r:   )locr:   r?   r   w      z'translate_native_yaml.<locals>.<lambda>rp   ro   rH   r   rX   zaten::i  )width)open
writelines	readlinesr    r   ospathexistsstatst_sizeyamlloadr&   rE   getintr   r-   popr3   r|   dump)r   r   r   rg   r   Z	aten_yamlr   Zpersisted_fieldsZfunc_to_scoped_nameZschema_dictZkernel_persist_dictZnative_yamlZ	native_esrm   opnamer   r   r:   )r   r   r?   translate_native_yaml(  sb    *








r   F)r   r   function_filterr   r9   c              	      s4  | r(t j| r(t | jdkr(t| }tj|td}W 5 Q R X t	dd |D rbt
|nd }|D ]}tD ]}||d  qrqjt| |d ||d}	tt||	j}
dd |
D |d k	rfdd	|j D }|
t|d
fS tttf tttf dfdd  fdd	|	j D }|
|fS g i fS d S )Nr   r   c                 s   s   | ]}d |kV  qdS )ZkernelsNr:   rl   r:   r:   r?   rW     s     zparse_yaml.<locals>.<genexpr>)r   Zloaded_yamlc                 S   s   g | ]}|j jqS r:   )rH   rM   r   r:   r:   r?   r@     s     zparse_yaml.<locals>.<listcomp>c                    s   i | ]\}}| kr||qS r:   r:   )r=   r   Zkernel_mappingop_namesr:   r?   r     s    zparse_yaml.<locals>.<dictcomp>index)mr9   c                    s    fdd D S )Nc                    s   i | ]}|kr| | qS r:   r:   )r=   r   )r   r   r:   r?   r     s       z1parse_yaml.<locals>.map_index.<locals>.<dictcomp>r:   r   r   r   r?   	map_index  s    zparse_yaml.<locals>.map_indexc                    s   i | ]\}}| |j qS r:   r   )r=   r   rR   )r   r:   r?   r     s     )r   r   r   r   r   r   r   r   r&   anyr!   r   r   r'   r   filterr   r   r   r   r   r0   r)   rP   )r   r   r   r   rO   esr   entryfieldparsed_yamlr   Zfiltered_indexrP   r:   )r   r   r?   
parse_yaml  s<    	&




r   )r   r   r   custom_ops_yaml_pathrf   rg   r9   c              
      s   ddl }ttd fdd}| }tj|d}	t|	d}
t| ||||
 W 5 Q R X t	|	| || \}}t	|| |d\}}t
|tst|}t
|tst|}|| }t||}t||}t||}W 5 Q R X ||fS )	a  Parses functions.yaml and custom_ops.yaml files.

    Args:
        tags_yaml_path: Path to a tags.yaml file to satisfy codegen parsing.
            It is not optional.
        aten_yaml_path: Path to ATen operator yaml file native_functions.yaml.
        native_yaml_path: Path to a functions.yaml file to parse.
            If the path does not exist in the filesystem, it is treated as an
            empty file. If `custom_ops_yaml_path` exists, the contents of that
            file are appended to the yaml input to be parsed.
        custom_ops_yaml_path: Path to a custom_ops.yaml file to parse. If
            the path does not exist in the filesystem, it is ignored.
        selector: For selective build.
        use_aten_lib: We use this flag to determine if we want to generate native
            functions. In ATen mode we should generate out= variants.
    Returns:
        A tuple with two elements:
        [0]: The parsed results of concatenating the contents of
             `native_yaml_path` and `custom_ops_yaml_path`.
        [1]: The parsed results of the contents of `custom_ops_yaml_path`, if
             present. If not present, None.
    r   Nri   c                    s
     | S rU   )Zis_native_function_selectedrS   rf   r:   r?   r     s    z)parse_yaml_files.<locals>.function_filterztranslated.yamlwT)tempfiler.   r{   TemporaryDirectoryr   r   rL   r   r   r   rE   r   Zfrom_backend_indicesZmerge_indicesr   )r   r   r   r   rf   rg   r   r   Z
tmpdirnameZtranslated_yaml_pathZ
translatedZtranslated_functionsZtranslated_indicesZcustom_ops_functionsZcustom_ops_indicesZcombined_functionsZcombined_kernel_indexZcombined_yamlcustom_ops_parsed_yamlr:   r   r?   parse_yaml_files  sH    
      



 
r  )r9   c               	   C   s6  t jdd} | jdddd | jddd	d | jd
ddd | jdddd | jdddddd | jdddd | jdddd | jdddd d! | jd"d#dd$d! | jd%d&d'd | jd(d)d | jd*dd+d | jd,d-dd.d | jd/tdd0d1gd0d1gd2d3 |  }|jstd4t|j|j	}t
|j|j|j|j||jd5\}}|j|j }}|rd|jng }t|d6}d0|jkrt||j|||||jd7 d1|jkrt||||j|d8 |rt|||||jd9 |jr2t|j }	|	j}
|	j}|d:ffD ]0\}}|| }|	j||
  }||t| q d S );NzGenerate operator source files)descriptionz-sz--source-pathz-path to source directory for kernel templates)helpz--functions-yaml-pathz--functions_yaml_pathzpath to the functions.yaml file to use. Optional, but at least one of --functions-yaml-path and --custom-ops-yaml-path must be specified.z--custom-ops-yaml-pathz--custom_ops_yaml_pathzpath to the custom_ops.yaml file to use. Optional, but at least one of --functions-yaml-path and --custom-ops-yaml-path must be specified.z--aten-yaml-pathz--aten_yaml_pathz#path to native_functions.yaml file.z-dz--install-dirz--install_dirzoutput directoryzbuild/generated)r  r   z-oz--output-dependenciesz:output a list of dependencies into the given file and exitz	--dry-run
store_truez5run without writing any files (still updates outputs))actionr  z--static-dispatch-backendz--static_dispatch_backend*z?generate static dispatch code for the specific backend (if set))nargsr  z--op-registration-whitelistz--op_registration_whitelistzfilter op registrations by the whitelist (if set); each item is `namespace`::`operator name` without overload name; e.g.: aten::empty aten::conv2d ...z--op-selection-yaml-pathz--op_selection_yaml_pathaD  Provide a path to the operator selection (for custom build) YAML that contains the information about the set of selected operators and their categories (training, ...). Each operator is either a full operator name with overload or just a bare operator name. The operator names also contain the namespace prefix (e.g. aten::)z--tags-pathz>Path to tags.yaml. Required by yaml parsing in codegen system.z--rocmz=reinterpret CUDA as ROCm/HIP and adjust filepaths accordinglyz--use-aten-libz--use_aten_libzka boolean flag to indicate whether we use ATen kernels or not, in the future this flag will be per operatorz
--generater   sourceszGenerate only a subset of files)typer  choicesr   r  z.tags.yaml is required by codegen yaml parsing.)r   r   r   r   rf   rg   )optionsr   )r   r   rf   rg   r   r   rQ   )argparseArgumentParseradd_argumentr|   
parse_argsZ	tags_pathr   r"   Zop_registration_whitelistZop_selection_yaml_pathr  r   Zfunctions_yaml_pathr   rg   r   r   r5   generater   r   r   r   Zoutput_dependenciespathlibPathresolverM   stemparentZwrite_outputs)parserr  rf   r   r   r   r   r   r   Zdepfile_pathZdepfile_nameZdepfile_stemfmr   varnamer   r:   r:   r?   main
  s
   	
	

r  __main__)F)]r  r   r  collectionsr   dataclassesr   typingr   r   r   r   r   r	   r
   r   r   r   Ztorchgenr   Ztorchgen.apir   rF   Ztorchgen.api.typesr   r   r   r   Ztorchgen.contextr   r   r   Ztorchgen.executorch.apir   Z"torchgen.executorch.api.custom_opsr   r   Ztorchgen.executorch.api.typesr   r   Z torchgen.executorch.api.unboxingr   Ztorchgen.executorch.modelr   r   r   Ztorchgen.executorch.parser   r    r!   Ztorchgen.genr"   r#   r$   r%   r&   r'   Ztorchgen.modelr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   Z!torchgen.selective_build.selectorr2   Ztorchgen.utilsr3   r4   r5   r6   r7   r|   rN   rb   rd   r}   r{   r   r   r   r   r   r   r   r   r  r  rw   r:   r:   r:   r?   <module>   s   , 0	
()^'
 
9
!`>g :F %
