Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1ccf7243
提交
1ccf7243
authored
11月 23, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
7b362c83
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
19 行删除
+21
-19
dnn.py
theano/sandbox/cuda/dnn.py
+2
-5
extra_ops.py
theano/sandbox/cuda/extra_ops.py
+1
-1
opt.py
theano/sandbox/cuda/opt.py
+18
-13
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
1ccf7243
...
@@ -13,7 +13,6 @@ from theano.compile.ops import shape_i
...
@@ -13,7 +13,6 @@ from theano.compile.ops import shape_i
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.nnet
import
SoftmaxGrad
from
theano.tensor.signal.downsample
import
(
from
theano.tensor.signal.downsample
import
(
DownsampleFactorMax
,
MaxPoolGrad
,
AveragePoolGrad
)
DownsampleFactorMax
,
MaxPoolGrad
,
AveragePoolGrad
)
from
theano.tensor.opt
import
register_specialize_device
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda
import
GpuOp
from
theano.sandbox.cuda
import
GpuOp
...
@@ -33,8 +32,6 @@ from theano.sandbox.cuda.nvcc_compiler import NVCC_compiler
...
@@ -33,8 +32,6 @@ from theano.sandbox.cuda.nvcc_compiler import NVCC_compiler
from
theano.tensor.nnet.abstract_conv2d
import
(
AbstractConv2d
,
from
theano.tensor.nnet.abstract_conv2d
import
(
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
)
AbstractConv2d_gradInputs
)
from
theano.tensor.opt
import
register_specialize_device
def
dnn_available
():
def
dnn_available
():
...
@@ -2453,8 +2450,8 @@ def local_abstractconv_cudnn(node):
...
@@ -2453,8 +2450,8 @@ def local_abstractconv_cudnn(node):
AbstractConv2d_gradInputs
))):
AbstractConv2d_gradInputs
))):
return
None
return
None
if
not
isinstance
(
inp1
.
type
,
CudaNdarrayType
)
or
\
if
(
not
isinstance
(
inp1
.
type
,
CudaNdarrayType
)
or
not
isinstance
(
inp2
.
type
,
CudaNdarrayType
):
not
isinstance
(
inp2
.
type
,
CudaNdarrayType
)
)
:
return
None
return
None
if
not
dnn_available
():
if
not
dnn_available
():
return
None
return
None
...
...
theano/sandbox/cuda/extra_ops.py
浏览文件 @
1ccf7243
...
@@ -9,7 +9,7 @@ from theano.tensor.extra_ops import CumsumOp
...
@@ -9,7 +9,7 @@ from theano.tensor.extra_ops import CumsumOp
if
cuda_available
:
if
cuda_available
:
from
theano.sandbox.cuda
import
CudaNdarrayType
from
theano.sandbox.cuda
import
CudaNdarrayType
from
theano.sandbox.cuda.basic_ops
import
host_from_gpu
,
gpu_from_host
,
HostFromGpu
from
theano.sandbox.cuda.basic_ops
import
host_from_gpu
,
gpu_from_host
,
HostFromGpu
from
theano.sandbox.cuda
.opt
import
register_opt
as
register_gpu_opt
from
theano.sandbox.cuda
import
register_opt
as
register_gpu_opt
class
GpuCumsum
(
CumsumOp
,
GpuOp
):
class
GpuCumsum
(
CumsumOp
,
GpuOp
):
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
1ccf7243
from
__future__
import
print_function
from
__future__
import
print_function
import
logging
_logger
=
logging
.
getLogger
(
'theano.sandbox.cuda.opt'
)
import
copy
import
copy
import
logging
import
pdb
import
sys
import
sys
import
time
import
time
import
warnings
import
warnings
import
pdb
import
numpy
import
numpy
from
six.moves
import
reduce
,
xrange
import
theano
import
theano
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
from
theano
import
config
,
tensor
,
gof
from
theano
import
config
,
tensor
,
gof
import
theano.ifelse
import
theano.ifelse
from
six.moves
import
reduce
,
xrange
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
ProxyDB
,
from
theano.gof
import
(
local_optimizer
,
EquilibriumDB
,
ProxyDB
,
Optimizer
,
TopoOptimizer
,
toolbox
)
Optimizer
,
TopoOptimizer
,
toolbox
)
...
@@ -66,6 +65,7 @@ from theano.sandbox.cuda.elemwise import erfinv_gpu
...
@@ -66,6 +65,7 @@ from theano.sandbox.cuda.elemwise import erfinv_gpu
from
theano.sandbox.cuda.elemwise
import
erfcx_gpu
from
theano.sandbox.cuda.elemwise
import
erfcx_gpu
from
theano.sandbox.cuda.var
import
CudaNdarrayConstant
from
theano.sandbox.cuda.var
import
CudaNdarrayConstant
from
theano.sandbox.cuda
import
gpu_optimizer
,
register_opt
,
gpu_seqopt
,
GpuOp
from
theano.sandbox.cuda
import
gpu_optimizer
,
register_opt
,
gpu_seqopt
,
GpuOp
import
theano.sandbox.cuda.extra_ops
from
theano.scan_module
import
scan_utils
,
scan_op
,
scan_opt
from
theano.scan_module
import
scan_utils
,
scan_op
,
scan_opt
from
theano.tensor.blas
import
_is_real_vector
,
_is_real_matrix
from
theano.tensor.blas
import
_is_real_vector
,
_is_real_matrix
...
@@ -75,7 +75,8 @@ from theano.tensor import slinalg
...
@@ -75,7 +75,8 @@ from theano.tensor import slinalg
from
theano.tensor.nnet.Conv3D
import
Conv3D
from
theano.tensor.nnet.Conv3D
import
Conv3D
from
theano.tests.breakpoint
import
PdbBreakpoint
from
theano.tests.breakpoint
import
PdbBreakpoint
from
theano.tensor.nnet.abstract_conv2d
import
(
BaseAbstractConv2d
,
AbstractConv2d
,
from
theano.tensor.nnet.abstract_conv2d
import
(
BaseAbstractConv2d
,
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
)
AbstractConv2d_gradInputs
)
from
theano.tensor.opt
import
register_specialize_device
from
theano.tensor.opt
import
register_specialize_device
...
@@ -88,6 +89,8 @@ except ImportError:
...
@@ -88,6 +89,8 @@ except ImportError:
pass
pass
_logger
=
logging
.
getLogger
(
'theano.sandbox.cuda.opt'
)
# optdb.print_summary() # shows what is currently registered
# optdb.print_summary() # shows what is currently registered
gpu_cut_copies
=
EquilibriumDB
()
gpu_cut_copies
=
EquilibriumDB
()
...
@@ -2627,11 +2630,11 @@ optdb.register('local_inplace_gpu_sparse_block_outer',
...
@@ -2627,11 +2630,11 @@ optdb.register('local_inplace_gpu_sparse_block_outer',
60
,
'fast_run'
,
'inplace'
,
'gpu'
)
# DEBUG
60
,
'fast_run'
,
'inplace'
,
'gpu'
)
# DEBUG
import
theano.sandbox.cuda.extra_ops
# Move to Gpu optimization
### Move to Gpu optimization
@local_optimizer
([
gpu_from_host
,
@local_optimizer
([
gpu_from_host
,
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
def
local_conv2d_gpu_conv
(
node
):
def
local_conv2d_gpu_conv
(
node
):
"""
"""
gpu_from_host(AbstractConv) -> AbstractConv(gpu_from_host)
gpu_from_host(AbstractConv) -> AbstractConv(gpu_from_host)
...
@@ -2640,7 +2643,8 @@ def local_conv2d_gpu_conv(node):
...
@@ -2640,7 +2643,8 @@ def local_conv2d_gpu_conv(node):
"""
"""
if
isinstance
(
node
.
op
,
GpuFromHost
):
if
isinstance
(
node
.
op
,
GpuFromHost
):
host_input
=
node
.
inputs
[
0
]
host_input
=
node
.
inputs
[
0
]
if
host_input
.
owner
and
isinstance
(
host_input
.
owner
.
op
,
BaseAbstractConv2d
):
if
host_input
.
owner
and
isinstance
(
host_input
.
owner
.
op
,
BaseAbstractConv2d
):
conv
=
host_input
.
owner
.
op
conv
=
host_input
.
owner
.
op
inps
=
list
(
host_input
.
owner
.
inputs
)
inps
=
list
(
host_input
.
owner
.
inputs
)
...
@@ -2686,8 +2690,7 @@ def local_conv2d_gpu_conv(node):
...
@@ -2686,8 +2690,7 @@ def local_conv2d_gpu_conv(node):
register_opt
()(
local_conv2d_gpu_conv
)
register_opt
()(
local_conv2d_gpu_conv
)
# Corrmm opt
### Corrmm opt
@local_optimizer
([
AbstractConv2d
])
@local_optimizer
([
AbstractConv2d
])
def
local_abstractconv_gemm
(
node
):
def
local_abstractconv_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d
):
...
@@ -2720,7 +2723,7 @@ def local_abstractconv_gemm(node):
...
@@ -2720,7 +2723,7 @@ def local_abstractconv_gemm(node):
# is larger than inputChannels * outputHeight * outputWidth.
# is larger than inputChannels * outputHeight * outputWidth.
# GpuConv does not always store information on the batchsize and
# GpuConv does not always store information on the batchsize and
# channels, though, so we only use what information we have.)
# channels, though, so we only use what information we have.)
if
((
subsample
==
(
1
,
1
))
and
if
((
subsample
==
(
1
,
1
))
and
(
node
.
op
.
imshp
is
not
None
)
and
(
node
.
op
.
imshp
is
not
None
)
and
(
None
not
in
node
.
op
.
imshp
[
-
2
:])
and
(
None
not
in
node
.
op
.
imshp
[
-
2
:])
and
(
node
.
op
.
kshp
is
not
None
)
and
(
node
.
op
.
kshp
is
not
None
)
and
...
@@ -2745,6 +2748,7 @@ def local_abstractconv_gemm(node):
...
@@ -2745,6 +2748,7 @@ def local_abstractconv_gemm(node):
)
.
dimshuffle
(
1
,
0
,
2
,
3
))
)
.
dimshuffle
(
1
,
0
,
2
,
3
))
return
[
rval
]
return
[
rval
]
@local_optimizer
([
AbstractConv2d_gradWeights
])
@local_optimizer
([
AbstractConv2d_gradWeights
])
def
local_abstractconv_gradweight_gemm
(
node
):
def
local_abstractconv_gradweight_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradWeights
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradWeights
):
...
@@ -2763,6 +2767,7 @@ def local_abstractconv_gradweight_gemm(node):
...
@@ -2763,6 +2767,7 @@ def local_abstractconv_gradweight_gemm(node):
rval
=
as_cuda_ndarray_variable
(
rval
)
rval
=
as_cuda_ndarray_variable
(
rval
)
return
[
rval
]
return
[
rval
]
@local_optimizer
([
AbstractConv2d_gradInputs
])
@local_optimizer
([
AbstractConv2d_gradInputs
])
def
local_abstractconv_gradinputs_gemm
(
node
):
def
local_abstractconv_gradinputs_gemm
(
node
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradInputs
):
if
not
isinstance
(
node
.
op
,
AbstractConv2d_gradInputs
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论