Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9afcee26
提交
9afcee26
authored
6月 09, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
created an fusion optimizer for the gpu.
上级
f1a3bae9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
46 行增加
和
6 行删除
+46
-6
configdefaults.py
theano/configdefaults.py
+5
-0
opt.py
theano/sandbox/cuda/opt.py
+21
-0
test_opt.py
theano/sandbox/cuda/tests/test_opt.py
+20
-6
opt.py
theano/tensor/opt.py
+0
-0
没有找到文件。
theano/configdefaults.py
浏览文件 @
9afcee26
...
@@ -45,6 +45,11 @@ AddConfigVar('tensor.local_elemwise_fusion',
...
@@ -45,6 +45,11 @@ AddConfigVar('tensor.local_elemwise_fusion',
"Enable or not in fast_run mode(fast_run optimization) the elemwise fusion optimization"
,
"Enable or not in fast_run mode(fast_run optimization) the elemwise fusion optimization"
,
BoolParam
(
True
))
BoolParam
(
True
))
AddConfigVar
(
'gpu.local_elemwise_fusion'
,
"Enable or not in fast_run mode(fast_run optimization) the gpu elemwise fusion optimization"
,
BoolParam
(
True
))
#http://developer.amd.com/CPU/LIBRARIES/LIBM/Pages/default.aspx
AddConfigVar
(
'lib.amdlibm'
,
AddConfigVar
(
'lib.amdlibm'
,
"Use amd's amdlibm numerical library"
,
"Use amd's amdlibm numerical library"
,
BoolParam
(
False
))
BoolParam
(
False
))
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
9afcee26
import
logging
_logger
=
logging
.
getLogger
(
'theano.sandbox.cuda.opt'
)
import
sys
import
sys
import
theano
import
theano
import
numpy
import
numpy
...
@@ -569,3 +572,21 @@ def local_gpu_join(node):
...
@@ -569,3 +572,21 @@ def local_gpu_join(node):
# After destroyhandler is in but before we try to make elemwise things inplace
# Try to make gpu gemm inplace
# Also, need to make the gemm optimisation(step 70) happen before the fusion of elemwise(step 71)
#optdb.register('InplaceGpuBlasOpt',
# EquilibriumOptimizer([local_inplace_gemm], failure_callback=EquilibriumOptimizer.warn_inplace,
# max_use_ratio=5),
# 70.0, 'fast_run', 'inplace')
#GpuElemwise fusion
gpu_local_elemwise_fusion
=
tensor
.
opt
.
local_elemwise_fusion_op
(
GpuElemwise
)
if
config
.
gpu
.
local_elemwise_fusion
:
_logger
.
debug
(
"enabling optimization fusion of gpu elemwise in fast_run"
)
compile
.
optdb
.
register
(
'gpu_elemwise_fusion'
,
tensor
.
opt
.
FusionOptimizer
(
gpu_local_elemwise_fusion
),
71.00
,
'fast_run'
,
'fusion'
,
'local_elemwise_fusion'
)
else
:
_logger
.
debug
(
"not enabling optimization fusion of gpu elemwise in fast_run"
)
compile
.
optdb
.
register
(
'gpu_elemwise_fusion'
,
tensor
.
opt
.
FusionOptimizer
(
gpu_local_elemwise_fusion
),
71.00
,
'fusion'
,
'local_elemwise_fusion'
)
theano/sandbox/cuda/tests/test_opt.py
浏览文件 @
9afcee26
...
@@ -7,8 +7,8 @@ import numpy
...
@@ -7,8 +7,8 @@ import numpy
# Skip test if cuda_ndarray is not available.
# Skip test if cuda_ndarray is not available.
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
import
theano.sandbox.cuda
as
cuda
_ndarray
import
theano.sandbox.cuda
as
cuda
if
cuda
_ndarray
.
cuda_available
==
False
:
if
cuda
.
cuda_available
==
False
:
raise
SkipTest
(
'Optional package cuda disabled'
)
raise
SkipTest
(
'Optional package cuda disabled'
)
import
theano.compile.mode
import
theano.compile.mode
...
@@ -76,8 +76,8 @@ def test_opt_gpujoin_onlyajoin():
...
@@ -76,8 +76,8 @@ def test_opt_gpujoin_onlyajoin():
# from a bug in normal sampling
# from a bug in normal sampling
_a
=
numpy
.
asarray
([[
1
,
2
],[
3
,
4
]],
dtype
=
'float32'
)
_a
=
numpy
.
asarray
([[
1
,
2
],[
3
,
4
]],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([[
5
,
6
,
7
],[
8
,
9
,
10
]],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([[
5
,
6
,
7
],[
8
,
9
,
10
]],
dtype
=
'float32'
)
a
=
cuda
_ndarray
.
shared_constructor
(
_a
)
a
=
cuda
.
shared_constructor
(
_a
)
b
=
cuda
_ndarray
.
shared_constructor
(
_b
)
b
=
cuda
.
shared_constructor
(
_b
)
c
=
tensor
.
join
(
1
,
a
,
b
)
c
=
tensor
.
join
(
1
,
a
,
b
)
...
@@ -100,8 +100,8 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
...
@@ -100,8 +100,8 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
# from a bug in gpu normal sampling
# from a bug in gpu normal sampling
_a
=
numpy
.
asarray
([
1
,
2
,
3
,
4
],
dtype
=
'float32'
)
_a
=
numpy
.
asarray
([
1
,
2
,
3
,
4
],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([
5
,
6
,
7
,
8
],
dtype
=
'float32'
)
_b
=
numpy
.
asarray
([
5
,
6
,
7
,
8
],
dtype
=
'float32'
)
a
=
cuda
_ndarray
.
shared_constructor
(
_a
)
a
=
cuda
.
shared_constructor
(
_a
)
b
=
cuda
_ndarray
.
shared_constructor
(
_b
)
b
=
cuda
.
shared_constructor
(
_b
)
a_prime
=
tensor
.
cos
(
a
)
a_prime
=
tensor
.
cos
(
a
)
b_prime
=
tensor
.
sin
(
b
)
b_prime
=
tensor
.
sin
(
b
)
...
@@ -125,6 +125,20 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
...
@@ -125,6 +125,20 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
assert
numpy
.
allclose
(
numpy
.
asarray
(
f
()),
concat
)
assert
numpy
.
allclose
(
numpy
.
asarray
(
f
()),
concat
)
def
test_elemwise_fusion
():
""" Test the the GpuElemwise fusion work correctly"""
shape
=
(
3
,
4
)
a
=
cuda
.
shared_constructor
(
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
'float32'
),
'a'
)
b
=
tensor
.
fmatrix
()
c
=
tensor
.
fmatrix
()
f
=
pfunc
([
b
,
c
],
[
a
+
b
+
c
],
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
env
.
toposort
()
for
i
,
node
in
enumerate
(
topo
):
print
>>
sys
.
stdout
,
i
,
node
assert
len
(
topo
)
==
4
assert
isinstance
(
topo
[
2
]
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
Composite
)
#let debugmode catch errors
f
(
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
'float32'
),
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
'float32'
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
theano/tensor/opt.py
浏览文件 @
9afcee26
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论