3
I4W^S  ã               @   sr   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddljjZddlZddd„ZdS )z
ONNXIFI a Caffe2 net
é    )Úabsolute_import)Údivision)Úprint_function)Úunicode_literals)Ú
caffe2_pb2)ÚcoreÚ	workspaceNé   FTc	          
   C   sj   i }	x|j ƒ D ]\}
}||	|
< qW tj| jƒ |	|r6|ng |dk	rD|ng |||||ƒ	}tjƒ }|j|ƒ |S )z[
    Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
    N)ÚitemsÚCZonnxifiZSerializeToStringr   ZNetDefZParseFromString)Zpred_netZinput_shapesZmax_batch_sizeZmax_seq_sizeÚdebugZuse_onnxZadjust_batchZ
black_listZweight_namesZshape_hintsÚkÚvZpred_net_strZpred_net_cut© r   ú;/tmp/pip-build-e66j97b2/torch/caffe2/python/onnx/onnxifi.pyÚonnxifi_caffe2_net   s    


r   )r	   r	   FTTNN)Ú__doc__Ú
__future__r   r   r   r   Zcaffe2.protor   Zcaffe2.pythonr   r   Z!caffe2.python._import_c_extensionÚpythonZ_import_c_extensionr   ZnumpyÚnpr   r   r   r   r   Ú<module>   s         