Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c09d92b1
提交
c09d92b1
authored
6月 03, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
6月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clone inner-graph before compiling in OpFromGraph
上级
88f02990
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
3 行删除
+22
-3
builders.py
aesara/compile/builders.py
+3
-3
test_builders.py
tests/compile/test_builders.py
+19
-0
没有找到文件。
aesara/compile/builders.py
浏览文件 @
c09d92b1
...
...
@@ -5,8 +5,8 @@ from functools import partial
from
typing
import
List
,
Optional
,
Sequence
,
cast
import
aesara.tensor
as
at
from
aesara
import
function
from
aesara.compile.function.pfunc
import
rebuild_collect_shared
from
aesara.compile.function.types
import
orig_function
from
aesara.compile.mode
import
optdb
from
aesara.compile.sharedvalue
import
SharedVariable
from
aesara.configdefaults
import
config
...
...
@@ -326,7 +326,7 @@ class OpFromGraph(Op, HasInnerGraph):
name
A name for debugging purposes.
kwargs
Check :func:`
orig_
function` for more arguments, only works when not
Check :func:`
aesara.
function` for more arguments, only works when not
inline.
"""
...
...
@@ -903,7 +903,7 @@ class OpFromGraph(Op, HasInnerGraph):
if
getattr
(
self
,
"_fn"
,
None
)
is
not
None
:
return
self
.
_fn
self
.
_fn
=
orig_
function
(
self
.
inner_inputs
,
self
.
inner_outputs
,
**
self
.
kwargs
)
self
.
_fn
=
function
(
self
.
inner_inputs
,
self
.
inner_outputs
,
**
self
.
kwargs
)
self
.
_fn
.
trust_input
=
True
return
self
.
_fn
...
...
tests/compile/test_builders.py
浏览文件 @
c09d92b1
...
...
@@ -541,6 +541,25 @@ class TestOpFromGraph(unittest_tools.InferShapeTester):
assert
np
.
array_equal
(
res_2
,
1.0
)
def
test_outputs_consistency
(
self
):
"""Make sure that `OpFromGraph.fn` doesn't change the value of `OpFromGraph.inner_outputs`."""
x
=
scalar
(
"x"
)
op
=
OpFromGraph
([
x
],
[
x
**
2
/
x
],
mode
=
"FAST_RUN"
)
# Confirm that the inner-graph is as expected
assert
equal_computations
(
op
.
inner_outputs
,
[
x
**
2
/
x
],
op
.
inner_inputs
,
[
x
])
# These outputs of the compiled `op.fgraph` should differ from the
# original, uncompiled `op.fgraph` outputs
fn
=
op
.
fn
new_inputs
=
fn
.
maker
.
fgraph
.
inputs
new_outputs
=
fn
.
maker
.
fgraph
.
outputs
assert
not
equal_computations
(
new_outputs
,
[
x
**
2
/
x
],
new_inputs
,
[
x
])
# The original `op.fgraph` outputs should stay the same, though
assert
equal_computations
(
op
.
inner_outputs
,
[
x
**
2
/
x
],
op
.
inner_inputs
,
[
x
])
@config.change_flags
(
floatX
=
"float64"
)
def
test_debugprint
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论