提交 8a15ca52 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

merge

import sys import sys
import os import os
import shutil
import inspect import inspect
from epydoc import docintrospecter from epydoc import docintrospecter
...@@ -98,13 +99,36 @@ if __name__ == '__main__': ...@@ -98,13 +99,36 @@ if __name__ == '__main__':
if options['--all'] or options['--epydoc']: if options['--all'] or options['--epydoc']:
from epydoc.cli import cli from epydoc.cli import cli
sys.path[0:0] = throot sys.path[0:0] = throot
#Generate HTML doc
#os.system("epydoc --config doc/api/epydoc.conf -o html/api")
sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot, '-o', 'api'] sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot, '-o', 'api']
cli() cli()
# os.system("epydoc --config doc/api/epydoc.conf -o html/api")
# Generate PDF doc
# TODO
if options['--all'] or options['--rst']: if options['--all'] or options['--rst']:
import sphinx import sphinx
sys.path[0:0] = [os.path.join(throot, 'doc')] sys.path[0:0] = [os.path.join(throot, 'doc')]
sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.']) sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.'])
# Generate latex file in a temp directory
import tempfile
workdir = tempfile.mkdtemp()
sphinx.main(['', '-E', '-b', 'latex',
os.path.join(throot, 'doc'), workdir])
# Compile to PDF
currentdir = os.getcwd()
os.chdir(workdir)
os.system('make')
try:
shutil.copy(os.path.join(workdir, 'theano.pdf'), currentdir)
os.chdir(currentdir)
shutil.rmtree(workdir)
except OSError, e:
print 'OSError:', e
...@@ -288,8 +288,12 @@ class Function(object): ...@@ -288,8 +288,12 @@ class Function(object):
# if we are allowing garbage collection, remove the input and output reference from the internal # if we are allowing garbage collection, remove the input and output reference from the internal
# storage cells # storage cells
if getattr(self.fn, 'allow_gc', False): if getattr(self.fn, 'allow_gc', False):
for x in self.output_storage: assert len(self.output_storage) == len(self.maker.env.outputs)
x.storage[0] = None #WARNING: This circumvents the 'readonly' attribute in x for o_container, o_result in zip(self.output_storage, self.maker.env.outputs):
if o_result.owner is not None:
# this node is the result of computation
# WARNING: This circumvents the 'readonly' attribute in x
o_container.storage[0] = None
# Update the inputs that have an update function # Update the inputs that have an update function
for input, storage in reversed(zip(self.maker.expanded_inputs, self.input_storage)): for input, storage in reversed(zip(self.maker.expanded_inputs, self.input_storage)):
......
...@@ -160,6 +160,8 @@ class DimShuffle(Op): ...@@ -160,6 +160,8 @@ class DimShuffle(Op):
def perform(self, node, (input, ), (storage, )): def perform(self, node, (input, ), (storage, )):
# drop # drop
res = input res = input
if type(res) != numpy.ndarray:
raise TypeError(res)
shape = list(res.shape) shape = list(res.shape)
for drop in reversed(self.drop): for drop in reversed(self.drop):
shape.pop(drop) shape.pop(drop)
...@@ -178,7 +180,7 @@ class DimShuffle(Op): ...@@ -178,7 +180,7 @@ class DimShuffle(Op):
if not self.inplace: if not self.inplace:
res = numpy.copy(res) res = numpy.copy(res)
storage[0] = res storage[0] = numpy.asarray(res) #asarray puts scalars back into array
def c_code(self, node, name, (input,), (res,), sub): def c_code(self, node, name, (input,), (res,), sub):
def statements(lst): def statements(lst):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论