Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f6297134
提交
f6297134
authored
11月 21, 2022
作者:
Brandon T. Willard
提交者:
Ricardo Vieira
11月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set the global mode during compilation
上级
bdf98ca9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
7 行删除
+14
-7
types.py
pytensor/compile/function/types.py
+14
-7
没有找到文件。
pytensor/compile/function/types.py
浏览文件 @
f6297134
...
@@ -32,6 +32,7 @@ from pytensor.link.utils import raise_with_op
...
@@ -32,6 +32,7 @@ from pytensor.link.utils import raise_with_op
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
pytensor.compile.mode
import
Mode
from
pytensor.link.vm
import
VM
from
pytensor.link.vm
import
VM
...
@@ -1391,9 +1392,16 @@ class FunctionMaker:
...
@@ -1391,9 +1392,16 @@ class FunctionMaker:
@staticmethod
@staticmethod
def
prepare_fgraph
(
def
prepare_fgraph
(
inputs
,
outputs
,
additional_outputs
,
fgraph
,
rewriter
,
linker
,
profile
inputs
,
outputs
,
additional_outputs
,
fgraph
:
FunctionGraph
,
mode
:
"Mode"
,
profile
,
):
):
rewriter
=
mode
.
optimizer
try
:
try
:
start_rewriter
=
time
.
perf_counter
()
start_rewriter
=
time
.
perf_counter
()
...
@@ -1401,6 +1409,7 @@ class FunctionMaker:
...
@@ -1401,6 +1409,7 @@ class FunctionMaker:
rewrite_time
=
None
rewrite_time
=
None
with
config
.
change_flags
(
with
config
.
change_flags
(
mode
=
mode
,
compute_test_value
=
config
.
compute_test_value_opt
,
compute_test_value
=
config
.
compute_test_value_opt
,
traceback__limit
=
config
.
traceback__compile_limit
,
traceback__limit
=
config
.
traceback__compile_limit
,
):
):
...
@@ -1440,7 +1449,7 @@ class FunctionMaker:
...
@@ -1440,7 +1449,7 @@ class FunctionMaker:
stacklevel
=
3
,
stacklevel
=
3
,
)
)
if
not
hasattr
(
linker
,
"accept"
):
if
not
hasattr
(
mode
.
linker
,
"accept"
):
raise
ValueError
(
raise
ValueError
(
"'linker' parameter of FunctionMaker should be "
"'linker' parameter of FunctionMaker should be "
f
"a Linker with an accept method or one of {list(pytensor.compile.mode.predefined_linkers.keys())}"
f
"a Linker with an accept method or one of {list(pytensor.compile.mode.predefined_linkers.keys())}"
...
@@ -1511,12 +1520,8 @@ class FunctionMaker:
...
@@ -1511,12 +1520,8 @@ class FunctionMaker:
self
.
fgraph
=
fgraph
self
.
fgraph
=
fgraph
rewriter
,
linker
=
mode
.
optimizer
,
copy
.
copy
(
mode
.
linker
)
if
not
no_fgraph_prep
:
if
not
no_fgraph_prep
:
self
.
prepare_fgraph
(
self
.
prepare_fgraph
(
inputs
,
outputs
,
found_updates
,
fgraph
,
mode
,
profile
)
inputs
,
outputs
,
found_updates
,
fgraph
,
rewriter
,
linker
,
profile
)
assert
len
(
fgraph
.
outputs
)
==
len
(
outputs
+
found_updates
)
assert
len
(
fgraph
.
outputs
)
==
len
(
outputs
+
found_updates
)
...
@@ -1528,6 +1533,8 @@ class FunctionMaker:
...
@@ -1528,6 +1533,8 @@ class FunctionMaker:
if
not
spec
.
borrow
if
not
spec
.
borrow
]
]
linker
=
copy
.
copy
(
mode
.
linker
)
if
no_borrow
:
if
no_borrow
:
self
.
linker
=
linker
.
accept
(
self
.
linker
=
linker
.
accept
(
fgraph
,
fgraph
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论