Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f26a5086
提交
f26a5086
authored
3月 07, 2021
作者:
kc611
提交者:
Thomas Wiecki
3月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a test for JAX conversion of unimplemented RVs
上级
d127fc14
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
3 行删除
+24
-3
jax_dispatch.py
aesara/link/jax/jax_dispatch.py
+1
-2
test_jax.py
tests/link/test_jax.py
+23
-1
没有找到文件。
aesara/link/jax/jax_dispatch.py
浏览文件 @
f26a5086
...
@@ -192,9 +192,8 @@ def jax_typify(data, dtype):
...
@@ -192,9 +192,8 @@ def jax_typify(data, dtype):
"""Convert instances of Aesara `Type`s to JAX types."""
"""Convert instances of Aesara `Type`s to JAX types."""
if
dtype
is
None
:
if
dtype
is
None
:
return
data
return
data
if
dtype
is
not
Non
e
:
els
e
:
return
jnp
.
array
(
data
,
dtype
=
dtype
)
return
jnp
.
array
(
data
,
dtype
=
dtype
)
raise
NotImplementedError
(
f
"No JAX conversion for data and dtype: {data}, {dtype}"
)
@jax_typify.register
(
np
.
ndarray
)
@jax_typify.register
(
np
.
ndarray
)
...
...
tests/link/test_jax.py
浏览文件 @
f26a5086
...
@@ -29,7 +29,7 @@ from aesara.tensor.math import clip, cosh, gammaln, log
...
@@ -29,7 +29,7 @@ from aesara.tensor.math import clip, cosh, gammaln, log
from
aesara.tensor.math
import
max
as
aet_max
from
aesara.tensor.math
import
max
as
aet_max
from
aesara.tensor.math
import
maximum
,
prod
from
aesara.tensor.math
import
maximum
,
prod
from
aesara.tensor.math
import
sum
as
aet_sum
from
aesara.tensor.math
import
sum
as
aet_sum
from
aesara.tensor.random.basic
import
normal
from
aesara.tensor.random.basic
import
RandomVariable
,
normal
from
aesara.tensor.random.utils
import
RandomStream
from
aesara.tensor.random.utils
import
RandomStream
from
aesara.tensor.shape
import
Shape
,
Shape_i
,
SpecifyShape
,
reshape
from
aesara.tensor.shape
import
Shape
,
Shape_i
,
SpecifyShape
,
reshape
from
aesara.tensor.type
import
(
from
aesara.tensor.type
import
(
...
@@ -978,6 +978,28 @@ def test_random():
...
@@ -978,6 +978,28 @@ def test_random():
compare_jax_and_py
(
fgraph
,
[])
compare_jax_and_py
(
fgraph
,
[])
def
test_random_unimplemented
():
class
NonExistentRV
(
RandomVariable
):
name
=
"non-existent"
ndim_supp
=
0
ndims_params
=
[]
dtype
=
"floatX"
def
__call__
(
self
,
size
=
None
,
**
kwargs
):
return
super
()
.
__call__
(
size
=
size
,
**
kwargs
)
def
rng_fn
(
cls
,
rng
,
size
):
return
0
nonexistentrv
=
NonExistentRV
()
rng
=
shared
(
np
.
random
.
RandomState
(
123
))
out
=
nonexistentrv
(
rng
=
rng
)
fgraph
=
FunctionGraph
([
out
.
owner
.
inputs
[
0
]],
[
out
],
clone
=
False
)
with
pytest
.
raises
(
NotImplementedError
):
compare_jax_and_py
(
fgraph
,
[])
def
test_RandomStream
():
def
test_RandomStream
():
srng
=
RandomStream
(
seed
=
123
)
srng
=
RandomStream
(
seed
=
123
)
out
=
srng
.
normal
()
-
srng
.
normal
()
out
=
srng
.
normal
()
-
srng
.
normal
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论