Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8464ed71
提交
8464ed71
authored
8月 04, 2015
作者:
Frederic
提交者:
ChienliMa
8月 20, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix profiling and add name to Function.copy()
上级
2ba562ae
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
4 行删除
+27
-4
function_module.py
theano/compile/function_module.py
+26
-3
pfunc.py
theano/compile/pfunc.py
+1
-1
没有找到文件。
theano/compile/function_module.py
浏览文件 @
8464ed71
...
@@ -15,7 +15,7 @@ import warnings
...
@@ -15,7 +15,7 @@ import warnings
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
gof
from
theano
import
config
,
gof
from
functools
import
partial
from
functools
import
partial
from
theano.compat
import
izip
from
theano.compat
import
izip
from
theano.gof
import
graph
from
theano.gof
import
graph
...
@@ -542,7 +542,8 @@ class Function(object):
...
@@ -542,7 +542,8 @@ class Function(object):
"""
"""
return
self
.
copy
()
return
self
.
copy
()
def
copy
(
self
,
share_memory
=
False
,
swap
=
None
,
delete_updates
=
False
):
def
copy
(
self
,
share_memory
=
False
,
swap
=
None
,
delete_updates
=
False
,
name
=
None
,
profile
=
None
):
"""
"""
Copy this function. Copied function will have separated maker and
Copy this function. Copied function will have separated maker and
fgraph with original function. User can choose whether to separate
fgraph with original function. User can choose whether to separate
...
@@ -562,6 +563,11 @@ class Function(object):
...
@@ -562,6 +563,11 @@ class Function(object):
delete_updates -- { boolean } Default is False. If True, Copied
delete_updates -- { boolean } Default is False. If True, Copied
function will not have update.
function will not have update.
name -- { string } If provided, will be the name of the new
Function. Otherwise, it will be old + " copy"
profile -- as theano.function profile parameter
---------------------
---------------------
Returns:
Returns:
func -- Copied theano.Function
func -- Copied theano.Function
...
@@ -664,11 +670,26 @@ class Function(object):
...
@@ -664,11 +670,26 @@ class Function(object):
for
key
in
storage_map
.
keys
():
for
key
in
storage_map
.
keys
():
if
key
not
in
i_o_vars
:
if
key
not
in
i_o_vars
:
new_storage_map
[
memo
[
key
]]
=
storage_map
[
key
]
new_storage_map
[
memo
[
key
]]
=
storage_map
[
key
]
if
not
name
and
self
.
name
:
name
=
self
.
name
+
" copy"
input_storage
=
[
i
.
value
for
i
in
ins
]
input_storage
=
[
i
.
value
for
i
in
ins
]
# reinitialize new maker and create new function
# reinitialize new maker and create new function
if
profile
is
None
:
profile
=
config
.
profile
# profile -> True or False
if
profile
is
True
:
if
name
:
message
=
name
else
:
message
=
str
(
maker
.
profile
.
message
)
+
" copy"
profile
=
theano
.
compile
.
profiling
.
ProfileStats
(
message
=
message
)
# profile -> object
elif
type
(
profile
)
==
str
:
profile
=
theano
.
compile
.
profiling
.
ProfileStats
(
message
=
profile
)
f_cpy
=
maker
.
__class__
(
inputs
=
ins
,
outputs
=
outs
,
fgraph
=
fg_cpy
,
f_cpy
=
maker
.
__class__
(
inputs
=
ins
,
outputs
=
outs
,
fgraph
=
fg_cpy
,
mode
=
maker
.
mode
,
profile
=
maker
.
profile
,
mode
=
maker
.
mode
,
profile
=
profile
,
on_unused_input
=
maker
.
on_unused_input
,
on_unused_input
=
maker
.
on_unused_input
,
function_builder
=
maker
.
function_builder
,
function_builder
=
maker
.
function_builder
,
accept_inplace
=
maker
.
accept_inplace
accept_inplace
=
maker
.
accept_inplace
...
@@ -699,6 +720,8 @@ class Function(object):
...
@@ -699,6 +720,8 @@ class Function(object):
f_cpy
.
finder
[
swap
[
in_ori
.
variable
]]
=
container
f_cpy
.
finder
[
swap
[
in_ori
.
variable
]]
=
container
in_cpy
.
variable
=
swap
[
in_ori
.
variable
]
in_cpy
.
variable
=
swap
[
in_ori
.
variable
]
f_cpy
.
name
=
name
f_cpy
.
maker
.
fgraph
.
name
=
name
return
f_cpy
return
f_cpy
def
__call__
(
self
,
*
args
,
**
kwargs
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
...
...
theano/compile/pfunc.py
浏览文件 @
8464ed71
...
@@ -421,7 +421,7 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
...
@@ -421,7 +421,7 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
if
profile
is
True
:
if
profile
is
True
:
profile
=
ProfileStats
(
message
=
name
)
profile
=
ProfileStats
(
message
=
name
)
# profile -> object
# profile -> object
if
type
(
profile
)
==
str
:
el
if
type
(
profile
)
==
str
:
profile
=
ProfileStats
(
message
=
profile
)
profile
=
ProfileStats
(
message
=
profile
)
# profile is typically either False or an object at this point.
# profile is typically either False or an object at this point.
# No need to block other objects being passed through though. It might be
# No need to block other objects being passed through though. It might be
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论