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

Remove automatic package-level imports from theano.link

上级 1d5236be
......@@ -73,7 +73,7 @@ extracted from the Mode. It is then called with the FunctionGraph as
argument to
produce a ``thunk``, which is a function with no arguments that
returns nothing. Along with the thunk, one list of input containers (a
theano.link.Container is a sort of object that wraps another and does
theano.link.basic.Container is a sort of object that wraps another and does
type casting) and one list of output containers are produced,
corresponding to the input and output Variables as well as the updates
defined for the inputs when applicable. To perform the computations,
......
......@@ -114,8 +114,8 @@ from theano.gof import (
utils,
)
from theano.gradient import Lop, Rop, grad, subgraph_grad
from theano.link import Container, Linker, LocalLinker, PerformLinker
from theano.link.c import CLinker, DualLinker, OpWiseCLinker
from theano.link.basic import Container, Linker, LocalLinker, PerformLinker
from theano.link.c.cc import CLinker, DualLinker, OpWiseCLinker
from theano.misc.safe_asarray import _asarray
from theano.printing import pp, pprint
from theano.updates import OrderedUpdates
......
......@@ -18,7 +18,7 @@ from warnings import warn
import numpy as np
import theano
from theano import config, gof, link
from theano import config, gof
from theano.compile.function.types import (
Function,
FunctionMaker,
......@@ -28,8 +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.link.basic import LocalLinker
from theano.link.utils import raise_with_op
from theano.link.basic import Container, LocalLinker
from theano.link.utils import map_storage, raise_with_op
from theano.utils import get_unbound_function
......@@ -1793,7 +1793,7 @@ class _Linker(LocalLinker):
# the function's outputs will always be freshly allocated.
no_recycling = []
input_storage, output_storage, storage_map = theano.link.map_storage(
input_storage, output_storage, storage_map = map_storage(
fgraph, order, input_storage_, output_storage_, storage_map
)
......@@ -2341,11 +2341,11 @@ class _Linker(LocalLinker):
return (
f,
[
link.Container(input, storage, readonly=False)
Container(input, storage, readonly=False)
for input, storage in zip(fgraph.inputs, input_storage)
],
[
link.Container(output, storage, readonly=True)
Container(output, storage, readonly=True)
for output, storage in zip(fgraph.outputs, output_storage)
],
thunks_py,
......@@ -2566,7 +2566,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
self.refeed = [
(
i.value is not None
and not isinstance(i.value, link.Container)
and not isinstance(i.value, Container)
and i.update is None
)
for i in self.inputs
......
......@@ -15,12 +15,14 @@ import numpy as np
import theano
import theano.compile.profiling
from theano import config, gof, link
from theano import config, gof
from theano.compile.io import In, SymbolicInput, SymbolicOutput
from theano.compile.ops import deep_copy_op, view_op
from theano.gof import graph
from theano.gof.op import ops_with_inner_function
from theano.gof.toolbox import is_same_graph
from theano.link.basic import Container
from theano.link.utils import raise_with_op
_logger = logging.getLogger("theano.compile.function.types")
......@@ -440,7 +442,7 @@ class Function:
if value is not None:
# Always initialize the storage.
if isinstance(value, link.Container):
if isinstance(value, Container):
# There is no point in obtaining the current value
# stored in the container, since the container is
# shared.
......@@ -485,7 +487,7 @@ class Function:
"names of the inputs of your function "
"for duplicates."
)
if isinstance(s, link.Container):
if isinstance(s, Container):
return s.value
else:
raise NotImplementedError
......@@ -503,7 +505,7 @@ class Function:
"names of the inputs of your function "
"for duplicates."
)
if isinstance(s, link.Container):
if isinstance(s, Container):
s.value = value
s.provided += 1
else:
......@@ -812,7 +814,7 @@ class Function:
def restore_defaults():
for i, (required, refeed, value) in enumerate(self.defaults):
if refeed:
if isinstance(value, link.Container):
if isinstance(value, Container):
value = value.storage[0]
self[i] = value
......@@ -978,7 +980,7 @@ class Function:
thunk = None
if hasattr(self.fn, "thunks"):
thunk = self.fn.thunks[self.fn.position_of_error]
link.raise_with_op(
raise_with_op(
self.maker.fgraph,
node=self.fn.nodes[self.fn.position_of_error],
thunk=thunk,
......@@ -1679,7 +1681,7 @@ class FunctionMaker:
self.refeed = [
(
i.value is not None
and not isinstance(i.value, link.Container)
and not isinstance(i.value, Container)
and i.update is None
)
for i in self.inputs
......@@ -1772,8 +1774,8 @@ class FunctionMaker:
if isinstance(input_storage_i, gof.Variable):
input_storage_i = input_storage_i.container
if isinstance(input_storage_i, link.Container):
# If the default is a link.Container, this means we want to
if isinstance(input_storage_i, Container):
# If the default is a Container, this means we want to
# share the same storage. This is done by appending
# input_storage_i.storage to input_storage_lists.
if indices is not None:
......
......@@ -6,7 +6,7 @@ Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out`.
import logging
from theano import link
from theano.link.basic import Container
_logger = logging.getLogger("theano.compile.io")
......@@ -208,9 +208,7 @@ class In(SymbolicInput):
if implicit is None:
from theano.compile.sharedvalue import SharedVariable
implicit = isinstance(value, link.Container) or isinstance(
value, SharedVariable
)
implicit = isinstance(value, Container) or isinstance(value, SharedVariable)
super().__init__(
variable=variable,
name=name,
......
......@@ -11,7 +11,7 @@ import numpy as np
from theano.gof.graph import Variable
from theano.gof.type import generic
from theano.gof.utils import add_tag_trace
from theano.link import Container
from theano.link.basic import Container
_logger = logging.getLogger("theano.compile.sharedvalue")
......
from theano.link.basic import (
Container,
Linker,
LocalLinker,
PerformLinker,
WrapLinker,
WrapLinkerMany,
)
from theano.link.utils import gc_helper, map_storage, raise_with_op, streamline

\ No newline at end of file
from theano.link.c.cc import CLinker, DualLinker, OpWiseCLinker
......@@ -3,7 +3,8 @@ from warnings import warn
from theano.gof import utils
from theano.gof.graph import Constant
from theano.link import Container, PerformLinker, gc_helper, map_storage, streamline
from theano.link.basic import Container, PerformLinker
from theano.link.utils import gc_helper, map_storage, streamline
class JAXLinker(PerformLinker):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论