
    Vh                       d dl mZ d dlZd dlZd dlZd dlmZmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZmZ d dlmZmZ erd d	lmZ  ed
eeef         Z	 	 	 	 ddZddZddZddZddZedk(  r e
d        e        yy)    )annotationsN)TYPE_CHECKINGTypeVarUnion)set_simple_logging)gen)native_function_manager)DispatchKeyNativeFunctionsGroupNativeFunctionsViewGroup)config	generator)SequenceNativeGroupT)boundc                    | sg S g }ddfd| D        }t        j                  |t        j                        D cg c]  \  }}t	        |       }}}|S c c}}w )Nc                n    t        |       5  t        j                  |       cd d d        S # 1 sw Y   y xY wN)r	   r   is_supported)gs    ^/home/dcms/DCMS/lib/python3.12/site-packages/torchgen/static_runtime/gen_static_runtime_ops.pyr   z0group_functions_by_op_name.<locals>.is_supported%   s-    $Q' 	-))!,	- 	- 	-s   +4c              3  4   K   | ]  } |      s|  y wr    ).0r   r   s     r   	<genexpr>z-group_functions_by_op_name.<locals>.<genexpr>)   s     K!<?AKs   )key)r   z/NativeFunctionsGroup | NativeFunctionsViewGroupreturnbool)	itertoolsgroupbyr   func_name_base_strlist)grouped_native_functionsgroupseligible_opskgroupr   s        @r   group_functions_by_op_namer(      so     $	F- L7KL --Au 	UF  Ms   Ac                4    dd l }|j                  dd| g       y )Nr   zclang-formatz-i)
subprocess
check_call)cpp_file_pathr*   s     r   clang_formatr-   7   s    >4?@    c                    dj                  |       }d| d}t        |d      5 }|j                  |       d d d        t        |       y # 1 sw Y   xY w)N
a  // @lint-ignore-every CLANGTIDY HOWTOEVEN
// AUTO-GENERATED FROM: torchgen/static_runtime/gen_static_runtime_ops.py
#include <torch/csrc/jit/runtime/static/ops.h>

#include <ATen/CPUFunctions.h>
#include <ATen/InferSize.h>
#include <ATen/NativeFunctions.h>
#include <ATen/Parallel.h>
#include <ATen/ScalarOps.h>
#include <ATen/TensorUtils.h>
#include <ATen/cpu/vec/functional.h>
#include <ATen/cpu/vec/vec.h>
#include <ATen/native/EmbeddingBag.h>
#include <ATen/native/Fill.h>
#include <ATen/native/IndexingUtils.h>
#include <ATen/native/NonSymbolicBC.h>
#include <ATen/native/Resize.h>
#include <ATen/native/SharedReduceOps.h>
#include <ATen/native/TensorAdvancedIndexing.h>
#include <ATen/native/cpu/SerialStackImpl.h>
#include <ATen/native/layer_norm.h>
#include <ATen/native/quantized/cpu/fbgemm_utils.h>
#include <ATen/native/quantized/cpu/qembeddingbag.h>
#include <ATen/native/quantized/cpu/qembeddingbag_prepack.h>
#include <ATen/quantized/QTensorImpl.h>
#include <ATen/quantized/Quantizer.h>
#include <c10/core/ScalarType.h>
#include <c10/core/WrapDimMinimal.h>
#include <c10/util/irange.h>
#include <torch/csrc/jit/ir/ir.h>
#include <torch/csrc/jit/runtime/static/impl.h>
#include <torch/csrc/jit/runtime/static/te_wrapper.h>
#include <torch/csrc/jit/runtime/vararg_functions.h>
#include <torch/csrc/jit/tensorexpr/ir.h>
#include <torch/csrc/jit/tensorexpr/ir_simplifier.h>
#include <torch/csrc/jit/tensorexpr/llvm_codegen.h>
#include <torch/csrc/jit/tensorexpr/loopnest.h>

namespace torch {
namespace jit {

z*

} // namespace jit
} // namespace torch
wjoinopenwriter-   cpp_ops	file_pathcode	generatedfs        r   	write_cppr<   =   sb    99WD)R  S-I\ 
i	 		    A

Ac                    dj                  |       }d| d}t        |d      5 }|j                  |       d d d        t        |       y # 1 sw Y   xY w)Nr0   aq  // @lint-ignore-every CLANGTIDY HOWTOEVEN
// AUTO-GENERATED FROM: torchgen/static_runtime/gen_static_runtime_ops.py
#include <gtest/gtest.h>
#include <torch/csrc/jit/runtime/static/impl.h>
#include <torch/torch.h>

