/usr/local/lib64/python3.6/site-packages/caffe2/python/trt/__pycache__
NameSizeModeActions
test_pt_onnx_trt.cpython-36.pyc89740644editdlrm
test_trt.cpython-36.pyc106460644editdlrm
transform.cpython-36.pyc29440644editdlrm
__init__.cpython-36.pyc1530644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/caffe2/python/trt/__pycache__/transform.cpython-36.pyc (2944B)
3 Eg¬ ã@shdZddlmZddlmZddljjZddl Z dd„Z dd„Z d d „Z ddd„Zdd„Zddd„ZdS)zK TensorRT related transformation Note that ONNX-TRT enforce an NCHW input! é)Ú caffe2_pb2)Ú workspaceNcCsdd„|DƒS)NcSsg|] }|j‘qS©)Z dim_value)Ú.0ÚxrrúG/usr/local/lib64/python3.6/site-packages/caffe2/python/trt/transform.pyú sz'_dim_values_to_list..r)Z dim_valuesrrrÚ_dim_values_to_listsr cCs*dd„|Dƒ}dd„|Dƒ}tt||ƒƒS)NcSsg|] }|j‘qSr)Úname)rrrrrrsz&_get_output_shapes..cSsg|]}t|jjjjƒ‘qSr)r ÚtypeZ tensor_typeÚshapeZdim)rrrrrrs)ÚdictÚzip)Zoutput_value_infosÚnamesZshapesrrrÚ_get_output_shapessrcCs<y tjƒWn*tk r6}ztdƒ‚WYdd}~XnXdS)Nz/TensorRT related functions require CUDA support)ÚCZget_cuda_versionÚ Exception)Ú_rrrÚ check_gpu_s ré@éiéFcCs<tƒtj|jƒt|jjƒ||||ƒ}tjƒ}|j |ƒ|S)z: Convert the whole ONNX model to a TensorRT C2 op ) rrZonnx_to_trt_opÚSerializeToStringrÚgraphÚoutputrZ OperatorDefÚParseFromString)Z onnx_modelÚmax_batch_sizeÚmax_workspace_sizeÚ verbosityÚ debug_builderZtrt_strÚoprrrÚconvert_onnx_model_to_trt_op#s   r!cCsŽtj|ƒi}xz|jD]p}x4|jD]*}||kr"tj|ƒ}t|dƒr"|j||<q"Wx4|jD]*}||krXtj|ƒ}t|dƒrX|j||<qXWqW|S)Nr )rZ RunNetOncer rZ FetchBlobÚhasattrr Úinput)Úpred_netÚinputsÚhintsr ÚoZblobÚirrrÚ _infer_shapes8s        r)TcCs˜tƒi}|rJi} x,|jƒD] \} } tjj| Žjtjƒ| | <qWt|| ƒ}x|jƒD]\} } | || <qTWtj |j ƒ||||||ƒ} t j ƒ} | j | ƒ| S)zS Transform the caffe2_net by collapsing TRT-runnable nodes into trt c2 ops )rÚitemsÚnpÚrandomZrandnZastypeZfloat32r)rZ transform_trtrrZNetDefr)r$Z input_shapesZpopulate_shapesrrrrZbuild_serializable_opZ shape_hintsZ input_dataÚkÚvZ pred_net_strZ pred_net_cutrrrÚtransform_caffe2_netJs&     r/ié )rr0rFié )Frr1rFT)Ú__doc__Z caffe2.protorZ caffe2.pythonrZ!caffe2.python._import_c_extensionÚpythonZ_import_c_extensionrZnumpyr+r rrr!r)r/rrrrÚs$