提交 f58f3152 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge pull request #505 from lamblin/pep8

PEP 8 fixes, assisted by Syntastic and flake8.
#!/usr/bin/env python #!/usr/bin/env python
import logging, os, sys import logging
import os
import sys
import theano import theano
from theano import config from theano import config
from theano.gof.cc import get_module_cache from theano.gof.cc import get_module_cache
...@@ -41,4 +44,3 @@ else: ...@@ -41,4 +44,3 @@ else:
print 'Type "theano-cache unlock" to unlock the cache directory' print 'Type "theano-cache unlock" to unlock the cache directory'
print 'Type "theano-cache cleanup" to delete keys in the old format' print 'Type "theano-cache cleanup" to delete keys in the old format'
sys.exit(1) sys.exit(1)
#!/usr/bin/env python #!/usr/bin/env python
__authors__ = "Olivier Delalleau, Pascal Lamblin" __authors__ = "Olivier Delalleau, Pascal Lamblin"
__contact__ = "delallea@iro" __contact__ = "delallea@iro"
""" """
This script should behave the same as the `nosetests` command. This script should behave the same as the `nosetests` command.
...@@ -68,6 +68,7 @@ def main(): ...@@ -68,6 +68,7 @@ def main():
return nose.main(addplugins=addplugins) return nose.main(addplugins=addplugins)
def help(): def help():
help_msg = """ help_msg = """
This script behaves mostly the same as the `nosetests` command. This script behaves mostly the same as the `nosetests` command.
......
...@@ -144,7 +144,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, ...@@ -144,7 +144,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
except ImportError: except ImportError:
return _do_download(version, download_base, to_dir, download_delay) return _do_download(version, download_base, to_dir, download_delay)
try: try:
pkg_resources.require("distribute>="+version) pkg_resources.require("distribute>=" + version)
return return
except pkg_resources.VersionConflict: except pkg_resources.VersionConflict:
e = sys.exc_info()[1] e = sys.exc_info()[1]
...@@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, ...@@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
if not no_fake: if not no_fake:
_create_fake_setuptools_pkg_info(to_dir) _create_fake_setuptools_pkg_info(to_dir)
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15): to_dir=os.curdir, delay=15):
"""Download distribute from a specified location and return its filename """Download distribute from a specified location and return its filename
...@@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, ...@@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
dst.close() dst.close()
return os.path.realpath(saveto) return os.path.realpath(saveto)
def _no_sandbox(function): def _no_sandbox(function):
def __no_sandbox(*args, **kw): def __no_sandbox(*args, **kw):
try: try:
...@@ -227,6 +229,7 @@ def _no_sandbox(function): ...@@ -227,6 +229,7 @@ def _no_sandbox(function):
return __no_sandbox return __no_sandbox
def _patch_file(path, content): def _patch_file(path, content):
"""Will backup the file then patch it""" """Will backup the file then patch it"""
existing_content = open(path).read() existing_content = open(path).read()
...@@ -245,15 +248,18 @@ def _patch_file(path, content): ...@@ -245,15 +248,18 @@ def _patch_file(path, content):
_patch_file = _no_sandbox(_patch_file) _patch_file = _no_sandbox(_patch_file)
def _same_content(path, content): def _same_content(path, content):
return open(path).read() == content return open(path).read() == content
def _rename_path(path): def _rename_path(path):
new_name = path + '.OLD.%s' % time.time() new_name = path + '.OLD.%s' % time.time()
log.warn('Renaming %s into %s', path, new_name) log.warn('Renaming %s into %s', path, new_name)
os.rename(path, new_name) os.rename(path, new_name)
return new_name return new_name
def _remove_flat_installation(placeholder): def _remove_flat_installation(placeholder):
if not os.path.isdir(placeholder): if not os.path.isdir(placeholder):
log.warn('Unkown installation at %s', placeholder) log.warn('Unkown installation at %s', placeholder)
...@@ -289,11 +295,13 @@ def _remove_flat_installation(placeholder): ...@@ -289,11 +295,13 @@ def _remove_flat_installation(placeholder):
_remove_flat_installation = _no_sandbox(_remove_flat_installation) _remove_flat_installation = _no_sandbox(_remove_flat_installation)
def _after_install(dist): def _after_install(dist):
log.warn('After install bootstrap.') log.warn('After install bootstrap.')
placeholder = dist.get_command_obj('install').install_purelib placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder) _create_fake_setuptools_pkg_info(placeholder)
def _create_fake_setuptools_pkg_info(placeholder): def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder): if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location') log.warn('Could not find the install location')
...@@ -321,7 +329,9 @@ def _create_fake_setuptools_pkg_info(placeholder): ...@@ -321,7 +329,9 @@ def _create_fake_setuptools_pkg_info(placeholder):
finally: finally:
f.close() f.close()
_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) _create_fake_setuptools_pkg_info = _no_sandbox(
_create_fake_setuptools_pkg_info)
def _patch_egg_dir(path): def _patch_egg_dir(path):
# let's check if it's already patched # let's check if it's already patched
...@@ -343,6 +353,7 @@ def _patch_egg_dir(path): ...@@ -343,6 +353,7 @@ def _patch_egg_dir(path):
_patch_egg_dir = _no_sandbox(_patch_egg_dir) _patch_egg_dir = _no_sandbox(_patch_egg_dir)
def _before_install(): def _before_install():
log.warn('Before install bootstrap.') log.warn('Before install bootstrap.')
_fake_setuptools() _fake_setuptools()
...@@ -351,7 +362,7 @@ def _before_install(): ...@@ -351,7 +362,7 @@ def _before_install():
def _under_prefix(location): def _under_prefix(location):
if 'install' not in sys.argv: if 'install' not in sys.argv:
return True return True
args = sys.argv[sys.argv.index('install')+1:] args = sys.argv[(sys.argv.index('install') + 1):]
for index, arg in enumerate(args): for index, arg in enumerate(args):
for option in ('--root', '--prefix'): for option in ('--root', '--prefix'):
if arg.startswith('%s=' % option): if arg.startswith('%s=' % option):
...@@ -359,7 +370,7 @@ def _under_prefix(location): ...@@ -359,7 +370,7 @@ def _under_prefix(location):
return location.startswith(top_dir) return location.startswith(top_dir)
elif arg == option: elif arg == option:
if len(args) > index: if len(args) > index:
top_dir = args[index+1] top_dir = args[index + 1]
return location.startswith(top_dir) return location.startswith(top_dir)
if arg == '--user' and USER_SITE is not None: if arg == '--user' and USER_SITE is not None:
return location.startswith(USER_SITE) return location.startswith(USER_SITE)
...@@ -380,7 +391,8 @@ def _fake_setuptools(): ...@@ -380,7 +391,8 @@ def _fake_setuptools():
replacement=False)) replacement=False))
except TypeError: except TypeError:
# old distribute API # old distribute API
setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools')) setuptools_dist = ws.find(
pkg_resources.Requirement.parse('setuptools'))
if setuptools_dist is None: if setuptools_dist is None:
log.warn('No setuptools distribution found') log.warn('No setuptools distribution found')
...@@ -422,7 +434,8 @@ def _relaunch(): ...@@ -422,7 +434,8 @@ def _relaunch():
log.warn('Relaunching...') log.warn('Relaunching...')
# we have to relaunch the process # we have to relaunch the process
# pip marker to avoid a relaunch bug # pip marker to avoid a relaunch bug
if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']: if (sys.argv[:3] ==
['-c', 'install', '--single-version-externally-managed']):
sys.argv[0] = 'setup.py' sys.argv[0] = 'setup.py'
args = [sys.executable] + sys.argv args = [sys.executable] + sys.argv
sys.exit(subprocess.call(args)) sys.exit(subprocess.call(args))
...@@ -448,7 +461,7 @@ def _extractall(self, path=".", members=None): ...@@ -448,7 +461,7 @@ def _extractall(self, path=".", members=None):
# Extract directories with a safe mode. # Extract directories with a safe mode.
directories.append(tarinfo) directories.append(tarinfo)
tarinfo = copy.copy(tarinfo) tarinfo = copy.copy(tarinfo)
tarinfo.mode = 448 # decimal for oct 0700 tarinfo.mode = 448 # decimal for oct 0700
self.extract(tarinfo, path) self.extract(tarinfo, path)
# Reverse sort directories. # Reverse sort directories.
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
# theano documentation build configuration file, created by # theano documentation build configuration file, created by
# sphinx-quickstart on Tue Oct 7 16:34:06 2008. # sphinx-quickstart on Tue Oct 7 16:34:06 2008.
# #
# This file is execfile()d with the current directory set to its containing dir. # This file is execfile()d with the current directory set to its containing
# directory.
# #
# The contents of this file are pickled, so don't put values in the namespace # The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically). # that aren't pickleable (module imports are okay, they're removed
# automatically).
# #
# All configuration values have a default value; values that are commented out # All configuration values have a default value; values that are commented out
# serve to show the default value. # serve to show the default value.
import sys, os
# If your extensions are in another directory, add it here. If the directory # If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it # is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here. # absolute, like shown here.
...@@ -21,8 +21,8 @@ import sys, os ...@@ -21,8 +21,8 @@ import sys, os
# General configuration # General configuration
# --------------------- # ---------------------
# Add any Sphinx extension module names here, as strings. They can be extensions # Add any Sphinx extension module names here, as strings. They can be
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo'] extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo']
todo_include_todos = True todo_include_todos = True
...@@ -64,11 +64,12 @@ today_fmt = '%B %d, %Y' ...@@ -64,11 +64,12 @@ today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build. # List of documents that shouldn't be included in the build.
#unused_docs = [] #unused_docs = []
# List of directories, relative to source directories, that shouldn't be searched # List of directories, relative to source directories, that shouldn't be
# for source files. # searched for source files.
exclude_dirs = ['images', 'scripts', 'sandbox'] exclude_dirs = ['images', 'scripts', 'sandbox']
# The reST default role (used for this markup: `text`) to use for all documents. # The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None #default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
...@@ -166,7 +167,8 @@ htmlhelp_basename = 'theanodoc' ...@@ -166,7 +167,8 @@ htmlhelp_basename = 'theanodoc'
latex_font_size = '11pt' latex_font_size = '11pt'
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]). # (source start file, target name, title, author, document class
# [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'theano.tex', 'theano Documentation', ('index', 'theano.tex', 'theano Documentation',
'LISA lab, University of Montreal', 'manual'), 'LISA lab, University of Montreal', 'manual'),
......
...@@ -4,16 +4,14 @@ import os ...@@ -4,16 +4,14 @@ import os
import shutil import shutil
import inspect import inspect
from epydoc import docintrospecter from epydoc import docintrospecter
from epydoc.apidoc import RoutineDoc from epydoc.apidoc import RoutineDoc
def Op_to_RoutineDoc(op, routine_doc, module_name=None): def Op_to_RoutineDoc(op, routine_doc, module_name=None):
routine_doc.specialize_to(RoutineDoc) routine_doc.specialize_to(RoutineDoc)
#NB: this code is lifted from #NB: this code is lifted from epydoc/docintrospecter.py
# /u/bergstrj/pub/prefix/x86_64-unknown-linux-gnu-Fedora_release_7__Moonshine_/lib/python2.5/site-packages/epydoc
# /u/bergstrj/pub/prefix/x86_64-unknown-linux-gnu-Fedora_release_7__Moonshine_/lib/python2.5/site-packages/epydoc/docintrospecter.py
# op should be an op instance # op should be an op instance
assert hasattr(op, 'perform') assert hasattr(op, 'perform')
...@@ -32,7 +30,7 @@ def Op_to_RoutineDoc(op, routine_doc, module_name=None): ...@@ -32,7 +30,7 @@ def Op_to_RoutineDoc(op, routine_doc, module_name=None):
routine_doc.kwarg = kwarg routine_doc.kwarg = kwarg
# Set default values for positional arguments. # Set default values for positional arguments.
routine_doc.posarg_defaults = [None]*len(args) routine_doc.posarg_defaults = [None] * len(args)
# Set the routine's line number. # Set the routine's line number.
if hasattr(func, 'func_code'): if hasattr(func, 'func_code'):
...@@ -50,8 +48,8 @@ def Op_to_RoutineDoc(op, routine_doc, module_name=None): ...@@ -50,8 +48,8 @@ def Op_to_RoutineDoc(op, routine_doc, module_name=None):
return routine_doc return routine_doc
docintrospecter.register_introspecter( docintrospecter.register_introspecter(
lambda value: getattr(value, '__epydoc_asRoutine', False), lambda value: getattr(value, '__epydoc_asRoutine', False),
Op_to_RoutineDoc, Op_to_RoutineDoc,
priority=-1) priority=-1)
...@@ -63,13 +61,17 @@ if __name__ == '__main__': ...@@ -63,13 +61,17 @@ if __name__ == '__main__':
throot = "/".join(sys.path[0].split("/")[:-2]) throot = "/".join(sys.path[0].split("/")[:-2])
options = defaultdict(bool) options = defaultdict(bool)
options.update(dict([x, y or True] for x, y in getopt.getopt(sys.argv[1:], 'o:', ['epydoc', 'rst', 'help', 'nopdf'])[0])) options.update(dict([x, y or True] for x, y in
getopt.getopt(sys.argv[1:],
'o:',
['epydoc', 'rst', 'help', 'nopdf'])[0]))
if options['--help']: if options['--help']:
print 'Usage: %s [OPTIONS]' % sys.argv[0] print 'Usage: %s [OPTIONS]' % sys.argv[0]
print ' -o <dir>: output the html files in the specified dir' print ' -o <dir>: output the html files in the specified dir'
print ' --rst: only compile the doc (requires sphinx)' print ' --rst: only compile the doc (requires sphinx)'
print ' --nopdf: do not produce a PDF file from the doc, only HTML' print ' --nopdf: do not produce a PDF file from the doc, only HTML'
print ' --epydoc: only compile the api documentation (requires epydoc)' print ' --epydoc: only compile the api documentation',
print '(requires epydoc)'
print ' --help: this help' print ' --help: this help'
sys.exit(0) sys.exit(0)
...@@ -94,13 +96,14 @@ if __name__ == '__main__': ...@@ -94,13 +96,14 @@ if __name__ == '__main__':
if options['--all'] or options['--epydoc']: if options['--all'] or options['--epydoc']:
mkdir("api") mkdir("api")
from epydoc.cli import cli
sys.path[0:0] = [throot] sys.path[0:0] = [throot]
#Generate HTML doc #Generate HTML doc
## This causes problems with the subsequent generation of sphinx doc ## This causes problems with the subsequent generation of sphinx doc
#sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot, '-o', 'api'] #from epydoc.cli import cli
#sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot,
# '-o', 'api']
#cli() #cli()
## So we use this instead ## So we use this instead
os.system("epydoc --config %s/doc/api/epydoc.conf -o api" % throot) os.system("epydoc --config %s/doc/api/epydoc.conf -o api" % throot)
...@@ -131,6 +134,3 @@ if __name__ == '__main__': ...@@ -131,6 +134,3 @@ if __name__ == '__main__':
print 'OSError:', e print 'OSError:', e
except IOError, e: except IOError, e:
print 'IOError:', e print 'IOError:', e
...@@ -53,6 +53,7 @@ ISRELEASED = False ...@@ -53,6 +53,7 @@ ISRELEASED = False
VERSION = '%d.%d.%d%s' % (MAJOR, MINOR, MICRO, SUFFIX) VERSION = '%d.%d.%d%s' % (MAJOR, MINOR, MICRO, SUFFIX)
def git_version(): def git_version():
""" """
Return the sha1 of local git HEAD as a string. Return the sha1 of local git HEAD as a string.
...@@ -86,13 +87,15 @@ def git_version(): ...@@ -86,13 +87,15 @@ def git_version():
git_revision = "unknown-git" git_revision = "unknown-git"
return git_revision return git_revision
def write_version_py(filename=os.path.join('theano', 'generated_version.py')): def write_version_py(filename=os.path.join('theano', 'generated_version.py')):
cnt = """ cnt = """
# THIS FILE IS GENERATED FROM THEANO SETUP.PY # THIS FILE IS GENERATED FROM THEANO SETUP.PY
short_version = '%(version)s' short_version = '%(version)s'
version = '%(version)s' version = '%(version)s'
git_revision = '%(git_revision)s' git_revision = '%(git_revision)s'
full_version = '%(version)s.dev-%%(git_revision)s' %% {'git_revision': git_revision} full_version = '%(version)s.dev-%%(git_revision)s' %% {
'git_revision': git_revision}
release = %(isrelease)s release = %(isrelease)s
if not release: if not release:
......
...@@ -95,7 +95,6 @@ import scalar ...@@ -95,7 +95,6 @@ import scalar
#import sparse #import sparse
import gradient import gradient
from gradient import Rop, Lop, grad from gradient import Rop, Lop, grad
import gof
if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'): if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
import theano.sandbox.cuda import theano.sandbox.cuda
......
import os import os
import logging import logging
import subprocess import subprocess
import sys
from theano.configparser import ( from theano.configparser import (
AddConfigVar, BoolParam, ConfigParam, EnumStr, IntParam, FloatParam, AddConfigVar, BoolParam, ConfigParam, EnumStr, IntParam,
StrParam, TheanoConfigParser) TheanoConfigParser)
_logger = logging.getLogger('theano.configdefaults') _logger = logging.getLogger('theano.configdefaults')
...@@ -41,10 +40,13 @@ AddConfigVar('int_division', ...@@ -41,10 +40,13 @@ AddConfigVar('int_division',
EnumStr('int', 'raise', 'floatX'), EnumStr('int', 'raise', 'floatX'),
in_c_key=False) in_c_key=False)
#gpu mean let the driver select the gpu. Needed in case of gpu in exclusive mode. # gpu means let the driver select the gpu. Needed in case of gpu in
#gpuX mean use the gpu number X. # exclusive mode.
# gpuX mean use the gpu number X.
AddConfigVar('device', AddConfigVar('device',
"Default device for computations. If gpu*, change the default to try to move computation to it and to put shared variable of float32 on it.", ("Default device for computations. If gpu*, change the default to try "
"to move computation to it and to put shared variable of float32 "
"on it."),
EnumStr('cpu', 'gpu', EnumStr('cpu', 'gpu',
'gpu0', 'gpu1', 'gpu2', 'gpu3', 'gpu0', 'gpu1', 'gpu2', 'gpu3',
'gpu4', 'gpu5', 'gpu6', 'gpu7', 'gpu4', 'gpu5', 'gpu6', 'gpu7',
...@@ -93,14 +95,16 @@ try: ...@@ -93,14 +95,16 @@ try:
stdin=dummy_stdin.fileno()) stdin=dummy_stdin.fileno())
# Keep the default linker the same as the one for the mode FAST_RUN # Keep the default linker the same as the one for the mode FAST_RUN
AddConfigVar('linker', AddConfigVar('linker',
"Default linker used if the theano flags mode is Mode or ProfileMode", ("Default linker used if the theano flags mode is Mode "
"or ProfileMode"),
EnumStr('c|py', 'py', 'c', 'c|py_nogc', 'c&py', EnumStr('c|py', 'py', 'c', 'c|py_nogc', 'c&py',
'vm', 'cvm', 'vm_nogc', 'cvm_nogc'), 'vm', 'cvm', 'vm_nogc', 'cvm_nogc'),
in_c_key=False) in_c_key=False)
except OSError: except OSError:
# g++ is not present, linker should default to python only # g++ is not present, linker should default to python only
AddConfigVar('linker', AddConfigVar('linker',
"Default linker used if the theano flags mode is Mode or ProfileMode", ("Default linker used if the theano flags mode is Mode "
"or ProfileMode"),
EnumStr('py', 'c|py', 'c', 'c|py_nogc', 'c&py', EnumStr('py', 'c|py', 'c', 'c|py_nogc', 'c&py',
'vm', 'cvm', 'vm_nogc', 'cvm_nogc'), 'vm', 'cvm', 'vm_nogc', 'cvm_nogc'),
in_c_key=False) in_c_key=False)
...@@ -113,12 +117,14 @@ del dummy_stdin ...@@ -113,12 +117,14 @@ del dummy_stdin
#Keep the default optimizer the same as the one for the mode FAST_RUN #Keep the default optimizer the same as the one for the mode FAST_RUN
AddConfigVar('optimizer', AddConfigVar('optimizer',
"Default optimizer. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)", ("Default optimizer. If not None, will use this linker with the Mode "
"object (not ProfileMode or DebugMode)"),
EnumStr('fast_run', 'merge', 'fast_compile', 'None'), EnumStr('fast_run', 'merge', 'fast_compile', 'None'),
in_c_key=False) in_c_key=False)
AddConfigVar('on_opt_error', AddConfigVar('on_opt_error',
"What to do when an optimization crashes: warn and skip it, or raise the exception", ("What to do when an optimization crashes: warn and skip it, or raise "
"the exception"),
EnumStr('warn', 'raise'), EnumStr('warn', 'raise'),
in_c_key=False) in_c_key=False)
...@@ -160,16 +166,18 @@ AddConfigVar('nocleanup', ...@@ -160,16 +166,18 @@ AddConfigVar('nocleanup',
# changed at runtime. # changed at runtime.
AddConfigVar('tensor.cmp_sloppy', AddConfigVar('tensor.cmp_sloppy',
"Relax tensor._allclose (0) not at all, (1) a bit, (2) more", "Relax tensor._allclose (0) not at all, (1) a bit, (2) more",
IntParam(0, lambda i: i in (0,1,2), allow_override=False), IntParam(0, lambda i: i in (0, 1, 2), allow_override=False),
in_c_key=False) in_c_key=False)
AddConfigVar('tensor.local_elemwise_fusion', AddConfigVar('tensor.local_elemwise_fusion',
"Enable or not in fast_run mode(fast_run optimization) the elemwise fusion optimization", ("Enable or not in fast_run mode(fast_run optimization) the elemwise "
"fusion optimization"),
BoolParam(True), BoolParam(True),
in_c_key=False) in_c_key=False)
AddConfigVar('gpu.local_elemwise_fusion', AddConfigVar('gpu.local_elemwise_fusion',
"Enable or not in fast_run mode(fast_run optimization) the gpu elemwise fusion optimization", ("Enable or not in fast_run mode(fast_run optimization) the gpu "
"elemwise fusion optimization"),
BoolParam(True), BoolParam(True),
in_c_key=False) in_c_key=False)
...@@ -179,7 +187,8 @@ AddConfigVar('lib.amdlibm', ...@@ -179,7 +187,8 @@ AddConfigVar('lib.amdlibm',
BoolParam(False)) BoolParam(False))
AddConfigVar('op.set_flops', AddConfigVar('op.set_flops',
"currently used only in ConvOp. The profile mode will print the flops/s for the op.", ("currently used only in ConvOp. The profile mode will print the "
"flops/s for the op."),
BoolParam(False), BoolParam(False),
in_c_key=False) in_c_key=False)
...@@ -244,8 +253,14 @@ AddConfigVar('numpy.seterr_invalid', ...@@ -244,8 +253,14 @@ AddConfigVar('numpy.seterr_invalid',
### To disable some warning about old bug that are fixed now. ### To disable some warning about old bug that are fixed now.
### ###
AddConfigVar('warn.ignore_bug_before', AddConfigVar('warn.ignore_bug_before',
"If 'None', we warn about all Theano bugs found by default. If 'all', we don't warn about Theano bugs found by default. If a version, we print only the warnings relative to Theano bugs found after that version. Warning for specific bugs can be configured with specific [warn] flags.", ("If 'None', we warn about all Theano bugs found by default. "
EnumStr('None', 'all', '0.3','0.4', '0.4.1', '0.5', allow_override=False), "If 'all', we don't warn about Theano bugs found by default. "
"If a version, we print only the warnings relative to Theano "
"bugs found after that version. "
"Warning for specific bugs can be configured with specific "
"[warn] flags."),
EnumStr('None', 'all', '0.3', '0.4', '0.4.1', '0.5',
allow_override=False),
in_c_key=False) in_c_key=False)
...@@ -263,34 +278,48 @@ def warn_default(version): ...@@ -263,34 +278,48 @@ def warn_default(version):
AddConfigVar('warn.argmax_pushdown_bug', AddConfigVar('warn.argmax_pushdown_bug',
"Warn if in past version of Theano we generated a bug with the theano.tensor.nnet.nnet.local_argmax_pushdown optimization. Was fixed 27 may 2010", ("Warn if in past version of Theano we generated a bug with the "
"theano.tensor.nnet.nnet.local_argmax_pushdown optimization. "
"Was fixed 27 may 2010"),
BoolParam(warn_default('0.3')), BoolParam(warn_default('0.3')),
in_c_key=False) in_c_key=False)
AddConfigVar('warn.gpusum_01_011_0111_bug', AddConfigVar('warn.gpusum_01_011_0111_bug',
"Warn if we are in a case where old version of Theano had a silent bug with GpuSum pattern 01,011 and 0111 when the first dimensions was bigger then 4096. Was fixed 31 may 2010", ("Warn if we are in a case where old version of Theano had a "
"silent bug with GpuSum pattern 01,011 and 0111 when the first "
"dimensions was bigger then 4096. Was fixed 31 may 2010"),
BoolParam(warn_default('0.3')), BoolParam(warn_default('0.3')),
in_c_key=False) in_c_key=False)
AddConfigVar('warn.sum_sum_bug', AddConfigVar('warn.sum_sum_bug',
"Warn if we are in a case where Theano version between version 9923a40c7b7a and the 2 august 2010(fixed date), generated an error in that case. This happen when their is 2 consecutive sum in the graph, bad code was generated. Was fixed 2 August 2010", ("Warn if we are in a case where Theano version between version "
"9923a40c7b7a and the 2 august 2010 (fixed date), generated an "
"error in that case. This happens when there are 2 consecutive "
"sums in the graph, bad code was generated. "
"Was fixed 2 August 2010"),
BoolParam(warn_default('0.3')), BoolParam(warn_default('0.3')),
in_c_key=False) in_c_key=False)
AddConfigVar('warn.sum_div_dimshuffle_bug', AddConfigVar('warn.sum_div_dimshuffle_bug',
"Warn if previous versions of Theano (between rev. 3bd9b789f5e8, 2010-06-16, and cfc6322e5ad4, 2010-08-03) would have given incorrect result. This bug was triggered by sum of division of dimshuffled tensors.", ("Warn if previous versions of Theano (between rev. "
"3bd9b789f5e8, 2010-06-16, and cfc6322e5ad4, 2010-08-03) "
"would have given incorrect result. This bug was triggered by "
"sum of division of dimshuffled tensors."),
BoolParam(warn_default('0.3')), BoolParam(warn_default('0.3')),
in_c_key=False) in_c_key=False)
AddConfigVar('warn.subtensor_merge_bug', AddConfigVar('warn.subtensor_merge_bug',
"Warn if previous versions of Theano (before 0.5rc2) could have given " "Warn if previous versions of Theano (before 0.5rc2) could have given "
"incorrect results when indexing into a subtensor with negative stride " "incorrect results when indexing into a subtensor with negative "
"(for instance, for instance, x[a:b:-1][c]).", "stride (for instance, for instance, x[a:b:-1][c]).",
BoolParam(warn_default('0.5')), BoolParam(warn_default('0.5')),
in_c_key=False) in_c_key=False)
AddConfigVar('compute_test_value', AddConfigVar('compute_test_value',
"If 'True', Theano will run each op at graph build time, using Constants, SharedVariables and the tag 'test_value' as inputs to the function. This helps the user track down problems in the graph before it gets optimized.", ("If 'True', Theano will run each op at graph build time, using "
"Constants, SharedVariables and the tag 'test_value' as inputs "
"to the function. This helps the user track down problems in the "
"graph before it gets optimized."),
EnumStr('off', 'ignore', 'warn', 'raise'), EnumStr('off', 'ignore', 'warn', 'raise'),
in_c_key=False) in_c_key=False)
...@@ -310,5 +339,5 @@ AddConfigVar('exception_verbosity', ...@@ -310,5 +339,5 @@ AddConfigVar('exception_verbosity',
A. Elemwise{add_no_inplace} A. Elemwise{add_no_inplace}
B. log_likelihood_v_given_h B. log_likelihood_v_given_h
C. log_likelihood_h""", C. log_likelihood_h""",
EnumStr('low','high'), EnumStr('low', 'high'),
in_c_key=False) in_c_key=False)
差异被折叠。
"""Defines Updates object for storing a (SharedVariable, new_value) mapping. """Defines Updates object for storing a (SharedVariable, new_value) mapping.
""" """
__authors__ = "theano-dev" __authors__ = "theano-dev"
__copyright__ = "(c) 2010, Universite de Montreal" __copyright__ = "(c) 2010, Universite de Montreal"
__license__ = "3-clause BSD License" __license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>" __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
from theano.compile.sharedvalue import SharedVariable from theano.compile.sharedvalue import SharedVariable
import logging import logging
logger = logging.getLogger('theano.updates') logger = logging.getLogger('theano.updates')
class Updates(dict): class Updates(dict):
""" """
Dict-like mapping from SharedVariable keys to their new values. Dict-like mapping from SharedVariable keys to their new values.
...@@ -30,14 +31,16 @@ class Updates(dict): ...@@ -30,14 +31,16 @@ class Updates(dict):
return super(Updates, self).__setitem__(key, value) return super(Updates, self).__setitem__(key, value)
else: else:
raise TypeError('Updates keys must inherit from SharedVariable', key) raise TypeError('Updates keys must inherit from SharedVariable',
key)
def update(self, other): def update(self, other):
for key, val in dict(other).iteritems(): for key, val in dict(other).iteritems():
if key in self: if key in self:
if self[key] == val: if self[key] == val:
continue continue
raise KeyError('Collision', key) raise KeyError('Collision', key)
self[key] = val # __setitem__ does type-checking self[key] = val # __setitem__ does type-checking
def __add__(self, other): def __add__(self, other):
rval = Updates() rval = Updates()
...@@ -50,4 +53,3 @@ class Updates(dict): ...@@ -50,4 +53,3 @@ class Updates(dict):
rval.update(other) rval.update(other)
rval.update(self) rval.update(self)
return rval return rval
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论