U
    d#
                     @   s   d dl Z d dlZd dlmZmZmZ d dlmZ	 d dl
mZmZ d dlm  mZ d dlm  mZ e ejj dG dd dejZedkre   dS )    N)assumegivensettings)core	workspacezNo MKLDNN support.c                   @   s   e Zd Zef eddeddeddeddeddeddeddedde e e d	eje	dd
ddd Z
dS )ConvTransposeTest      r            
      )stridepadkerneladjsizeinput_channelsoutput_channels
batch_sizeuse_biastraining_mode
compute_dXd   )Zmax_examplestimeoutc                 C   s,  |
rdnd}t ||k  tj||||tjd }tj||||tjd }tj|tjd }tjd|	rdddgnddgdg|||||| d		}|	r|||gn||g}| j|||dgd
d |
r(|	r|rdddg}n$|	rddg}n|rddg}ndg}|D ]}| 	||||dg qd S )Nr   r   g      ?ZConvTransposeXwbY)r   r   r   r   r   Zno_gradient_to_inputgMbP?)	thresholdr	   )
r   nprandomZrandZastypeZfloat32r   ZCreateOperatorZassertDeviceChecksZassertGradientChecks)selfr   r   r   r   r   r   r   r   r   r   r   gcdcZtrainingr   r   r   opinputsZoutputs_to_checki r)   K/tmp/pip-unpacked-wheel-ua33x9lu/caffe2/python/ideep/conv_transpose_test.py$test_convolution_transpose_gradients   s\          

z6ConvTransposeTest.test_convolution_transpose_gradientsN)__name__
__module____qualname__r   stZintegersZbooleansmuZgcsr   r+   r)   r)   r)   r*   r      s    







r   __main__)ZunittestZnumpyr!   Z
hypothesisr   r   r   Zhypothesis.strategiesZ
strategiesr/   Zcaffe2.pythonr   r   Z"caffe2.python.hypothesis_test_utilpythonZhypothesis_test_utilhuZcaffe2.python.ideep_test_utilZideep_test_utilr0   ZskipIfCZ
use_mkldnnZHypothesisTestCaser   r,   mainr)   r)   r)   r*   <module>   s   ;