提交 23d425f1 authored 作者: Frederic's avatar Frederic

remove shared.value.

上级 677e7a2e
...@@ -18,13 +18,6 @@ from theano.gof import Container, Variable, generic ...@@ -18,13 +18,6 @@ from theano.gof import Container, Variable, generic
_logger = logging.getLogger('theano.compile.sharedvalue') _logger = logging.getLogger('theano.compile.sharedvalue')
AddConfigVar('shared.value_borrows',
("DEPRECATED. You should not use the 'value' property of shared"
" variables, but use the .get_value() and .set_value() methods."
" False: shared variables 'value' property is guaranteed to not"
" alias theano-managed memory. True: no guarantee, but faster."),
BoolParam(True),
in_c_key=False)
class SharedVariable(Variable): class SharedVariable(Variable):
""" """
...@@ -125,29 +118,6 @@ class SharedVariable(Variable): ...@@ -125,29 +118,6 @@ class SharedVariable(Variable):
cp.tag = copy.copy(self.tag) cp.tag = copy.copy(self.tag)
return cp return cp
def _value_get(self):
warnings.warn(("The .value property of shared variables is deprecated."
" You should use the .get_value() method instead."),
stacklevel=2)
return self.get_value(borrow=config.shared.value_borrows, return_internal_type=False)
def _value_set(self, new_value):
warnings.warn(("The .value property of shared variables is deprecated."
" You should use the .set_value() method instead."),
stacklevel=2)
return self.set_value(new_value, borrow=config.shared.value_borrows)
#TODO: USE A CONFIG VARIABLE TO set these get/set methods to the non-borrowing versions
# Semantically things are clearer when using non-borrow versions. That should be the
# default. The default support transparently (if slowly) when the 'raw' value is in a
# different memory space (e.g. GPU or other machine).
value = property(_value_get, _value_set,
doc=("DEPRECATED. Shortcut for self.get_value() and "
"self.set_value(). "
"The `borrow` argument to these methods is read from "
"`theano.config.shared.value_borrows`. "
"You should call get_value() and set_value() directly."))
def filter_update(self, update): def filter_update(self, update):
""" """
When this shared variable is updated by a pfunc, the update value will be run through this function. When this shared variable is updated by a pfunc, the update value will be run through this function.
......
...@@ -350,27 +350,6 @@ def makeSharedTester(shared_constructor_, ...@@ -350,27 +350,6 @@ def makeSharedTester(shared_constructor_,
assert may_share_memory(old_data, x_shared.container.storage[0]) assert may_share_memory(old_data, x_shared.container.storage[0])
x_shared.get_value(borrow=True) x_shared.get_value(borrow=True)
# Test by .value
# As we know that .value is deprecated, we filter out the warning
warnings.filterwarnings(
action='ignore',
message='The .value property of shared variables is deprecated.'
)
try:
nd += 1
old_data = x_shared.container.storage[0]
x_shared.value = nd
assert numpy.allclose(self.ref_fct(x_shared.value), self.ref_fct(self.cast_value(nd)))
assert may_share_memory(old_data, x_shared.container.storage[0]) == self.set_value_inplace
finally:
# Restore the default behavior.
# TODO There is a cleaner way to do this in Python 2.6, once
# Theano drops support of Python 2.4 and 2.5.
warnings.filterwarnings(
action='default',
message='The .value property of shared variables is deprecated.'
)
# Test by set_value with borrow=False # Test by set_value with borrow=False
nd += 1 nd += 1
old_data = x_shared.container.storage[0] old_data = x_shared.container.storage[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论