Ejemplo n.º 1
0
 def _broadcast_scalar_input(self, ary, shape):
     if dgpu_present:
         return devicearray.DeviceNDArray(shape=shape,
                                      strides=(0,),
                                      dtype=ary.dtype,
                                      dgpu_data=ary.dgpu_data)
     else:
         return np.lib.stride_tricks.as_strided(ary, shape=(shape,),
                                            strides=(0,))
Ejemplo n.º 2
0
 def _broadcast_add_axis(self, ary, newshape):
     newax = len(newshape) - len(ary.shape)
     # Add 0 strides for missing dimension
     newstrides = (0,) * newax + ary.strides
     if dgpu_present:
             return devicearray.DeviceNDArray(shape=newshape,
                                      strides=newstrides,
                                      dtype=ary.dtype,
                                      dgpu_data=ary.dgpu_data)
     else:
             raise NotImplementedError