Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c6dae89f
提交
c6dae89f
authored
8月 30, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
9月 20, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move view_roots to the only file where it is used
上级
d8beb7e4
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
26 行删除
+21
-26
basic.py
pytensor/graph/basic.py
+0
-19
blas.py
pytensor/tensor/blas.py
+21
-2
test_basic.py
tests/graph/test_basic.py
+0
-5
没有找到文件。
pytensor/graph/basic.py
浏览文件 @
c6dae89f
...
@@ -1787,25 +1787,6 @@ def as_string(
...
@@ -1787,25 +1787,6 @@ def as_string(
return
[
describe
(
output
)
for
output
in
outputs
]
return
[
describe
(
output
)
for
output
in
outputs
]
def
view_roots
(
node
:
Variable
)
->
list
[
Variable
]:
"""Return the leaves from a search through consecutive view-maps."""
owner
=
node
.
owner
if
owner
is
not
None
:
try
:
vars_to_views
=
{
owner
.
outputs
[
o
]:
i
for
o
,
i
in
owner
.
op
.
view_map
.
items
()}
except
AttributeError
:
return
[
node
]
if
node
in
vars_to_views
:
answer
=
[]
for
i
in
vars_to_views
[
node
]:
answer
+=
view_roots
(
owner
.
inputs
[
i
])
return
answer
else
:
return
[
node
]
else
:
return
[
node
]
def
apply_depends_on
(
apply
:
Apply
,
depends_on
:
Apply
|
Collection
[
Apply
])
->
bool
:
def
apply_depends_on
(
apply
:
Apply
,
depends_on
:
Apply
|
Collection
[
Apply
])
->
bool
:
"""Determine if any `depends_on` is in the graph given by ``apply``.
"""Determine if any `depends_on` is in the graph given by ``apply``.
...
...
pytensor/tensor/blas.py
浏览文件 @
c6dae89f
...
@@ -85,7 +85,7 @@ from pathlib import Path
...
@@ -85,7 +85,7 @@ from pathlib import Path
import
numpy
as
np
import
numpy
as
np
from
scipy.linalg
import
get_blas_funcs
from
scipy.linalg
import
get_blas_funcs
from
pytensor.graph
import
vectorize_graph
from
pytensor.graph
import
Variable
,
vectorize_graph
from
pytensor.npy_2_compat
import
normalize_axis_tuple
from
pytensor.npy_2_compat
import
normalize_axis_tuple
...
@@ -97,7 +97,7 @@ except ImportError:
...
@@ -97,7 +97,7 @@ except ImportError:
import
pytensor.scalar
import
pytensor.scalar
from
pytensor.configdefaults
import
config
from
pytensor.configdefaults
import
config
from
pytensor.graph.basic
import
Apply
,
view_roots
from
pytensor.graph.basic
import
Apply
from
pytensor.graph.op
import
Op
from
pytensor.graph.op
import
Op
from
pytensor.graph.utils
import
InconsistencyError
,
MethodNotDefined
,
TestValueError
from
pytensor.graph.utils
import
InconsistencyError
,
MethodNotDefined
,
TestValueError
from
pytensor.link.c.op
import
COp
from
pytensor.link.c.op
import
COp
...
@@ -114,6 +114,25 @@ from pytensor.tensor.type import DenseTensorType, tensor
...
@@ -114,6 +114,25 @@ from pytensor.tensor.type import DenseTensorType, tensor
_logger
=
logging
.
getLogger
(
"pytensor.tensor.blas"
)
_logger
=
logging
.
getLogger
(
"pytensor.tensor.blas"
)
def
view_roots
(
node
:
Variable
)
->
list
[
Variable
]:
"""Return the leaves from a search through consecutive view-maps."""
owner
=
node
.
owner
if
owner
is
not
None
:
try
:
vars_to_views
=
{
owner
.
outputs
[
o
]:
i
for
o
,
i
in
owner
.
op
.
view_map
.
items
()}
except
AttributeError
:
return
[
node
]
if
node
in
vars_to_views
:
answer
=
[]
for
i
in
vars_to_views
[
node
]:
answer
+=
view_roots
(
owner
.
inputs
[
i
])
return
answer
else
:
return
[
node
]
else
:
return
[
node
]
def
must_initialize_y_gemv
():
def
must_initialize_y_gemv
():
# Check whether Scipy GEMV could output nan if y in not initialized
# Check whether Scipy GEMV could output nan if y in not initialized
from
scipy.linalg.blas
import
get_blas_funcs
from
scipy.linalg.blas
import
get_blas_funcs
...
...
tests/graph/test_basic.py
浏览文件 @
c6dae89f
...
@@ -589,11 +589,6 @@ def test_io_connection_pattern():
...
@@ -589,11 +589,6 @@ def test_io_connection_pattern():
raise
AssertionError
()
raise
AssertionError
()
@pytest.mark.xfail
(
reason
=
"Not implemented"
)
def
test_view_roots
():
raise
AssertionError
()
def
test_get_var_by_name
():
def
test_get_var_by_name
():
r1
,
r2
,
r3
=
MyVariable
(
1
),
MyVariable
(
2
),
MyVariable
(
3
)
r1
,
r2
,
r3
=
MyVariable
(
1
),
MyVariable
(
2
),
MyVariable
(
3
)
o1
=
MyOp
(
r1
,
r2
)
o1
=
MyOp
(
r1
,
r2
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论