提交 5bb459cf authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Brandon T. Willard

Migrate all of theano.gof.link to theano.link sub-package

上级 8bf588af
...@@ -11,7 +11,7 @@ purpose of it is to hack it to investigate what your own particular program is d ...@@ -11,7 +11,7 @@ purpose of it is to hack it to investigate what your own particular program is d
.. code-block:: python .. code-block:: python
from theano.gof.link import WrapLinkerMany from theano.link import WrapLinkerMany
from theano import config from theano import config
from theano.compile.mode import (Mode, register_mode, predefined_modes, predefined_linkers, from theano.compile.mode import (Mode, register_mode, predefined_modes, predefined_linkers,
predefined_optimizers) predefined_optimizers)
......
...@@ -5,9 +5,9 @@ import theano ...@@ -5,9 +5,9 @@ import theano
from theano.gof import fg from theano.gof import fg
from theano.gof.cc import CLinker, DualLinker, OpWiseCLinker from theano.gof.cc import CLinker, DualLinker, OpWiseCLinker
from theano.gof.graph import Apply, Constant, Variable from theano.gof.graph import Apply, Constant, Variable
from theano.gof.link import PerformLinker
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.type import Type from theano.gof.type import Type
from theano.link import PerformLinker
def as_variable(x): def as_variable(x):
......
...@@ -5,10 +5,9 @@ import numpy as np ...@@ -5,10 +5,9 @@ import numpy as np
import theano import theano
from theano.gof import fg, graph from theano.gof import fg, graph
from theano.gof.graph import Apply, Constant, Variable from theano.gof.graph import Apply, Constant, Variable
from theano.gof.link import PerformLinker, WrapLinker
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.type import Type from theano.gof.type import Type
from theano.link import Container from theano.link import Container, PerformLinker, WrapLinker
from theano.utils import cmp from theano.utils import cmp
......
...@@ -6,6 +6,7 @@ from tests import unittest_tools as utt ...@@ -6,6 +6,7 @@ from tests import unittest_tools as utt
from theano import config, function, scalar from theano import config, function, scalar
from theano.gof import FunctionGraph from theano.gof import FunctionGraph
from theano.gof.opt import out2in from theano.gof.opt import out2in
from theano.link.basic import PerformLinker
# from theano.tensor import matrix,max_and_argmax,MaaxAndArgmax,neg # from theano.tensor import matrix,max_and_argmax,MaaxAndArgmax,neg
from theano.tensor.elemwise import CAReduce, DimShuffle, Elemwise from theano.tensor.elemwise import CAReduce, DimShuffle, Elemwise
...@@ -158,7 +159,7 @@ def test_local_dimshuffle_alloc(): ...@@ -158,7 +159,7 @@ def test_local_dimshuffle_alloc():
g = FunctionGraph([x], [out]) g = FunctionGraph([x], [out])
reshape_dimshuffle(g) reshape_dimshuffle(g)
l = theano.gof.PerformLinker() l = PerformLinker()
l.accept(g) l.accept(g)
f = l.make_function() f = l.make_function()
......
...@@ -28,7 +28,8 @@ from theano.compile.function.types import ( ...@@ -28,7 +28,8 @@ from theano.compile.function.types import (
from theano.compile.mode import Mode, register_mode from theano.compile.mode import Mode, register_mode
from theano.compile.ops import OutputGuard, _output_guard from theano.compile.ops import OutputGuard, _output_guard
from theano.gof import graph, ops_with_inner_function, utils from theano.gof import graph, ops_with_inner_function, utils
from theano.gof.link import raise_with_op from theano.link.basic import LocalLinker
from theano.link.debugging import raise_with_op
from theano.utils import get_unbound_function from theano.utils import get_unbound_function
...@@ -1739,14 +1740,14 @@ class _DummyLinker: ...@@ -1739,14 +1740,14 @@ class _DummyLinker:
return self return self
class _Linker(link.LocalLinker): class _Linker(LocalLinker):
""" """
Special debugging linker. Special debugging linker.
""" """
def __init__(self, maker, schedule=None): def __init__(self, maker, schedule=None):
super(gof.LocalLinker, self).__init__() super().__init__()
self.fgraph = None self.fgraph = None
self.maker = maker self.maker = maker
super().__init__(scheduler=schedule) super().__init__(scheduler=schedule)
...@@ -1792,7 +1793,7 @@ class _Linker(link.LocalLinker): ...@@ -1792,7 +1793,7 @@ class _Linker(link.LocalLinker):
# the function's outputs will always be freshly allocated. # the function's outputs will always be freshly allocated.
no_recycling = [] no_recycling = []
input_storage, output_storage, storage_map = theano.gof.link.map_storage( input_storage, output_storage, storage_map = theano.link.map_storage(
fgraph, order, input_storage_, output_storage_, storage_map fgraph, order, input_storage_, output_storage_, storage_map
) )
......
...@@ -15,7 +15,7 @@ import numpy as np ...@@ -15,7 +15,7 @@ import numpy as np
import theano import theano
import theano.compile.profiling import theano.compile.profiling
from theano import config, gof from theano import config, gof, link
from theano.compile.io import In, SymbolicInput, SymbolicOutput from theano.compile.io import In, SymbolicInput, SymbolicOutput
from theano.compile.ops import deep_copy_op, view_op from theano.compile.ops import deep_copy_op, view_op
from theano.gof import graph from theano.gof import graph
...@@ -978,7 +978,7 @@ class Function: ...@@ -978,7 +978,7 @@ class Function:
thunk = None thunk = None
if hasattr(self.fn, "thunks"): if hasattr(self.fn, "thunks"):
thunk = self.fn.thunks[self.fn.position_of_error] thunk = self.fn.thunks[self.fn.position_of_error]
gof.link.raise_with_op( link.raise_with_op(
self.maker.fgraph, self.maker.fgraph,
node=self.fn.nodes[self.fn.position_of_error], node=self.fn.nodes[self.fn.position_of_error],
thunk=thunk, thunk=thunk,
......
...@@ -5,7 +5,6 @@ from theano.gof.cc import CLinker, DualLinker, HideC, OpWiseCLinker ...@@ -5,7 +5,6 @@ from theano.gof.cc import CLinker, DualLinker, HideC, OpWiseCLinker
from theano.gof.destroyhandler import DestroyHandler from theano.gof.destroyhandler import DestroyHandler
from theano.gof.fg import FunctionGraph, InconsistencyError, MissingInputError from theano.gof.fg import FunctionGraph, InconsistencyError, MissingInputError
from theano.gof.graph import Apply, Constant, Variable, view_roots from theano.gof.graph import Apply, Constant, Variable, view_roots
from theano.gof.link import PerformLinker, WrapLinker, WrapLinkerMany
from theano.gof.op import ( from theano.gof.op import (
COp, COp,
Op, Op,
...@@ -47,7 +46,14 @@ from theano.gof.toolbox import ( ...@@ -47,7 +46,14 @@ from theano.gof.toolbox import (
) )
from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic
from theano.gof.utils import MethodNotDefined, hashtype, object2 from theano.gof.utils import MethodNotDefined, hashtype, object2
from theano.link import Container, Linker, LocalLinker from theano.link import (
Container,
Linker,
LocalLinker,
PerformLinker,
WrapLinker,
WrapLinkerMany,
)
if theano.config.cmodule__preload_cache: if theano.config.cmodule__preload_cache:
......
...@@ -11,8 +11,8 @@ from io import StringIO ...@@ -11,8 +11,8 @@ from io import StringIO
import numpy as np import numpy as np
from theano import config from theano import config, link
from theano.gof import cmodule, graph, link, utils from theano.gof import cmodule, graph, utils
from theano.gof.callcache import CallCache from theano.gof.callcache import CallCache
from theano.gof.compilelock import get_lock, release_lock from theano.gof.compilelock import get_lock, release_lock
......
...@@ -13,9 +13,7 @@ import warnings ...@@ -13,9 +13,7 @@ import warnings
from collections import defaultdict from collections import defaultdict
import theano.gof.cmodule import theano.gof.cmodule
from theano import config from theano import config, link
from . import link
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
from theano.link.basic import Container, Linker, LocalLinker import sys
from theano.link.basic import (
Container,
Linker,
LocalLinker,
PerformLinker,
WrapLinker,
WrapLinkerMany,
gc_helper,
map_storage,
streamline,
)
from theano.link.debugging import raise_with_op, set_excepthook
set_excepthook(handler=sys.stdout)
差异被折叠。
...@@ -3,14 +3,14 @@ from warnings import warn ...@@ -3,14 +3,14 @@ from warnings import warn
from theano.gof import utils from theano.gof import utils
from theano.gof.graph import Constant from theano.gof.graph import Constant
from theano.gof.link import ( from theano.link.basic import (
Container,
PerformLinker, PerformLinker,
add_clear_storage, add_clear_storage,
gc_helper, gc_helper,
map_storage, map_storage,
streamline, streamline,
) )
from theano.link import Container
class JAXLinker(PerformLinker): class JAXLinker(PerformLinker):
......
...@@ -53,7 +53,7 @@ from collections import OrderedDict ...@@ -53,7 +53,7 @@ from collections import OrderedDict
import numpy as np import numpy as np
import theano import theano
from theano import compile, config, gof, gradient, tensor from theano import compile, config, gof, gradient, link, tensor
from theano.compile.builders import infer_shape from theano.compile.builders import infer_shape
from theano.compile.function import function from theano.compile.function import function
from theano.compile.io import In, Out from theano.compile.io import In, Out
...@@ -1465,7 +1465,7 @@ class Scan(PureOp): ...@@ -1465,7 +1465,7 @@ class Scan(PureOp):
# done by raise_with_op is not implemented in C. # done by raise_with_op is not implemented in C.
if hasattr(fn, "thunks"): if hasattr(fn, "thunks"):
# For the CVM # For the CVM
gof.link.raise_with_op( link.raise_with_op(
self.fn.maker.fgraph, self.fn.maker.fgraph,
fn.nodes[fn.position_of_error], fn.nodes[fn.position_of_error],
fn.thunks[fn.position_of_error], fn.thunks[fn.position_of_error],
...@@ -1475,7 +1475,7 @@ class Scan(PureOp): ...@@ -1475,7 +1475,7 @@ class Scan(PureOp):
# We don't have access from python to all the # We don't have access from python to all the
# temps values So for now, we just don't print # temps values So for now, we just don't print
# the extra shapes/strides info # the extra shapes/strides info
gof.link.raise_with_op( link.raise_with_op(
self.fn.maker.fgraph, fn.nodes[fn.position_of_error] self.fn.maker.fgraph, fn.nodes[fn.position_of_error]
) )
else: else:
......
...@@ -61,7 +61,7 @@ cimport numpy ...@@ -61,7 +61,7 @@ cimport numpy
import copy import copy
import time import time
from theano import gof from theano import gof, link
def get_version(): def get_version():
...@@ -405,7 +405,7 @@ def perform( ...@@ -405,7 +405,7 @@ def perform(
# done by raise_with_op is not implemented in C. # done by raise_with_op is not implemented in C.
if hasattr(fn, 'thunks'): if hasattr(fn, 'thunks'):
# For the CVM # For the CVM
gof.link.raise_with_op(fn.maker.fgraph, link.raise_with_op(fn.maker.fgraph,
fn.nodes[fn.position_of_error], fn.nodes[fn.position_of_error],
fn.thunks[fn.position_of_error]) fn.thunks[fn.position_of_error])
else: else:
...@@ -413,7 +413,7 @@ def perform( ...@@ -413,7 +413,7 @@ def perform(
# We don't have access from python to all the # We don't have access from python to all the
# temps values So for now, we just don't print # temps values So for now, we just don't print
# the extra shapes/strides info # the extra shapes/strides info
gof.link.raise_with_op(fn.maker.fgraph, fn.nodes[fn.position_of_error]) link.raise_with_op(fn.maker.fgraph, fn.nodes[fn.position_of_error])
else: else:
# old-style linkers raise their own exceptions # old-style linkers raise their own exceptions
raise raise
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论