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

Refactor __init__ imports and comments in theano and theano.gof sub-packages

These `__init__.py` modules contained multiple confusing import orders and assumed a few indirect imports (e.g. `tensor` in `theano/__init__.py` and `cc` in `theano/gof/__init__.py`) that unnecessarily confounded static analysis tools.
上级 3861b86c
...@@ -30,7 +30,6 @@ __docformat__ = "restructuredtext en" ...@@ -30,7 +30,6 @@ __docformat__ = "restructuredtext en"
import logging import logging
import os import os
import sys import sys
import warnings
theano_logger = logging.getLogger("theano") theano_logger = logging.getLogger("theano")
...@@ -121,20 +120,11 @@ from theano.misc.safe_asarray import _asarray ...@@ -121,20 +120,11 @@ from theano.misc.safe_asarray import _asarray
from theano.printing import pprint, pp from theano.printing import pprint, pp
from theano.scan_module import scan, map, reduce, foldl, foldr, clone, scan_checkpoints from theano import tensor
from theano import scalar
from theano.updates import OrderedUpdates from theano.updates import OrderedUpdates
# scan_module import above initializes tensor and scalar making these imports
# redundant
# import tensor
# import scalar
# we don't import by default as we don't want to force having scipy installed.
# import sparse
from theano.gradient import Rop, Lop, grad, subgraph_grad from theano.gradient import Rop, Lop, grad, subgraph_grad
if ( if (
...@@ -228,4 +218,6 @@ def sparse_grad(var): ...@@ -228,4 +218,6 @@ def sparse_grad(var):
return ret return ret
__import__("theano.tensor.shared_randomstreams") import theano.tensor.shared_randomstreams
from theano.scan_module import scan, map, reduce, foldl, foldr, clone, scan_checkpoints
""" """Graph optimization framework"""
gof.py
gof stands for Graph Optimization Framework.
The gof submodule of theano implements a framework
for manipulating programs described as graphs. The
gof module defines basic theano graph concepts:
-Apply nodes, which represent the application
of an Op to Variables. Together these make up a
graph.
-The Type, needed for Variables to make sense.
-The FunctionGraph, which defines how a subgraph
should be interpreted to implement a function.
-The Thunk, a callable object that becames part
of the executable emitted by theano.
-Linkers/VMs, the objects that call Thunks in
sequence in order to execute a theano program.
Conceptually, gof is intended to be sufficiently abstract
that it could be used to implement a language other than
theano. ie, theano is a domain-specific language for
numerical computation, created by implementing
tensor Variables and Ops that perform mathematical functions.
A different kind of domain-specific language could be
made by using gof with different Variables and Ops.
In practice, gof and the rest of theano are somewhat more
tightly intertwined.
Currently, gof also contains much of the C compilation
functionality. Ideally this should be refactored into
a different submodule.
For more details and discussion, see the theano-dev
e-mail thread "What is gof?".
"""
from theano.gof.cc import CLinker, OpWiseCLinker, DualLinker, HideC from theano.gof.cc import CLinker, OpWiseCLinker, DualLinker, HideC
...@@ -111,4 +75,6 @@ from theano.gof.params_type import ParamsType, Params ...@@ -111,4 +75,6 @@ from theano.gof.params_type import ParamsType, Params
import theano import theano
if theano.config.cmodule.preload_cache: if theano.config.cmodule.preload_cache:
cc.get_module_cache() from theano.gof.cc import get_module_cache
get_module_cache()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论