提交 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 ...@@ -73,7 +73,7 @@ extracted from the Mode. It is then called with the FunctionGraph as
argument to argument to
produce a ``thunk``, which is a function with no arguments that produce a ``thunk``, which is a function with no arguments that
returns nothing. Along with the thunk, one list of input containers (a 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, type casting) and one list of output containers are produced,
corresponding to the input and output Variables as well as the updates corresponding to the input and output Variables as well as the updates
defined for the inputs when applicable. To perform the computations, defined for the inputs when applicable. To perform the computations,
......
...@@ -114,8 +114,8 @@ from theano.gof import ( ...@@ -114,8 +114,8 @@ from theano.gof import (
utils, utils,
) )
from theano.gradient import Lop, Rop, grad, subgraph_grad from theano.gradient import Lop, Rop, grad, subgraph_grad
from theano.link import Container, Linker, LocalLinker, PerformLinker from theano.link.basic import Container, Linker, LocalLinker, PerformLinker
from theano.link.c import CLinker, DualLinker, OpWiseCLinker from theano.link.c.cc import CLinker, DualLinker, OpWiseCLinker
from theano.misc.safe_asarray import _asarray from theano.misc.safe_asarray import _asarray
from theano.printing import pp, pprint from theano.printing import pp, pprint
from theano.updates import OrderedUpdates from theano.updates import OrderedUpdates
......
...@@ -18,7 +18,7 @@ from warnings import warn ...@@ -18,7 +18,7 @@ from warnings import warn
import numpy as np import numpy as np
import theano import theano
from theano import config, gof, link from theano import config, gof
from theano.compile.function.types import ( from theano.compile.function.types import (
Function, Function,
FunctionMaker, FunctionMaker,
...@@ -28,8 +28,8 @@ from theano.compile.function.types import ( ...@@ -28,8 +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.link.basic import LocalLinker from theano.link.basic import Container, LocalLinker
from theano.link.utils import raise_with_op from theano.link.utils import map_storage, raise_with_op
from theano.utils import get_unbound_function from theano.utils import get_unbound_function
...@@ -1793,7 +1793,7 @@ class _Linker(LocalLinker): ...@@ -1793,7 +1793,7 @@ class _Linker(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.link.map_storage( input_storage, output_storage, storage_map = map_storage(
fgraph, order, input_storage_, output_storage_, storage_map fgraph, order, input_storage_, output_storage_, storage_map
) )
...@@ -2341,11 +2341,11 @@ class _Linker(LocalLinker): ...@@ -2341,11 +2341,11 @@ class _Linker(LocalLinker):
return ( return (
f, f,
[ [
link.Container(input, storage, readonly=False) Container(input, storage, readonly=False)
for input, storage in zip(fgraph.inputs, input_storage) 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) for output, storage in zip(fgraph.outputs, output_storage)
], ],
thunks_py, thunks_py,
...@@ -2566,7 +2566,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2566,7 +2566,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
self.refeed = [ self.refeed = [
( (
i.value is not None i.value is not None
and not isinstance(i.value, link.Container) and not isinstance(i.value, Container)
and i.update is None and i.update is None
) )
for i in self.inputs for i in self.inputs
......
...@@ -15,12 +15,14 @@ import numpy as np ...@@ -15,12 +15,14 @@ import numpy as np
import theano import theano
import theano.compile.profiling 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.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
from theano.gof.op import ops_with_inner_function from theano.gof.op import ops_with_inner_function
from theano.gof.toolbox import is_same_graph 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") _logger = logging.getLogger("theano.compile.function.types")
...@@ -440,7 +442,7 @@ class Function: ...@@ -440,7 +442,7 @@ class Function:
if value is not None: if value is not None:
# Always initialize the storage. # Always initialize the storage.
if isinstance(value, link.Container): if isinstance(value, Container):
# There is no point in obtaining the current value # There is no point in obtaining the current value
# stored in the container, since the container is # stored in the container, since the container is
# shared. # shared.
...@@ -485,7 +487,7 @@ class Function: ...@@ -485,7 +487,7 @@ class Function:
"names of the inputs of your function " "names of the inputs of your function "
"for duplicates." "for duplicates."
) )
if isinstance(s, link.Container): if isinstance(s, Container):
return s.value return s.value
else: else:
raise NotImplementedError raise NotImplementedError
...@@ -503,7 +505,7 @@ class Function: ...@@ -503,7 +505,7 @@ class Function:
"names of the inputs of your function " "names of the inputs of your function "
"for duplicates." "for duplicates."
) )
if isinstance(s, link.Container): if isinstance(s, Container):
s.value = value s.value = value
s.provided += 1 s.provided += 1
else: else:
...@@ -812,7 +814,7 @@ class Function: ...@@ -812,7 +814,7 @@ class Function:
def restore_defaults(): def restore_defaults():
for i, (required, refeed, value) in enumerate(self.defaults): for i, (required, refeed, value) in enumerate(self.defaults):
if refeed: if refeed:
if isinstance(value, link.Container): if isinstance(value, Container):
value = value.storage[0] value = value.storage[0]
self[i] = value self[i] = value
...@@ -978,7 +980,7 @@ class Function: ...@@ -978,7 +980,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]
link.raise_with_op( 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,
...@@ -1679,7 +1681,7 @@ class FunctionMaker: ...@@ -1679,7 +1681,7 @@ class FunctionMaker:
self.refeed = [ self.refeed = [
( (
i.value is not None i.value is not None
and not isinstance(i.value, link.Container) and not isinstance(i.value, Container)
and i.update is None and i.update is None
) )
for i in self.inputs for i in self.inputs
...@@ -1772,8 +1774,8 @@ class FunctionMaker: ...@@ -1772,8 +1774,8 @@ class FunctionMaker:
if isinstance(input_storage_i, gof.Variable): if isinstance(input_storage_i, gof.Variable):
input_storage_i = input_storage_i.container input_storage_i = input_storage_i.container
if isinstance(input_storage_i, link.Container): if isinstance(input_storage_i, Container):
# If the default is a link.Container, this means we want to # If the default is a Container, this means we want to
# share the same storage. This is done by appending # share the same storage. This is done by appending
# input_storage_i.storage to input_storage_lists. # input_storage_i.storage to input_storage_lists.
if indices is not None: if indices is not None:
......
...@@ -6,7 +6,7 @@ Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out`. ...@@ -6,7 +6,7 @@ Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out`.
import logging import logging
from theano import link from theano.link.basic import Container
_logger = logging.getLogger("theano.compile.io") _logger = logging.getLogger("theano.compile.io")
...@@ -208,9 +208,7 @@ class In(SymbolicInput): ...@@ -208,9 +208,7 @@ class In(SymbolicInput):
if implicit is None: if implicit is None:
from theano.compile.sharedvalue import SharedVariable from theano.compile.sharedvalue import SharedVariable
implicit = isinstance(value, link.Container) or isinstance( implicit = isinstance(value, Container) or isinstance(value, SharedVariable)
value, SharedVariable
)
super().__init__( super().__init__(
variable=variable, variable=variable,
name=name, name=name,
......
...@@ -11,7 +11,7 @@ import numpy as np ...@@ -11,7 +11,7 @@ import numpy as np
from theano.gof.graph import Variable from theano.gof.graph import Variable
from theano.gof.type import generic from theano.gof.type import generic
from theano.gof.utils import add_tag_trace 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") _logger = logging.getLogger("theano.compile.sharedvalue")
......
from theano.link.basic import ( 
Container, \ No newline at end of file
Linker,
LocalLinker,
PerformLinker,
WrapLinker,
WrapLinkerMany,
)
from theano.link.utils import gc_helper, map_storage, raise_with_op, streamline
from theano.link.c.cc import CLinker, DualLinker, OpWiseCLinker
...@@ -3,7 +3,8 @@ from warnings import warn ...@@ -3,7 +3,8 @@ 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.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): class JAXLinker(PerformLinker):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论