Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
26d81f81
提交
26d81f81
authored
2月 10, 2026
作者:
ricardoV94
提交者:
Ricardo Vieira
2月 10, 2026
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Respect introduction of ShapeFeature
上级
9bee61d5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
32 行增加
和
6 行删除
+32
-6
shape.py
pytensor/tensor/rewriting/shape.py
+1
-4
basic.py
pytensor/xtensor/basic.py
+3
-0
utils.py
pytensor/xtensor/rewriting/utils.py
+2
-2
test_basic.py
tests/xtensor/test_basic.py
+26
-0
没有找到文件。
pytensor/tensor/rewriting/shape.py
浏览文件 @
26d81f81
...
...
@@ -729,11 +729,8 @@ class ShapeFeature(Feature):
class
ShapeOptimizer
(
GraphRewriter
):
"""Rewriter that adds `ShapeFeature` as a feature."""
def
add_requirements
(
self
,
fgraph
):
fgraph
.
attach_feature
(
ShapeFeature
())
def
apply
(
self
,
fgraph
):
pass
fgraph
.
attach_feature
(
ShapeFeature
())
class
UnShapeOptimizer
(
GraphRewriter
):
...
...
pytensor/xtensor/basic.py
浏览文件 @
26d81f81
...
...
@@ -24,6 +24,9 @@ class XTypeCastOp(TypeCastingOp):
This is like a `ViewOp` but without the expectation the input and output have identical types.
"""
def
infer_shape
(
self
,
fgraph
,
node
,
input_shapes
):
return
input_shapes
class
TensorFromXTensor
(
XTypeCastOp
):
__props__
=
()
...
...
pytensor/xtensor/rewriting/utils.py
浏览文件 @
26d81f81
...
...
@@ -17,7 +17,7 @@ optdb.register(
"fast_run"
,
"fast_compile"
,
"minimum_compile"
,
position
=
0.
1
,
position
=
0.
09
,
# before ShapeOpt, so we don't accidentally reintroduce xtensor Ops
)
# Register OFG inline again after lowering xtensor
...
...
@@ -26,7 +26,7 @@ optdb.register(
dfs_rewriter
(
inline_ofg_expansion
),
"fast_run"
,
"fast_compile"
,
position
=
0.
1
1
,
position
=
0.
09
1
,
)
...
...
tests/xtensor/test_basic.py
0 → 100644
浏览文件 @
26d81f81
import
numpy
as
np
from
pytensor
import
function
from
pytensor.xtensor.basic
import
Rename
from
pytensor.xtensor.type
import
xtensor
def
test_shape_feature_does_not_see_xop
():
CALLED
=
False
x
=
xtensor
(
"x"
,
dims
=
(
"a"
,),
dtype
=
"int64"
)
class
XOpWithBadInferShape
(
Rename
):
def
infer_shape
(
self
,
node
,
inputs
,
outputs
):
global
CALLED
CALLED
=
True
raise
NotImplementedError
()
test_xop
=
XOpWithBadInferShape
(
new_dims
=
(
"b"
,))
out
=
test_xop
(
x
)
-
test_xop
(
x
)
assert
out
.
dims
==
(
"b"
,)
fn
=
function
([
x
],
out
)
np
.
testing
.
assert_allclose
(
fn
([
1
,
2
,
3
]),
[
0
,
0
,
0
])
assert
not
CALLED
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论