Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
846cfabd
提交
846cfabd
authored
5月 27, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Checking tensortype before creating new graph
上级
39d04970
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
22 行删除
+28
-22
gcc
gcc
+0
-2
opt.py
theano/gpuarray/opt.py
+28
-20
没有找到文件。
gcc
deleted
120000 → 0
浏览文件 @
39d04970
/usr/bin/gcc
\ No newline at end of file
theano/gpuarray/opt.py
浏览文件 @
846cfabd
...
@@ -11,7 +11,7 @@ from theano.compile import optdb
...
@@ -11,7 +11,7 @@ from theano.compile import optdb
from
theano.compile.ops
import
shape_i
from
theano.compile.ops
import
shape_i
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
TopoOptimizer
,
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
TopoOptimizer
,
SequenceDB
,
Optimizer
,
toolbox
)
SequenceDB
,
Optimizer
,
toolbox
)
from
theano.gof.optdb
import
LocalGroupDB
from
theano.gof.optdb
import
LocalGroupDB
,
Query
from
theano.gof.op
import
Op
from
theano.gof.op
import
Op
from
theano.ifelse
import
IfElse
from
theano.ifelse
import
IfElse
...
@@ -228,16 +228,20 @@ class GraphToGPU(Optimizer):
...
@@ -228,16 +228,20 @@ class GraphToGPU(Optimizer):
move_to_GPU
=
True
move_to_GPU
=
True
# Building a new graph
# Building a new graph
# Iterating through inputs of graph
for
i
in
fgraph
.
inputs
:
for
i
in
fgraph
.
inputs
:
if
type
(
i
)
is
not
theano
.
tensor
.
TensorVariable
:
if
isinstance
(
i
.
type
,
tensor
.
TensorType
):
continue
mapping
[
i
]
=
GpuFromHost
(
None
)(
i
)
mapping
[
i
]
=
GpuFromHost
(
None
)(
i
)
else
:
mapping
[
i
]
=
i
# Iterating through output of all the nodes
for
n
in
fgraph
.
toposort
():
for
n
in
fgraph
.
toposort
():
for
o
in
n
.
outputs
:
for
o
in
n
.
outputs
:
if
type
(
o
)
is
not
theano
.
tensor
.
TensorVariable
:
if
isinstance
(
i
.
type
,
tensor
.
TensorType
):
continue
mapping
[
o
]
=
GpuFromHost
(
None
)(
o
)
mapping
[
o
]
=
GpuFromHost
(
None
)(
o
)
else
:
mapping
[
o
]
=
o
for
node
in
fgraph
.
toposort
():
for
node
in
fgraph
.
toposort
():
...
@@ -252,25 +256,23 @@ class GraphToGPU(Optimizer):
...
@@ -252,25 +256,23 @@ class GraphToGPU(Optimizer):
# Will return a list of OP
# Will return a list of OP
# If None, means can't be moved.
# If None, means can't be moved.
new_ops
=
[]
new_ops
=
None
for
lopt
in
(
gpu_optimizer
.
query
()
.
local_optimizers_all
+
gpu_optimizer
.
query
()
.
local_optimizers_map
.
get
(
type
(
node
.
op
),
[])
+
gpu_optimizer
.
query
()
.
local_optimizers_map
.
get
(
node
.
op
,
[])):
new_ops
.
append
(
lopt
.
transform
(
node
)
or
lopt
(
node
))
# Selecting the best optimizer
# TODO : the tag should be updated to the one user provides
# currently using fast_run and fast_compile tag
for
lopt
in
(
gpu_optimizer
.
query
(
include
=
[
'fast_run'
,
'fast_compile'
])
.
local_optimizers_all
+
gpu_optimizer
.
query
(
include
=
[
'fast_run'
,
'fast_compile'
])
.
local_optimizers_map
.
get
(
type
(
node
.
op
),
[])
+
gpu_optimizer
.
query
(
include
=
[
'fast_run'
,
'fast_compile'
])
.
local_optimizers_map
.
get
(
node
.
op
,
[])):
if
all
(
isinstance
(
x
,
Op
)
for
x
in
new_ops
):
new_ops
=
lopt
.
transform
(
node
)
or
lopt
(
node
)
move_to_GPU
=
False
break
if
not
new_ops
:
if
not
new_ops
:
move_to_GPU
=
False
move_to_GPU
=
False
for
i
in
node
.
inputs
:
if
type
(
i
)
is
not
theano
.
tensor
.
TensorVariable
:
continue
newnode
=
node
.
clone_with_new_inputs
([
mapping
.
get
(
i
)
for
i
in
node
.
inputs
])
if
move_to_GPU
:
if
move_to_GPU
:
newnode
=
new_ops
(
*
[
mapping
.
get
(
i
)
for
i
in
node
.
inputs
])
for
new_o
,
old_o
in
zip
(
newnode
.
outputs
,
node
.
outputs
):
for
new_o
,
old_o
in
zip
(
newnode
.
outputs
,
node
.
outputs
):
mapping
[
old_o
]
=
new_o
mapping
[
old_o
]
=
new_o
else
:
else
:
...
@@ -278,9 +280,15 @@ class GraphToGPU(Optimizer):
...
@@ -278,9 +280,15 @@ class GraphToGPU(Optimizer):
mapping
[
o
]
=
o
mapping
[
o
]
=
o
for
o
in
fgraph
.
outputs
:
for
o
in
fgraph
.
outputs
:
if
type
(
i
)
is
not
theano
.
tensor
.
TensorVariable
:
try
:
continue
new_o
=
mapping
[
o
]
fgraph
.
replace_validate
(
o
,
mapping
[
o
])
except
KeyError
as
k
:
pass
if
new_o
.
type
!=
o
.
type
:
assert
isinstance
(
o
.
type
,
tensor
.
TensorType
)
assert
isinstance
(
new_o
.
type
,
GpuArrayType
)
new_o
=
host_from_gpu
(
new_o
)
fgraph
.
replace_validate
(
o
,
new_o
)
gpu_seqopt
.
register
(
'GraphToGPU'
,
GraphToGPU
(),
gpu_seqopt
.
register
(
'GraphToGPU'
,
GraphToGPU
(),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论