/usr/local/lib64/python3.6/site-packages/torch/fx/experimental/__pycache__
NameSizeModeActions
accelerator_partitioner.cpython-36.pyc292110644editdlrm
const_fold.cpython-36.pyc58990644editdlrm
graph_gradual_typechecker.cpython-36.pyc268710644editdlrm
merge_matmul.cpython-36.pyc57470644editdlrm
normalize.cpython-36.pyc50010644editdlrm
optimization.cpython-36.pyc141050644editdlrm
partitioner_utils.cpython-36.pyc92750644editdlrm
refinement_types.cpython-36.pyc9210644editdlrm
rewriter.cpython-36.pyc48130644editdlrm
schema_type_annotation.cpython-36.pyc40370644editdlrm
unify_refinements.cpython-36.pyc29000644editdlrm
__init__.cpython-36.pyc1570644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/fx/experimental/__pycache__/normalize.cpython-36.pyc (5001B)
3 Eg>@sddlZddlmZmZmZmZmZddlZddlZddlj Z ddlm Z m Z ddl m Z mZmZmZddlmZmZmZddlmZGdd d e ZGd d d eZdS) N)AnyCallableDictTupleOptional) TransformerProxy)ArgumentTargetNode map_aggregate)normalize_modulenormalize_functioncreate_type_hint)AnnotateTypesWithSchemac seZdZdZdejjedfdd Ze e dfdd Z de e ed feee fee e d feeee fd fd d Ze e ed feee fdfdd ZZS) NormalizeArgsa Normalize arguments to Python targets. This means that `args/kwargs` will be matched up to the module/functional's signature and rewritten to exclusively kwargs in positional order if `normalize_to_only_use_kwargs` is true. Also populates default values. Does not support positional-only parameters or varargs parameters (*args, **kwargs). If the nodes have 'type' metadata, it will use it to disambiguate overloads. Otherwise, it will throw an error. Example usage: m = torchvision.models.resnet18() traced = torch.fx.symbolic_trace(m) traced = NormalizeArgs(traced).transform() T)modulenormalize_to_only_use_kwargscstj|i|_||_dS)N)super__init__node_mapr)selfrr) __class__K/usr/local/lib64/python3.6/site-packages/torch/fx/experimental/normalize.pyr$s zNormalizeArgs.__init__)nreturncs|j\}}fddtj}t|ts4ttdd|D}fdd|jD}jdkr||jj ||||}n t j }jdkr|j |<j |j_ |S) Ncs,t|tjr$djkr jdSdSt|S)Ntype) isinstancefxr metar)arg)rrrget_type.s z(NormalizeArgs.run_node..get_typecSsg|] }t|qSr)r).0irrr 5sz*NormalizeArgs.run_node..csi|]\}}||qSrr)r$kv)r#rr 6sz*NormalizeArgs.run_node.. call_functionoutput)Zfetch_args_kwargs_from_envr argsrtupleAssertionErroritemsopr*targetrrun_noderr!node)rrr,kwargs arg_types kwarg_typesout)r)r#rrr2+s       zNormalizeArgs.run_nodeN.)r1r,r4r5r6c sRt|s tt||||||j}|r>|\}}|jjd|||Stj|||SdS)Nr*)callabler.rrZtracerZ create_proxyrr*) rr1r,r4r5r6new_args_and_kwargsnew_args new_kwargs)rrrr*@s  zNormalizeArgs.call_function)r1r,r4csRt|tstt|j||||j}|r>|\}}tj|||Stj|||SdS)N)rstrr.r rrr call_module)rr1r,r4r9r:r;)rrrr=YszNormalizeArgs.call_module)T)NN)__name__ __module__ __qualname____doc__torchnnModuleboolrr rr2r rr rr<rr*r= __classcell__rr)rrrs DrcseZdZUdZejejejejejejej ej ej ej ej ejejejejejejejejejejejejeji Zeeeegefeeegeffeeedfeeefdfdd ZZS)NormalizeOperatorsa Normalize callsites that are different ways of "spelling" the same invocation into a single, canonical call. Currently supports: 1. Normalize operators (e.g. operator.add) to the `torch` ops they ultimately invoke (e.g. torch.add) when it is possible to statically reason that Example usage: m = torchvision.models.resnet18() traced = torch.fx.symbolic_trace(m) traced = NormalizeOperators(traced).transform() .)r1r,r4csft|s t||jkrVt|dkr2tj|||S|\}}tj|j|||fidStj|||S)N)r1r,r4)r8r.binary_magic_method_remaplenrr*)rr1r,r4lhsrhs)rrrr*s   z NormalizeOperators.call_function)r>r?r@rArBaddoperatormulsubdivtruedivZ floor_dividefloordiv remaindermodeqneltlegtgerIrrrr rr r<r*rFrr)rrrGks 0rG)rNtypingrrrrrrBZtorch.fxr rrZ torch.fx.noder r r r Ztorch.fx.operator_schemasr rrZschema_type_annotationrrrGrrrrs  Y