aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/integrate
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-13 03:50:52 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-13 03:55:00 -0700
commit9b44e8bd7b116503f9f1fe605d8ff43ef6ee132e (patch)
tree2c6850a7fe047fa2d16a4a0df8c0399f8178d6e7 /tensorflow/contrib/integrate
parent4dc13f1aa7bdfb9fc21fc0fc4961c69cb8cb1d20 (diff)
Fix 2 bugs in the logic of the ODE, impacting efficiency:
1) if either of the side is always zero, you never want to do the multiplication 2) because of the zero at the end, the if clause was never hit, not saving those flops. PiperOrigin-RevId: 208457125
Diffstat (limited to 'tensorflow/contrib/integrate')
-rw-r--r--tensorflow/contrib/integrate/python/ops/odes.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/contrib/integrate/python/ops/odes.py b/tensorflow/contrib/integrate/python/ops/odes.py
index 61f78febfc..7b7ac4f347 100644
--- a/tensorflow/contrib/integrate/python/ops/odes.py
+++ b/tensorflow/contrib/integrate/python/ops/odes.py
@@ -73,7 +73,7 @@ def _scaled_dot_product(scale, xs, ys, name=None):
# _possibly_nonzero lets us avoid wasted computation.
return math_ops.add_n(
[(scale * x) * y for x, y in zip(xs, ys)
- if _possibly_nonzero(x) or _possibly_nonzero(y)],
+ if _possibly_nonzero(x) and _possibly_nonzero(y)],
name=scope)
@@ -122,7 +122,7 @@ def _runge_kutta_step(func,
yi = y0 + _scaled_dot_product(dt_cast, beta_i, k)
k.append(func(yi, ti))
- if not (tableau.c_sol[-1] == 0 and tableau.c_sol == tableau.beta[-1]):
+ if not (tableau.c_sol[-1] == 0 and tableau.c_sol[:-1] == tableau.beta[-1]):
# This property (true for Dormand-Prince) lets us save a few FLOPs.
yi = y0 + _scaled_dot_product(dt_cast, tableau.c_sol, k)