/usr/local/lib64/python3.6/site-packages/torch/quantization/fx/__pycache__
NameSizeModeActions
convert.cpython-36.pyc130810644editdlrm
fuse.cpython-36.pyc25980644editdlrm
fusion_patterns.cpython-36.pyc49420644editdlrm
graph_module.cpython-36.pyc55130644editdlrm
lower_to_fbgemm.cpython-36.pyc5060644editdlrm
lower_to_qnnpack.cpython-36.pyc5090644editdlrm
match_utils.cpython-36.pyc43240644editdlrm
pattern_utils.cpython-36.pyc17540644editdlrm
prepare.cpython-36.pyc259380644editdlrm
qconfig_utils.cpython-36.pyc73400644editdlrm
quantization_patterns.cpython-36.pyc453210644editdlrm
quantization_types.cpython-36.pyc3150644editdlrm
quantized_fusion_patterns_and_replacements.cpython-36.pyc12480644editdlrm
utils.cpython-36.pyc146600644editdlrm
_equalize.cpython-36.pyc249460644editdlrm
_lower_to_native_backend.cpython-36.pyc9260644editdlrm
__init__.cpython-36.pyc3800644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/quantization/fx/__pycache__/convert.cpython-36.pyc (13081B)
3 Eg_@sddlmZmZmZmZmZmZmZddlm Z ddl Z ddl m Z m Z mZddlmZmZddlmZddlmZd d lmZdd lmZdd lmZmZmZdd lmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ddl,m-Z-m.Z.d dl#m/Z/m0Z0ddl1m1Z1e j2j3j4j5e j2j3j4j6e j2j3j4j7e j2j3j4j8e j2j3j4j9hZ:e ddddZ;eeee eeeefeeksz/fold_weight..load_arg..)r )a)r:r4r5load_argjszfold_weight..load_argrZ_packed_weight_Zget_attr)dictr+r,r-r.WEIGHT_PREPACK_OPSrr9r r getlistZusersrsetattrZ create_node node_copyrZpreserved_attr_names)r7r8Zpacked_weightsZ folded_nodesr1Z nodes_to_foldZ node_to_foldZprepacking_moduleZ packed_weightZ folded_graphr=Zquantized_rootquantized_graphZ prepack_nodeZop_node module_path_Zget_new_packed_weight_nameZpacked_weight_namer4)r:r5 fold_weightNsB        rGcCs,t|std|j}|j}|j}|||fS)Nz-incoming model must be produced by prepare_fx)rAssertionErrorZ_prepare_custom_config_dictZ_node_name_to_scopeZ _patterns)r(prepare_custom_config_dictr8patternsr4r4r5 restore_states  rKFT)model is_referenceconvert_custom_config_dictis_standalone_module_remove_qconfig_flagr)c$ s|dkr i}t|\}}|j}|s,|jt|jdd}t|d} t|j|||| d} |jdk rzt ||} t ||| t |t t ddg} x&|jjD]} | jdkr| j| jqWttd fd d tjd fd d ttd fdd tttttttjftjttdffttgtfdfdd }ttdfdd d*ttt tt!tj"j#ftdfdd }ttt!tj"j#fddfdd }d}d}|j$dg}|j$d g}x^|jjD]P} | jd!kr2|}|d"7}||krt%| j&d}nt%| j&d}j'|q| j$| jd+\}}}}}|| kr>| jd#kolt(|| j)}|dkr| rj*| }d}n||dk st+|r|| j)j,j-}t.|d"kst+d$d|k}|| j}|j/| |||||d%}|s|| ||||}|r(|| jt0|<n|| jtj1<qn4|dk rr|dkrڈj*| }|| jtj1<q| jd#krt2|| j)r|| |n| jdkr|} |d"7}| |krֈj*| | jtj3<nj*| | jtj1<n:t4| rj*| | jd<nj*| | jtj1<qWt }!ittd&fd'd( }"x|jD]r} | jd!kr|!j't%| j&d|"qV| jd#krt2|| j)r| j&dj| j<n|!j*| |"| j<qVW|rt5|t6|j$d)g}#t7||!|#}|st8|}t9|}|S),ag standalone_module means it a submodule that is not inlined in parent module, and will be quantized separately as one unit. Returns a quantized standalone module, whether input/output is quantized is specified by prepare_custom_config_dict, with input_quantized_idxs, output_quantized_idxs, please see docs for prepare_fx for details NF)Zremove_duplicateZ)observed_to_quantized_custom_module_class)custom_module_classescSsttS)N)r rr4r4r4r5r;szconvert.. placeholder)nr)cs|jks$td|jdt|j}tj|krB|tjSd|krR|dSd}x*tjtjtjgD]}||krh||}PqhW|dk stdj|t |j j |jtj<|jtjSdS)Nz+trying to load float node but did not find znode:z in env: z+Did not find a supported quantized dtype:{}z0trying to load float node but did not find node:) r9rHstrtorchfloatquint8qint8float16formatr Z dequantizer1)rS dtype_to_nodeZquantized_nodedtype)r:r4r5load_non_quantizeds       z#convert..load_non_quantized)r\cstdfdd }|S)N)rScs|jks$td|jdt|j}}|tjkrH||krHd}|tjdgkr^|S||ksztdd|||S)Nz4trying to load quantized node but did not find node:z in environment:z Expecting z in )r9rHrTrUrV)rSr[Z local_dtype)r\r:r]r4r5load_quantized_impls  z.load_quantized..load_quantized_impl)r)r\r^)r:r])r\r5load_quantizeds zconvert..load_quantizedcsz|jkstd|jd|j}tjtjtjtjdg}x|D]}||krB||SqBWtd|d|d|jdS)Nznode z does not exist in environmentzdtype z not found in environment: z for node )r9rHrUrWrXrYfloat32 Exception)rSr[Zdtypesr\)r:r4r5load_xs    zconvert..load_x.)r7r)cs`dks(tttttjfs(ttttttfrJtdkrJtj fdd}|S)a Input: quantized, which can be None, torch.dtype, list or tuple - if quantized is None, then we'll load the node as long as it exists - if quantized is a dtype, then all args will be quantized to the specific dtype - if quantized is an empty list or tuple, then it is the same as load_arg(quantized=torch.float) - if quantized is a list or tuple, then arg should be a list and the args with corresponding indexes will be quantized to torch.quint8 Output: fn which takes arg_or_args, and loads them from the corresponding environment depending on the value of quantized. NrcsF}tttfr6tdkr6t|tr6dkr6tj}|dkrHt|St|tjrbt||St|ttfrt|ttfst |g}xDt |D]8\}}||kr|j t|tjq|j t|qWt ||St|t rBg}xHt |D]<\}}||kr"|j t|||q|j t|qWt ||SdS)Nrr) isinstancetuplerAlenrrUrWr r\rHr/appendtyper>)Z arg_or_argsZupdated_quantizedZ loaded_argsr2r<)r]r_rbr7r4r5 load_arg_impls4      z0convert..load_arg..load_arg_impl) rcrdrAr>rUr\rHrgrerV)r7rh)r]r_rb)r7r5r=s  'zconvert..load_arg)r3r)cst|trX|jkstd|jkrR|jtfddtjtjtjgDSdSn:t|t rt |}t |rxdSt|sdSt dndSdS)Nz+Expecting node_arg to be in the environmentcsg|] }|kqSr4r4).0x)r[r4r5 Esz:convert..node_arg_is_quantized..FTz2partially quantized inputs in list not handled yet) rcrr9rHanyrUrWrXrYrAmapallra)r3r7)r:node_arg_is_quantized)r[r5ro?s     "  z&convert..node_arg_is_quantized)r1objqconfigmodulesr)cst|dk s t|j||}|j|rL|jd ks>td|jd|jd}t| s`|j rdd}t|rpd}|S) z* Check if output node is quantized or not N call_moduler* call_methodz$FixedQParamsQuantizeHandler of type z is not handledrF)rsr*rt)rHis_output_quantizedZ8should_mark_output_quantized_from_input_quantized_statusr-r0r%Zinput_output_observedr)r1rprqrrrMr7)ror4r5ruTs     z$convert..is_output_quantized)r1rrr)c s(|dk s tt|jtst||j}|jd}|jtjkrVj||j tj <nt|t r|j kr؈|j }|j}||kr|||j |<n@|d}t|t st|j}t ||||dd|j |<nL|d}t|jdt st|j}t |jd|||dd|j |<dS)zQ Given a activation_post_process module call node, insert a quantize nodeNrT)Zis_input) rHrcr.rTr0r\rUr`rCr9rVrr) r1rrZobserver_moduleZ prev_nodeZprev_dtype_to_nodeZ current_dtypeZ root_moduleZobserver_dtyper\)r:r]r8rDr4r5insert_quantize_nodexs6      z%convert..insert_quantize_noderinput_quantized_idxsoutput_quantized_idxsoutputrrsz,Currently standalone only support one output)rMrN)r<r)cst|fddS)Ncs |jS)N)r9)r1) remove_envr4r5r;sz2convert..load_arg_remove..)r )r<)r{r4r5load_arg_removesz convert..load_arg_removepreserved_attributes)F)NNNNN):rKZ _qconfig_mapcpur>Z named_modulesr!rr+Z_equalization_qconfig_maprrr6r r r,r-rfr9rrUr\rrrintrrrrrboolrrrTnnModuler@r r0rzrr.rCrHZ(_standalone_module_output_quantized_idxstolistreconvertr&rVr$rWrr#setrrGr')$rLrMrNrOrPrJrIZ qconfig_maprrrQmatchesZweight_eq_obs_dictZ graph_inputsr1r=rurwZplaceholder_node_seen_cntZoutput_node_seen_cntrxryZcur_output_node_idxZ graph_outputZ root_nodematchedZmatched_patternrprqZ"is_observed_standalone_module_noderesultr7Zout_quant_idxsZcur_placeholder_node_idxZact_post_process_removed_graphr|r}r4)r:r]r_rbror8rDr{r5rs        * >("()                   r)FNFT)Btypingrrrrrrr collectionsr rUZtorch.fxr r r Ztorch.fx.graphr rZ torch.fx.noderZquantization_typesrrqrZ match_utilsrZ graph_modulerrrZquantization_patternsrZ _equalizerrutilsrrrrrr r!r"Ztorch.ao.quantization.quantizer#r$r%r&r'Z_opsopsr7Zlinear_prepackZlinear_prepack_fp16Zconv1d_prepackZconv2d_prepackZconv3d_prepackr?r6rTrgrGrKrrr4r4r4r5s:$      (       78