ó
àÆ÷Xc           @` s°   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z e si d  d l	 m
 Z
 e
 d ƒ ‚ n  d  d l m Z m Z d  d l Z d d
 „ Z d d „ Z d „  Z d S(   i    (   t   absolute_importt   print_functiont   divisionN(   t   gnumpy_available(   t   SkipTests.   gnumpy not installed. Skip test related to it.(   t   garray_to_cudandarrayt   cudandarray_to_garrayi   i   i   c         C` s  t  j j j j } | t  j j d ƒ ƒ } t  j | g | | d ƒ ƒ } t j	 |  Œ  } t
 | ƒ } | j | j k s| t ‚ | | ƒ } t | ƒ } | j | j k s¬ t ‚ | d j ƒ  } | j ƒ  }	 t j | ƒ }
 | |	 k j ƒ  sï t ‚ | |
 k j ƒ  st ‚ d S(   sf   
    Make sure that the gnumpy conversion is exact from garray to
    CudaNdarray back to garray.
    t   Ui   N(   t   theanot   sandboxt   cudat	   basic_opst   gpu_from_hostt   tensort   ftensor3t   functiont   gnumpyt   randR   t   shapet   AssertionErrorR   t   asarrayt   npt   arrayt   all(   R   t   gpuR   t   iit   At   A_cndt   B_cndt   Bt   ut   vt   w(    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_gnumpy_utils.pyt   test   s    c         C` s  t  j j j j } | t  j j d ƒ ƒ } t  j | g | | d ƒ ƒ t j	 j
 |  Œ  j d ƒ } t  j j j | ƒ } t | ƒ } | j | j k s› t ‚ t | ƒ } | j | j k s¿ t ‚ | j | j k s× t ‚ | j | j k sï t ‚ t j | ƒ } | | k j ƒ  st ‚ d S(   sk   
    Make sure that the gnumpy conversion is exact from CudaNdarray to
    garray back to CudaNdarray.
    R   i   t   float32N(   R   R	   R
   R   R   R   R   R   R   t   randomR   t   astypet   CudaNdarrayR   R   R   R   t   _stridest   gpudataR   R   (   R   R   R   R   R   t   A_garR   R   (    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_gnumpy_utils.pyt   test2*   s    c           C` s@   t  d ƒ t  d ƒ t  d ƒ t d ƒ t d	 ƒ t d
 ƒ d S(   sd   
    Test with some dimensions being 1.
    CudaNdarray use 0 for strides for those dimensions.
    i   i   i   N(   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   i   i   i   (   R!   R)   (    (    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_gnumpy_utils.pyt   test_broadcast_dimsD   s    




(   i   i   i   (   i   i   i   (   t
   __future__R    R   R   t   numpyR   R   t   theano.misc.gnumpy_utilsR   t   nose.plugins.skipR   R   R   R   R!   R)   R*   (    (    (    sC   /tmp/pip-build-X4mzal/theano/theano/misc/tests/test_gnumpy_utils.pyt   <module>   s   