提交 cd2fdd51 authored 作者: Frederic Bastien's avatar Frederic Bastien

Document filter_inplace

上级 fd3550ae
......@@ -42,6 +42,16 @@ default values.
have a default value of ``False``. The third argument must be called
``allow_downcast`` and must have a default value of ``None``.
.. method:: filter_inplace(value, storage, strict=False, allow_downcast=None)
If filter_inplace is defined, it will be called instead of
filter() This is to allow reusing the old allocated memory. As
of this writing this is used only when we transfer new data to a
shared variable on the gpu.
``storage`` will be the old value. i.e. The old numpy array,
CudaNdarray, ...
.. method:: is_valid_value(value)
Returns True iff the value is compatible with the Type. If
......
......@@ -224,6 +224,13 @@ class PureType(object):
"""
raise MethodNotDefined("filter", type(self), self.__class__.__name__)
# If filter_inplace is defined, it will be called instead of
# filter() This is to allow reusing the old allocated memory. As
# of this writing this is used only when we transfer new data to a
# shared variable on the gpu.
#def filter_inplace(value, storage, strict=False, allow_downcast=None)
def is_valid_value(self, a):
"""Required: Return True for any python object `a` that would be a legal value for a Variable of this Type"""
try:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论