提交 6796db42 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Apply isort to theano.gof sub-package modules

上级 1c28df91
"""Graph optimization framework""" """Graph optimization framework"""
import theano
from theano.gof.cc import CLinker, OpWiseCLinker, DualLinker, HideC from theano.gof.cc import CLinker, DualLinker, HideC, OpWiseCLinker
from theano.gof.fg import (
InconsistencyError,
MissingInputError,
FunctionGraph,
)
from theano.gof.destroyhandler import DestroyHandler from theano.gof.destroyhandler import DestroyHandler
from theano.gof.fg import FunctionGraph, InconsistencyError, MissingInputError
from theano.gof.graph import Apply, Variable, Constant, view_roots from theano.gof.graph import Apply, Constant, Variable, view_roots
from theano.gof.link import ( from theano.gof.link import (
Container, Container,
Linker, Linker,
...@@ -21,58 +13,48 @@ from theano.gof.link import ( ...@@ -21,58 +13,48 @@ from theano.gof.link import (
WrapLinker, WrapLinker,
WrapLinkerMany, WrapLinkerMany,
) )
from theano.gof.op import ( from theano.gof.op import (
COp,
Op, Op,
OpenMPOp, OpenMPOp,
PureOp, PureOp,
COp,
ops_with_inner_function,
get_test_value, get_test_value,
ops_with_inner_function,
) )
from theano.gof.type import EnumType, EnumList, CEnumType
from theano.gof.opt import ( from theano.gof.opt import (
Optimizer, CheckStackTraceOptimization,
optimizer, EquilibriumOptimizer,
inplace_optimizer,
SeqOptimizer,
MergeOptimizer,
LocalOptimizer,
local_optimizer,
LocalOptGroup, LocalOptGroup,
OpSub, LocalOptimizer,
MergeOptimizer,
NavigatorOptimizer,
OpKeyOptimizer,
OpRemove, OpRemove,
OpSub,
Optimizer,
PatternSub, PatternSub,
NavigatorOptimizer, SeqOptimizer,
TopoOptimizer, TopoOptimizer,
EquilibriumOptimizer, inplace_optimizer,
OpKeyOptimizer, local_optimizer,
CheckStackTraceOptimization, optimizer,
) )
from theano.gof.optdb import DB, EquilibriumDB, LocalGroupDB, ProxyDB, Query, SequenceDB
from theano.gof.optdb import DB, LocalGroupDB, Query, EquilibriumDB, SequenceDB, ProxyDB from theano.gof.params_type import Params, ParamsType
from theano.gof.toolbox import ( from theano.gof.toolbox import (
Feature,
Bookkeeper, Bookkeeper,
Feature,
History, History,
Validator,
ReplaceValidate,
NodeFinder, NodeFinder,
NoOutputFromInplace,
PrintListener, PrintListener,
ReplacementDidntRemovedError, ReplacementDidntRemovedError,
NoOutputFromInplace, ReplaceValidate,
Validator,
) )
from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic
from theano.gof.utils import MethodNotDefined, hashtype, object2
from theano.gof.type import Type, Generic, generic
from theano.gof.utils import hashtype, object2, MethodNotDefined
from theano.gof.params_type import ParamsType, Params
import theano
if theano.config.cmodule.preload_cache: if theano.config.cmodule.preload_cache:
from theano.gof.cc import get_module_cache from theano.gof.cc import get_module_cache
......
import logging import logging
import six.moves.cPickle as pickle import six.moves.cPickle as pickle
_logger = logging.getLogger("theano.gof.callcache") _logger = logging.getLogger("theano.gof.callcache")
......
...@@ -2,25 +2,21 @@ ...@@ -2,25 +2,21 @@
Defines Linkers that deal with C implementations. Defines Linkers that deal with C implementations.
""" """
import logging
import os import os
import sys import sys
import logging
import numpy as np
import theano
from copy import copy from copy import copy
from six import string_types, reraise import numpy as np
from six import reraise, string_types
from six.moves import StringIO from six.moves import StringIO
import theano
from theano import config from theano import config
from theano.compat import PY3 from theano.compat import PY3
from theano.gof import cmodule, graph, link, utils
from theano.gof import graph, link, utils, cmodule
from theano.gof.compilelock import get_lock, release_lock
from theano.gof.callcache import CallCache from theano.gof.callcache import CallCache
from theano.gof.compilelock import get_lock, release_lock
_logger = logging.getLogger("theano.gof.cc") _logger = logging.getLogger("theano.gof.cc")
......
...@@ -3,37 +3,34 @@ Generate and compile C modules for Python. ...@@ -3,37 +3,34 @@ Generate and compile C modules for Python.
""" """
import atexit import atexit
import textwrap import distutils.sysconfig
import six.moves.cPickle as pickle
import logging import logging
import os import os
import platform
import re import re
import shutil import shutil
import stat import stat
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import textwrap
import time import time
import platform
import distutils.sysconfig
import warnings import warnings
import numpy.distutils import numpy.distutils
import six.moves.cPickle as pickle
from six import BytesIO, StringIO, b, string_types
import theano import theano
from six import b, BytesIO, StringIO, string_types
from theano import config from theano import config
from theano.compat import PY3, decode, decode_iter from theano.compat import PY3, decode, decode_iter
from theano.gof.utils import flatten from theano.configdefaults import gcc_version_str, local_bitwidth
from theano.gof.utils import hash_from_code
from theano.misc.windows import subprocess_Popen, output_subprocess_Popen
# we will abuse the lockfile mechanism when reading and writing the registry # we will abuse the lockfile mechanism when reading and writing the registry
from theano.gof import compilelock from theano.gof import compilelock
from theano.configdefaults import gcc_version_str, local_bitwidth from theano.gof.utils import flatten, hash_from_code
from theano.misc.windows import output_subprocess_Popen, subprocess_Popen
importlib = None importlib = None
try: try:
......
import logging
import os import os
import shutil import shutil
import logging
import six.moves.cPickle as pickle
import numpy as np import numpy as np
import six.moves.cPickle as pickle
import theano
from six import string_types from six import string_types
import theano
from theano import config from theano import config
from theano.gof.utils import flatten from theano.gof.utils import flatten
......
...@@ -3,20 +3,18 @@ Locking mechanism to ensure no two compilations occur simultaneously ...@@ -3,20 +3,18 @@ Locking mechanism to ensure no two compilations occur simultaneously
in the same compilation directory (which can cause crashes). in the same compilation directory (which can cause crashes).
""" """
import atexit import atexit
import logging
import os import os
import socket # only used for gethostname() import socket # only used for gethostname()
import time import time
import logging from contextlib import contextmanager
import numpy as np import numpy as np
from six import PY3 from six import PY3
from contextlib import contextmanager
from theano import config from theano import config
random = np.random.RandomState([2015, 8, 2]) random = np.random.RandomState([2015, 8, 2])
_logger = logging.getLogger("theano.gof.compilelock") _logger = logging.getLogger("theano.gof.compilelock")
......
...@@ -2,11 +2,13 @@ import errno ...@@ -2,11 +2,13 @@ import errno
import os import os
import sys import sys
from theano import config
from theano.compat import PY3 from theano.compat import PY3
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
from theano import config
from . import cmodule from . import cmodule
# TODO These two lines may be removed in the future, when we are 100% sure # TODO These two lines may be removed in the future, when we are 100% sure
# no one has an old cutils_ext.so lying around anymore. # no one has an old cutils_ext.so lying around anymore.
if os.path.exists(os.path.join(config.compiledir, "cutils_ext.so")): if os.path.exists(os.path.join(config.compiledir, "cutils_ext.so")):
......
...@@ -4,16 +4,13 @@ and inplace operations. ...@@ -4,16 +4,13 @@ and inplace operations.
""" """
import itertools import itertools
from collections import OrderedDict, deque
import theano import theano
from collections import deque, OrderedDict
from theano import config from theano import config
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
from . import toolbox from . import graph, toolbox
from . import graph
from .fg import InconsistencyError from .fg import InconsistencyError
......
...@@ -5,18 +5,17 @@ types that it can raise. ...@@ -5,18 +5,17 @@ types that it can raise.
""" """
import time import time
import theano
from collections import OrderedDict from collections import OrderedDict
from six.moves import StringIO from six.moves import StringIO
import theano
from theano import config from theano import config
from theano.gof import graph, utils, toolbox from theano.gof import graph, toolbox, utils
from theano.gof.utils import get_variable_trace_string, TestValueError from theano.gof.utils import TestValueError, get_variable_trace_string
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
NullType = None NullType = None
......
...@@ -3,27 +3,26 @@ Node classes (`Apply`, `Variable`) and expression graph algorithms. ...@@ -3,27 +3,26 @@ Node classes (`Apply`, `Variable`) and expression graph algorithms.
""" """
import contextlib import contextlib
import warnings import warnings
import theano
from collections import deque from collections import deque
from copy import copy from copy import copy
from itertools import count from itertools import count
from six import string_types, integer_types from six import integer_types, string_types
import theano
from theano import config from theano import config
from theano.gof.utils import ( from theano.gof.utils import (
TestValueError,
object2,
MethodNotDefined, MethodNotDefined,
Scratchpad, Scratchpad,
TestValueError,
ValidatingScratchpad, ValidatingScratchpad,
get_variable_trace_string,
add_tag_trace, add_tag_trace,
get_variable_trace_string,
object2,
) )
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
NoParams = object() NoParams = object()
......
import errno import errno
import logging import logging
import os import os
from six.moves import reload_module as reload
import sys import sys
import warnings import warnings
from six.moves import reload_module as reload
import theano import theano
from theano import config from theano import config
from theano.gof.compilelock import get_lock, release_lock
from theano.gof import cmodule from theano.gof import cmodule
from theano.gof.compilelock import get_lock, release_lock
_logger = logging.getLogger("theano.gof.lazylinker_c") _logger = logging.getLogger("theano.gof.lazylinker_c")
......
import sys import sys
import traceback import traceback
import numpy as np
import theano
from sys import getsizeof
from copy import copy, deepcopy from copy import copy, deepcopy
from sys import getsizeof
import numpy as np
from six import reraise from six import reraise
from six.moves import StringIO from six.moves import StringIO
from theano.gof import utils import theano
from theano.gof import graph from theano.gof import graph, utils
from theano.gof.type import Type from theano.gof.type import Type
from .utils import undef from .utils import undef
__excepthook = sys.excepthook __excepthook = sys.excepthook
......
...@@ -5,29 +5,29 @@ The `Op` class is the base interface for all operations ...@@ -5,29 +5,29 @@ The `Op` class is the base interface for all operations
compatible with `gof`'s :doc:`graph` routines. compatible with `gof`'s :doc:`graph` routines.
""" """
import inspect
import logging
import os import os
import re import re
import sys import sys
import inspect
import logging
import warnings import warnings
import numpy as np import numpy as np
import theano import theano
import theano.gof.cc import theano.gof.cc
from theano import config from theano import config
from theano.gof import graph from theano.gof import graph
from theano.gof.cmodule import GCC_compiler
from theano.gof.fg import FunctionGraph
from theano.gof.utils import ( from theano.gof.utils import (
object2,
TestValueError,
get_variable_trace_string,
MethodNotDefined, MethodNotDefined,
TestValueError,
add_tag_trace, add_tag_trace,
get_variable_trace_string,
object2,
) )
from theano.gof.cmodule import GCC_compiler
from theano.gof.fg import FunctionGraph
__authors__ = "theano-dev" __authors__ = "theano-dev"
__copyright__ = "(c) 2010, Universite de Montreal" __copyright__ = "(c) 2010, Universite de Montreal"
......
...@@ -3,7 +3,6 @@ Defines the base class for optimizations as well as a certain ...@@ -3,7 +3,6 @@ Defines the base class for optimizations as well as a certain
amount of useful generic optimization tools. amount of useful generic optimization tools.
""" """
from collections import deque, defaultdict, OrderedDict
import contextlib import contextlib
import copy import copy
import inspect import inspect
...@@ -11,25 +10,23 @@ import logging ...@@ -11,25 +10,23 @@ import logging
import pdb import pdb
import sys import sys
import time import time
import warnings
import traceback import traceback
import warnings
from collections import OrderedDict, defaultdict, deque
from functools import reduce
import numpy as np import numpy as np
from six import integer_types, string_types
import theano import theano
from functools import reduce
from six import string_types, integer_types
from theano import config from theano import config
from theano.gof import graph, op, toolbox, unify, utils
from theano.gof import graph, op, utils, unify, toolbox
from theano.gof.fg import InconsistencyError from theano.gof.fg import InconsistencyError
from theano.misc.ordered_set import OrderedSet from theano.misc.ordered_set import OrderedSet
from . import destroyhandler as dh from . import destroyhandler as dh
_logger = logging.getLogger("theano.gof.opt") _logger = logging.getLogger("theano.gof.opt")
_optimizer_idx = [0] _optimizer_idx = [0]
......
import copy import copy
import sys
import math import math
import sys
from theano.compat import DefaultOrderedDict
from theano.misc.ordered_set import OrderedSet
from six import StringIO, integer_types from six import StringIO, integer_types
from theano.gof import opt
from theano import config from theano import config
from theano.compat import DefaultOrderedDict
from theano.gof import opt
from theano.misc.ordered_set import OrderedSet
class DB(object): class DB(object):
......
...@@ -113,10 +113,11 @@ for more info about enumeration aliases). ...@@ -113,10 +113,11 @@ for more info about enumeration aliases).
""" """
import re
import hashlib import hashlib
import re
from theano.gof.type import EnumType, Type
from theano.gof.utils import MethodNotDefined, c_cpp_keywords from theano.gof.utils import MethodNotDefined, c_cpp_keywords
from theano.gof import Type, EnumType
class Params(dict): class Params(dict):
......
...@@ -3,6 +3,7 @@ from collections import defaultdict ...@@ -3,6 +3,7 @@ from collections import defaultdict
from theano.compat import cmp from theano.compat import cmp
from theano.gof.graph import list_of_nodes from theano.gof.graph import list_of_nodes
# {{{ http://code.activestate.com/recipes/578231/ (r1) # {{{ http://code.activestate.com/recipes/578231/ (r1)
# Copyright (c) Oren Tirosh 2012 # Copyright (c) Oren Tirosh 2012
# #
......
import sys
import copy import copy
import time
import inspect import inspect
import sys
import numpy as np import time
import theano
from functools import partial
from collections import OrderedDict from collections import OrderedDict
from functools import partial
import numpy as np
from six.moves import StringIO from six.moves import StringIO
import theano
from theano import config from theano import config
from theano.gof.graph import ( from theano.gof.graph import equal_computations, inputs, io_toposort, variables
inputs,
io_toposort,
equal_computations,
variables,
)
class AlreadyThere(Exception): class AlreadyThere(Exception):
......
...@@ -8,19 +8,20 @@ Defines the `Type` class. ...@@ -8,19 +8,20 @@ Defines the `Type` class.
import ctypes import ctypes
import platform import platform
import re
from six import string_types from six import string_types
import re
import theano import theano
from theano.gof import graph, utils
from theano.gof.utils import MethodNotDefined, object2
from theano import change_flags from theano import change_flags
from theano.gof import graph, utils
######## ########
# Type # # Type #
######## ########
from theano.gof.op import CLinkerObject, Op from theano.gof.op import CLinkerObject, Op
from theano.gof.utils import MethodNotDefined, object2
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
...@@ -643,8 +644,8 @@ class _make_cdata(Op): ...@@ -643,8 +644,8 @@ class _make_cdata(Op):
return False return False
def make_node(self, val): def make_node(self, val):
from theano.scalar import as_scalar
from theano import Apply from theano import Apply
from theano.scalar import as_scalar
val = as_scalar(val).astype("uint64") val = as_scalar(val).astype("uint64")
return Apply(self, [val], [self.rtype()]) return Apply(self, [val], [self.rtype()])
......
...@@ -11,9 +11,10 @@ that satisfies the constraints. That's useful for pattern matching. ...@@ -11,9 +11,10 @@ that satisfies the constraints. That's useful for pattern matching.
""" """
from copy import copy from copy import copy
from functools import partial from functools import partial
from theano.gof.utils import ANY_TYPE, comm_guard, FALL_THROUGH
from theano.gof.utils import ANY_TYPE, FALL_THROUGH, comm_guard
################################ ################################
......
import sys
import linecache import linecache
import sys
import traceback import traceback
import numpy as np import numpy as np
from six import integer_types, string_types, with_metaclass from six import integer_types, string_types, with_metaclass
from six.moves import StringIO from six.moves import StringIO
......
...@@ -6,19 +6,18 @@ VM was a better name at some point. ...@@ -6,19 +6,18 @@ VM was a better name at some point.
""" """
import logging import logging
import platform
import sys import sys
import time import time
import warnings import warnings
import platform
import theano.gof.cmodule
from collections import defaultdict from collections import defaultdict
from theano.configparser import config, _config_var_list import theano.gof.cmodule
from theano.configparser import _config_var_list, config
from . import link from . import link
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论