提交 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
.. code-block:: python
from theano.gof.link import WrapLinkerMany
from theano.link import WrapLinkerMany
from theano import config
from theano.compile.mode import (Mode, register_mode, predefined_modes, predefined_linkers,
predefined_optimizers)
......
......@@ -5,9 +5,9 @@ import theano
from theano.gof import fg
from theano.gof.cc import CLinker, DualLinker, OpWiseCLinker
from theano.gof.graph import Apply, Constant, Variable
from theano.gof.link import PerformLinker
from theano.gof.op import Op
from theano.gof.type import Type
from theano.link import PerformLinker
def as_variable(x):
......
......@@ -5,10 +5,9 @@ import numpy as np
import theano
from theano.gof import fg, graph
from theano.gof.graph import Apply, Constant, Variable
from theano.gof.link import PerformLinker, WrapLinker
from theano.gof.op import Op
from theano.gof.type import Type
from theano.link import Container
from theano.link import Container, PerformLinker, WrapLinker
from theano.utils import cmp
......
......@@ -6,6 +6,7 @@ from tests import unittest_tools as utt
from theano import config, function, scalar
from theano.gof import FunctionGraph
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.elemwise import CAReduce, DimShuffle, Elemwise
......@@ -158,7 +159,7 @@ def test_local_dimshuffle_alloc():
g = FunctionGraph([x], [out])
reshape_dimshuffle(g)
l = theano.gof.PerformLinker()
l = PerformLinker()
l.accept(g)
f = l.make_function()
......
......@@ -28,7 +28,8 @@ from theano.compile.function.types import (
from theano.compile.mode import Mode, register_mode
from theano.compile.ops import OutputGuard, _output_guard
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
......@@ -1739,14 +1740,14 @@ class _DummyLinker:
return self
class _Linker(link.LocalLinker):
class _Linker(LocalLinker):
"""
Special debugging linker.
"""
def __init__(self, maker, schedule=None):
super(gof.LocalLinker, self).__init__()
super().__init__()
self.fgraph = None
self.maker = maker
super().__init__(scheduler=schedule)
......@@ -1792,7 +1793,7 @@ class _Linker(link.LocalLinker):
# the function's outputs will always be freshly allocated.
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
)
......
......@@ -15,7 +15,7 @@ import numpy as np
import theano
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.ops import deep_copy_op, view_op
from theano.gof import graph
......@@ -978,7 +978,7 @@ class Function:
thunk = None
if hasattr(self.fn, "thunks"):
thunk = self.fn.thunks[self.fn.position_of_error]
gof.link.raise_with_op(
link.raise_with_op(
self.maker.fgraph,
node=self.fn.nodes[self.fn.position_of_error],
thunk=thunk,
......
......@@ -5,7 +5,6 @@ from theano.gof.cc import CLinker, DualLinker, HideC, OpWiseCLinker
from theano.gof.destroyhandler import DestroyHandler
from theano.gof.fg import FunctionGraph, InconsistencyError, MissingInputError
from theano.gof.graph import Apply, Constant, Variable, view_roots
from theano.gof.link import PerformLinker, WrapLinker, WrapLinkerMany
from theano.gof.op import (
COp,
Op,
......@@ -47,7 +46,14 @@ from theano.gof.toolbox import (
)
from theano.gof.type import CEnumType, EnumList, EnumType, Generic, Type, generic
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:
......
......@@ -11,8 +11,8 @@ from io import StringIO
import numpy as np
from theano import config
from theano.gof import cmodule, graph, link, utils
from theano import config, link
from theano.gof import cmodule, graph, utils
from theano.gof.callcache import CallCache
from theano.gof.compilelock import get_lock, release_lock
......
......@@ -13,9 +13,7 @@ import warnings
from collections import defaultdict
import theano.gof.cmodule
from theano import config
from . import link
from theano import config, link
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
from theano.gof import utils
from theano.gof.graph import Constant
from theano.gof.link import (
from theano.link.basic import (
Container,
PerformLinker,
add_clear_storage,
gc_helper,
map_storage,
streamline,
)
from theano.link import Container
class JAXLinker(PerformLinker):
......
......@@ -53,7 +53,7 @@ from collections import OrderedDict
import numpy as np
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.function import function
from theano.compile.io import In, Out
......@@ -1465,7 +1465,7 @@ class Scan(PureOp):
# done by raise_with_op is not implemented in C.
if hasattr(fn, "thunks"):
# For the CVM
gof.link.raise_with_op(
link.raise_with_op(
self.fn.maker.fgraph,
fn.nodes[fn.position_of_error],
fn.thunks[fn.position_of_error],
......@@ -1475,7 +1475,7 @@ class Scan(PureOp):
# We don't have access from python to all the
# temps values So for now, we just don't print
# the extra shapes/strides info
gof.link.raise_with_op(
link.raise_with_op(
self.fn.maker.fgraph, fn.nodes[fn.position_of_error]
)
else:
......
......@@ -61,7 +61,7 @@ cimport numpy
import copy
import time
from theano import gof
from theano import gof, link
def get_version():
......@@ -405,7 +405,7 @@ def perform(
# done by raise_with_op is not implemented in C.
if hasattr(fn, 'thunks'):
# 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.thunks[fn.position_of_error])
else:
......@@ -413,7 +413,7 @@ def perform(
# We don't have access from python to all the
# temps values So for now, we just don't print
# 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:
# old-style linkers raise their own exceptions
raise
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论