a
    –¥»aø  ã                   @   s@  d dl Z d dlZd dlmZ d dlmZmZ d dlZd dl	Z	d dl
ZG dd„ deƒZG dd„ dejƒZe  ¡ Zej	jeƒ ee dd	¡ƒee dd	¡ƒfed
d� e	 ej¡Zej dd	¡ ej¡Zej dd	¡ ej¡Zejj	j e¡Zejj d  jeejj d jeiZ!e "e!¡d  Z#e $ed ¡Z%e%e% e Z&ej' (e&e#¡ dS )é    N)Únn)ÚVariableÚFunctionc                   @   s$   e Zd Zedd„ ƒZedd„ ƒZdS )Ú
MyFunctionc                 C   s   || | S ©N© )ÚctxÚxÚyr   r   úY/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/caffe2/contrib/aten/docs/sample.pyÚforward   s    zMyFunction.forwardc                 C   s    |   d||¡}|   d||¡}|S )NÚmulÚadd)Úat)Úgraphr	   r
   Zx2Úrr   r   r   Úsymbolic   s    zMyFunction.symbolicN)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r   r   r   r   r   r      s   
r   c                   @   s   e Zd Zdd„ ZdS )ÚMyModulec                 C   s   t  ¡ |ƒ}t ||¡S r   )r   ZReLUr   Úapply)Úselfr	   r
   r   r   r   r      s    zMyModule.forwardN)r   r   r   r   r   r   r   r   r      s   r   é   é   T)Úverboseé   ))ÚtempfileÚnumpyÚnpZtorchr   Ztorch.autogradr   r   Z
torch.onnxZonnxZcaffe2.python.onnx.backendZcaffe2r   ÚModuler   ÚNamedTemporaryFileÚfÚexportZonesÚloadÚnamer   ÚrandomZrandnZastypeÚfloat32ÚaÚbÚpythonÚbackendÚprepareZprepared_backendÚinputÚWÚrunZc2_outÚmaximumr	   r   ZtestingZassert_array_almost_equalr   r   r   r   Ú<module>   s,   
þ 