Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f8ba9bb1
提交
f8ba9bb1
authored
12月 02, 2016
作者:
Thomas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added op lifter for slinalg.solve
上级
1494d16f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
0 行删除
+27
-0
opt.py
theano/gpuarray/opt.py
+10
-0
test_opt.py
theano/gpuarray/tests/test_opt.py
+17
-0
没有找到文件。
theano/gpuarray/opt.py
浏览文件 @
f8ba9bb1
...
...
@@ -31,6 +31,7 @@ from theano.tensor.nnet.abstract_conv import (BaseAbstractConv,
AbstractConv3d_gradWeights
,
AbstractConv3d_gradInputs
)
import
theano.tensor.signal.pool
as
pool
import
theano.tensor.slinalg
as
slinalg
from
theano.tests.breakpoint
import
PdbBreakpoint
...
...
@@ -68,6 +69,7 @@ from .subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1_dev20
)
from
.opt_util
import
alpha_merge
,
output_merge
,
pad_dims
,
unpad_dims
from
.reduction
import
GpuMaxAndArgmax
from
.linalg
import
GpuCusolverSolve
_logger
=
logging
.
getLogger
(
"theano.gpuarray.opt"
)
...
...
@@ -1884,6 +1886,14 @@ def _scan_type_infer(node):
def
local_gpu_maxandargmax
(
op
,
context_name
,
inputs
,
outputs
):
return
GpuMaxAndArgmax
(
op
.
get_params
(
None
))
# solve
@register_opt
(
'fast_compile'
)
@op_lifter
([
theano
.
tensor
.
slinalg
.
Solve
])
@register_opt2
([
theano
.
tensor
.
slinalg
.
Solve
],
'fast_compile'
)
def
local_gpu_solve
(
op
,
context_name
,
inputs
,
outputs
):
return
GpuCusolverSolve
()
# Do not register in fast_run or fast_compile.
# It will be added to fast_run if the GPU is enabled.
optdb
.
register
(
'gpua_scanOp_make_inplace'
,
...
...
theano/gpuarray/tests/test_opt.py
浏览文件 @
f8ba9bb1
...
...
@@ -4,6 +4,7 @@ from nose.tools import assert_raises
import
theano
from
theano
import
tensor
import
theano.tensor.slinalg
as
slinalg
from
theano.tests.breakpoint
import
PdbBreakpoint
from
theano.tests
import
unittest_tools
as
utt
,
test_ifelse
from
theano.tensor.tests
import
test_basic
...
...
@@ -16,6 +17,7 @@ from ..basic_ops import (
from
..blas
import
GpuGemm
from
..elemwise
import
GpuCAReduceCuda
,
GpuCAReduceCPY
,
GpuElemwise
from
..subtensor
import
GpuSubtensor
from
..linalg
import
GpuCusolverSolve
from
.config
import
mode_with_gpu
,
test_ctx_name
...
...
@@ -496,3 +498,18 @@ def test_no_complex():
stft_out
=
tensor
.
exp
(
width_var
*
freq_var
)
*
signal_var
theano
.
function
([
width_var
,
freq_var
,
signal_var
],
stft_out
,
mode
=
mode_with_gpu
)
def
test_local_lift_solve
():
A
=
tensor
.
fmatrix
()
b
=
tensor
.
fmatrix
()
o
=
slinalg
.
solve
(
A
,
b
)
f_cpu
=
theano
.
function
([
A
,
b
],
o
)
f_gpu
=
theano
.
function
([
A
,
b
],
o
,
mode
=
mode_with_gpu
)
assert
not
any
(
isinstance
(
n
.
op
,
slinalg
.
Solve
)
for
n
in
f_gpu
.
maker
.
fgraph
.
apply_nodes
)
assert
any
(
isinstance
(
n
.
op
,
GpuCusolverSolve
)
for
n
in
f_gpu
.
maker
.
fgraph
.
apply_nodes
)
A_val
=
numpy
.
random
.
uniform
(
-
0.4
,
0.4
,
(
5
,
5
))
.
astype
(
"float32"
)
b_val
=
numpy
.
random
.
uniform
(
-
0.4
,
0.4
,
(
5
,
3
))
.
astype
(
"float32"
)
utt
.
assert_allclose
(
f_cpu
(
A_val
,
b_val
),
f_gpu
(
A_val
,
b_val
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论