Theano/Theano — pull request #176 by jaberg (2011-10-31 18:23:27+00:00)
Title: Composite fixes

Chasing a bug on my mac at home, I made changes that I think are improvements to Composite. The bug I was finding was that on unpickling, from the cache, the Ops didn't match because Composite was testing the hash of a saved cmodule_key. I was unable to understand the problem, because only the hash of an old cmodule key was still around.

Looking through the code though, I found and fixed a few bugs:
1. the name of composite doesn't identify what it does: {mul,add} could mean (a+(b*c)) or ((a*b)+c)

2. the hashing strategy using the cmodule key is too complicated and I think unreliable. It's not tested and I didn't trust it. I modified it to use the generated _c_code directly to identify the 'meaning' of the Op. This is still not thoroughly tested, but now at least it's much simpler and easier to debug (no md5 hash of configparser in the __hash__ function).

3. the code generation strategy was potentially wrong. C code and support code was not embedding the name of nodes of self.env. I suspect that in the case of compiling certain nested composite nodes for the GPU, this could cause compilation errors or wrong results, due to name collisions in support code. It could also cause name collisions in the c code. It's a lot of work to set up the test to prove that this is the case, and what's there now is certainly at least as correct as what was there before. Therefore, please accept the pull request without demanding more work from me, debugging these things has already taken for ever.