提交 2d9e40e3 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/sandbox/cuda/fftconv.py

上级 3e1612db
...@@ -171,10 +171,11 @@ class CuIFFTOp(ScikitsCudaOp): ...@@ -171,10 +171,11 @@ class CuIFFTOp(ScikitsCudaOp):
def to_complex_gpuarray(x, copyif=False): def to_complex_gpuarray(x, copyif=False):
""" """
adapted version of theano.misc.pycuda_utils.to_gpuarray that takes Adapted version of theano.misc.pycuda_utils.to_gpuarray that takes
an array with an extra trailing dimension of length 2 for an array with an extra trailing dimension of length 2 for
real/imaginary parts, and turns it into a complex64 PyCUDA real/imaginary parts, and turns it into a complex64 PyCUDA
GPUArray. GPUArray.
""" """
if not isinstance(x, CudaNdarray): if not isinstance(x, CudaNdarray):
raise ValueError("We can transfer only CudaNdarray " raise ValueError("We can transfer only CudaNdarray "
...@@ -213,7 +214,8 @@ def bptrs(a): ...@@ -213,7 +214,8 @@ def bptrs(a):
""" """
Pointer array when input represents a batch of matrices. Pointer array when input represents a batch of matrices.
taken from scikits.cuda tests/test_cublas.py Taken from scikits.cuda tests/test_cublas.py.
""" """
return pycuda.gpuarray.arange(a.ptr, a.ptr + a.shape[0] * a.strides[0], return pycuda.gpuarray.arange(a.ptr, a.ptr + a.shape[0] * a.strides[0],
a.strides[0], dtype=cublas.ctypes.c_void_p) a.strides[0], dtype=cublas.ctypes.c_void_p)
...@@ -222,8 +224,9 @@ def bptrs(a): ...@@ -222,8 +224,9 @@ def bptrs(a):
def sc_complex_dot_batched(bx_gpu, by_gpu, bc_gpu, transa='N', transb='N', def sc_complex_dot_batched(bx_gpu, by_gpu, bc_gpu, transa='N', transb='N',
handle=None): handle=None):
""" """
uses cublasCgemmBatched to compute a bunch of complex dot products Uses cublasCgemmBatched to compute a bunch of complex dot products
in parallel in parallel.
""" """
if handle is None: if handle is None:
handle = scikits.cuda.misc._global_cublas_handle handle = scikits.cuda.misc._global_cublas_handle
...@@ -292,7 +295,9 @@ class BatchedComplexDotOp(ScikitsCudaOp): ...@@ -292,7 +295,9 @@ class BatchedComplexDotOp(ScikitsCudaOp):
""" """
This version uses cublasCgemmBatched under the hood, instead of This version uses cublasCgemmBatched under the hood, instead of
doing multiple cublasCgemm calls. doing multiple cublasCgemm calls.
""" """
def make_node(self, inp1, inp2): def make_node(self, inp1, inp2):
inp1 = basic_ops.gpu_contiguous( inp1 = basic_ops.gpu_contiguous(
basic_ops.as_cuda_ndarray_variable(inp1)) basic_ops.as_cuda_ndarray_variable(inp1))
...@@ -355,10 +360,15 @@ batched_complex_dot = BatchedComplexDotOp() ...@@ -355,10 +360,15 @@ batched_complex_dot = BatchedComplexDotOp()
def mult_and_reduce(input_fft_v, filters_fft_v, input_shape=None, def mult_and_reduce(input_fft_v, filters_fft_v, input_shape=None,
filter_shape=None): filter_shape=None):
""" """
input_fft_v is (b, ic, i0, i1//2 + 1, 2)
filters_fft_v is (oc, ic, i0, i1//2 + 1, 2)
"""
Parameters
----------
input_fft_v
It's (b, ic, i0, i1//2 + 1, 2).
filters_fft_v
It's (oc, ic, i0, i1//2 + 1, 2).
"""
if input_shape is None: if input_shape is None:
input_shape = input_fft_v.shape # symbolic input_shape = input_fft_v.shape # symbolic
...@@ -405,16 +415,19 @@ def conv2d_fft(input, filters, image_shape=None, filter_shape=None, ...@@ -405,16 +415,19 @@ def conv2d_fft(input, filters, image_shape=None, filter_shape=None,
On valid mode the filters must be smaller than the input. On valid mode the filters must be smaller than the input.
input: (b, ic, i0, i1) Parameters
filters: (oc, ic, f0, f1) ----------
input
border_mode: 'valid' of 'full' (b, ic, i0, i1).
filters
(oc, ic, f0, f1).
border_mode : {'valid', 'full'}
pad_last_dim
Unconditionally pad the last dimension of the input
to to turn it from odd to even. Will strip the
padding before returning the result.
pad_last_dim: Unconditionally pad the last dimension of the input
to to turn it from odd to even. Will strip the
padding before returning the result.
""" """
# use symbolic shapes to compute shape info at runtime if not specified # use symbolic shapes to compute shape info at runtime if not specified
if image_shape is None: if image_shape is None:
image_shape = input.shape image_shape = input.shape
...@@ -546,16 +559,19 @@ def conv3d_fft(input, filters, image_shape=None, filter_shape=None, ...@@ -546,16 +559,19 @@ def conv3d_fft(input, filters, image_shape=None, filter_shape=None,
On valid mode the filters must be smaller than the input. On valid mode the filters must be smaller than the input.
input: (b, ic, i0, i1, i2) Parameters
filters: (oc, ic, f0, f1, i2) ----------
input
border_mode: 'valid' of 'full' (b, ic, i0, i1, i2).
filters
(oc, ic, f0, f1, i2).
border_mode : {'valid', 'full'}.
pad_last_dim
Unconditionally pad the last dimension of the input
to to turn it from odd to even. Will strip the
padding before returning the result.
pad_last_dim: Unconditionally pad the last dimension of the input
to to turn it from odd to even. Will strip the
padding before returning the result.
""" """
# use symbolic shapes to compute shape info at runtime if not specified # use symbolic shapes to compute shape info at runtime if not specified
if image_shape is None: if image_shape is None:
image_shape = input.shape image_shape = input.shape
...@@ -670,5 +686,3 @@ def conv3d_fft(input, filters, image_shape=None, filter_shape=None, ...@@ -670,5 +686,3 @@ def conv3d_fft(input, filters, image_shape=None, filter_shape=None,
# output should now be the result of a batched valid convolution # output should now be the result of a batched valid convolution
# of the input with the filters. # of the input with the filters.
return basic_ops.as_cuda_ndarray_variable(output) return basic_ops.as_cuda_ndarray_variable(output)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论