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

Remove mentions of unimplemented reoptimize_unpickled_function option

上级 c8de0d44
......@@ -378,13 +378,6 @@ def add_basic_configvars():
in_c_key=False,
)
config.add(
"reoptimize_unpickled_function",
"Re-optimize the graph when an Aesara function is unpickled from the disk.",
BoolParam(False, mutable=True),
in_c_key=False,
)
def _is_gt_0(x):
return x > 0
......
......@@ -72,15 +72,6 @@ detection algorithm. If the graph is big enough,we suggest that you use
this flag instead of ``optimizer_excluding=inplace``. It will result in a
computation time that is in between fast compile and fast run.
Aesara flag `reoptimize_unpickled_function` controls if an unpickled
aesara function should reoptimize its graph or not. Aesara users can
use the standard python pickle tools to save a compiled aesara
function. When pickling, both graph before and after the optimization
are saved, including shared variables. When set to True, the graph is
reoptimized when being unpickled. Otherwise, skip the graph
optimization and use directly the optimized graph from the pickled
file. The default is False.
Faster Aesara function
----------------------
......
......@@ -820,12 +820,6 @@ import ``aesara`` and print the config variable, as in:
If ``'True'``, Aesara will include the test values in a variable's
``__str__`` output.
.. attribute:: reoptimize_unpickled_function
Bool value, default: False
When this option is set to ``True``, a graph is re-optimized when unpickled.
.. attribute:: exception_verbosity
String Value: ``'low'``, ``'high'``.
......
......@@ -3,7 +3,6 @@ import pickle
import re
import shutil
import tempfile
from collections import OrderedDict
import numpy as np
import pytest
......@@ -12,13 +11,11 @@ from aesara.compile import shared
from aesara.compile.function import function, function_dump
from aesara.compile.io import In
from aesara.configdefaults import config
from aesara.tensor.math import sum as at_sum
from aesara.tensor.type import (
bscalar,
bvector,
dscalar,
dvector,
fmatrix,
fscalar,
fvector,
vector,
......@@ -236,68 +233,3 @@ class TestFunctionIn:
# If allow_downcast is None, like False
with pytest.raises(TypeError):
f(z, z, [0.1])
def test_pickle_unpickle_with_reoptimization():
mode = config.mode
if mode in ["DEBUG_MODE", "DebugMode"]:
mode = "FAST_RUN"
x1 = fmatrix("x1")
x2 = fmatrix("x2")
x3 = shared(np.ones((10, 10), dtype=floatX))
x4 = shared(np.ones((10, 10), dtype=floatX))
y = at_sum(at_sum(at_sum(x1**2 + x2) + x3) + x4)
updates = OrderedDict()
updates[x3] = x3 + 1
updates[x4] = x4 + 1
f = function([x1, x2], y, updates=updates, mode=mode)
# now pickle the compiled aesara fn
string_pkl = pickle.dumps(f, -1)
in1 = np.ones((10, 10), dtype=floatX)
in2 = np.ones((10, 10), dtype=floatX)
# test unpickle with optimization
default = config.reoptimize_unpickled_function
try:
# the default is True
config.reoptimize_unpickled_function = True
f_ = pickle.loads(string_pkl)
assert f(in1, in2) == f_(in1, in2)
finally:
config.reoptimize_unpickled_function = default
def test_pickle_unpickle_without_reoptimization():
mode = config.mode
if mode in ["DEBUG_MODE", "DebugMode"]:
mode = "FAST_RUN"
x1 = fmatrix("x1")
x2 = fmatrix("x2")
x3 = shared(np.ones((10, 10), dtype=floatX))
x4 = shared(np.ones((10, 10), dtype=floatX))
y = at_sum(at_sum(at_sum(x1**2 + x2) + x3) + x4)
updates = OrderedDict()
updates[x3] = x3 + 1
updates[x4] = x4 + 1
f = function([x1, x2], y, updates=updates, mode=mode)
# now pickle the compiled aesara fn
string_pkl = pickle.dumps(f, -1)
# compute f value
in1 = np.ones((10, 10), dtype=floatX)
in2 = np.ones((10, 10), dtype=floatX)
# test unpickle without optimization
default = config.reoptimize_unpickled_function
try:
# the default is True
config.reoptimize_unpickled_function = False
f_ = pickle.loads(string_pkl)
assert f(in1, in2) == f_(in1, in2)
finally:
config.reoptimize_unpickled_function = default
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论