delallea/Theano — comment on commit d19531723ea96f00a7a75d50b9735bdc75226349
File:  line 0
By delallea:

Here's the tentative signature of my new function. What do you think about it?
I thought about the name and I prefer "is_same_graph" to "equal_computations" because the latter may lead one to believe it would return True e.g. when comparing (x * (y * z)) and ((x * y) * z).
Also, I don't think the MergeOptimizer-based version can easily do exactly what your equal_computations function does (although I'm not entirely sure)... I think it's easier to think of the "ignore_inputs" case as a substitution of variables like in the "givens" argument to theano.function, so I am reusing "givens" here.

```python
def is_same_graph(var1, var2, givens={}):
"""
Return True iff Variables `var1` and `var2` perform the same computation.

The current implementation is not efficient since it verifies equality by
calling two different functions that are expected to return the same
output. The goal is to verify this assumption, to eventually get rid of
one of them in the future.

:param var1: The first Variable to compare.

:param var2: The second Variable to compare.

:param givens: Similar to the `givens` argument of `theano.function`, it
can be used to perform substitutions in the computational graph of `var1`
and `var2`. This argument is associated to neither `var1` nor `var2`:
substitutions may affect both graphs if the substituted variable is present
in both.

Examples:

====== ====== ====== ======
var1 var2 givens output
====== ====== ====== ======
x + 1 x + 1 {} True
x + 1 y + 1 {} False
x + 1 y + 1 {x: y} True
====== ====== ====== ======
"""
```