New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New destroy handler #6000
New destroy handler #6000
Conversation
Now that #5794 has been merged, you will probably need to rebase on the master. That will make the diff easier to check. |
theano/gof/destroyhandler.py
Outdated
for item in l: | ||
droot, _, root_destroyer = self.refresh_droot_impact() | ||
try: | ||
[root_destroyer[droot[item]]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you wanted this line to be:
if root_destroyer[droot[item]]:
return True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah! thanks.
theano/gof/destroyhandler.py
Outdated
try: | ||
[root_destroyer[droot[item]]] | ||
return True | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you copied the Exception from above, but this is a bad practice. We should try to catch a much more precise exception.
Anyway, this isn't the optimized algorythm anyway. Both otherwise, you seem to have done the first part well. If with my modif in the other comment and tests pass, the structural change would be done. It would only miss the optimized implementation here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Thanks I changed it to KeyError
5728dbf
to
e9597e1
Compare
theano/compile/function_module.py
Outdated
for r in self.protected + list(fgraph.outputs): | ||
if fgraph.destroyers(r): | ||
if config.cycle_detection == 'fast': | ||
if fgraph.destroyers[1](self.protected + list(fgraph.outputs)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nouiz , do we need to pass fgraph.outputs
here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so.
e9597e1
to
590f2f6
Compare
theano/compile/function_module.py
Outdated
if fgraph.fast_destroyers_check(self.protected): | ||
raise gof.InconsistencyError("Trying to destroy a protected" | ||
"Variable.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else: return True
theano/gof/destroyhandler.py
Outdated
def recursive_destroys_finder(clients_list): | ||
for client in clients_list: | ||
# client is a tuple (I don't know if its size is always one) | ||
for item in client: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more like:
def recursive_destroys_finder(clients_list):
for (app, idx) in clients_list:
if app == 'output':
continue
if idx in flatten(getattr(app.op, 'destroy_map', {}).values()):
return True
for var in app.outputs[getattr(app.op, 'view_map', {}).keys()]:
if recursive_destroys_finder(var.clients):
return True
return False
theano/gof/destroyhandler.py
Outdated
for protected_var in protected_list: | ||
if recursive_destroys_finder(protected_var.clients): | ||
clients_set.update(protected_var.clients) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the clients list of tuple (app, idx) is already a set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So mostly, that commit don't help. There is some saving possible if one node reuse the same variable multiple time as input, but it happen so infrequently that I don't think the extra complexity is useful.
95d9429
to
6090615
Compare
I removed that commit. Now we need to check the failing tests and make sure they are the same tests that are failing in the master with |
Just to be sure, make them as known failure only when cycle='fast'
…On Mon, Jun 5, 2017 at 1:25 PM Reyhane Askari ***@***.***> wrote:
I removed that commit. Now we need to check the failing tests and make
sure they are the same tests that are failing in the master with
THEANO_FLAGS=cycle_detetion='fast'. @lamblin <https://github.com/lamblin>
suggested that I mark the failing tests in master as nosetests' known
failures.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6000 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AALC--UcopxR5lhHFzJjFo5wzs1_ggz3ks5sBDoLgaJpZM4Ntcs->
.
|
theano/gof/destroyhandler.py
Outdated
def has_destroyers(protected_list): | ||
visited_app_set = set() | ||
|
||
def recursive_destroys_finder(clients_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the interface to have this function take a variable as input. Then it would loop over var.clients itself. I think it is a nicer interface and will help the conversion to the recursion free version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Thanks.
theano/gof/destroyhandler.py
Outdated
destroy_maps = getattr(app.op, 'destroy_map', {}).values() | ||
if idx in [dmap for sublist in destroy_maps for dmap in sublist]: | ||
return True | ||
for var in getattr(app.op, 'view_map', {}).keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, this is too much restrictif. We are asking that all view of app are not destroyed. But we only care the outputs that are a view of app.inputs[idx].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thanks. Is this check good?
for var in getattr(app.op, 'view_map', {}).keys():
if idx in app.op.view_map[var] and recursive_destroys_finder(app.outputs[var]):
return True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seem good. To help read it, I would rename var to var_idx, to tell it is an index, not a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Thanks.
@lamblin, @nouiz I could only find import unittest
from theano import config
def expectedFailure_fast():
return unittest.expectedFailure if config.cycle_detection == 'fast' else lambda x: x
@expectedFailure_fast()
def test_usage_loop_through_views_2(): Do you have any suggestions on where to add this code snippet? I was thinking maybe |
theano.gof.utils seem the right place for that. |
theano/gof/destroyhandler.py
Outdated
if recursive_destroys_finder(app.outputs[var].clients): | ||
return True | ||
if idx in app.op.view_map[var] and recursive_destroys_finder(app.outputs[var]): | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you added an extra indentation that isn't useful.
theano.tests.unittests_tools would be better then theano.gof.utils I think. |
dd15fb3
to
ef610c1
Compare
Most issues seem to be:
|
@@ -27,6 +27,7 @@ def makeSharedTester(shared_constructor_, | |||
theano_fct_, | |||
ref_fct_, | |||
cast_value_=np.asarray, | |||
need_decorator=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm on it.
There was a small conflict here with jenkins and travis wouldn't run with out resolving it. I resolved the conflict online and committed it. The name was automatically generated as |
1cc937e
to
5c79a2f
Compare
@lamblin @nouiz I was not sure if there are cases where |
f072886
to
7e4a569
Compare
There were many failures in the tests because we were inplace in some cases where we shouldn't have been. I checked these tests and found out that we are not raising the error in the The mechanism of I guess it will be too complicated to support these cases. For now I removed the |
Conclusion of IRL discussion:
|
We won't remove the view_map for the output Guard for now since it's causing many errors. We will handle that in another PR where we'll completely remove the output Guard. |
Is there a way to add the flag to the examples inside the docs? Maybe the easier way to change the cycle_detection flag was to change the default value to |
Doing your suggestion would have done it.
…On Tue, Jun 13, 2017 at 2:17 PM Reyhane Askari ***@***.***> wrote:
Is there a way to add the flag to the examples inside the docs? Maybe the
easier way to change the cycle_detection flag was to change the default
value to fast for the testing purposes and revert it back in the end.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6000 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AALC-68x2ky6NgOogQxIMwQgvETlSxufks5sDtIngaJpZM4Ntcs->
.
|
b8cfafb
to
216beeb
Compare
Issue #5976. Supervisor class is kept but we added a has_destroyers attribute to fgraph, but some tests regarding dumping the pickle failed because a new attribute was added to the fgraph. I changed it like this :
@nouiz what do you suggest?
fix #6230