提交 f1bfd31d authored 作者: James Bergstra's avatar James Bergstra

added FAST_RUN mode to test_log1p to make sure optimization actually happens

上级 07061384
...@@ -910,31 +910,31 @@ def test_log1p(): ...@@ -910,31 +910,31 @@ def test_log1p():
x = dvector() x = dvector()
f = function([x], T.log(1+(x)), mode='FAST_RUN') f = function([x], T.log(1+(x)), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.log1p] assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
f = (function([x], T.log(1+(-x)))) f = (function([x], T.log(1+(-x))), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.neg, inplace.log1p_inplace] assert [node.op for node in f.maker.env.toposort()] == [T.neg, inplace.log1p_inplace]
f = (function([x], -T.log(1+(-x)))) f = (function([x], -T.log(1+(-x))), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.neg, inplace.log1p_inplace, inplace.neg_inplace] assert [node.op for node in f.maker.env.toposort()] == [T.neg, inplace.log1p_inplace, inplace.neg_inplace]
# check trickier cases (and use different dtype) # check trickier cases (and use different dtype)
y = fmatrix() y = fmatrix()
f = (function([x,y], T.log(fill(y,1)+(x)))) f = (function([x,y], T.log(fill(y,1)+(x))), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill] assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill]
f = (function([x,y], T.log(0+(x) + fill(y,1.0) ))) f = (function([x,y], T.log(0+(x) + fill(y,1.0) )), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill] assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill]
f = (function([x,y], T.log(2+(x) - fill(y,1.0) ))) f = (function([x,y], T.log(2+(x) - fill(y,1.0) )), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill] assert [node.op for node in f.maker.env.toposort()] == [T.DimShuffle([False], ['x', 0], True), T.log1p, T.fill]
f([1e-7, 10], [[0, 0], [0, 0]]) #debugmode will verify values f([1e-7, 10], [[0, 0], [0, 0]]) #debugmode will verify values
# should work for complex # should work for complex
z = zmatrix() z = zmatrix()
f = function([z], T.log(1+(z))) f = function([z], T.log(1+(z)), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.log1p] assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
# should work for int # should work for int
z = imatrix() z = imatrix()
f = function([z], T.log(1+(z))) f = function([z], T.log(1+(z)), mode='FAST_RUN')
assert [node.op for node in f.maker.env.toposort()] == [T.log1p] assert [node.op for node in f.maker.env.toposort()] == [T.log1p]
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论