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

make import follow our coding style.

上级 93470824
## PENDING REWRITE OF tensor_opt.py ## PENDING REWRITE OF tensor_opt.py
import copy
import time import time
import unittest
import numpy import numpy
from nose.plugins.skip import SkipTest
from numpy.testing.noseclasses import KnownFailureTest
import theano import theano
from theano import gof from theano import gof
...@@ -16,11 +20,7 @@ from theano import pprint, shared ...@@ -16,11 +20,7 @@ from theano import pprint, shared
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
from theano import function, compile from theano import function, compile
from nose.plugins.skip import SkipTest
from numpy.testing.noseclasses import KnownFailureTest
import unittest, copy
from copy import copy as cp
def inputs(xbc = (0, 0), ybc = (0, 0), zbc = (0, 0)): def inputs(xbc = (0, 0), ybc = (0, 0), zbc = (0, 0)):
x = TensorType(broadcastable = xbc, dtype = 'float64')('x') x = TensorType(broadcastable = xbc, dtype = 'float64')('x')
...@@ -835,7 +835,7 @@ class test_fusion(unittest.TestCase): ...@@ -835,7 +835,7 @@ class test_fusion(unittest.TestCase):
def test_elemwise_fusion(self): def test_elemwise_fusion(self):
shp=(5,5) shp=(5,5)
mode=cp(compile.mode.get_default_mode()) mode=copy.copy(compile.mode.get_default_mode())
#we need the optimisation enabled and the canonicalize. #we need the optimisation enabled and the canonicalize.
#the canonicalize is needed to merge multiplication/addition by constant. #the canonicalize is needed to merge multiplication/addition by constant.
mode._optimizer=mode._optimizer.including('local_elemwise_fusion','canonicalize') mode._optimizer=mode._optimizer.including('local_elemwise_fusion','canonicalize')
...@@ -866,13 +866,13 @@ class test_fusion(unittest.TestCase): ...@@ -866,13 +866,13 @@ class test_fusion(unittest.TestCase):
# linker=gof.CLinker # linker=gof.CLinker
# linker=gof.OpWiseCLinker # linker=gof.OpWiseCLinker
mode1=cp(compile.get_default_mode()) mode1=copy.copy(compile.get_default_mode())
mode1._optimizer=mode1._optimizer.including('local_elemwise_fusion') mode1._optimizer=mode1._optimizer.including('local_elemwise_fusion')
#TODO:clinker is much faster... but use to much memory #TODO:clinker is much faster... but use to much memory
#Possible cause: as their is do deletion of intermediate value when we don't keep the fct. #Possible cause: as their is do deletion of intermediate value when we don't keep the fct.
#More plausible cause: we keep a link to the output data? #More plausible cause: we keep a link to the output data?
#Follow up. Clinker do the same... second cause? #Follow up. Clinker do the same... second cause?
mode2=cp(compile.get_default_mode()) mode2=copy.copy(compile.get_default_mode())
mode2._optimizer=mode2._optimizer.excluding('local_elemwise_fusion') mode2._optimizer=mode2._optimizer.excluding('local_elemwise_fusion')
print "test with linker", str(mode1.linker) print "test with linker", str(mode1.linker)
times1=self.do(mode1, shared_fn, shp, gpu=gpu, nb_repeat=nb_repeat, assert_len_topo=False,slice=s) times1=self.do(mode1, shared_fn, shp, gpu=gpu, nb_repeat=nb_repeat, assert_len_topo=False,slice=s)
...@@ -888,7 +888,7 @@ class test_fusion(unittest.TestCase): ...@@ -888,7 +888,7 @@ class test_fusion(unittest.TestCase):
print "min", d.min(), "argmin", d.argmin(), "max", d.max(), "mean", d.mean(), "std", d.std() print "min", d.min(), "argmin", d.argmin(), "max", d.max(), "mean", d.mean(), "std", d.std()
def test_fusion_inplace(self): def test_fusion_inplace(self):
mode=cp(compile.mode.get_default_mode()) mode=copy.copy(compile.mode.get_default_mode())
#we need the optimisation enabled and the canonicalize. #we need the optimisation enabled and the canonicalize.
#the canonicalize is needed to merge multiplication/addition by constant. #the canonicalize is needed to merge multiplication/addition by constant.
mode._optimizer=mode._optimizer.including('local_elemwise_fusion','canonicalize','inplace') mode._optimizer=mode._optimizer.including('local_elemwise_fusion','canonicalize','inplace')
...@@ -909,7 +909,7 @@ class test_fusion(unittest.TestCase): ...@@ -909,7 +909,7 @@ class test_fusion(unittest.TestCase):
s=slice(31,36) s=slice(31,36)
# linker=gof.CLinker # linker=gof.CLinker
linker=gof.OpWiseCLinker linker=gof.OpWiseCLinker
mode=compile.Mode(linker(), cp(compile.mode.OPT_FAST_RUN)) mode=compile.Mode(linker(), copy.copy(compile.mode.OPT_FAST_RUN))
mode=compile.ProfileMode() mode=compile.ProfileMode()
print "time", self.do(mode, shared, shp=(1000,1000),gpu=False, assert_len_topo=False,slice=s, nb_repeat=100) print "time", self.do(mode, shared, shp=(1000,1000),gpu=False, assert_len_topo=False,slice=s, nb_repeat=100)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论