Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ea0d37ec
提交
ea0d37ec
authored
6月 24, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduced unwanted code
上级
d7688cea
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
8 行增加
和
19 行删除
+8
-19
opt.py
theano/gpuarray/opt.py
+7
-16
test_basic_ops.py
theano/gpuarray/tests/test_basic_ops.py
+1
-1
opt.py
theano/tensor/opt.py
+0
-2
没有找到文件。
theano/gpuarray/opt.py
浏览文件 @
ea0d37ec
...
@@ -342,7 +342,8 @@ class GraphToGPU(NavigatorOptimizer):
...
@@ -342,7 +342,8 @@ class GraphToGPU(NavigatorOptimizer):
break
break
if
(
not
move_to_GPU
and
if
(
not
move_to_GPU
and
isinstance
(
node
.
op
,
(
theano
.
tensor
.
Alloc
,
isinstance
(
node
.
op
,
(
theano
.
tensor
.
Alloc
,
theano
.
tensor
.
AllocEmpty
))):
theano
.
tensor
.
AllocEmpty
,
theano
.
tensor
.
basic
.
Eye
))):
# If the Alloc[Empty] have a client that will be moved
# If the Alloc[Empty] have a client that will be moved
# to the GPU, we should move the Alloc* on the GPU.
# to the GPU, we should move the Alloc* on the GPU.
...
@@ -762,9 +763,7 @@ def local_gpua_dimshuffle(op, context_name, inputs, outputs):
...
@@ -762,9 +763,7 @@ def local_gpua_dimshuffle(op, context_name, inputs, outputs):
def
local_gpua_specifyShape
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpua_specifyShape
(
op
,
context_name
,
inputs
,
outputs
):
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
return
return
inp
=
[
as_gpuarray_variable
(
inputs
[
0
],
context_name
)]
return
local_gpua_specifyShape_graph
(
op
,
context_name
,
inputs
,
outputs
)
inp
+=
inputs
[
1
:]
return
tensor
.
specify_shape
(
*
inp
)
@register_opt2
([
tensor
.
SpecifyShape
],
'fast_compile'
)
@register_opt2
([
tensor
.
SpecifyShape
],
'fast_compile'
)
...
@@ -781,13 +780,11 @@ def local_gpua_shape(op, context_name, inputs, outputs):
...
@@ -781,13 +780,11 @@ def local_gpua_shape(op, context_name, inputs, outputs):
# always on the CPU.
# always on the CPU.
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
return
return
return
[
as_gpuarray_variable
(
inputs
[
0
],
context_name
)
.
shape
]
return
local_gpua_shape_graph
(
op
,
context_name
,
inputs
,
outputs
)
@register_opt2
([
tensor
.
compile
.
ops
.
Shape
],
'fast_compile'
)
@register_opt2
([
tensor
.
compile
.
ops
.
Shape
],
'fast_compile'
)
def
local_gpua_shape_graph
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpua_shape_graph
(
op
,
context_name
,
inputs
,
outputs
):
# op_lifter will call this opt too frequently as the output is
# always on the CPU.
return
[
as_gpuarray_variable
(
inputs
[
0
],
context_name
)
.
shape
]
return
[
as_gpuarray_variable
(
inputs
[
0
],
context_name
)
.
shape
]
...
@@ -1209,7 +1206,7 @@ def local_gpua_dot22scalar(op, context_name, inputs, outputs):
...
@@ -1209,7 +1206,7 @@ def local_gpua_dot22scalar(op, context_name, inputs, outputs):
@op_lifter
([
tensor
.
basic
.
Eye
])
@op_lifter
([
tensor
.
basic
.
Eye
])
@register_opt2
([
tensor
.
basic
.
Eye
],
'fast_compile'
)
@register_opt2
([
tensor
.
basic
.
Eye
],
'fast_compile'
)
def
local_gpua_eye
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpua_eye
(
op
,
context_name
,
inputs
,
outputs
):
return
GpuEye
(
dtype
=
op
.
dtype
,
context_name
=
context_name
)
return
[
GpuEye
(
dtype
=
op
.
dtype
,
context_name
=
context_name
)(
*
inputs
)]
@register_opt
(
'fast_compile'
)
@register_opt
(
'fast_compile'
)
...
@@ -1245,8 +1242,7 @@ def local_gpua_softmaxwithbias(op, context_name, inputs, outputs):
...
@@ -1245,8 +1242,7 @@ def local_gpua_softmaxwithbias(op, context_name, inputs, outputs):
def
local_assert
(
op
,
context_name
,
inputs
,
outputs
):
def
local_assert
(
op
,
context_name
,
inputs
,
outputs
):
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
if
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
return
return
return
[
op
(
as_gpuarray_variable
(
inputs
[
0
],
context_name
),
return
local_assert_graph
(
op
,
context_name
,
inputs
,
outputs
)
*
inputs
[
1
:])]
@register_opt2
([
theano
.
tensor
.
opt
.
Assert
],
'fast_compile'
)
@register_opt2
([
theano
.
tensor
.
opt
.
Assert
],
'fast_compile'
)
...
@@ -1310,12 +1306,7 @@ def local_lift_abstractconv2d(op, context_name, inputs, outputs):
...
@@ -1310,12 +1306,7 @@ def local_lift_abstractconv2d(op, context_name, inputs, outputs):
if
isinstance
(
outputs
[
0
]
.
type
,
GpuArrayType
):
if
isinstance
(
outputs
[
0
]
.
type
,
GpuArrayType
):
# Don't handle this node here, it's already on the GPU.
# Don't handle this node here, it's already on the GPU.
return
return
inps
=
list
(
inputs
)
local_lift_abstractconv2d_graph
(
op
,
context_name
,
inputs
,
outputs
)
inps
[
0
]
=
as_gpuarray_variable
(
inputs
[
0
],
context_name
=
context_name
)
inps
[
1
]
=
as_gpuarray_variable
(
inputs
[
1
],
context_name
=
context_name
)
return
[
op
(
*
inps
)]
@register_opt2
([
AbstractConv2d
,
@register_opt2
([
AbstractConv2d
,
...
...
theano/gpuarray/tests/test_basic_ops.py
浏览文件 @
ea0d37ec
...
@@ -396,7 +396,7 @@ def test_gpueye():
...
@@ -396,7 +396,7 @@ def test_gpueye():
k_symb
=
numpy
.
asarray
(
0
)
k_symb
=
numpy
.
asarray
(
0
)
out
=
T
.
eye
(
N_symb
,
M_symb
,
k_symb
,
dtype
=
dtype
)
out
=
T
.
eye
(
N_symb
,
M_symb
,
k_symb
,
dtype
=
dtype
)
f
=
theano
.
function
([
N_symb
,
M_symb
],
f
=
theano
.
function
([
N_symb
,
M_symb
],
out
,
T
.
stack
(
out
)
,
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
result
=
numpy
.
asarray
(
f
(
N
,
M
))
result
=
numpy
.
asarray
(
f
(
N
,
M
))
assert
numpy
.
allclose
(
result
,
numpy
.
eye
(
N
,
M_
,
dtype
=
dtype
))
assert
numpy
.
allclose
(
result
,
numpy
.
eye
(
N
,
M_
,
dtype
=
dtype
))
...
...
theano/tensor/opt.py
浏览文件 @
ea0d37ec
...
@@ -1477,8 +1477,6 @@ class UnShapeOptimizer(Optimizer):
...
@@ -1477,8 +1477,6 @@ class UnShapeOptimizer(Optimizer):
# Register it after merge1 optimization at 0. We don't want to track
# Register it after merge1 optimization at 0. We don't want to track
# the shape of merged node.
# the shape of merged node.
# As local_shape_to_shape_i is not in fast_compile,
# dont register this opt in fast_compile.
theano
.
compile
.
mode
.
optdb
.
register
(
'ShapeOpt'
,
ShapeOptimizer
(),
theano
.
compile
.
mode
.
optdb
.
register
(
'ShapeOpt'
,
ShapeOptimizer
(),
0.1
,
'fast_run'
,
'fast_compile'
)
0.1
,
'fast_run'
,
'fast_compile'
)
# Not enabled by default for now. Some crossentropy opt use the
# Not enabled by default for now. Some crossentropy opt use the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论