ó
àÆ÷Xc           @` sa  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z e j j	 j
 sn d  d l m Z e d ƒ ‚ n  d  d l j j Z e j s¨ d  d l m Z e d ƒ ‚ n  d  d l j Z d  d l m Z m Z e j j d k re j j j d ƒ j d	 ƒ Z e j j j d ƒ j d	 ƒ Z n6 e j j j  ƒ  j d	 ƒ Z e j j j  ƒ  j d	 ƒ Z d
 „  Z! d S(   i    (   t   absolute_importt   print_functiont   divisionN(   t   SkipTests>   Pycuda not installed. Skip test of theano op with pycuda code.s   Optional package cuda disabled(   t   PycudaElemwiseSourceModuleOpt%   PycudaElemwiseSourceModuleMakeThunkOpt   FAST_COMPILEt   FAST_RUNt   gpuc          C` s  xd d d d g D]ý}  xôt  j j j t  j j j g D]Ô} t j d ƒ } t j d ƒ } t  j j | ƒ } t	 | ƒ } t
 | ƒ } t  j | | g | | | ƒ d	 t ƒ} t  j | | g t  j j j | | | ƒ ƒ d	 t ƒ} t j d
 ƒ }	 t  j | | g | | | ƒ d	 |	 ƒ}
 t  j | | g t  j j j | | | ƒ ƒ d	 t ƒ} t g  | j j j ƒ  D]! } t | j t  j j j ƒ ^ qeƒ s•t ‚ t g  | j j j ƒ  D] } t | j t	 ƒ ^ q«ƒ sÒt ‚ t g  |
 j j j ƒ  D] } t | j t	 ƒ ^ qèƒ st ‚ t g  | j j j ƒ  D] } t | j t
 ƒ ^ q%ƒ sLt ‚ t j t j j |  Œ  d d ƒ} t j t j j |  Œ  d d ƒ} t j | | | ƒ | | | ƒ ƒ s¸t ‚ t j | | | ƒ |
 | | ƒ ƒ sât ‚ t j | | | ƒ | | | ƒ ƒ s8 t ‚ q8 Wq Wd  S(   Ni   i
   i1   i2   iô  iõ  t   xt   yt   modet   local_pycuda_gpu_elemwiset   dtypet   float32(   i   i   (   i
   i1   (   i2   i1   (   iô  iõ  (   t   theanot   scalart   basict   mult   addt   Tt   fmatrixt   tensort   ElemwiseR   R   t   functiont   mode_with_gput   sandboxt   cudat   host_from_gput	   includingt   anyt   makert   fgrapht   toposortt
   isinstancet   opt   GpuElemwiset   AssertionErrort   npt   asarrayt   randomt   randt   allclose(   t   shapeR#   R	   R
   t   elemwise_opt	   pycuda_opt   pycuda_op_thunkt   ft   f2t   mode_pycudat   f3t   f4t   nodet   val1t   val2(    (    sE   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_pycuda_example.pyt"   test_pycuda_elemwise_source_module   s@    %'			@777!!**("   t
   __future__R    R   R   t   numpyR&   R   t   theano.misc.pycuda_initt   misct   pycuda_initt   pycuda_availablet   nose.plugins.skipR   t   theano.sandbox.cudaR   R   t   cuda_ndarrayt   cuda_availablet   theano.tensorR   R   t   theano.misc.pycuda_exampleR   R   t   configR   t   compilet   get_modeR   R   t	   excludingt   mode_without_gput   get_default_modeR7   (    (    (    sE   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_pycuda_example.pyt   <module>   s(   		L