#include "test_utils.h"

using namespace caffe2;
using namespace torch;
using namespace torch::jit;
using namespace torch::jit::test;
using c10::IValue;



r1   r2   r6   s        r   write_test_cppr@   r   s_    99WD  I" 
i	 		 r=   c                 d   t        j                  d      } | j                  dddd       | j                  dd	d
d       | j                  ddd
d       | j                         }t        j
                  j                  |j                  d      }t        j
                  j                  |j                  d      }t        j                  ||      }|j                  |j                  }}t        j                         }t        j                         }t        j                  |      D 	cg c]  }	t!        |	t"              r|	 }
}	t%        |
      }|D cg c]%  }|j'                  ||t(        j*                           ' }}|D cg c]  }|j'                  |       }}t        j,                  |      D 	cg c]  }	t!        |	t.              r|	 }}	t%        |      }|D cg c]%  }|j1                  ||t(        j*                           ' }}|D cg c]  }|j1                  |       }}|dgz   |z   }|dgz   |z   }t3        ||j4                         t7        ||j8                         t;        dt=        t        j                  |            d       t;        dt=        |
      d       t?        d |D              }t;        d|d       t;        dt=        |      d       t?        d |D              }t;        d|d       t;        d||z   d       y c c}	w c c}w c c}w c c}	w c c}w c c}w )NzGenerate ATen source files)descriptionz-sz--source-pathz!path to source directory for ATenzcaffe2/aten/src/ATen)helpdefaultz-pz--generated-ops-cpp-pathz5path to directory to generate op dispatcher .cpp filez6caffe2/torch/csrc/jit/runtime/static/generated_ops.cppz-tz--generated-ops-test-cpp-pathz6caffe2/benchmarks/static_runtime/test_generated_ops.ccznative/native_functions.yamlznative/tags.yamlr?   z
total grouped native ops: dz%grouped native ops with out variant: c              3  2   K   | ]  }t        |        y wr   lenr   r$   s     r   r   zmain.<locals>.<genexpr>   s     !W&#f+!W   z-generated functions groups with out variant: z
view grouped native ops: c              3  2   K   | ]  }t        |        y wr   rG   rI   s     r   r   zmain.<locals>.<genexpr>   s      'F'rJ   z!generated functions view groups: z
overall generated : ) argparseArgumentParseradd_argument
parse_argsospathr3   source_pathr   parse_native_yamlnative_functionsbackend_indicesr   GenOpDispatcherGenOpTestCaseget_grouped_native_functions
isinstancer   r(   out_variantr
   CPU$get_grouped_by_view_native_functionsr   viewr<   generated_ops_cpp_pathr@   generated_ops_test_cpp_pathprintrH   sum)parseroptionsnative_yaml_pathtags_yaml_pathparsed_yamlrT   rU   op_generatortest_case_generatorr   native_functions_groupssupported_functions_groupsr$   out_variant_op_resultout_variant_test_resultnative_functions_view_groupssupported_functions_view_groupsview_op_resultview_test_result	op_resulttest_resultsupported_functions_numsupported_view_functions_nums                          r   mainru      s   $$1MNF
0&	   "DH	   'DH	   !Gww||G$7$79WXWW\\'"5"57IJN''(8.IK$$## &
 ,,.L#113 112BCa-. 	
  "<<S!T 1 	  )IJ 
 ?Y4:''/  99:JK$a12 	
$  $ 'A$'# 6 	&/+//"BCN 
 8W-3  (  &0>AI)VH47GGKi778; C CD	
&s3+K+KL\+]'^_`&ab 
1#6M2Nq1Q
RS!!W<V!WW	9:QRS9T
UV	',H(I!'L
MN#& '"A' $  
-.J1-M
NO	
 !8;W!WXY Z[m$s$   'L*LL2L#*L(L-__main__F)escape_newlines)r#   zSequence[NativeGroupT]r   z Sequence[Sequence[NativeGroupT]])r,   strr   None)r7   zSequence[str]r8   rx   r   ry   )r   ry   )
__future__r   rL   r   rP   typingr   r   r   libfb.py.logr   torchgenr   torchgen.contextr	   torchgen.modelr
   r   r   torchgen.static_runtimer   r   collections.abcr   r   r(   r-   r<   r@   ru   __name__r   r.   r   <module>r      s    "   	 0 0 +  4 V V 5 ( 
$&>>
?4%2A2j0Xv zu-F r.   