Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1e63a48f
提交
1e63a48f
authored
9月 14, 2022
作者:
Rémi Louf
提交者:
Brandon T. Willard
9月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Warn instead of raise when converting `CheckAndRaise`
上级
b35d6188
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
13 行删除
+11
-13
basic.py
aesara/link/jax/dispatch/basic.py
+9
-10
test_basic.py
tests/link/jax/test_basic.py
+2
-3
没有找到文件。
aesara/link/jax/dispatch/basic.py
浏览文件 @
1e63a48f
...
@@ -10,7 +10,7 @@ from aesara.configdefaults import config
...
@@ -10,7 +10,7 @@ from aesara.configdefaults import config
from
aesara.graph.fg
import
FunctionGraph
from
aesara.graph.fg
import
FunctionGraph
from
aesara.ifelse
import
IfElse
from
aesara.ifelse
import
IfElse
from
aesara.link.utils
import
fgraph_to_python
from
aesara.link.utils
import
fgraph_to_python
from
aesara.raise_op
import
CheckAndRaise
from
aesara.raise_op
import
Assert
,
CheckAndRaise
if
config
.
floatX
==
"float64"
:
if
config
.
floatX
==
"float64"
:
...
@@ -81,19 +81,18 @@ def jax_funcify_IfElse(op, **kwargs):
...
@@ -81,19 +81,18 @@ def jax_funcify_IfElse(op, **kwargs):
return
ifelse
return
ifelse
@jax_funcify.register
(
Assert
)
@jax_funcify.register
(
CheckAndRaise
)
@jax_funcify.register
(
CheckAndRaise
)
def
jax_funcify_CheckAndRaise
(
op
,
**
kwargs
):
def
jax_funcify_CheckAndRaise
(
op
,
**
kwargs
):
warnings
.
warn
(
f
"""Skipping `CheckAndRaise` Op (assertion: {op.msg}) as JAX tracing would remove it."""
,
stacklevel
=
2
,
)
raise
NotImplementedError
(
def
assert_fn
(
x
,
*
inputs
):
f
"""This exception is raised because you tried to convert an aesara graph with a `CheckAndRaise` Op (message: {op.msg}) to JAX.
return
x
JAX uses tracing to jit-compile functions, and assertions typically
don't do well with tracing. The appropriate workaround depends on what
you intended to do with the assertions in the first place.
Note that all assertions can be removed from the graph by adding
return
assert_fn
`local_remove_all_assert` to the rewrites."""
)
def
jnp_safe_copy
(
x
):
def
jnp_safe_copy
(
x
):
...
...
tests/link/jax/test_basic.py
浏览文件 @
1e63a48f
...
@@ -205,7 +205,6 @@ def test_jax_checkandraise():
...
@@ -205,7 +205,6 @@ def test_jax_checkandraise():
p
.
tag
.
test_value
=
0
p
.
tag
.
test_value
=
0
res
=
assert_op
(
p
,
p
<
1.0
)
res
=
assert_op
(
p
,
p
<
1.0
)
res_fg
=
FunctionGraph
([
p
],
[
res
])
with
pytest
.
raises
(
NotImplementedError
):
with
pytest
.
warns
(
UserWarning
):
compare_jax_and_py
(
res_fg
,
[
1.0
]
)
function
((
p
,),
res
,
mode
=
jax_mode
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论