<s> from __future__ import absolute_import , print_function , division <EOL> import string <EOL> import numpy as np <EOL> import theano <EOL> import theano . tensor as T <EOL> from theano . sandbox . cuda import cuda_available , GpuOp <EOL> from theano . ifelse import ifelse <EOL> from theano . misc . pycuda_init import pycuda_available <EOL> if cuda_available : <EOL> from theano . sandbox . cuda import ( basic_ops , CudaNdarrayType , <EOL> CudaNdarray ) <EOL> if pycuda_available : <EOL> import pycuda . gpuarray <EOL> try : <EOL> import scikits . cuda <EOL> from scikits . cuda import fft , cublas <EOL> scikits . cuda . misc . init ( ) <EOL> scikits_cuda_available = True <EOL> except ( ImportError , Exception ) : <EOL> scikits_cuda_available = False <EOL> class ScikitsCudaOp ( GpuOp ) : <EOL> def __eq__ ( self , other ) : <EOL> return type ( self ) == type ( other ) <EOL> def __hash__ ( self ) : <EOL> return hash ( type ( self ) ) <EOL> def __str__ ( self ) : <EOL> return self . __class__ . __name__ <EOL> def output_type ( self , inp ) : <EOL> raise NotImplementedError <EOL> def make_node ( self , inp ) : <EOL> inp = basic_ops . gpu_contiguous ( <EOL> basic_ops . as_cuda_ndarray_variable ( inp ) ) <EOL> assert inp . dtype == "<STR_LIT>" <EOL> return theano . Apply ( self , [ inp ] , [ self . output_type ( inp ) ( ) ] ) <EOL> def make_thunk ( self , node , storage_map , _ , _2 ) : <EOL> if not scikits_cuda_available : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class CuFFTOp ( ScikitsCudaOp ) : <EOL> def output_type ( self , inp ) : <EOL> return CudaNdarrayType ( <EOL> broadcastable = [ False ] * ( inp . type . ndim + <NUM_LIT:1> ) ) <EOL> def make_thunk ( self , node , storage_map , _ , _2 ) : <EOL> super ( CuFFTOp , self ) . make_thunk ( node , storage_map , _ , _2 ) <EOL> from theano . misc . pycuda_utils import to_gpuarray <EOL> inputs = [ storage_map [ v ] for v in node . inputs ] <EOL> outputs = [ storage_map [ v ] for v in node . outputs ] <EOL> plan_input_shape = [ None ] <EOL> plan = [ None ] <EOL> def thunk ( ) : <EOL> input_shape = inputs [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . shape <EOL> output_shape = list ( input_shape ) <EOL> output_shape [ - <NUM_LIT:1> ] = output_shape [ - <NUM_LIT:1> ] // <NUM_LIT:2> + <NUM_LIT:1> <EOL> output_shape += [ <NUM_LIT:2> ] <EOL> output_shape = tuple ( output_shape ) <EOL> z = outputs [ <NUM_LIT:0> ] <EOL> if z [ <NUM_LIT:0> ] is None or z [ <NUM_LIT:0> ] . shape != output_shape : <EOL> z [ <NUM_LIT:0> ] = CudaNdarray . zeros ( output_shape ) <EOL> input_pycuda = to_gpuarray ( inputs [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> output_pycuda = to_gpuarray ( z [ <NUM_LIT:0> ] ) <EOL> if plan [ <NUM_LIT:0> ] is None or plan_input_shape [ <NUM_LIT:0> ] != input_shape : <EOL> plan_input_shape [ <NUM_LIT:0> ] = input_shape <EOL> plan [ <NUM_LIT:0> ] = fft . Plan ( input_shape [ <NUM_LIT:1> : ] , np . float32 , np . complex64 , <EOL> batch = input_shape [ <NUM_LIT:0> ] ) <EOL> fft . fft ( input_pycuda , output_pycuda , plan [ <NUM_LIT:0> ] ) <EOL> thunk . inputs = inputs <EOL> thunk . outputs = outputs <EOL> thunk . lazy = False <EOL> return thunk <EOL> class CuIFFTOp ( ScikitsCudaOp ) : <EOL> def output_type ( self , inp ) : <EOL> return CudaNdarrayType ( <EOL> broadcastable = [ False ] * ( inp . type . ndim - <NUM_LIT:1> ) ) <EOL> def make_thunk ( self , node , storage_map , _ , _2 ) : <EOL> super ( CuIFFTOp , self ) . make_thunk ( node , storage_map , _ , _2 ) <EOL> from theano . misc . pycuda_utils import to_gpuarray <EOL> inputs = [ storage_map [ v ] for v in node . inputs ] <EOL> outputs = [ storage_map [ v ] for v in node . outputs ] <EOL> plan_input_shape = [ None ] <EOL> plan = [ None ] <EOL> def thunk ( ) : <EOL> input_shape = inputs [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . shape <EOL> output_shape = list ( input_shape [ : - <NUM_LIT:1> ] ) <EOL> output_shape [ - <NUM_LIT:1> ] = ( output_shape [ - <NUM_LIT:1> ] - <NUM_LIT:1> ) * <NUM_LIT:2> <EOL> output_shape = tuple ( output_shape ) <EOL> z = outputs [ <NUM_LIT:0> ] <EOL> if z [ <NUM_LIT:0> ] is None or z [ <NUM_LIT:0> ] . shape != output_shape : <EOL> z [ <NUM_LIT:0> ] = CudaNdarray . zeros ( output_shape ) <EOL> input_pycuda = to_gpuarray ( inputs [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> output_pycuda = to_gpuarray ( z [ <NUM_LIT:0> ] ) <EOL> if plan [ <NUM_LIT:0> ] is None or plan_input_shape [ <NUM_LIT:0> ] != input_shape : <EOL> plan_input_shape [ <NUM_LIT:0> ] = input_shape <EOL> plan [ <NUM_LIT:0> ] = fft . Plan ( output_shape [ <NUM_LIT:1> : ] , np . complex64 , np . float32 , <EOL> batch = output_shape [ <NUM_LIT:0> ] ) <EOL> fft . ifft ( input_pycuda , output_pycuda , plan [ <NUM_LIT:0> ] ) <EOL> thunk . inputs = inputs <EOL> thunk . outputs = outputs <EOL> thunk . lazy = False <EOL> return thunk <EOL> def to_complex_gpuarray ( x , copyif = False ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( x , CudaNdarray ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> assert x . shape [ - <NUM_LIT:1> ] == <NUM_LIT:2> <EOL> assert x . dtype == '<STR_LIT>' <EOL> size = <NUM_LIT:1> <EOL> c_contiguous = True <EOL> for i in range ( x . ndim - <NUM_LIT:1> , - <NUM_LIT:1> , - <NUM_LIT:1> ) : <EOL> if x . shape [ i ] == <NUM_LIT:1> : <EOL> continue <EOL> if x . _strides [ i ] != size : <EOL> c_contiguous = False <EOL> break <EOL> size *= x . shape [ i ] <EOL> if not c_contiguous : <EOL> if copyif : <EOL> x = x . copy ( ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> px = pycuda . gpuarray . GPUArray ( x . shape [ : - <NUM_LIT:1> ] , np . complex64 , base = x , <EOL> gpudata = x . gpudata ) <EOL> return px <EOL> def bptrs ( a ) : <EOL> """<STR_LIT>""" <EOL> return pycuda . gpuarray . arange ( a . ptr , a . ptr + a . shape [ <NUM_LIT:0> ] * a . strides [ <NUM_LIT:0> ] , <EOL> a . strides [ <NUM_LIT:0> ] , dtype = cublas . ctypes . c_void_p ) <EOL> def sc_complex_dot_batched ( bx_gpu , by_gpu , bc_gpu , transa = '<STR_LIT:N>' , transb = '<STR_LIT:N>' , <EOL> handle = None ) : <EOL> """<STR_LIT>""" <EOL> if handle is None : <EOL> handle = scikits . cuda . misc . _global_cublas_handle <EOL> assert len ( bx_gpu . shape ) == <NUM_LIT:3> <EOL> assert len ( by_gpu . shape ) == <NUM_LIT:3> <EOL> assert len ( bc_gpu . shape ) == <NUM_LIT:3> <EOL> assert bx_gpu . dtype == np . complex64 <EOL> assert by_gpu . dtype == np . complex64 <EOL> assert bc_gpu . dtype == np . complex64 <EOL> bx_shape = bx_gpu . shape <EOL> by_shape = by_gpu . shape <EOL> alpha = np . complex64 ( <NUM_LIT:1.0> ) <EOL> beta = np . complex64 ( <NUM_LIT:0.0> ) <EOL> transa = string . lower ( transa ) <EOL> transb = string . lower ( transb ) <EOL> if transb in [ '<STR_LIT:t>' , '<STR_LIT:c>' ] : <EOL> N , m , k = by_shape <EOL> elif transb in [ '<STR_LIT:n>' ] : <EOL> N , k , m = by_shape <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if transa in [ '<STR_LIT:t>' , '<STR_LIT:c>' ] : <EOL> N2 , l , n = bx_shape <EOL> elif transa in [ '<STR_LIT:n>' ] : <EOL> N2 , n , l = bx_shape <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if l != k : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if N != N2 : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if transb == '<STR_LIT:n>' : <EOL> lda = max ( <NUM_LIT:1> , m ) <EOL> else : <EOL> lda = max ( <NUM_LIT:1> , k ) <EOL> if transa == '<STR_LIT:n>' : <EOL> ldb = max ( <NUM_LIT:1> , k ) <EOL> else : <EOL> ldb = max ( <NUM_LIT:1> , n ) <EOL> ldc = max ( <NUM_LIT:1> , m ) <EOL> bx_arr = bptrs ( bx_gpu ) <EOL> by_arr = bptrs ( by_gpu ) <EOL> bc_arr = bptrs ( bc_gpu ) <EOL> cublas . cublasCgemmBatched ( handle , transb , transa , m , n , k , alpha , <EOL> by_arr . gpudata , lda , bx_arr . gpudata , ldb , <EOL> beta , bc_arr . gpudata , ldc , N ) <EOL> class BatchedComplexDotOp ( ScikitsCudaOp ) : <EOL> """<STR_LIT>""" <EOL> def make_node ( self , inp1 , inp2 ) : <EOL> inp1 = basic_ops . gpu_contiguous ( <EOL> basic_ops . as_cuda_ndarray_variable ( inp1 ) ) <EOL> inp2 = basic_ops . gpu_contiguous ( <EOL> basic_ops . as_cuda_ndarray_variable ( inp2 ) ) <EOL> assert inp1 . dtype == "<STR_LIT>" <EOL> assert inp2 . dtype == "<STR_LIT>" <EOL> assert inp1 . ndim == <NUM_LIT:4> <EOL> assert inp2 . ndim == <NUM_LIT:4> <EOL> return theano . Apply ( self , [ inp1 , inp2 ] , [ self . output_type ( inp1 ) ( ) ] ) <EOL> def output_type ( self , inp ) : <EOL> return CudaNdarrayType ( broadcastable = [ False ] * inp . type . ndim ) <EOL> def make_thunk ( self , node , storage_map , _ , _2 ) : <EOL> super ( BatchedComplexDotOp , self ) . make_thunk ( node , storage_map , _ , _2 ) <EOL> inputs = [ storage_map [ v ] for v in node . inputs ] <EOL> outputs = [ storage_map [ v ] for v in node . outputs ] <EOL> def thunk ( ) : <EOL> bx = inputs [ <NUM_LIT:0> ] <EOL> by = inputs [ <NUM_LIT:1> ] <EOL> input_shape_x = bx [ <NUM_LIT:0> ] . shape <EOL> input_shape_y = by [ <NUM_LIT:0> ] . shape <EOL> output_shape = ( input_shape_x [ <NUM_LIT:0> ] , input_shape_x [ <NUM_LIT:1> ] , <EOL> input_shape_y [ <NUM_LIT:2> ] , <NUM_LIT:2> ) <EOL> bz = outputs [ <NUM_LIT:0> ] <EOL> if bz [ <NUM_LIT:0> ] is None or bz [ <NUM_LIT:0> ] . shape != output_shape : <EOL> bz [ <NUM_LIT:0> ] = CudaNdarray . zeros ( output_shape ) <EOL> input_bx_pycuda = to_complex_gpuarray ( bx [ <NUM_LIT:0> ] ) <EOL> input_by_pycuda = to_complex_gpuarray ( by [ <NUM_LIT:0> ] ) <EOL> output_b_pycuda = to_complex_gpuarray ( bz [ <NUM_LIT:0> ] ) <EOL> sc_complex_dot_batched ( input_bx_pycuda , input_by_pycuda , <EOL> output_b_pycuda ) <EOL> thunk . inputs = inputs <EOL> thunk . outputs = outputs <EOL> thunk . lazy = False <EOL> return thunk <EOL> cufft = CuFFTOp ( ) <EOL> cuifft = CuIFFTOp ( ) <EOL> batched_complex_dot = BatchedComplexDotOp ( ) <EOL> def mult_and_reduce ( input_fft_v , filters_fft_v , input_shape = None , <EOL> filter_shape = None ) : <EOL> """<STR_LIT>""" <EOL> if input_shape is None : <EOL> input_shape = input_fft_v . shape <EOL> if filter_shape is None : <EOL> filter_shape = filters_fft_v . shape <EOL> b , ic , i0 , i1_f , _ = input_shape <EOL> oc = filter_shape [ <NUM_LIT:0> ] <EOL> input_r = input_fft_v . reshape ( ( b , ic , i0 * i1_f , <NUM_LIT:2> ) ) <EOL> filters_r = filters_fft_v . reshape ( ( oc , ic , i0 * i1_f , <NUM_LIT:2> ) ) <EOL> input_s = input_r . dimshuffle ( <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> filters_s = filters_r . dimshuffle ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> output_s = batched_complex_dot ( input_s , filters_s ) <EOL> output_r = output_s . dimshuffle ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> output = output_r . reshape ( ( b , oc , i0 , i1_f , <NUM_LIT:2> ) ) <EOL> return output <EOL> def conv2d_fft ( input , filters , image_shape = None , filter_shape = None , <EOL> border_mode = '<STR_LIT>' , pad_last_dim = False ) : <EOL> """<STR_LIT>""" <EOL> if image_shape is None : <EOL> image_shape = input . shape <EOL> if filter_shape is None : <EOL> filter_shape = filters . shape <EOL> b , ic , i0 , i1 = image_shape <EOL> oc , ic_ , f0 , f1 = filter_shape <EOL> if border_mode == '<STR_LIT>' : <EOL> o0 = i0 <EOL> if pad_last_dim : <EOL> o1 = i1 + <NUM_LIT:1> <EOL> input_padded = T . zeros ( ( b , ic , o0 , o1 ) , dtype = '<STR_LIT>' ) <EOL> input_padded = T . set_subtensor ( input_padded [ : , : , : i0 , : i1 ] , <EOL> input ) <EOL> else : <EOL> o1 = i1 <EOL> input_padded = input <EOL> filters_padded = T . zeros ( ( oc , ic , o0 , o1 ) , dtype = '<STR_LIT>' ) <EOL> filters_padded = T . set_subtensor ( filters_padded [ : , : , : f0 , : f1 ] , <EOL> filters ) <EOL> elif border_mode == '<STR_LIT>' : <EOL> o0 = i0 + <NUM_LIT:2> * ( f0 - <NUM_LIT:1> ) <EOL> o1 = i1 + <NUM_LIT:2> * ( f1 - <NUM_LIT:1> ) <EOL> if pad_last_dim : <EOL> o1 = o1 + <NUM_LIT:1> <EOL> filters_padded = T . zeros ( ( oc , ic , o0 , o1 ) , dtype = '<STR_LIT>' ) <EOL> filters_padded = T . set_subtensor ( filters_padded [ : , : , : f0 , : f1 ] , <EOL> filters ) <EOL> input_padded = T . zeros ( ( b , ic , o0 , o1 ) , dtype = '<STR_LIT>' ) <EOL> input_padded = T . set_subtensor ( input_padded [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 ) ] , <EOL> input ) <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> input_padded = T . opt . Assert ( "<STR_LIT>" ) ( <EOL> input_padded , T . eq ( o1 % <NUM_LIT:2> , <NUM_LIT:0> ) ) <EOL> input_flat = input_padded . reshape ( ( b * ic , o0 , o1 ) ) <EOL> filters_flat = filters_padded . reshape ( ( oc * ic , o0 , o1 ) ) <EOL> input_fft_flat = cufft ( input_flat ) <EOL> filters_fft_flat = cufft ( filters_flat ) <EOL> input_fft_v_shape = ( b , ic , o0 , o1 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> filters_fft_v_shape = ( oc , ic , o0 , o1 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> input_fft_v = input_fft_flat . reshape ( input_fft_v_shape ) <EOL> filters_fft_v = filters_fft_flat . reshape ( filters_fft_v_shape ) <EOL> output_fft_s = mult_and_reduce ( input_fft_v , filters_fft_v , <EOL> input_shape = input_fft_v_shape , <EOL> filter_shape = filters_fft_v_shape ) <EOL> output_fft_flat = output_fft_s . reshape ( ( b * oc , o0 , o1 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> output_flat = cuifft ( output_fft_flat ) <EOL> output_circ = output_flat . reshape ( ( b , oc , o0 , o1 ) ) <EOL> if border_mode == '<STR_LIT>' : <EOL> output = output_circ [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 - f0 + <NUM_LIT:1> ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 - f1 + <NUM_LIT:1> ) ] <EOL> elif border_mode == '<STR_LIT>' : <EOL> output = output_circ [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 + f0 - <NUM_LIT:1> ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 + f1 - <NUM_LIT:1> ) ] <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> output = ( <NUM_LIT:1.0> / T . cast ( o0 * o1 , '<STR_LIT>' ) ) * output <EOL> return basic_ops . as_cuda_ndarray_variable ( output ) <EOL> def conv3d_fft ( input , filters , image_shape = None , filter_shape = None , <EOL> border_mode = '<STR_LIT>' , pad_last_dim = False ) : <EOL> """<STR_LIT>""" <EOL> if image_shape is None : <EOL> image_shape = input . shape <EOL> if filter_shape is None : <EOL> filter_shape = filters . shape <EOL> b , ic , i0 , i1 , i2 = image_shape <EOL> oc , ic_ , f0 , f1 , f2 = filter_shape <EOL> is_odd = T . eq ( T . mod ( input . shape [ <NUM_LIT:4> ] , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> if border_mode == '<STR_LIT>' : <EOL> o0 = i0 <EOL> o1 = i1 <EOL> o2 = i2 <EOL> input_padded = input <EOL> if pad_last_dim : <EOL> o2 = ifelse ( is_odd , o2 + <NUM_LIT:1> , o2 ) <EOL> input_padded = T . zeros ( ( b , ic , o0 , o1 , o2 ) , dtype = '<STR_LIT>' ) <EOL> input_padded = T . set_subtensor ( input_padded [ : , : , : i0 , : i1 , : i2 ] , <EOL> input ) <EOL> filters_padded = T . zeros ( ( oc , ic , o0 , o1 , o2 ) , dtype = '<STR_LIT>' ) <EOL> filters_padded = T . set_subtensor ( filters_padded [ : , : , : f0 , : f1 , : f2 ] , <EOL> filters ) <EOL> elif border_mode == '<STR_LIT>' : <EOL> o0 = i0 + <NUM_LIT:2> * ( f0 - <NUM_LIT:1> ) <EOL> o1 = i1 + <NUM_LIT:2> * ( f1 - <NUM_LIT:1> ) <EOL> o2 = i2 + <NUM_LIT:2> * ( f2 - <NUM_LIT:1> ) <EOL> if pad_last_dim : <EOL> o2 = ifelse ( is_odd , o2 + <NUM_LIT:1> , o2 ) <EOL> filters_padded = T . zeros ( ( oc , ic , o0 , o1 , o2 ) , dtype = '<STR_LIT>' ) <EOL> filters_padded = T . set_subtensor ( filters_padded [ : , : , : f0 , : f1 , : f2 ] , <EOL> filters ) <EOL> input_padded = T . zeros ( ( b , ic , o0 , o1 , o2 ) , dtype = '<STR_LIT>' ) <EOL> input_padded = T . set_subtensor ( input_padded [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 ) , ( f2 - <NUM_LIT:1> ) : ( f2 - <NUM_LIT:1> + i2 ) ] , <EOL> input ) <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> input_flat = input_padded . reshape ( ( b * ic , o0 , o1 , o2 ) ) <EOL> filters_flat = filters_padded . reshape ( ( oc * ic , o0 , o1 , o2 ) ) <EOL> input_fft_flat = cufft ( input_flat ) <EOL> filters_fft_flat = cufft ( filters_flat ) <EOL> input_fft_v_shape = ( b , ic , o0 * o1 , o2 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> filters_fft_v_shape = ( oc , ic , o0 * o1 , o2 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> input_fft_v = input_fft_flat . reshape ( input_fft_v_shape ) <EOL> filters_fft_v = filters_fft_flat . reshape ( filters_fft_v_shape ) <EOL> output_fft_s = mult_and_reduce ( input_fft_v , filters_fft_v , <EOL> input_shape = input_fft_v_shape , <EOL> filter_shape = filters_fft_v_shape ) <EOL> output_fft_flat = output_fft_s . reshape ( ( b * oc , o0 , o1 , o2 // <NUM_LIT:2> + <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> output_flat = cuifft ( output_fft_flat ) <EOL> output_circ = output_flat . reshape ( ( b , oc , o0 , o1 , o2 ) ) <EOL> if border_mode == '<STR_LIT>' : <EOL> output = output_circ [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 - f0 + <NUM_LIT:1> ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 - f1 + <NUM_LIT:1> ) , ( f2 - <NUM_LIT:1> ) : ( f2 - <NUM_LIT:1> + i2 - f2 + <NUM_LIT:1> ) ] <EOL> elif border_mode == '<STR_LIT>' : <EOL> output = output_circ [ : , : , ( f0 - <NUM_LIT:1> ) : ( f0 - <NUM_LIT:1> + i0 + f0 - <NUM_LIT:1> ) , ( f1 - <NUM_LIT:1> ) : ( f1 - <NUM_LIT:1> + i1 + f1 - <NUM_LIT:1> ) , ( f2 - <NUM_LIT:1> ) : ( f2 - <NUM_LIT:1> + i2 + f2 - <NUM_LIT:1> ) ] <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> output = ( <NUM_LIT:1.0> / T . cast ( o0 * o1 * o2 , '<STR_LIT>' ) ) * output <EOL> return basic_ops . as_cuda_ndarray_variable ( output ) </s>
