Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ae729683
提交
ae729683
authored
11月 16, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
12月 14, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix wrap_jax when there is a mix of statically known and unknown shapes
上级
42587563
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
3 行删除
+16
-3
ops.py
pytensor/link/jax/ops.py
+4
-3
test_wrap_jax.py
tests/link/jax/test_wrap_jax.py
+12
-0
没有找到文件。
pytensor/link/jax/ops.py
浏览文件 @
ae729683
...
...
@@ -9,7 +9,7 @@ from pytensor.compile.function import function
from
pytensor.compile.mode
import
Mode
from
pytensor.gradient
import
DisconnectedType
from
pytensor.graph
import
Apply
,
Op
,
Variable
from
pytensor.tensor.basic
import
infer_static_shape
from
pytensor.tensor.basic
import
as_tensor
,
infer_static_shape
from
pytensor.tensor.type
import
TensorType
...
...
@@ -384,7 +384,7 @@ def _find_output_types(
try
:
shape_evaluation_function
=
function
(
[],
resolved_input_shapes
,
[
as_tensor
(
s
,
dtype
=
"int64"
)
for
s
in
resolved_input_shapes
]
,
on_unused_input
=
"ignore"
,
mode
=
Mode
(
linker
=
"py"
,
optimizer
=
"fast_compile"
),
)
...
...
@@ -394,7 +394,7 @@ def _find_output_types(
"Please provide inputs with fully determined shapes by "
"calling pt.specify_shape."
)
from
e
resolved_input_shapes
=
shape_evaluation_function
()
resolved_input_shapes
=
[
tuple
(
s
)
for
s
in
shape_evaluation_function
()]
# Determine output types using jax.eval_shape with dummy inputs
output_metadata_storage
=
{}
...
...
@@ -422,6 +422,7 @@ def _find_output_types(
output_static
=
output_metadata_storage
[
"output_static"
]
# If we used shape evaluation, set all output shapes to unknown
# TODO: This is throwing away potential static shape information.
if
requires_shape_evaluation
:
output_types
=
[
TensorType
(
...
...
tests/link/jax/test_wrap_jax.py
浏览文件 @
ae729683
...
...
@@ -559,3 +559,15 @@ class TestDtypes:
compare_jax_and_py
([
x
,
y
],
[
out
,
*
grad_out
],
test_values
)
else
:
compare_jax_and_py
([
x
,
y
],
[
out
],
test_values
)
def
test_mixed_static_shape
():
x_unknown
=
shared
(
np
.
ones
((
3
,)))
x_known
=
shared
(
np
.
ones
((
4
,)),
shape
=
(
4
,))
def
f
(
x1
,
x2
):
return
jax
.
numpy
.
concatenate
([
x1
,
x2
])
assert
wrap_jax
(
f
)(
x_known
,
x_known
)
.
type
.
shape
==
(
8
,)
assert
wrap_jax
(
f
)(
x_known
,
x_unknown
)
.
type
.
shape
==
(
None
,)
assert
wrap_jax
(
f
)(
x_unknown
,
x_known
)
.
type
.
shape
==
(
None
,)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论