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

Remove a useless check. It can be a cached constant. This is safe in the…

Remove a useless check. It can be a cached constant. This is safe in the make_node. inplace opt will disallow that later, but it should be safe.
上级 bd2ec838
...@@ -852,9 +852,6 @@ class Gemm(GemmRelated): ...@@ -852,9 +852,6 @@ class Gemm(GemmRelated):
(self, len(inputs))) (self, len(inputs)))
z, a, x, y, b = inputs z, a, x, y, b = inputs
# For the consistency check we don't want z to be a cached constant.
if getattr(z, 'cached', False):
z = copy.copy(z)
zr, xr, yr = [set(view_roots(i)) for i in (z, x, y)] zr, xr, yr = [set(view_roots(i)) for i in (z, x, y)]
# We want the gemm to be inplace. When this op is inplace, it # We want the gemm to be inplace. When this op is inplace, it
...@@ -867,10 +864,11 @@ class Gemm(GemmRelated): ...@@ -867,10 +864,11 @@ class Gemm(GemmRelated):
# think there is another mechanism that would prevent this, # think there is another mechanism that would prevent this,
# but I don't what to modify old code and have chance to break # but I don't what to modify old code and have chance to break
# something. # something.
if zr.intersection(xr): if self.inplace:
raise InconsistencyError(Gemm.E_z_uniq, (z, x)) if zr.intersection(xr):
if zr.intersection(yr): raise InconsistencyError(Gemm.E_z_uniq, (z, x))
raise InconsistencyError(Gemm.E_z_uniq, (z, y)) if zr.intersection(yr):
raise InconsistencyError(Gemm.E_z_uniq, (z, y))
if z.ndim != 2: if z.ndim != 2:
raise TypeError(Gemm.E_rank, z) raise TypeError(Gemm.E_rank, z)
......
...@@ -105,7 +105,7 @@ class t_gemm(TestCase): ...@@ -105,7 +105,7 @@ class t_gemm(TestCase):
def test0a(self): def test0a(self):
Gemm.debug = True Gemm.debug = True
try: try:
g = gemm_inplace([1.], 1., [1.], [1.], 1.) g = gemm_no_inplace([1.], 1., [1.], [1.], 1.)
except TypeError as e: except TypeError as e:
if exc_message(e) is Gemm.E_rank: if exc_message(e) is Gemm.E_rank:
return return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论