提交 44e57b3c authored 作者: David Warde-Farley's avatar David Warde-Farley

Merge pull request #752 from goodfeli/rename_env

Rename env
......@@ -36,32 +36,32 @@ Here is an overview of the various steps that are done with the
computation graph in the compilation phase:
Step 1 - Create an Env
Step 1 - Create a FunctionGraph
^^^^^^^^^^^^^^^^^^^^^^
The subgraph given by the end user is wrapped in a structure called
*Env*. That structure defines several hooks on adding and
*FunctionGraph*. That structure defines several hooks on adding and
removing (pruning) nodes as well as on modifying links between nodes
(for example, modifying an input of an :ref:`apply` node) (see the
article about :ref:`libdoc_gof_env` for more information).
Env provides a method to change the input of an Apply node from one
FunctionGraph provides a method to change the input of an Apply node from one
Variable to another and a more high-level method to replace a Variable
with another. This is the structure that :ref:`Optimizers
<optimization>` work on.
Some relevant :ref:`Features <libdoc_gof_envfeature>` are typically added to the
Env, namely to prevent any optimization from operating inplace on
FunctionGraph, namely to prevent any optimization from operating inplace on
inputs declared as immutable.
Step 2 - Execute main Optimizer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the Env is made, an :term:`optimizer` is produced
Once the FunctionGraph is made, an :term:`optimizer` is produced
by the :term:`mode` passed to ``function`` or to the Method/Module's
``make`` (the Mode basically has two important fields, ``linker`` and
``optimizer``). That optimizer is applied on the Env using its
``optimizer``). That optimizer is applied on the FunctionGraph using its
optimize() method.
The optimizer is typically obtained through :attr:`optdb`.
......@@ -71,7 +71,8 @@ Step 3 - Execute linker to obtain a thunk
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the computation graph is optimized, the :term:`linker` is
extracted from the Mode. It is then called with the Env as argument to
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.gof.Container is a sort of object that wraps another and does
......
......@@ -13,7 +13,7 @@ import numpy
import theano
from theano import gof
from theano.gof import Env, graph, utils, link, ops_with_inner_function
from theano.gof import FunctionGraph as Env, graph, utils, link, ops_with_inner_function
from theano.gof.link import raise_with_op
from theano.gof.cc import CLinker
from theano.gof.python25 import all, any, product as itertools_product
......@@ -667,7 +667,7 @@ def _optcheck_env(input_specs, output_specs, accept_inplace=False):
inputs, outputs = gof.graph.clone(orig_inputs, orig_outputs)
equivalence_tracker = _VariableEquivalenceTracker()
env = gof.env.Env(inputs, outputs,
env = gof.fg.FunctionGraph(inputs, outputs,
#DestroyHandler is not needed because it is actually installed by an optimization
# after canonicalization. This variables in a big speed gain.
#features=[equivalence_tracker, gof.DestroyHandler(do_imports_on_attach=False)])
......
......@@ -129,7 +129,7 @@ def std_env(input_specs, output_specs, accept_inplace = False):
orig_outputs = [spec.variable for spec in output_specs] + updates
inputs, outputs = gof.graph.clone(orig_inputs, orig_outputs)
env = gof.env.Env(inputs, outputs)
env = gof.fg.FunctionGraph(inputs, outputs)
for node in env.nodes:
if getattr(node.op, 'destroy_map', None):
......
......@@ -42,8 +42,10 @@ from cc import \
import compiledir # adds config vars
from env import \
InconsistencyError, MissingInputError, Env
from fg import \
InconsistencyError, MissingInputError, FunctionGraph
#deprecated alias to support code written with old name
Env = FunctionGraph
from destroyhandler import \
DestroyHandler
......
......@@ -10,7 +10,7 @@ import toolbox
import graph
from theano.gof.python25 import deque
from env import InconsistencyError
from fg import InconsistencyError
class ProtocolError(Exception):
"""WRITEME"""
......
......@@ -21,7 +21,7 @@ from theano import config
import cc
import graph
import utils
from env import Env
from fg import FunctionGraph as Env
class CLinkerObject(object):
......
......@@ -11,7 +11,7 @@ import time
import numpy
import graph
from env import InconsistencyError
from fg import InconsistencyError
import op
import utils
import unify
......@@ -598,7 +598,7 @@ def is_same_graph_with_merge(var1, var2, givens=None):
givens = copied[2]
# Create Env.
inputs = theano.gof.graph.inputs(vars)
env = theano.gof.env.Env(inputs, vars)
env = theano.gof.fg.FunctionGraph(inputs, vars)
# Perform Variable substitution.
for to_replace, replace_by in givens.iteritems():
env.replace(to_replace, replace_by)
......
......@@ -6,7 +6,8 @@ from theano.gof.cc import *
from theano.gof.type import Type
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.op import Op
from theano.gof import env
from theano.gof import fg
env = fg
from theano.gof import toolbox
......@@ -171,7 +172,7 @@ def inputs():
def Env(inputs, outputs):
e = env.Env(inputs, outputs)
e = fg.FunctionGraph(inputs, outputs)
return e
......
......@@ -8,7 +8,7 @@ from theano.gof.op import Op
from theano.gof.opt import *
from theano.gof import destroyhandler
from theano.gof.env import Env, InconsistencyError
from theano.gof.fg import FunctionGraph as Env, InconsistencyError
from theano.gof.toolbox import ReplaceValidate
from copy import copy
......
......@@ -4,7 +4,7 @@ from theano.gof import graph
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.type import Type
from theano.gof.op import Op
from theano.gof import env
from theano.gof import fg
from theano.gof import toolbox
from theano.gof.link import *
......@@ -75,7 +75,7 @@ def perform_linker(env):
def Env(inputs, outputs):
e = env.Env(inputs, outputs)
e = fg.FunctionGraph(inputs, outputs)
return e
......
......@@ -3,7 +3,7 @@ from theano.gof.type import Type
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.op import Op
from theano.gof.opt import *
from theano.gof.env import Env
from theano.gof.fg import FunctionGraph as Env
from theano.gof.toolbox import *
......
......@@ -3,7 +3,7 @@ from theano.gof.graph import Variable, Apply
from theano.gof.type import Type
from theano.gof.op import Op
from theano.gof.env import Env, InconsistencyError
from theano.gof.fg import FunctionGraph as Env, InconsistencyError
from theano.gof.toolbox import *
......@@ -85,4 +85,4 @@ class TestNodeFinder:
raise Exception("Expected: %i times %s" % (num, type))
......@@ -3,7 +3,7 @@ from theano.gof.type import Type
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.op import Op
from theano.gof.opt import *
from theano.gof.env import Env
from theano.gof.fg import FunctionGraph as Env
from theano.gof.toolbox import *
import theano.tensor.basic as T
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论