Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2ccd9cca
提交
2ccd9cca
authored
5月 26, 2022
作者:
Ricardo
提交者:
Brandon T. Willard
6月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Separate failing conditions in test_jax_IncSubtensor
Also avoid using `at.arange` in these tests as it always yields `ConcretizationTypeError`s in more recent versions of JAX
上级
2e35e6c4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
41 行增加
和
18 行删除
+41
-18
test_jax.py
tests/link/test_jax.py
+41
-18
没有找到文件。
tests/link/test_jax.py
浏览文件 @
2ccd9cca
...
@@ -3,6 +3,7 @@ from typing import Optional
...
@@ -3,6 +3,7 @@ from typing import Optional
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
from
jax._src.errors
import
NonConcreteBooleanIndexError
from
packaging.version
import
parse
as
version_parse
from
packaging.version
import
parse
as
version_parse
import
aesara.scalar.basic
as
aes
import
aesara.scalar.basic
as
aes
...
@@ -674,15 +675,11 @@ def test_jax_Subtensors_omni():
...
@@ -674,15 +675,11 @@ def test_jax_Subtensors_omni():
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
@pytest.mark.xfail
(
version_parse
(
jax
.
__version__
)
>=
version_parse
(
"0.2.12"
),
reason
=
"Omnistaging cannot be disabled"
,
)
def
test_jax_IncSubtensor
():
def
test_jax_IncSubtensor
():
rng
=
np
.
random
.
default_rng
(
213234
)
rng
=
np
.
random
.
default_rng
(
213234
)
x_np
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
3
,
4
,
5
))
.
astype
(
config
.
floatX
)
x_np
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
3
,
4
,
5
))
.
astype
(
config
.
floatX
)
x_at
=
at
.
arange
(
3
*
4
*
5
)
.
reshape
((
3
,
4
,
5
))
.
astype
(
config
.
floatX
)
x_at
=
at
.
constant
(
np
.
arange
(
3
*
4
*
5
)
.
reshape
((
3
,
4
,
5
))
.
astype
(
config
.
floatX
)
)
# "Set" basic indices
# "Set" basic indices
st_at
=
at
.
as_tensor_variable
(
np
.
array
(
-
10.0
,
dtype
=
config
.
floatX
))
st_at
=
at
.
as_tensor_variable
(
np
.
array
(
-
10.0
,
dtype
=
config
.
floatX
))
...
@@ -707,7 +704,7 @@ def test_jax_IncSubtensor():
...
@@ -707,7 +704,7 @@ def test_jax_IncSubtensor():
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
4
,
5
))
.
astype
(
config
.
floatX
)
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
4
,
5
))
.
astype
(
config
.
floatX
)
)
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
np
.
r_
[
0
,
2
]],
st_at
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
np
.
r_
[
0
,
2
]],
st_at
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
1
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
...
@@ -717,14 +714,8 @@ def test_jax_IncSubtensor():
...
@@ -717,14 +714,8 @@ def test_jax_IncSubtensor():
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
st_at
=
at
.
as_tensor_variable
(
x_np
[[
0
,
2
],
0
,
:
3
])
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[[
0
,
2
],
0
,
:
3
],
st_at
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
# "Set" boolean indices
# "Set" boolean indices
mask_at
=
at
.
as_tensor_variable
(
x_np
)
>
0
mask_at
=
at
.
constant
(
x_np
>
0
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
0.0
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
0.0
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
...
@@ -753,7 +744,7 @@ def test_jax_IncSubtensor():
...
@@ -753,7 +744,7 @@ def test_jax_IncSubtensor():
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
4
,
5
))
.
astype
(
config
.
floatX
)
rng
.
uniform
(
-
1
,
1
,
size
=
(
2
,
4
,
5
))
.
astype
(
config
.
floatX
)
)
)
out_at
=
at_subtensor
.
inc_subtensor
(
x_at
[
np
.
r_
[
0
,
2
]],
st_at
)
out_at
=
at_subtensor
.
inc_subtensor
(
x_at
[
np
.
r_
[
0
,
2
]],
st_at
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
1
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
...
@@ -763,18 +754,50 @@ def test_jax_IncSubtensor():
...
@@ -763,18 +754,50 @@ def test_jax_IncSubtensor():
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
st_at
=
at
.
as_tensor_variable
(
x_np
[[
0
,
2
],
0
,
:
3
])
# "Increment" boolean indices
out_at
=
at_subtensor
.
inc_subtensor
(
x_at
[[
0
,
2
],
0
,
:
3
],
st_at
)
mask_at
=
at
.
constant
(
x_np
>
0
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
1.0
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
compare_jax_and_py
(
out_fg
,
[])
# "Increment" boolean indices
def
test_jax_IncSubtensors_unsupported
():
rng
=
np
.
random
.
default_rng
(
213234
)
x_np
=
rng
.
uniform
(
-
1
,
1
,
size
=
(
3
,
4
,
5
))
.
astype
(
config
.
floatX
)
x_at
=
at
.
constant
(
np
.
arange
(
3
*
4
*
5
)
.
reshape
((
3
,
4
,
5
))
.
astype
(
config
.
floatX
))
mask_at
=
at
.
as_tensor
(
x_np
)
>
0
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
0.0
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
with
pytest
.
raises
(
NonConcreteBooleanIndexError
,
match
=
"Array boolean indices must be concrete"
):
compare_jax_and_py
(
out_fg
,
[])
mask_at
=
at
.
as_tensor_variable
(
x_np
)
>
0
mask_at
=
at
.
as_tensor_variable
(
x_np
)
>
0
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
1.0
)
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[
mask_at
],
1.0
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
out_fg
=
FunctionGraph
([],
[
out_at
])
compare_jax_and_py
(
out_fg
,
[])
with
pytest
.
raises
(
NonConcreteBooleanIndexError
,
match
=
"Array boolean indices must be concrete"
):
compare_jax_and_py
(
out_fg
,
[])
st_at
=
at
.
as_tensor_variable
(
x_np
[[
0
,
2
],
0
,
:
3
])
out_at
=
at_subtensor
.
set_subtensor
(
x_at
[[
0
,
2
],
0
,
:
3
],
st_at
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
with
pytest
.
raises
(
IndexError
,
match
=
"Array slice indices must have static"
):
compare_jax_and_py
(
out_fg
,
[])
st_at
=
at
.
as_tensor_variable
(
x_np
[[
0
,
2
],
0
,
:
3
])
out_at
=
at_subtensor
.
inc_subtensor
(
x_at
[[
0
,
2
],
0
,
:
3
],
st_at
)
assert
isinstance
(
out_at
.
owner
.
op
,
at_subtensor
.
AdvancedIncSubtensor
)
out_fg
=
FunctionGraph
([],
[
out_at
])
with
pytest
.
raises
(
IndexError
,
match
=
"Array slice indices must have static"
):
compare_jax_and_py
(
out_fg
,
[])
def
test_jax_ifelse
():
def
test_jax_ifelse
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论