提交 3a74c6ae authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #2218 from nouiz/mixed

Doc, error message
......@@ -47,21 +47,11 @@
:type: class:`Container`
.. function:: shared(value, name=None, strict=False, **kwargs)
.. autofunction:: theano.compile.sharedvalue.shared
Return a :class:`SharedVariable` Variable, initialized with a copy or reference of `value`.
This function iterates over constructor functions (see `shared_constructor`) to find a
suitable SharedVariable subclass. The suitable one is the first constructor
that doesn't raise an exception.
This function is meant as a convenient default. If you want to use a
specific shared variable constructor, consider calling it directly.
.. note::
.. function:: shared_constructor(ctor)
By passing `kwargs`, you effectively limit the set of potential constructors to those that
can accept those kwargs.
Append `ctor` to the list of shared constructors (see :func:`shared`).
Each registered constructor ``ctor`` will be called like this:
......@@ -69,12 +59,4 @@
ctor(value, name=name, strict=strict, **kwargs)
.. attribute:: constructors
A list of shared variable constructors that will be tried in reverse
order.
.. function:: shared_constructor(ctor)
Append `ctor` to the list of shared constructors (see :func:`shared`).
If it do not support given value, it must raise a TypeError.
......@@ -169,15 +169,33 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
"""Return a SharedVariable Variable, initialized with a copy or
reference of `value`.
This function iterates over constructor functions (see
`shared_constructor`) to find a suitable SharedVariable subclass.
This function iterates over
:ref:`constructor functions <shared_constructor>`
to find a suitable SharedVariable subclass.
The suitable one is the first constructor that accept the given value.
This function is meant as a convenient default. If you want to use a
specific shared variable constructor, consider calling it directly.
``theano.shared`` is a shortcut to this function.
:note: By passing kwargs, you effectively limit the set of
potential constructors to those that can accept those kwargs.
potential constructors to those that can accept those kwargs.
:note: Some shared variable have 'borrow' as extra kwargs.
:note: Some shared variable have ``borrow`` as extra kwargs.
`See <http://deeplearning.net/software/theano/tutorial/aliasing.html#borrowing-when-creating-shared-variables>`_ for detail.
:note: Some shared variable have ``broadcastable`` as extra kwargs.
As shared variable shapes can change, all dimensions default
to not being broadcastable, even if ``value`` has a shape of 1
along some dimension. This parameter allows you to create
for example a `row` or `column` 2d tensor.
.. attribute:: constructors
A list of shared variable constructors that will be tried in reverse
order.
"""
try:
......
......@@ -154,9 +154,10 @@ def raise_with_op(node, thunk=None, exc_info=None):
else:
hints.append(
"HINT: Re-running with most Theano optimization disabled could"
" give you a back-traces when this node was created. This can"
" be done with by setting the Theano flags"
" optimizer=fast_compile")
" give you a back-trace of when this node was created. This can"
" be done with by setting the Theano flag"
" 'optimizer=fast_compile'. If that does not work,"
" Theano optimizations can be disabled with 'optimizer=None'.")
if theano.config.exception_verbosity == 'high':
f = StringIO.StringIO()
......
......@@ -3025,15 +3025,17 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
{
int *gpu_data = (int*)device_malloc(sizeof(int)*2);
if(gpu_data == NULL){
return PyErr_Format(PyExc_MemoryError,
"CudaNdarray_ptr_int_size: Can't allocate memory on the gpu.");
return NULL;
}
get_gpu_ptr_size<<<1,1>>>(gpu_data);
if (cudaSuccess != cudaGetLastError()){
cudaError_t cudaErr = cudaGetLastError();
if (cudaSuccess != cudaErr){
device_free(gpu_data);
return PyErr_Format(PyExc_RuntimeError,
"CudaNdarray_ptr_int_size: error when calling the gpu code.");
"CudaNdarray_ptr_int_size: error when calling the gpu code. (%s)",
cudaGetErrorString(cudaErr));
}
// Transfer the result to cpu
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论