Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e7d77b00
提交
e7d77b00
authored
4月 15, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
4月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a missing inputs check to OpFromGraph
上级
e464e50a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
0 行删除
+13
-0
builders.py
aesara/compile/builders.py
+6
-0
test_builders.py
tests/compile/test_builders.py
+7
-0
没有找到文件。
aesara/compile/builders.py
浏览文件 @
e7d77b00
...
@@ -22,6 +22,7 @@ from aesara.graph.fg import FunctionGraph
...
@@ -22,6 +22,7 @@ from aesara.graph.fg import FunctionGraph
from
aesara.graph.null_type
import
NullType
from
aesara.graph.null_type
import
NullType
from
aesara.graph.op
import
HasInnerGraph
,
Op
from
aesara.graph.op
import
HasInnerGraph
,
Op
from
aesara.graph.opt
import
in2out
,
local_optimizer
from
aesara.graph.opt
import
in2out
,
local_optimizer
from
aesara.graph.utils
import
MissingInputError
from
aesara.tensor.basic_opt
import
ShapeFeature
from
aesara.tensor.basic_opt
import
ShapeFeature
...
@@ -340,6 +341,10 @@ class OpFromGraph(Op, HasInnerGraph):
...
@@ -340,6 +341,10 @@ class OpFromGraph(Op, HasInnerGraph):
if
isinstance
(
i
,
SharedVariable
):
if
isinstance
(
i
,
SharedVariable
):
raise
TypeError
(
f
"SharedVariables not allowed as inputs; {i}"
)
raise
TypeError
(
f
"SharedVariables not allowed as inputs; {i}"
)
for
var
in
graph_inputs
(
outputs
,
inputs
):
if
var
not
in
inputs
and
not
isinstance
(
var
,
(
Constant
,
SharedVariable
)):
raise
MissingInputError
(
f
"OpFromGraph is missing an input: {var}"
)
if
"updates"
in
kwargs
or
"givens"
in
kwargs
:
if
"updates"
in
kwargs
or
"givens"
in
kwargs
:
raise
NotImplementedError
(
"Updates and givens are not allowed here"
)
raise
NotImplementedError
(
"Updates and givens are not allowed here"
)
...
@@ -362,6 +367,7 @@ class OpFromGraph(Op, HasInnerGraph):
...
@@ -362,6 +367,7 @@ class OpFromGraph(Op, HasInnerGraph):
local_outputs
,
local_outputs
,
(
clone_d
,
update_d
,
update_expr
,
shared_inputs
),
(
clone_d
,
update_d
,
update_expr
,
shared_inputs
),
)
=
new
)
=
new
assert
len
(
local_inputs
)
==
len
(
inputs
)
+
len
(
self
.
shared_inputs
)
assert
len
(
local_inputs
)
==
len
(
inputs
)
+
len
(
self
.
shared_inputs
)
assert
len
(
local_outputs
)
==
len
(
outputs
)
assert
len
(
local_outputs
)
==
len
(
outputs
)
assert
not
update_d
assert
not
update_d
...
...
tests/compile/test_builders.py
浏览文件 @
e7d77b00
...
@@ -12,6 +12,7 @@ from aesara.gradient import DisconnectedType, Rop, disconnected_type, grad
...
@@ -12,6 +12,7 @@ from aesara.gradient import DisconnectedType, Rop, disconnected_type, grad
from
aesara.graph.fg
import
FunctionGraph
from
aesara.graph.fg
import
FunctionGraph
from
aesara.graph.null_type
import
NullType
from
aesara.graph.null_type
import
NullType
from
aesara.graph.opt_utils
import
optimize_graph
from
aesara.graph.opt_utils
import
optimize_graph
from
aesara.graph.utils
import
MissingInputError
from
aesara.printing
import
debugprint
from
aesara.printing
import
debugprint
from
aesara.tensor.basic
import
as_tensor
from
aesara.tensor.basic
import
as_tensor
from
aesara.tensor.basic_opt
import
ShapeOptimizer
from
aesara.tensor.basic_opt
import
ShapeOptimizer
...
@@ -503,6 +504,12 @@ class TestOpFromGraph(unittest_tools.InferShapeTester):
...
@@ -503,6 +504,12 @@ class TestOpFromGraph(unittest_tools.InferShapeTester):
out_fn
=
function
([],
out
)
out_fn
=
function
([],
out
)
assert
np
.
array_equal
(
out_fn
(),
2.0
)
assert
np
.
array_equal
(
out_fn
(),
2.0
)
def
test_missing_input
(
self
):
x
=
at
.
lscalar
(
"x"
)
with
pytest
.
raises
(
MissingInputError
):
OpFromGraph
([],
[
x
])
def
test_debugprint
():
def
test_debugprint
():
x
,
y
,
z
=
matrices
(
"xyz"
)
x
,
y
,
z
=
matrices
(
"xyz"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论