提交 375e144b authored 作者: James Bergstra's avatar James Bergstra

Added docstrings to CudaNdarraySharedVariable

上级 4d10ce7c
...@@ -49,8 +49,30 @@ class CudaNdarrayConstant(Constant, _operators): ...@@ -49,8 +49,30 @@ class CudaNdarrayConstant(Constant, _operators):
CudaNdarrayType.Constant = CudaNdarrayConstant CudaNdarrayType.Constant = CudaNdarrayConstant
class CudaNdarraySharedVariable(SharedVariable, _operators): class CudaNdarraySharedVariable(SharedVariable, _operators):
"""
Shared Variable interface to CUDA-allocated arrays
"""
def get_value(self, borrow=False, return_internal_type=False): def get_value(self, borrow=False, return_internal_type=False):
"""
Return the value of this SharedVariable's internal array.
:param borrow:
permit the return of internal storage, when used in conjunction with
``return_internal_type=True``
:param return_internal_type:
True to return the internal ``cuda_ndarray`` instance rather than a ``numpy.ndarray``
(Default False)
By default ``get_value()`` copies from the GPU to a ``numpy.ndarray`` and returns that
host-allocated array.
``get_value(False,True)`` will return a GPU-allocated copy of the original GPU array.
``get_value(True,True)`` will return the original GPU-allocated array without any
copying.
"""
if return_internal_type: # return a cuda_ndarray if return_internal_type: # return a cuda_ndarray
if borrow: if borrow:
return self.container.value return self.container.value
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论