提交 b8d236f1 authored 作者: Reyhane Askari's avatar Reyhane Askari

added warning when Supervisor was not added.

上级 4e8eac00
...@@ -18,7 +18,6 @@ import theano ...@@ -18,7 +18,6 @@ import theano
from theano import config, gof from theano import config, gof
from theano.compat import izip from theano.compat import izip
from theano.gof import graph from theano.gof import graph
import theano.compile.mode
import theano.compile.profiling import theano.compile.profiling
from theano.compile.io import ( from theano.compile.io import (
In, SymbolicInput, SymbolicOutput) In, SymbolicInput, SymbolicOutput)
......
...@@ -4,6 +4,7 @@ WRITEME ...@@ -4,6 +4,7 @@ WRITEME
""" """
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import logging import logging
import warnings
import theano import theano
from theano import gof from theano import gof
...@@ -11,6 +12,7 @@ import theano.gof.vm ...@@ -11,6 +12,7 @@ import theano.gof.vm
from theano.configparser import config from theano.configparser import config
from theano.compile.ops import _output_guard from theano.compile.ops import _output_guard
from six import string_types from six import string_types
from theano.compile.function_module import Supervisor
_logger = logging.getLogger('theano.compile.mode') _logger = logging.getLogger('theano.compile.mode')
...@@ -111,6 +113,16 @@ class AddDestroyHandler(gof.Optimizer): ...@@ -111,6 +113,16 @@ class AddDestroyHandler(gof.Optimizer):
""" """
def apply(self, fgraph): def apply(self, fgraph):
supervisor_added = False
for feature in fgraph._features:
if isinstance(feature, Supervisor):
supervisor_added = True
return
if not supervisor_added:
warnings.warn("WARNING: Supervisor is not added. Please do not"
"use some_op.optimize(fgraph). Instead use theano.function"
"to add the optimiztions.",
stacklevel=3)
for o in fgraph.outputs: for o in fgraph.outputs:
try: try:
fgraph.replace_validate(o, _output_guard(o), fgraph.replace_validate(o, _output_guard(o),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论