Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
df769f6c
提交
df769f6c
authored
5月 24, 2024
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
7月 03, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add dprint shortcut to FunctionGraph and Function
上级
448e5582
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
38 行增加
和
0 行删除
+38
-0
types.py
pytensor/compile/function/types.py
+12
-0
fg.py
pytensor/graph/fg.py
+12
-0
test_types.py
tests/compile/function/test_types.py
+7
-0
test_fg.py
tests/graph/test_fg.py
+7
-0
没有找到文件。
pytensor/compile/function/types.py
浏览文件 @
df769f6c
...
@@ -1097,6 +1097,18 @@ class Function:
...
@@ -1097,6 +1097,18 @@ class Function:
# NOTE: sync was needed on old gpu backend
# NOTE: sync was needed on old gpu backend
pass
pass
def
dprint
(
self
,
**
kwargs
):
"""Debug print itself
Parameters
----------
kwargs:
Optional keyword arguments to pass to debugprint function.
"""
from
pytensor.printing
import
debugprint
return
debugprint
(
self
,
**
kwargs
)
# pickling/deepcopy support for Function
# pickling/deepcopy support for Function
def
_pickle_Function
(
f
):
def
_pickle_Function
(
f
):
...
...
pytensor/graph/fg.py
浏览文件 @
df769f6c
...
@@ -927,3 +927,15 @@ class FunctionGraph(MetaObject):
...
@@ -927,3 +927,15 @@ class FunctionGraph(MetaObject):
return
item
in
self
.
apply_nodes
return
item
in
self
.
apply_nodes
else
:
else
:
raise
TypeError
()
raise
TypeError
()
def
dprint
(
self
,
**
kwargs
):
"""Debug print itself
Parameters
----------
kwargs:
Optional keyword arguments to pass to debugprint function.
"""
from
pytensor.printing
import
debugprint
return
debugprint
(
self
,
**
kwargs
)
tests/compile/function/test_types.py
浏览文件 @
df769f6c
...
@@ -16,6 +16,7 @@ from pytensor.graph.basic import Constant
...
@@ -16,6 +16,7 @@ from pytensor.graph.basic import Constant
from
pytensor.graph.rewriting.basic
import
OpKeyGraphRewriter
,
PatternNodeRewriter
from
pytensor.graph.rewriting.basic
import
OpKeyGraphRewriter
,
PatternNodeRewriter
from
pytensor.graph.utils
import
MissingInputError
from
pytensor.graph.utils
import
MissingInputError
from
pytensor.link.vm
import
VMLinker
from
pytensor.link.vm
import
VMLinker
from
pytensor.printing
import
debugprint
from
pytensor.tensor.math
import
dot
,
tanh
from
pytensor.tensor.math
import
dot
,
tanh
from
pytensor.tensor.math
import
sum
as
pt_sum
from
pytensor.tensor.math
import
sum
as
pt_sum
from
pytensor.tensor.type
import
(
from
pytensor.tensor.type
import
(
...
@@ -862,6 +863,12 @@ class TestFunction:
...
@@ -862,6 +863,12 @@ class TestFunction:
with
pytest
.
raises
(
AssertionError
):
with
pytest
.
raises
(
AssertionError
):
function
([
x
],
outputs
=
{(
1
,
"b"
):
x
,
1.0
:
x
**
2
})
function
([
x
],
outputs
=
{(
1
,
"b"
):
x
,
1.0
:
x
**
2
})
def
test_dprint
(
self
):
x
=
pt
.
scalar
(
"x"
)
out
=
x
+
1
f
=
function
([
x
],
out
)
assert
f
.
dprint
(
file
=
"str"
)
==
debugprint
(
f
,
file
=
"str"
)
class
TestPicklefunction
:
class
TestPicklefunction
:
def
test_deepcopy
(
self
):
def
test_deepcopy
(
self
):
...
...
tests/graph/test_fg.py
浏览文件 @
df769f6c
...
@@ -8,6 +8,7 @@ from pytensor.configdefaults import config
...
@@ -8,6 +8,7 @@ from pytensor.configdefaults import config
from
pytensor.graph.basic
import
NominalVariable
from
pytensor.graph.basic
import
NominalVariable
from
pytensor.graph.fg
import
FunctionGraph
from
pytensor.graph.fg
import
FunctionGraph
from
pytensor.graph.utils
import
MissingInputError
from
pytensor.graph.utils
import
MissingInputError
from
pytensor.printing
import
debugprint
from
tests.graph.utils
import
(
from
tests.graph.utils
import
(
MyConstant
,
MyConstant
,
MyOp
,
MyOp
,
...
@@ -706,3 +707,9 @@ class TestFunctionGraph:
...
@@ -706,3 +707,9 @@ class TestFunctionGraph:
assert
nm2
not
in
fg
.
inputs
assert
nm2
not
in
fg
.
inputs
assert
nm
in
fg
.
variables
assert
nm
in
fg
.
variables
assert
nm2
in
fg
.
variables
assert
nm2
in
fg
.
variables
def
test_dprint
(
self
):
r1
,
r2
=
MyVariable
(
"x"
),
MyVariable
(
"y"
)
o1
=
op1
(
r1
,
r2
)
fg
=
FunctionGraph
([
r1
,
r2
],
[
o1
],
clone
=
False
)
assert
fg
.
dprint
(
file
=
"str"
)
==
debugprint
(
fg
,
file
=
"str"
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论