Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cd26cc10
提交
cd26cc10
authored
11月 24, 2014
作者:
f0k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor cleanups suggested by @nouiz
上级
17f7b9ec
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
18 行删除
+17
-18
opt.py
theano/gof/opt.py
+2
-3
opt.py
theano/sandbox/cuda/opt.py
+15
-15
没有找到文件。
theano/gof/opt.py
浏览文件 @
cd26cc10
...
@@ -839,7 +839,7 @@ class LocalMetaOptimizer(LocalOptimizer):
...
@@ -839,7 +839,7 @@ class LocalMetaOptimizer(LocalOptimizer):
return
self
.
_tracks
return
self
.
_tracks
def
transform
(
self
,
node
):
def
transform
(
self
,
node
):
# safety check:
not sure if needed, but all optimizers do it
# safety check:
depending on registration, tracks may have been ignored
if
self
.
_tracks
is
not
None
:
if
self
.
_tracks
is
not
None
:
if
not
isinstance
(
node
.
op
,
tuple
(
self
.
_tracks
)):
if
not
isinstance
(
node
.
op
,
tuple
(
self
.
_tracks
)):
return
return
...
@@ -852,8 +852,7 @@ class LocalMetaOptimizer(LocalOptimizer):
...
@@ -852,8 +852,7 @@ class LocalMetaOptimizer(LocalOptimizer):
pass
pass
elif
hasattr
(
input
.
tag
,
'test_value'
):
elif
hasattr
(
input
.
tag
,
'test_value'
):
givens
[
input
]
=
theano
.
shared
(
givens
[
input
]
=
theano
.
shared
(
numpy
.
require
(
input
.
tag
.
test_value
,
input
.
type
.
filter
(
input
.
tag
.
test_value
),
dtype
=
input
.
dtype
),
input
.
name
,
borrow
=
True
)
input
.
name
,
borrow
=
True
)
else
:
else
:
missing
.
add
(
input
)
missing
.
add
(
input
)
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
cd26cc10
...
@@ -155,21 +155,6 @@ gpu_seqopt.register('InputToGpuOptimizer', InputToGpuOptimizer(),
...
@@ -155,21 +155,6 @@ gpu_seqopt.register('InputToGpuOptimizer', InputToGpuOptimizer(),
'merge'
)
# TODO: how to make it mandatory for gpu_seqopt?
'merge'
)
# TODO: how to make it mandatory for gpu_seqopt?
class
LocalCudaMetaOptimizer
(
LocalMetaOptimizer
):
"""Base class for CUDA-based LocalMetaOptimizers"""
def
__init__
(
self
,
*
args
):
super
(
LocalCudaMetaOptimizer
,
self
)
.
__init__
(
*
args
)
def
time_call
(
self
,
fn
):
# Override time_call() to do device synchronization
theano
.
sandbox
.
cuda
.
synchronize
()
start
=
time
.
time
()
fn
()
theano
.
sandbox
.
cuda
.
synchronize
()
return
time
.
time
()
-
start
@local_optimizer
([
gpu_from_host
,
host_from_gpu
])
@local_optimizer
([
gpu_from_host
,
host_from_gpu
])
def
local_cut_gpu_host_gpu
(
node
):
def
local_cut_gpu_host_gpu
(
node
):
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
gpu_from_host
,
host_from_gpu
):
if
tensor
.
opt
.
opt
.
check_chain
(
node
,
gpu_from_host
,
host_from_gpu
):
...
@@ -1362,6 +1347,18 @@ conv_groupopt.register('local_conv_gemm', local_conv_gemm, 30,
...
@@ -1362,6 +1347,18 @@ conv_groupopt.register('local_conv_gemm', local_conv_gemm, 30,
'fast_compile'
,
'fast_run'
)
'fast_compile'
,
'fast_run'
)
class
LocalCudaMetaOptimizer
(
LocalMetaOptimizer
):
"""Base class for CUDA-based LocalMetaOptimizers"""
def
time_call
(
self
,
fn
):
# Override time_call() to do device synchronization
theano
.
sandbox
.
cuda
.
synchronize
()
start
=
time
.
time
()
fn
()
theano
.
sandbox
.
cuda
.
synchronize
()
return
time
.
time
()
-
start
# Convolution Meta-optimizer
# Convolution Meta-optimizer
class
ConvMetaOptimizer
(
LocalCudaMetaOptimizer
):
class
ConvMetaOptimizer
(
LocalCudaMetaOptimizer
):
...
@@ -1386,6 +1383,9 @@ class ConvMetaOptimizer(LocalCudaMetaOptimizer):
...
@@ -1386,6 +1383,9 @@ class ConvMetaOptimizer(LocalCudaMetaOptimizer):
(
shape
is
not
None
)
and
(
shape
is
not
None
)
and
not
any
(
s
is
None
for
s
in
shape
)):
not
any
(
s
is
None
for
s
in
shape
)):
result
[
var
]
=
theano
.
shared
(
result
[
var
]
=
theano
.
shared
(
# TODO: Use var.type.filter when cuda_ndarray.filter supports non-strict casts
# var.type.filter(numpy.random.randn(*shape),
# allow_downcast=True),
numpy
.
require
(
numpy
.
random
.
randn
(
*
shape
),
numpy
.
require
(
numpy
.
random
.
randn
(
*
shape
),
dtype
=
var
.
dtype
),
dtype
=
var
.
dtype
),
var
.
name
,
borrow
=
True
)
var
.
name
,
borrow
=
True
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论