Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
be866f9f
提交
be866f9f
authored
12月 27, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
12月 28, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Numba RVs: Include output_bc_pattern in cache key
Size is ignored when the output_bc_pattern implies it must be length 1, but shouldn't be ignored otherwise
上级
f091b86b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
4 行删除
+11
-4
random.py
pytensor/link/numba/dispatch/random.py
+2
-4
test_random.py
tests/link/numba/test_random.py
+9
-0
没有找到文件。
pytensor/link/numba/dispatch/random.py
浏览文件 @
be866f9f
...
@@ -485,16 +485,14 @@ def numba_funcify_RandomVariable(op: RandomVariableWithCoreShape, node, **kwargs
...
@@ -485,16 +485,14 @@ def numba_funcify_RandomVariable(op: RandomVariableWithCoreShape, node, **kwargs
# If the core RV can't be cached, then the whole RV can't be cached
# If the core RV can't be cached, then the whole RV can't be cached
random_rv_key
=
None
# type: ignore[unreachable]
random_rv_key
=
None
# type: ignore[unreachable]
else
:
else
:
rv_op_props_dict
=
rv_op
.
props_dict
()
if
hasattr
(
rv_op
,
"props_dict"
)
else
{}
random_rv_key_contents
=
(
random_rv_key_contents
=
(
type
(
op
),
type
(
op
),
type
(
rv_op
),
type
(
rv_op
),
rv_op
,
tuple
(
rv_op
.
_props_dict
()
.
items
()),
# type: ignore[attr-defined]
tuple
(
rv_op_props_dict
.
items
()),
size_len
,
size_len
,
core_shape_len
,
core_shape_len
,
inplace
,
input_bc_patterns
,
input_bc_patterns
,
output_bc_patterns
,
core_cache_key
,
core_cache_key
,
)
)
random_rv_key
=
sha256
(
str
(
random_rv_key_contents
)
.
encode
())
.
hexdigest
()
random_rv_key
=
sha256
(
str
(
random_rv_key_contents
)
.
encode
())
.
hexdigest
()
...
...
tests/link/numba/test_random.py
浏览文件 @
be866f9f
...
@@ -689,6 +689,15 @@ def test_dirichlet_discrete_alpha():
...
@@ -689,6 +689,15 @@ def test_dirichlet_discrete_alpha():
assert
np
.
unique
(
res
)
.
size
>
2
# Make sure we have more than just 0s and 1s
assert
np
.
unique
(
res
)
.
size
>
2
# Make sure we have more than just 0s and 1s
def
test_cache_size_bcast_change
():
# Regression bug for caching with the same key in case where size is meaningful vs not
alpha
=
pt
.
dvector
()
for
s
in
(
1
,
2
,
3
):
x
=
ptr
.
dirichlet
(
alpha
,
size
=
(
s
,))
fn
=
function
([
alpha
],
x
,
mode
=
numba_mode
)
assert
fn
([
0.2
,
0.3
,
0.5
])
.
shape
==
(
s
,
3
)
def
test_rv_inside_ofg
():
def
test_rv_inside_ofg
():
rng_np
=
np
.
random
.
default_rng
(
562
)
rng_np
=
np
.
random
.
default_rng
(
562
)
rng
=
shared
(
rng_np
)
rng
=
shared
(
rng_np
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论