提交 e3f79f19 authored 作者: Frederic Bastien's avatar Frederic Bastien

fix a bug in PatternSub when their is a constant in the pattern. In one case the…

fix a bug in PatternSub when their is a constant in the pattern. In one case the optimization was not applied when it needed to be. Only affect the new optimization done this week.
上级 48248330
...@@ -4,14 +4,16 @@ amount of useful generic optimization tools. ...@@ -4,14 +4,16 @@ amount of useful generic optimization tools.
""" """
import sys, logging, time import copy, logging, sys, time
import numpy
import graph import graph
from env import InconsistencyError from env import InconsistencyError
import utils import utils
import unify import unify
import toolbox import toolbox
import op import op
from copy import copy
from theano.gof.python25 import any, all from theano.gof.python25 import any, all
from theano.configparser import AddConfigVar, BoolParam, config from theano.configparser import AddConfigVar, BoolParam, config
import theano import theano
...@@ -642,7 +644,7 @@ class PatternSub(LocalOptimizer): ...@@ -642,7 +644,7 @@ class PatternSub(LocalOptimizer):
else: else:
u = u.merge(expr, v) u = u.merge(expr, v)
elif isinstance(pattern, (int, float)) and isinstance(expr, graph.Constant): elif isinstance(pattern, (int, float)) and isinstance(expr, graph.Constant):
if all(theano.tensor.constant(pattern).value==expr.value): if numpy.all(theano.tensor.constant(pattern).value==expr.value):
return u return u
else: else:
return retry_with_equiv() return retry_with_equiv()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论