Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
880a57aa
提交
880a57aa
authored
5月 19, 2024
作者:
Dhruvanshu-Joshi
提交者:
Ricardo Vieira
5月 20, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove list_of_nodes in favor of similar applys_between
上级
8c157a25
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
2 行增加
和
46 行删除
+2
-46
basic.py
pytensor/graph/basic.py
+0
-32
basic.py
pytensor/scalar/basic.py
+2
-2
test_basic.py
tests/graph/test_basic.py
+0
-12
没有找到文件。
pytensor/graph/basic.py
浏览文件 @
880a57aa
...
@@ -1789,38 +1789,6 @@ def view_roots(node: Variable) -> list[Variable]:
...
@@ -1789,38 +1789,6 @@ def view_roots(node: Variable) -> list[Variable]:
return
[
node
]
return
[
node
]
def
list_of_nodes
(
inputs
:
Collection
[
Variable
],
outputs
:
Iterable
[
Variable
]
)
->
list
[
Apply
]:
r"""Return the `Apply` nodes of the graph between `inputs` and `outputs`.
Parameters
----------
inputs : list of Variable
Input `Variable`\s.
outputs : list of Variable
Output `Variable`\s.
"""
def
expand
(
o
:
Apply
)
->
list
[
Apply
]:
return
[
inp
.
owner
for
inp
in
o
.
inputs
if
inp
.
owner
and
not
any
(
i
in
inp
.
owner
.
outputs
for
i
in
inputs
)
]
return
list
(
cast
(
Iterable
[
Apply
],
walk
(
[
o
.
owner
for
o
in
outputs
if
o
.
owner
],
expand
,
),
)
)
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/scalar/basic.py
浏览文件 @
880a57aa
...
@@ -24,7 +24,7 @@ import pytensor
...
@@ -24,7 +24,7 @@ import pytensor
from
pytensor
import
printing
from
pytensor
import
printing
from
pytensor.configdefaults
import
config
from
pytensor.configdefaults
import
config
from
pytensor.gradient
import
DisconnectedType
,
grad_undefined
from
pytensor.gradient
import
DisconnectedType
,
grad_undefined
from
pytensor.graph.basic
import
Apply
,
Constant
,
Variable
,
clone
,
list_of_nodes
from
pytensor.graph.basic
import
Apply
,
Constant
,
Variable
,
applys_between
,
clone
from
pytensor.graph.fg
import
FunctionGraph
from
pytensor.graph.fg
import
FunctionGraph
from
pytensor.graph.op
import
HasInnerGraph
from
pytensor.graph.op
import
HasInnerGraph
from
pytensor.graph.rewriting.basic
import
MergeOptimizer
from
pytensor.graph.rewriting.basic
import
MergeOptimizer
...
@@ -4125,7 +4125,7 @@ class ScalarInnerGraphOp(ScalarOp, HasInnerGraph):
...
@@ -4125,7 +4125,7 @@ class ScalarInnerGraphOp(ScalarOp, HasInnerGraph):
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
,
impl
):
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
,
impl
):
if
impl
not
in
self
.
prepare_node_called
:
if
impl
not
in
self
.
prepare_node_called
:
for
n
in
list_of_nodes
(
self
.
inputs
,
self
.
outputs
):
for
n
in
applys_between
(
self
.
inputs
,
self
.
outputs
):
n
.
op
.
prepare_node
(
n
,
None
,
None
,
impl
)
n
.
op
.
prepare_node
(
n
,
None
,
None
,
impl
)
self
.
prepare_node_called
.
add
(
impl
)
self
.
prepare_node_called
.
add
(
impl
)
...
...
tests/graph/test_basic.py
浏览文件 @
880a57aa
...
@@ -23,7 +23,6 @@ from pytensor.graph.basic import (
...
@@ -23,7 +23,6 @@ from pytensor.graph.basic import (
get_var_by_name
,
get_var_by_name
,
graph_inputs
,
graph_inputs
,
io_toposort
,
io_toposort
,
list_of_nodes
,
orphans_between
,
orphans_between
,
truncated_graph_inputs
,
truncated_graph_inputs
,
variable_depends_on
,
variable_depends_on
,
...
@@ -567,17 +566,6 @@ def test_ops():
...
@@ -567,17 +566,6 @@ def test_ops():
assert
res_list
==
[
o3
.
owner
,
o2
.
owner
,
o1
.
owner
]
assert
res_list
==
[
o3
.
owner
,
o2
.
owner
,
o1
.
owner
]
def
test_list_of_nodes
():
r1
,
r2
,
r3
=
MyVariable
(
1
),
MyVariable
(
2
),
MyVariable
(
3
)
o1
=
MyOp
(
r1
,
r2
)
o1
.
name
=
"o1"
o2
=
MyOp
(
r3
,
o1
)
o2
.
name
=
"o2"
res
=
list_of_nodes
([
r1
,
r2
],
[
o2
])
assert
res
==
[
o2
.
owner
,
o1
.
owner
]
def
test_apply_depends_on
():
def
test_apply_depends_on
():
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论