提交 45f18bad authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/sandbox/gpuarray/conv.py

上级 acebecd7
...@@ -12,7 +12,48 @@ from .basic_ops import as_gpuarray_variable ...@@ -12,7 +12,48 @@ from .basic_ops import as_gpuarray_variable
class GpuConv(gof.Op): class GpuConv(gof.Op):
""" """
Implement the batched and stacked 2d convolution on the gpu. Implement the batched and stacked 2d convolution on the gpu.
Parameters
----------
version
Each version of c_code implements many kernels for the convolution.
By default we try to guess the best one. You can force one version with
this parameter. This parameter is used by the tests.
direction_hint
'forward', 'bprop weights' or 'bprop inputs'. Serves as a hint for graph
optimizers replacing GpuConv by other implementations. If the GpuConv is
inserted automatically, we take its value from ConvOp.
verbose
For value of 1,2 and 3. Print more information during the execution of
the convolution. Mostly used for optimization or debugging.
kshp
The size of the kernel. If provided, can generate faster code. If the
GpuConv op is automatically inserted, we take its value automatically
from the Conv op.
imshp
The size of the image. Not used for code generation but allows to select
an experimental new version in another repo.
max_threads_dim0
The maximum number of threads for the block size dimensions 0
(blockDim.x) used by the GPU function.
nkern
The number of kernels. Not used for this op, but can be used by graph
optimizers to select a more optimal convolution implementation. If the
GpuConv op is inserted automatically, we take its value from the Conv
op.
bsize
The batch size. Not used for this op, but can be used by graph
optimizers to select a more optimal convolution implementation. If the
GpuConv op is inserted automatically, we take its value from the Conv
op.
fft_opt
Deactivate fft_opt optimization at the op level when set to False. Note
that by default fft optimization aren't enabled.
See :ref:`convolution documentation <libdoc_tensor_nnet_conv>` to enable
them.
""" """
@staticmethod @staticmethod
def logical_output_shape_2d(imshp, kshp, mode): def logical_output_shape_2d(imshp, kshp, mode):
if mode == 'valid': if mode == 'valid':
...@@ -35,43 +76,6 @@ class GpuConv(gof.Op): ...@@ -35,43 +76,6 @@ class GpuConv(gof.Op):
nkern=None, nkern=None,
bsize=None, bsize=None,
fft_opt=True): fft_opt=True):
"""
:param version: each version of c_code implements many kernels for the
convolution. By default we try to guess the best one.
You can force one version with this parameter. This
parameter is used by the tests.
:param direction_hint: 'forward', 'bprop weights' or 'bprop inputs'.
Serves as a hint for graph optimizers replacing
GpuConv by other implementations. If the GpuConv is
inserted automatically, we take its value from ConvOp.
:param verbose: for value of 1,2 and 3. Print more information during
the execution of the convolution. Mostly used for
optimization or debugging.
:param kshp: The size of the kernel. If provided, can generate
faster code. If the GpuConv op is automatically
inserted,
we take its value automatically from the Conv op.
:param imshp: The size of the image. Not used for code generation but
allows to select an experimental new version in another
repo.
:param max_threads_dim0: The maximum number of threads for the
block size dimensions 0 (blockDim.x) used by the
GPU function.
:param nkern: The number of kernels. Not used for this op, but can be
used by graph optimizers to select a more optimal
convolution implementation. If the GpuConv op is inserted
automatically, we take its value from the Conv op.
:param bsize: The batch size. Not used for this op, but can be
used by graph optimizers to select a more optimal
convolution implementation. If the GpuConv op is inserted
automatically, we take its value from the Conv op.
:param fft_opt: deactivate fft_opt optimization at the op level when
set to False. Note that by default fft optimization
aren't enabled. See
:ref:`convolution documentation <libdoc_tensor_nnet_conv>`
to enable them.
"""
self.border_mode = border_mode self.border_mode = border_mode
self.subsample = subsample self.subsample = subsample
if logical_img_hw is not None: if logical_img_hw is not None:
...@@ -169,7 +173,10 @@ class GpuConv(gof.Op): ...@@ -169,7 +173,10 @@ class GpuConv(gof.Op):
return gof.Apply(self, [img, kern], [out]) return gof.Apply(self, [img, kern], [out])
def flops(self, inputs, outputs): def flops(self, inputs, outputs):
""" Useful with the hack in profilemode to print the MFlops""" """
Useful with the hack in profilemode to print the MFlops.
"""
images, kerns = inputs images, kerns = inputs
out, = outputs out, = outputs
assert images[1] == kerns[1] assert images[1] == kerns[1]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论