Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5a6d92c3
提交
5a6d92c3
authored
12月 29, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
1月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix more old style exceptions
上级
444f13c7
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
18 行增加
和
12 行删除
+18
-12
pfunc.py
aesara/compile/function/pfunc.py
+3
-4
subtensor.py
aesara/tensor/subtensor.py
+5
-8
test_pfunc.py
tests/compile/function/test_pfunc.py
+10
-0
没有找到文件。
aesara/compile/function/pfunc.py
浏览文件 @
5a6d92c3
...
...
@@ -113,9 +113,8 @@ def rebuild_collect_shared(
)
if
v_update
.
type
!=
v
.
type
:
raise
TypeError
(
"an update must have the same type as "
"the original shared variable"
,
(
v
,
v
.
type
,
v_update
,
v_update
.
type
),
"An update must have a type compatible with "
"the original shared variable"
)
update_d
[
v
]
=
v_update
update_expr
.
append
((
v
,
v_update
))
...
...
@@ -134,7 +133,7 @@ def rebuild_collect_shared(
for
v_orig
,
v_repl
in
replace_pairs
:
if
not
isinstance
(
v_orig
,
Variable
):
raise
TypeError
(
"
given keys must be Variable"
,
v_orig
)
raise
TypeError
(
"
`givens` keys must be Variables"
)
if
not
isinstance
(
v_repl
,
Variable
):
v_repl
=
shared
(
v_repl
)
...
...
aesara/tensor/subtensor.py
浏览文件 @
5a6d92c3
...
...
@@ -697,15 +697,13 @@ class Subtensor(COp):
input_types
=
get_slice_elements
(
idx_list
,
lambda
entry
:
isinstance
(
entry
,
Type
)
)
if
len
(
inputs
)
!=
len
(
input_types
):
raise
IndexError
(
"Not enough inputs to fill in the Subtensor template."
,
inputs
,
idx_list
)
assert
len
(
inputs
)
==
len
(
input_types
)
for
input
,
expected_type
in
zip
(
inputs
,
input_types
):
if
input
.
type
!=
expected_type
:
raise
TypeError
(
"Wrong type for Subtensor template. Expected
%
s, got
%
s."
%
(
input
.
type
,
expected_type
)
f
"Incompatible types for Subtensor template. Expected {input.type}, got {expected_type}."
)
# infer the broadcasting pattern
...
...
@@ -1533,8 +1531,7 @@ class IncSubtensor(COp):
for
input
,
expected_type
in
zip
(
inputs
,
input_types
):
if
input
.
type
!=
expected_type
:
raise
TypeError
(
"Wrong type for Subtensor template. Expected
%
s, got
%
s."
%
(
input
.
type
,
expected_type
)
f
"Wrong type for Subtensor template. Expected {input.type}, got {expected_type}."
)
return
Apply
(
self
,
(
x
,
y
)
+
inputs
,
[
x
.
type
()])
...
...
tests/compile/function/test_pfunc.py
浏览文件 @
5a6d92c3
...
...
@@ -4,6 +4,7 @@ import pytest
import
aesara.tensor
as
at
from
aesara.compile
import
UnusedInputError
from
aesara.compile.function
import
function
,
pfunc
from
aesara.compile.function.pfunc
import
rebuild_collect_shared
from
aesara.compile.io
import
In
from
aesara.compile.sharedvalue
import
shared
from
aesara.configdefaults
import
config
...
...
@@ -1045,3 +1046,12 @@ class TestRebuildStrict:
z_val
=
f
(
np
.
ones
((
3
,
5
),
dtype
=
"int32"
),
np
.
arange
(
5
,
dtype
=
"int32"
))
assert
z_val
.
ndim
==
2
assert
np
.
all
(
z_val
==
np
.
ones
((
3
,
5
))
*
np
.
arange
(
5
))
def
test_rebuild_collect_shared
():
x
,
y
=
ivectors
(
"x"
,
"y"
)
z
=
x
*
y
with
pytest
.
raises
(
TypeError
):
rebuild_collect_shared
([
z
],
replace
=
{
1
:
2
})
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论