U
    d                     @   s   d dl Zd dlmZ d dlZd dlm  mZ	 d dl
mZmZ d dl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)core	workspace)givenzNo MKLDNN support.c                   @   s   e Zd Zef ejddejdddejddddd	ejddddd	ejddddd	ejddddd	d
e	j
dd Zef ejddejdddejddddd	ejddddd	ejddddd	ejddddd	d
e	j
dd ZdS )TestAdamOps   )nr   i'  )	min_value	max_valueg{Gz?gGz?F)r   r	   	allow_nanZallow_infinity)inputsITERLRbeta1beta2epsilonc	              	   C   s   |\}	}
}}t j|gt jd}t j|gt jd}t |}tjdddddddgd	d
dg|||d}tjtjd}| j	|||	|
||||gdg|dd d S )NZdtypeAdamparammom1mom2gradlriteroutput_paramoutput_mom1output_mom2r   r   r   r   r   r   MbP?input_device_options	threshold
nparrayZint64Zfloat32absoluter   ZCreateOperatorhuZcpu_doZassertDeviceChecksselfr   r   r   r   r   r   gcdcr   r   r   r   opr     r,   D/tmp/pip-unpacked-wheel-ua33x9lu/caffe2/python/ideep/adam_op_test.py	test_adam   s*    
   zTestAdamOps.test_adamc	              	   C   s   |\}	}
}}t j|gt jd}t j|gt jd}t |}tjdddddddgd	d
ddg|||d}tjtjd}| j	|||	|
||||gdg|dd d S )Nr   r   r   r   r   r   r   r   r   r   r   Zoutput_gradr   r   r   r   r   r"   r'   r,   r,   r-   test_adam_output_grad0   s*    

   z!TestAdamOps.test_adam_output_gradN)__name__
__module____qualname__r   r&   ZtensorsstZintegersZfloatsmuZgcsr.   r/   r,   r,   r,   r-   r      sX       

    
r   __main__)Znumpyr#   Zhypothesis.strategiesZ
strategiesr3   ZunittestZ"caffe2.python.hypothesis_test_utilpythonZhypothesis_test_utilr&   Zcaffe2.pythonr   r   Z
hypothesisr   Zcaffe2.python.ideep_test_utilZideep_test_utilr4   ZskipIfCZ
use_mkldnnZHypothesisTestCaser   r0   mainr,   r,   r,   r-   <module>   s   A