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

Fix comments and add some type annotations to aesara.compile.function.pfunc

上级 e588b752
...@@ -5,7 +5,7 @@ Provide a simple user friendly API. ...@@ -5,7 +5,7 @@ Provide a simple user friendly API.
import logging import logging
from aesara.compile.function.types import UnusedInputError, orig_function from aesara.compile.function.types import Function, UnusedInputError, orig_function
from aesara.compile.io import In, Out from aesara.compile.io import In, Out
from aesara.compile.profiling import ProfileStats from aesara.compile.profiling import ProfileStats
from aesara.compile.sharedvalue import SharedVariable, shared from aesara.compile.sharedvalue import SharedVariable, shared
...@@ -27,8 +27,7 @@ def rebuild_collect_shared( ...@@ -27,8 +27,7 @@ def rebuild_collect_shared(
copy_inputs_over=True, copy_inputs_over=True,
no_default_updates=False, no_default_updates=False,
): ):
""" """Replace subgraphs of a computational graph.
Function that allows replacing subgraphs of a computational graph.
It returns a set of dictionaries and lists which collect (partial?) It returns a set of dictionaries and lists which collect (partial?)
different information about shared variables. This info is required by different information about shared variables. This info is required by
...@@ -280,7 +279,7 @@ def pfunc( ...@@ -280,7 +279,7 @@ def pfunc(
profile=None, profile=None,
on_unused_input=None, on_unused_input=None,
output_keys=None, output_keys=None,
): ) -> Function:
""" """
Function-constructor for graphs with shared variables. Function-constructor for graphs with shared variables.
...@@ -328,33 +327,27 @@ def pfunc( ...@@ -328,33 +327,27 @@ def pfunc(
Returns Returns
------- -------
aesara.compile.Function A callable object that will compute the outputs (given the inputs) and
A callable object that will compute the outputs (given the inputs) and update the implicit function arguments according to the `updates`.
update the implicit function arguments according to the `updates`.
Notes Notes
----- -----
Regarding givens: Be careful to make sure that these substitutions are Regarding givens: Be careful to make sure that these substitutions are
independent--behaviour when Var1 of one pair appears in the graph leading independent--behaviour when ``Var1`` of one pair appears in the graph leading
to Var2 in another expression is undefined. Replacements specified with to ``Var2`` in another expression is undefined. Replacements specified with
givens are different from optimizations in that Var2 is not expected to be givens are different from optimizations in that ``Var2`` is not expected to
equivalent to Var1. be equivalent to ``Var1``.
""" """
if profile is None: if profile is None:
profile = config.profile or config.print_global_stats profile = config.profile or config.print_global_stats
# profile -> True or False
if profile is False: if profile is False:
profile = None profile = None
if profile is True: if profile is True:
profile = ProfileStats(message=name) profile = ProfileStats(message=name)
# profile -> object
elif isinstance(profile, str): elif isinstance(profile, str):
profile = ProfileStats(message=profile) profile = ProfileStats(message=profile)
# profile is typically either False or an object at this point.
# No need to block other objects being passed through though. It might be
# useful.
inputs, cloned_outputs = construct_pfunc_ins_and_outs( inputs, cloned_outputs = construct_pfunc_ins_and_outs(
params, params,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论